diff --git a/CHANGELOG b/CHANGELOG index 0c7f453e5..75ff8927b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,8 @@ Changes between 2.3.3 and 2.3.4.dev with autouse fixtures. If you need generative tests, use @pytest.mark.parametrize or pytest_generate_tests, see the many examples at http://pytest.org/latest/example/parametrize.html +- fix autouse-issue where autouse-fixtures would not be discovered + if defined in a a/conftest.py file and tests in a/tests/test_some.py - fix issue226 - LIFO ordering for fixture teardowns - fix issue224 - invocations with >256 char arguments now work - fix issue91 - add/discuss package/directory level setups in example diff --git a/_pytest/__init__.py b/_pytest/__init__.py index b3ea02e4e..5c84caa5f 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.4.dev5' +__version__ = '2.3.4.dev6' diff --git a/_pytest/python.py b/_pytest/python.py index 476296cb4..cc7b5ba20 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1455,7 +1455,7 @@ class FixtureManager: for baseid, basenames in self._nodeid_and_autousenames: if nodeid.startswith(baseid): if baseid: - i = len(baseid) + 1 + i = len(baseid) nextchar = nodeid[i:i+1] if nextchar and nextchar not in ":/": continue diff --git a/setup.py b/setup.py index 626a82e55..4b5dcbb4a 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.4.dev5', + version='2.3.4.dev6', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 0e412dbe7..a1afe9f57 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -948,7 +948,26 @@ class TestAutouseDiscovery: reprec = testdir.inline_run() reprec.assertoutcome(passed=3) + class TestAutouseManagement: + def test_autouse_conftest_mid_directory(self, testdir): + pkgdir = testdir.mkpydir("xyz123") + pkgdir.join("conftest.py").write(py.code.Source(""" + import pytest + @pytest.fixture(autouse=True) + def app(): + import sys + sys._myapp = "hello" + """)) + t = pkgdir.ensure("tests", "test_app.py") + t.write(py.code.Source(""" + import sys + def test_app(): + assert sys._myapp == "hello" + """)) + reprec = testdir.inline_run("-s") + reprec.assertoutcome(passed=1) + def test_funcarg_and_setup(self, testdir): testdir.makepyfile(""" import pytest