New issue 507: pytest-2.5.2: Assertion breaks with dictionary comprehention https://bitbucket.org/hpk42/pytest/issue/507/pytest-252-assertion-breaks-with
Matthew Story: In version 2.5.2 assertions break when you use a comprehension on one side of the comparison: ``` def assert_subsetof(d1, d2): '''Assert d1 is a subset of d2, with equal values for all defined keys''' > assert {k:d2[k] for k in d1 if d2.has_key(k)} == d1 E AssertionError: NameError: << global name 'd2' is not defined /usr/axm/lib/python2.7/site-packages/apitests/assertions.py:4: AssertionError ``` When writing in pure python, the same operation works fine: ``` #!python >>> def foo(d1, d2): ... assert {k:d2[k] for k in d1 if d2.has_key(k)} == d1 ... >>> foo({'a': 'b'}, {'a': 'b', 'b': 'c'}) ``` _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit