Skip to content

Some tests are failing with Python 3.13  #13

@fabaff

Description

@fabaff

Some tests are failing with Python 3.13. With Python 3.12 they pass.

============================= test session starts ==============================
platform linux -- Python 3.13.1, pytest-8.3.3, pluggy-1.5.0
rootdir: /build/source
configfile: pyproject.toml
collected 64 items / 3 deselected / 61 selected

tests/test_PyComponent.py F..                                            [  4%]
tests/test_PyStdLibIncludeOrNot.py FFFFF                                 [ 13%]
tests/test_jsmin.py s                                                    [ 14%]
tests/test_jsminOnline.py .                                              [ 16%]
tests/test_mkPrefixCss.py .....                                          [ 24%]
tests/test_py2js.py FFFFFFFF                                             [ 37%]
tests/test_renderFiles.py ..                                             [ 40%]
tests/test_trans.py .                                                    [ 42%]
tests/test_vbuild.py ..............                                      [ 65%]
tests/test_vbuild_encoding.py ....                                       [ 72%]
tests/test_vbuild_less.py s                                              [ 73%]
tests/test_vbuild_sass.py s                                              [ 75%]
tests/test_vueparser.py ...............                                  [100%]

=================================== FAILURES ===================================
___________________________________ test_ok ____________________________________

self = <[AttributeError("'VBuild' object has no attribute '_script'") raised in repr()] VBuild object at 0x7ffff5d10ec0>
filename = 'pyc.vue'
content = '<template>\n    <div>\n        {{name}} {{cpt}}\n        <button @click="inc()">++</button>\n    </div>\n</template>\....cpt=0\n\n    def inc(self):\n        self.cpt+=1\n\n</script>\n<style scoped>\n    :scope {background:#EEE}\n</style>'

    def __init__(self, filename, content):
        """ Create a VBuild class, by providing a :
                filename: which will be used to name the component, and create the namespace for the template
                content: the string buffer which contains the sfc/vue component
        """
        if not filename:
            raise VBuildException("Component %s should be named" % filename)

        if type(content) != type(filename):  # only py2, transform
            if type(content) == unicode:  # filename to the same type
                filename = filename.decode("utf8")  # of content to avoid
            else:  # troubles with implicit
                filename = filename.encode("utf8")  # ascii conversions (regex)

        name = os.path.splitext(os.path.basename(filename))[0]

        unique = filename[:-4].replace("/", "-").replace("\\", "-").replace(":", "-").replace(".", "-")
        # unique = name+"-"+''.join(random.choice(string.letters + string.digits) for _ in range(8))
        tplId = "tpl-" + unique
        dataId = "data-" + unique

        vp = VueParser(content, filename)
        if vp.html is None:
            raise VBuildException("Component %s doesn't have a template" % filename)
        else:
            html = re.sub(r"^<([\w-]+)", r"<\1 %s" % dataId, vp.html.value)

            self.tags = [name]
            # self.html="""<script type="text/x-template" id="%s">%s</script>""" % (tplId, transHtml(html) )
            self._html = [(tplId, html)]

            self._styles = []
            for style in vp.styles:
                self._styles.append(("", style, filename))
            for style in vp.scopedStyles:
                self._styles.append(("*[%s]" % dataId, style, filename))

            # and set self._script !
            if vp.script and ("class Component:" in vp.script.value):
                ######################################################### python
                try:
                    self._script = [
>                       mkPythonVueComponent(
                            name, "#" + tplId, vp.script.value, fullPyComp
                        )
                    ]

vbuild/__init__.py:297:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

name = 'pyc', template = '#tpl-pyc'
code = 'class C:\n    def __init__(self, name):\n        self.cpt=0\n\n    def inc(self):\n        self.cpt+=1'
genStdLibMethods = True

    def mkPythonVueComponent(name, template, code, genStdLibMethods=True):
        """ Transpile the component 'name', which have the template 'template',
            and the code 'code' (which should contains a valid Component class)
            to a valid Vue.component js statement.

            genStdLibMethods : generate own std lib method inline (with the js)
                    (if False: use pscript.get_full_std_lib() to get them)
        """
        import pscript
        code = code.replace(
            "class Component:", "class C:"
        )  # minimize class name (todo: use py2js option for that)
        exec(code, globals(), locals())
>       klass = locals()["C"]
E       KeyError: 'C'

vbuild/__init__.py:421: KeyError

During handling of the above exception, another exception occurred:
[...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions