Skip to content

Changes in Python 3.12 break tests #618

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

Closed
hrnciar opened this issue May 16, 2023 · 2 comments · Fixed by #619
Closed

Changes in Python 3.12 break tests #618

hrnciar opened this issue May 16, 2023 · 2 comments · Fixed by #619

Comments

@hrnciar
Copy link
Contributor

hrnciar commented May 16, 2023

Hi, in Fedora we are rebuilding all upcoming Python packages with upcoming Python 3.12.0a7. There are two changes in CPython causing troubles.

gh-101446: Change repr of collections.OrderedDict to use regular dictionary formating instead of pairs of keys and values.

gh-96670: The parser now raises SyntaxError when parsing source code containing null bytes. Patch by Pablo Galindo

=================================== FAILURES ===================================
__________________________ TestOrderedDict.test_repr ___________________________

self = <test_future.test_backports.TestOrderedDict testMethod=test_repr>

    def test_repr(self):
        od = OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])
>       self.assertEqual(repr(od),
            "OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])")
E       AssertionError: "OrderedDict({'c': 1, 'b': 2, 'a': 3, 'd': 4, 'e': 5, 'f': 6})" != "OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])"
E       - OrderedDict({'c': 1, 'b': 2, 'a': 3, 'd': 4, 'e': 5, 'f': 6})
E       ?             ^   ^       ^       ^       ^       ^       ^  ^
E       + OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])
E       ?             ^^   ^  +  +   ^  +  +   ^  +  +   ^  +  +   ^  +  +   ^  ^^

tests/test_future/test_backports.py:602: AssertionError
_____________________ TestOrderedDict.test_repr_recursive ______________________

self = <test_future.test_backports.TestOrderedDict testMethod=test_repr_recursive>

    def test_repr_recursive(self):
        # See issue #9826
        od = OrderedDict.fromkeys('abc')
        od['x'] = od
>       self.assertEqual(repr(od),
            "OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])")
E       AssertionError: "OrderedDict({'a': None, 'b': None, 'c': None, 'x': ...})" != "OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])"
E       - OrderedDict({'a': None, 'b': None, 'c': None, 'x': ...})
E       ?             ^   ^          ^          ^          ^    ^
E       + OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])
E       ?             ^^   ^     +  +   ^     +  +   ^     +  +   ^    ^^

tests/test_future/test_backports.py:611: AssertionError
___________________________ BuiltinTest.test_compile ___________________________

self = <test_future.test_builtins.BuiltinTest testMethod=test_compile>

    def test_compile(self):
        compile('print(1)\n', '', 'exec')
        bom = b'\xef\xbb\xbf'
        compile(bom + b'print(1)\n', '', 'exec')
        compile(source='pass', filename='?', mode='exec')
        compile(dont_inherit=0, filename='tmp', source='0', mode='eval')
        compile('pass', '?', dont_inherit=1, mode='exec')
        # Fails on Py2.7:
        # Was: compile(memoryview(b"text"), "name", "exec")
        self.assertRaises(TypeError, compile)
        self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'badmode')
        self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'single', 0xff)
        # Raises TypeError in Python < v3.5, ValueError in v3.5:
>       self.assertRaises((TypeError, ValueError), compile, chr(0), 'f', 'exec')
E       SyntaxError: source code string cannot contain null bytes

tests/test_future/test_builtins.py:527: SyntaxError
=========================== short test summary info ============================
FAILED tests/test_future/test_backports.py::TestOrderedDict::test_repr - Asse...
FAILED tests/test_future/test_backports.py::TestOrderedDict::test_repr_recursive
FAILED tests/test_future/test_builtins.py::BuiltinTest::test_compile - Syntax...
3 failed, 1037 passed, 40 skipped, 15 deselected, 47 xfailed, 55 warnings in 13.50s
@mcepl
Copy link

mcepl commented Jul 4, 2023

It actually breaks with 3.11.4 as well.

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Jul 6, 2023
@s3v-
Copy link

s3v- commented Nov 4, 2023

It actually breaks with 3.11.4 as well.

Upstream has backported those changes to Python 3.11 as well
python/cpython#104195

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

Successfully merging a pull request may close this issue.

3 participants