question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestAssertionRewrite test failures on 3.7.0b5

See original GitHub issue

Running on Fedora 28.

$ tox -e py37 -- testing/test_assertrewrite.py

The tests pass with 3.7.0b4, bt two of them fail with 3.7.0b5:

============================= test session starts ==============================
platform linux -- Python 3.7.0b5, pytest-3.6.1.dev44+gd609b635, py-1.5.3, pluggy-0.6.0
rootdir: /home/churchyard/Dokumenty/pytest, inifile: tox.ini
plugins: hypothesis-3.57.0
collected 57 items                                                             

testing/test_assertrewrite.py FF.....................................s.. [ 73%]
ssss...........                                                          [100%]

=================================== FAILURES ===================================
_______________ TestAssertionRewrite.test_place_initial_imports ________________

self = <test_assertrewrite.TestAssertionRewrite object at 0x7fd164296a58>

    def test_place_initial_imports(self):
        s = """'Doc string'\nother = stuff"""
        m = rewrite(s)
        # Module docstrings in 3.7 are part of Module node, it's not in the body
        # so we remove it so the following body items have the same indexes on
        # all Python versions
        if sys.version_info < (3, 7):
            assert isinstance(m.body[0], ast.Expr)
            assert isinstance(m.body[0].value, ast.Str)
            del m.body[0]
        for imp in m.body[0:2]:
>           assert isinstance(imp, ast.Import)
E           AssertionError: assert False
E            +  where False = isinstance(<_ast.Expr object at 0x7fd16422ee48>, <class '_ast.Import'>)
E            +    where <class '_ast.Import'> = ast.Import

testing/test_assertrewrite.py:81: AssertionError
____________________ TestAssertionRewrite.test_dont_rewrite ____________________

self = <test_assertrewrite.TestAssertionRewrite object at 0x7fd1642cdbe0>

    def test_dont_rewrite(self):
        s = """'PYTEST_DONT_REWRITE'\nassert 14"""
        m = rewrite(s)
        if sys.version_info < (3, 7):
            assert len(m.body) == 2
            assert isinstance(m.body[0], ast.Expr)
            assert isinstance(m.body[0].value, ast.Str)
            del m.body[0]
        else:
>           assert len(m.body) == 1
E           assert 2 == 1
E            +  where 2 = len([<_ast.Expr object at 0x7fd164274710>, <_ast.Assert object at 0x7fd16428cba8>])
E            +    where [<_ast.Expr object at 0x7fd164274710>, <_ast.Assert object at 0x7fd16428cba8>] = <_ast.Module object at 0x7fd164274898>.body

testing/test_assertrewrite.py:133: AssertionError
=========================== short test summary info ============================
FAIL testing/test_assertrewrite.py::TestAssertionRewrite::()::test_place_initial_imports
FAIL testing/test_assertrewrite.py::TestAssertionRewrite::()::test_dont_rewrite
SKIP [1] testing/test_assertrewrite.py:845: python 2 only
SKIP [1] testing/test_assertrewrite.py:895: condition: sys.version_info[0] >= 3
SKIP [1] testing/test_assertrewrite.py:904: condition: sys.version_info[0] >= 3
SKIP [1] testing/test_assertrewrite.py:915: condition: sys.version_info[0] >= 3
SKIP [1] testing/test_assertrewrite.py:926: condition: sys.version_info[0] >= 3
================ 2 failed, 50 passed, 5 skipped in 6.19 seconds ================

Happens on both 3.6.0 and master.

The docstring chanages in AST change form 3.7 got reverted. This might be relevant.

See also https://github.com/PyCQA/mccabe/issues/61#issuecomment-393137462

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nicoddemuscommented, Jun 5, 2018

Was planning on making a release this week, might as well prepare one right away: #3534.

0reactions
hroncokcommented, Jun 4, 2018

Any plans for a release in couple of days, or should I backport the fix as a patch (in Fedora)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Release Python 3.7.0b5
This release, 3.7.0b5, is now the final planned beta release preview. ... Python projects to test with 3.7 during the beta phase and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found