pytest: Assertions on nested comprehensions can give NameError
This test:
def test_nested_comprehension():
s = [[True, True], [True, True]]
assert all(e for row in s for e in row)
works fine in pytest 4.4.1 and 4.5.0. In pytest 4.6.1 it produces a NameError:
$ pytest
===================================================== test session starts =====================================================
platform darwin -- Python 3.7.3, pytest-4.6.1, py-1.8.0, pluggy-0.12.0
collected 1 item
test_it.py F [100%]
========================================================== FAILURES ===========================================================
__________________________________________________ test_nested_comprehension __________________________________________________
def test_nested_comprehension():
s = [[True, True], [True, True]]
> assert all(e for row in s for e in row)
E NameError: name 'e' is not defined
test_it.py:3: NameError
================================================== 1 failed in 0.06 seconds ===================================================
Pip list gives:
$ pip list
Package Version
------------------ -------
atomicwrites 1.3.0
attrs 19.1.0
importlib-metadata 0.17
more-itertools 7.0.0
packaging 19.0
pip 19.1.1
pluggy 0.12.0
py 1.8.0
pyparsing 2.4.0
pytest 4.6.1
setuptools 41.0.1
six 1.12.0
wcwidth 0.1.7
wheel 0.33.4
zipp 0.5.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 16 (13 by maintainers)
Commits related to this issue
- Merge #86 86: Update pytest to 5.0.1 r=rehandalal a=pyup-bot This PR updates [pytest](https://pypi.org/project/pytest) from **4.6.3** to **5.0.1**. <details> <summary>Changelog</summary> ... — committed to rehandalal/therapist by bors[bot] 5 years ago
- Merge #32 32: Pin pytest to latest version 5.1.3 r=duckinator a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **5.1.3**. <details> <summary>Changelog</s... — committed to duckinator/bork by bors[bot] 5 years ago
- Merge #1 1: Initial Update r=aragilar a=pyup-bot This PR sets up pyup.io on this repo and updates all dependencies at once, in a single branch. Subsequent pull requests will update one dependency... — committed to aragilar/pytest-info-collector by bors[bot] 4 years ago
- Merge #1 1: Initial Update r=aragilar a=pyup-bot This PR sets up pyup.io on this repo and updates all dependencies at once, in a single branch. Subsequent pull requests will update one dependency... — committed to aragilar/spaceplot by bors[bot] 4 years ago
- Merge #1 1: Initial Update r=aragilar a=pyup-bot This PR sets up pyup.io on this repo and updates all dependencies at once, in a single branch. Subsequent pull requests will update one dependency... — committed to aragilar/venv_tools by bors[bot] 4 years ago
- Merge #5 5: Initial Update r=aragilar a=pyup-bot This PR sets up pyup.io on this repo and updates all dependencies at once, in a single branch. Subsequent pull requests will update one dependency... — committed to aragilar/root-solver by bors[bot] 4 years ago
I’ve compiled the list of regressions in the original issue (#5062) to make sure we don’t miss any in the future. 👍
Hi @alimcmaster1,
Thanks for the offer, but I don’t think we should add specific tests for
allin the assertion rewriter tests given that we don’t have any special handling for it anymore.But we will definitely revisit all examples reported and include them in the test suite if/when we re-introduce all() unrolling in the assertion rewriter. 👍