Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some tests are failing with Python 3.13 #13

Open
fabaff opened this issue Jan 8, 2025 · 0 comments
Open

Some tests are failing with Python 3.13 #13

fabaff opened this issue Jan 8, 2025 · 0 comments

Comments

@fabaff
Copy link

fabaff commented Jan 8, 2025

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:
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant