Merge pull request #2140 from pelme/issue2121

Handle python_files correctly in assertion rewrite
This commit is contained in:
Bruno Oliveira 2017-06-01 07:55:42 -03:00 committed by GitHub
commit bcbad5b1af
4 changed files with 17 additions and 3 deletions

View File

@ -11,7 +11,6 @@ import re
import struct
import sys
import types
from fnmatch import fnmatch
import py
from _pytest.assertion import util
@ -167,7 +166,7 @@ class AssertionRewritingHook(object):
# latter might trigger an import to fnmatch.fnmatch
# internally, which would cause this method to be
# called recursively
if fnmatch(fn_pypath.basename, pat):
if fn_pypath.fnmatch(pat):
state.trace("matched test file %r" % (fn,))
return True

1
changelog/2121.bugfix Normal file
View File

@ -0,0 +1 @@
Respect ``python_files`` in assertion rewriting.

View File

@ -43,7 +43,7 @@ def has_environment_marker_support():
def main():
install_requires = ['py>=1.4.29', 'setuptools'] # pluggy is vendored in _pytest.vendored_packages
install_requires = ['py>=1.4.33', 'setuptools'] # pluggy is vendored in _pytest.vendored_packages
extras_require = {}
if has_environment_marker_support():
extras_require[':python_version=="2.6"'] = ['argparse']

View File

@ -956,3 +956,17 @@ class TestIssue925(object):
result = testdir.runpytest()
result.stdout.fnmatch_lines('*E*assert True == ((False == True) == True)')
class TestIssue2121():
def test_simple(self, testdir):
testdir.tmpdir.join("tests/file.py").ensure().write("""
def test_simple_failure():
assert 1 + 1 == 3
""")
testdir.tmpdir.join("pytest.ini").write(py.std.textwrap.dedent("""
[pytest]
python_files = tests/**.py
"""))
result = testdir.runpytest()
result.stdout.fnmatch_lines('*E*assert (1 + 1) == 3')