Pytest: Unexpected behaviour for generator expressions in python 3.7

Created on 3 Jun 2019  路  2Comments  路  Source: pytest-dev/pytest

When running the following example with pytest 4.6.1 with python 3.6 from conda, the test passes, however when running with the same pytest version with python 3.7 the second assert statement fails

def test_example():
    assert all(list(x for x in [True, False] if x))
    assert all(x for x in [True, False] if x)
    def test_example():
        assert all(list(x for x in [True, False] if x))
>       assert all(x for x in [True, False] if x)
E       assert False

pytest_example.py:4: AssertionError



md5-4b69995460b45556a2fbdaea27ce952a



name: pytest_test
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - pytest
rewrite bug regression

All 2 comments

I reproduced this exact issue with Python 3.6.8. It's failing in one environment, but working in another with the same version of python, and the same version of pytest.

this has been released as part of 4.6.2 -- those that were experiencing these issues may need to clean .pyc files after upgrading

Was this page helpful?
0 / 5 - 0 ratings