New issue 608: Failed assertions with any/all and generator expressions raise 
NameError
https://bitbucket.org/hpk42/pytest/issue/608/failed-assertions-with-any-all-and

Bjørnar Snoksrud:

Tested with pytest 2.6.1:

repro.py:

```
#!python

from repro2 import foo
                      
                      
def test_case():      
    foo()   
```
          

repro2.py:

```
#!python

def foo():                           
    obj = {}                         
    assert all(x in obj for x in '1')
```

Running the test.
```
#!python

$ py.test repro.py 
platform linux2 -- Python 2.7.5 -- py-1.4.23 -- pytest-2.5.2
plugins: xdist
collected 1 items 

repro.py F

============================================= FAILURES 
_____________________________________________ test_case 

    def test_case():
>       foo()

repro.py:5: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def foo():
        obj = {}
>       assert all(x in obj for x in '1')
E       AssertionError: NameError: all(<generator object <genexpr> at 
0x2ab35a0>)  << global name 'obj' is not defined
```

This looks alot like #339, but the kicker is this: if you move the 'foo()' 
function to the file  containing the testcase, it works as expected.



_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to