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

Test failures with Python 3.9: test_simple_translate_mapping, test_pt_files #307

Closed
hroncok opened this issue May 10, 2020 · 2 comments
Closed
Assignees
Labels

Comments

@hroncok
Copy link

hroncok commented May 10, 2020

In Fedora, we attempted to rebuild chameleon with Python 3.9.0a6, there were test failures. I've reproduced them with:

$ tox -e py39  # on master
GLOB sdist-make: .../chameleon/setup.py
py39 inst-nodeps: .../chameleon/.tox/.tmp/package/1/Chameleon-3.7.0.zip
py39 installed: Chameleon==3.7.0
py39 run-test-pre: PYTHONHASHSEED='3739817816'
py39 run-test: commands[0] | python setup.py -q test -q
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
warning: manifest_maker: MANIFEST.in, line 2: 'recursive-exclude' expects <dir> <pattern1> <pattern2> ...

..................................F.........F......................................
======================================================================
FAIL: test_simple_translate_mapping (chameleon.tests.test_templates.ZopePageTemplatesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../chameleon/src/chameleon/tests/test_templates.py", line 560, in test_simple_translate_mapping
    self.assertEqual(template(), '<div><span>foo</span></div>')
AssertionError: '<div><span>foo</span>${name}</div>' != '<div><span>foo</span></div>'
- <div><span>foo</span>${name}</div>
?                      -------
+ <div><span>foo</span></div>


======================================================================
FAIL: test_pt_files (chameleon.tests.test_templates.ZopeTemplatesTestSuite)
.../chameleon/src/chameleon/tests/inputs/012-translation.pt
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../chameleon/src/chameleon/tests/test_templates.py", line 693, in test_pt_files
    self.execute(
  File ".../chameleon/src/chameleon/tests/test_templates.py", line 808, in execute
    self.fail("(%s) - \n%s\n\nCode:\n%s" % (
AssertionError: (.../chameleon/src/chameleon/tests/inputs/012-translation.pt) - 
Expected:
    <html>
      <body>
        <div></div>
        <div>Hello world!</div>
        <div>Hello world!</div>
        <div><sup>Hello world!</sup></div>
        <div>Hello <em>world</em>! Goodbye <em>planet</em>!</div>
        <div>Hello <em>world</em>! Goodbye <em>planet</em>!</div>
      </body>
    </html>
Got:
    <html>
      <body>
        <div></div>
        <div>
          Hello world!
        </div>
        <div>
          Hello world!
        </div>
        <div>
          <sup>Hello world!</sup>
        </div>
        <div>
          Hello <em>world</em>${first}!
          Goodbye <em>planet</em>${second}!
        </div>
        <div>
          Hello <em>world</em>${first}!
          Goodbye <em>planet</em>${second}!
        </div>
      </body>
    </html>

Code:
b'__filename = \'.../chameleon/src/chameleon/tests/inputs/012-translation.pt\'\n__default = object()\n__tokens = {308: ("${\'world\'}", 14, 34), 310: ("\'world\'", 14, 36), 362: ("${\'planet\'}", 15, 37), 364: ("\'planet\'", 15, 39), 466: ("${\'world\'}", 18, 34), 468: ("\'world\'", 18, 36), 520: ("${\'planet\'}", 19, 37), 522: ("\'planet\'", 19, 39)}\n\nfrom sys import exc_info as _exc_info\n\n_static_140472179106768 = {}\n\nimport re\nimport functools\nfrom itertools import chain as __chain\n__marker = object()\ng_re_amp = re.compile(\'&(?!([A-Za-z]+|#[0-9]+);)\')\ng_re_needs_escape = re.compile(\'[&<>\\\\"\\\\\\\']\').search\n__re_whitespace = functools.partial(re.compile(\'\\\\s+\').sub, \' \')\n\ndef initialize(__loader, macros, nothing, template):\n\n    def render(__stream, econtext, rcontext, __i18n_domain=None, __i18n_context=None):\n        __append = __stream.append\n        __re_amp = g_re_amp\n        __token = None\n        __re_needs_escape = g_re_needs_escape\n\n        def __convert(target):\n            if (target is None):\n                return\n            __tt = type(target)\n            if ((__tt is int) or (__tt is float) or (__tt is int)):\n                target = str(target)\n            else:\n                if (__tt is bytes):\n                    target = decode(target)\n                else:\n                    if (__tt is not str):\n                        try:\n                            target = target.__html__\n                        except AttributeError:\n                            __converted = convert(target)\n                            target = (str(target) if (target is __converted) else __converted)\n                        else:\n                            target = target()\n            return target\n\n        def __quote(target, quote, quote_entity, default, default_marker):\n            if (target is None):\n                return\n            if (target is default_marker):\n                return default\n            __tt = type(target)\n            if ((__tt is int) or (__tt is float) or (__tt is int)):\n                target = str(target)\n            else:\n                if (__tt is bytes):\n                    target = decode(target)\n                else:\n                    if (__tt is not str):\n                        try:\n                            target = target.__html__\n                        except:\n                            __converted = convert(target)\n                            target = (str(target) if (target is __converted) else __converted)\n                        else:\n                            return target()\n                if (target is not None):\n                    try:\n                        escape = (__re_needs_escape(target) is not None)\n                    except TypeError:\n                        pass\n                    else:\n                        if escape:\n                            if (\'&\' in target):\n                                target = target.replace(\'&\', \'&amp;\')\n                            if (\'<\' in target):\n                                target = target.replace(\'<\', \'&lt;\')\n                            if (\'>\' in target):\n                                target = target.replace(\'>\', \'&gt;\')\n                            if ((quote is not None) and (quote in target)):\n                                target = target.replace(quote, quote_entity)\n            return target\n        translate = econtext[\'__translate\']\n        decode = econtext[\'__decode\']\n        convert = econtext[\'__convert\']\n        on_error_handler = econtext[\'__on_error_handler\']\n        try:\n            getitem = econtext.__getitem__\n            get = econtext.get\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472177723280\n            __attrs_140472177723280 = _static_140472179106768\n\n            # <html ... (1:0)\n            # --------------------------------------------------------\n            __append(\'<html\')\n            __append(\'>\')\n            __append(\'\\n  \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472177723136\n            __attrs_140472177723136 = _static_140472179106768\n\n            # <body ... (2:2)\n            # --------------------------------------------------------\n            __append(\'<body\')\n            __append(\'>\')\n            __append(\'\\n    \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472177725056\n            __attrs_140472177725056 = _static_140472179106768\n\n            # <div ... (3:4)\n            # --------------------------------------------------------\n            __append(\'<div\')\n            __append(\'>\')\n            __stream_140472177723040 = []\n            __append_140472177723040 = __stream_140472177723040.append\n            __msgid_140472177723040 = __re_whitespace(\'\'.join(__stream_140472177723040)).strip()\n            if __msgid_140472177723040:\n                __append(translate(__msgid_140472177723040, mapping=None, default=__msgid_140472177723040, domain=__i18n_domain, context=__i18n_context, target_language=getitem(\'target_language\')))\n            __append(\'</div>\')\n            __append(\'\\n    \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472177723424\n            __attrs_140472177723424 = _static_140472179106768\n\n            # <div ... (4:4)\n            # --------------------------------------------------------\n            __append(\'<div\')\n            __append(\'>\')\n            __stream_140472177722368 = []\n            __append_140472177722368 = __stream_140472177722368.append\n            __append(\'\\n      Hello world!\\n    \')\n            __msgid_140472177722368 = __re_whitespace(\'\'.join(__stream_140472177722368)).strip()\n            if __msgid_140472177722368:\n                __append(translate(__msgid_140472177722368, mapping=None, default=__msgid_140472177722368, domain=__i18n_domain, context=__i18n_context, target_language=getitem(\'target_language\')))\n            __append(\'</div>\')\n            __append(\'\\n    \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472178724976\n            __attrs_140472178724976 = _static_140472179106768\n\n            # <div ... (7:4)\n            # --------------------------------------------------------\n            __append(\'<div\')\n            __append(\'>\')\n            __stream_140472178726512 = []\n            __append_140472178726512 = __stream_140472178726512.append\n            __append(\'\\n      Hello world!\\n    \')\n            __msgid_140472178726512 = __re_whitespace(\'\'.join(__stream_140472178726512)).strip()\n            if \'hello_world\':\n                __append(translate(\'hello_world\', mapping=None, default=__msgid_140472178726512, domain=__i18n_domain, context=__i18n_context, target_language=getitem(\'target_language\')))\n            __append(\'</div>\')\n            __append(\'\\n    \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176012448\n            __attrs_140472176012448 = _static_140472179106768\n\n            # <div ... (10:4)\n            # --------------------------------------------------------\n            __append(\'<div\')\n            __append(\'>\')\n            __stream_140472178726368 = []\n            __append_140472178726368 = __stream_140472178726368.append\n            __append(\'\\n      \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176012736\n            __attrs_140472176012736 = _static_140472179106768\n\n            # <sup ... (11:6)\n            # --------------------------------------------------------\n            __append(\'<sup\')\n            __append(\'>\')\n            __append(\'Hello world!\')\n            __append(\'</sup>\')\n            __append(\'\\n    \')\n            __msgid_140472178726368 = __re_whitespace(\'\'.join(__stream_140472178726368)).strip()\n            if __msgid_140472178726368:\n                __append(translate(__msgid_140472178726368, mapping=None, default=__msgid_140472178726368, domain=__i18n_domain, context=__i18n_context, target_language=getitem(\'target_language\')))\n            __append(\'</div>\')\n            __append(\'\\n    \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176012640\n            __attrs_140472176012640 = _static_140472179106768\n\n            # <div ... (13:4)\n            # --------------------------------------------------------\n            __append(\'<div\')\n            __append(\'>\')\n            __stream_140472178518272_first = \'\'\n            __stream_140472178518272_second = \'\'\n            __stream_140472176010144 = []\n            __append_140472176010144 = __stream_140472176010144.append\n            __append(\'\\n      Hello \')\n            __stream_140472178518272_first = []\n            __append_140472178518272_first = __stream_140472178518272_first.append\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176010048\n            __attrs_140472176010048 = _static_140472179106768\n\n            # <em ... (14:12)\n            # --------------------------------------------------------\n            __append(\'<em\')\n            __append(\'>\')\n\n            # <Interpolation value=<Substitution "${\'world\'}" (14:34)> braces_required=True translation=False at 7fc23a26e5e0> -> __content_140472192345200\n            __token = 308\n            __token = 310\n            __content_140472192345200 = \'world\'\n            __content_140472192345200 = __quote(__content_140472192345200, \'\\x00\', \'&#0;\', None, False)\n            __content_140472192345200 = __content_140472192345200\n            if (__content_140472192345200 is None):\n                pass\n            else:\n                if (__content_140472192345200 is False):\n                    __content_140472192345200 = None\n                else:\n                    __tt = type(__content_140472192345200)\n                    if ((__tt is int) or (__tt is float) or (__tt is int)):\n                        __content_140472192345200 = str(__content_140472192345200)\n                    else:\n                        if (__tt is bytes):\n                            __content_140472192345200 = decode(__content_140472192345200)\n                        else:\n                            if (__tt is not str):\n                                try:\n                                    __content_140472192345200 = __content_140472192345200.__html__\n                                except get(\'AttributeError\', AttributeError):\n                                    __converted = convert(__content_140472192345200)\n                                    __content_140472192345200 = (str(__content_140472192345200) if (__content_140472192345200 is __converted) else __converted)\n                                else:\n                                    __content_140472192345200 = __content_140472192345200()\n            if (__content_140472192345200 is not None):\n                __append(__content_140472192345200)\n            __append(\'</em>\')\n            __append(\'${first}\')\n            __stream_140472178518272_first = \'\'.join(__stream_140472178518272_first)\n            __append(\'!\\n      Goodbye \')\n            __stream_140472178518272_second = []\n            __append_140472178518272_second = __stream_140472178518272_second.append\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176010960\n            __attrs_140472176010960 = _static_140472179106768\n\n            # <em ... (15:14)\n            # --------------------------------------------------------\n            __append(\'<em\')\n            __append(\'>\')\n\n            # <Interpolation value=<Substitution "${\'planet\'}" (15:37)> braces_required=True translation=False at 7fc23a28e160> -> __content_140472192345200\n            __token = 362\n            __token = 364\n            __content_140472192345200 = \'planet\'\n            __content_140472192345200 = __quote(__content_140472192345200, \'\\x00\', \'&#0;\', None, False)\n            __content_140472192345200 = __content_140472192345200\n            if (__content_140472192345200 is None):\n                pass\n            else:\n                if (__content_140472192345200 is False):\n                    __content_140472192345200 = None\n                else:\n                    __tt = type(__content_140472192345200)\n                    if ((__tt is int) or (__tt is float) or (__tt is int)):\n                        __content_140472192345200 = str(__content_140472192345200)\n                    else:\n                        if (__tt is bytes):\n                            __content_140472192345200 = decode(__content_140472192345200)\n                        else:\n                            if (__tt is not str):\n                                try:\n                                    __content_140472192345200 = __content_140472192345200.__html__\n                                except get(\'AttributeError\', AttributeError):\n                                    __converted = convert(__content_140472192345200)\n                                    __content_140472192345200 = (str(__content_140472192345200) if (__content_140472192345200 is __converted) else __converted)\n                                else:\n                                    __content_140472192345200 = __content_140472192345200()\n            if (__content_140472192345200 is not None):\n                __append(__content_140472192345200)\n            __append(\'</em>\')\n            __append(\'${second}\')\n            __stream_140472178518272_second = \'\'.join(__stream_140472178518272_second)\n            __append(\'!\\n    \')\n            __msgid_140472176010144 = __re_whitespace(\'\'.join(__stream_140472176010144)).strip()\n            if __msgid_140472176010144:\n                __append(translate(__msgid_140472176010144, mapping={\'second\': __stream_140472178518272_second, \'first\': __stream_140472178518272_first, }, default=__msgid_140472176010144, domain=__i18n_domain, context=__i18n_context, target_language=getitem(\'target_language\')))\n            __append(\'</div>\')\n            __append(\'\\n    \')\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176141600\n            __attrs_140472176141600 = _static_140472179106768\n\n            # <div ... (17:4)\n            # --------------------------------------------------------\n            __append(\'<div\')\n            __append(\'>\')\n            __stream_140472178518272_first = \'\'\n            __stream_140472178518272_second = \'\'\n            __stream_140472176140400 = []\n            __append_140472176140400 = __stream_140472176140400.append\n            __append(\'\\n      Hello \')\n            __stream_140472178518272_first = []\n            __append_140472178518272_first = __stream_140472178518272_first.append\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176140832\n            __attrs_140472176140832 = _static_140472179106768\n\n            # <em ... (18:12)\n            # --------------------------------------------------------\n            __append(\'<em\')\n            __append(\'>\')\n\n            # <Interpolation value=<Substitution "${\'world\'}" (18:34)> braces_required=True translation=False at 7fc23a28e3a0> -> __content_140472192345200\n            __token = 466\n            __token = 468\n            __content_140472192345200 = \'world\'\n            __content_140472192345200 = __quote(__content_140472192345200, \'\\x00\', \'&#0;\', None, False)\n            __content_140472192345200 = __content_140472192345200\n            if (__content_140472192345200 is None):\n                pass\n            else:\n                if (__content_140472192345200 is False):\n                    __content_140472192345200 = None\n                else:\n                    __tt = type(__content_140472192345200)\n                    if ((__tt is int) or (__tt is float) or (__tt is int)):\n                        __content_140472192345200 = str(__content_140472192345200)\n                    else:\n                        if (__tt is bytes):\n                            __content_140472192345200 = decode(__content_140472192345200)\n                        else:\n                            if (__tt is not str):\n                                try:\n                                    __content_140472192345200 = __content_140472192345200.__html__\n                                except get(\'AttributeError\', AttributeError):\n                                    __converted = convert(__content_140472192345200)\n                                    __content_140472192345200 = (str(__content_140472192345200) if (__content_140472192345200 is __converted) else __converted)\n                                else:\n                                    __content_140472192345200 = __content_140472192345200()\n            if (__content_140472192345200 is not None):\n                __append(__content_140472192345200)\n            __append(\'</em>\')\n            __append(\'${first}\')\n            __stream_140472178518272_first = \'\'.join(__stream_140472178518272_first)\n            __append(\'!\\n      Goodbye \')\n            __stream_140472178518272_second = []\n            __append_140472178518272_second = __stream_140472178518272_second.append\n\n            # <Static value=<ast.Dict object at 0x7fc23a5623d0> name=None at 7fc23a562430> -> __attrs_140472176142944\n            __attrs_140472176142944 = _static_140472179106768\n\n            # <em ... (19:14)\n            # --------------------------------------------------------\n            __append(\'<em\')\n            __append(\'>\')\n\n            # <Interpolation value=<Substitution "${\'planet\'}" (19:37)> braces_required=True translation=False at 7fc23a28ef40> -> __content_140472192345200\n            __token = 520\n            __token = 522\n            __content_140472192345200 = \'planet\'\n            __content_140472192345200 = __quote(__content_140472192345200, \'\\x00\', \'&#0;\', None, False)\n            __content_140472192345200 = __content_140472192345200\n            if (__content_140472192345200 is None):\n                pass\n            else:\n                if (__content_140472192345200 is False):\n                    __content_140472192345200 = None\n                else:\n                    __tt = type(__content_140472192345200)\n                    if ((__tt is int) or (__tt is float) or (__tt is int)):\n                        __content_140472192345200 = str(__content_140472192345200)\n                    else:\n                        if (__tt is bytes):\n                            __content_140472192345200 = decode(__content_140472192345200)\n                        else:\n                            if (__tt is not str):\n                                try:\n                                    __content_140472192345200 = __content_140472192345200.__html__\n                                except get(\'AttributeError\', AttributeError):\n                                    __converted = convert(__content_140472192345200)\n                                    __content_140472192345200 = (str(__content_140472192345200) if (__content_140472192345200 is __converted) else __converted)\n                                else:\n                                    __content_140472192345200 = __content_140472192345200()\n            if (__content_140472192345200 is not None):\n                __append(__content_140472192345200)\n            __append(\'</em>\')\n            __append(\'${second}\')\n            __stream_140472178518272_second = \'\'.join(__stream_140472178518272_second)\n            __append(\'!\\n    \')\n            __msgid_140472176140400 = __re_whitespace(\'\'.join(__stream_140472176140400)).strip()\n            if \'hello_goodbye\':\n                __append(translate(\'hello_goodbye\', mapping={\'second\': __stream_140472178518272_second, \'first\': __stream_140472178518272_first, }, default=__msgid_140472176140400, domain=__i18n_domain, context=__i18n_context, target_language=getitem(\'target_language\')))\n            __append(\'</div>\')\n            __append(\'\\n  \')\n            __append(\'</body>\')\n            __append(\'\\n\')\n            __append(\'</html>\')\n            __append(\'\\n\')\n        except:\n            if (__token is not None):\n                rcontext.setdefault(\'__error__\', []).append((__tokens[__token] + (__filename, _exc_info()[1], )))\n            raise\n\n    return {\'render\': render, }'

----------------------------------------------------------------------
Ran 83 tests in 0.570s

FAILED (failures=2)
Test failed: <unittest.runner.TextTestResult run=83 errors=0 failures=2>
error: Test failed: <unittest.runner.TextTestResult run=83 errors=0 failures=2>
ERROR: InvocationError for command .../chameleon/.tox/py39/bin/python setup.py -q test -q (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py39: commands failed

This hapens with 3.9.0a5 and a6.

@malthe malthe added the core label May 10, 2020
@malthe malthe self-assigned this May 10, 2020
@malthe
Copy link
Owner

malthe commented May 10, 2020

I believe this regression is caused by https://bugs.python.org/issue39639. Since ast.Suite is now both deprecated and seemingly defunct, this needs fixing.

@malthe
Copy link
Owner

malthe commented May 10, 2020

Fix available in the 3.7.1 release.

@malthe malthe closed this as completed May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants