TL;DR; The eval() method of the Frame object is not “inheriting” the __future__ imports from the frame. Long explanation
Suppose I have a fixture in which I write my assert statements. If this fixture has strings on the assert statement then when the assert fails I get the wrong kind of errors. The problem is that the pytest assertion rewrite mechanism is calling eval() on the code that contains the frame To better illustrate what happens, see this gist <https://gist.github.com/edisongustavo/5533a1c36de6cab6f39a> The tests <https://gist.github.com/edisongustavo/5533a1c36de6cab6f39a#file-test_unicode_error_with_plugin_fixture-py> have the following output: - test_plugin_fixture - *fail* - test_conftest_fixture - *fail* - test_inline_fixture - pass - test_no_fixture - pass The output of *test_plugin_fixture* (omitted some output for brevity): $ pytest -k test_plugin_fixture msg = e.value.msg > assert msg.startswith('assert <classes.ValueAndString object'), msg E AssertionError: ValueError: ValueAndString(2, 'lkajflaskjfalskf') << Error! While debugging I found out that the ValueAndString constructor was being called 3 times, instead of 2. The 3rd call happened in code.py:100, which is part of the py lib <https://bitbucket.org/hpk42/py> library. The “wrong” behaviour can be seen on the run_pyframe_eval.py <https://gist.github.com/edisongustavo/5533a1c36de6cab6f39a#file-run_pyframe_eval-py> . I’ve tested this code on Pytest 2.6.4 with Python 2.7.8 in Windows 7 - 64bits.
_______________________________________________ pytest-dev mailing list pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev