1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/changeset/6d5db6fbe405/ changeset: 6d5db6fbe405 user: hpk42 date: 2012-06-26 21:56:03 summary: fix issue151 - heuristcally lookup conftest files on all command line arguments, not just the first existing dir/file you can install the corresponding pytest-2.3.dev2 via pip install -i http:/pypi.testrun.org -U pytest affected #: 4 files diff -r b6692c800dd434d1b6abca3e4b4bb261b59911eb -r 6d5db6fbe405aacc5b828ec1f461f7699fa25664 _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.0.dev1' +__version__ = '2.3.0.dev2' diff -r b6692c800dd434d1b6abca3e4b4bb261b59911eb -r 6d5db6fbe405aacc5b828ec1f461f7699fa25664 _pytest/config.py --- a/_pytest/config.py +++ b/_pytest/config.py @@ -151,20 +151,24 @@ p = current.join(opt1[len(opt)+1:], abs=1) self._confcutdir = p break - for arg in args + [current]: + foundanchor = False + for arg in args: if hasattr(arg, 'startswith') and arg.startswith("--"): continue anchor = current.join(arg, abs=1) if anchor.check(): # we found some file object - self._path2confmods[None] = self.getconftestmodules(anchor) - # let's also consider test* dirs - if anchor.check(dir=1): - for x in anchor.listdir("test*"): - if x.check(dir=1): - self.getconftestmodules(x) - break - else: - assert 0, "no root of filesystem?" + self._try_load_conftest(anchor) + foundanchor = True + if not foundanchor: + self._try_load_conftest(current) + + def _try_load_conftest(self, anchor): + self._path2confmods[None] = self.getconftestmodules(anchor) + # let's also consider test* subdirs + if anchor.check(dir=1): + for x in anchor.listdir("test*"): + if x.check(dir=1): + self.getconftestmodules(x) def getconftestmodules(self, path): """ return a list of imported conftest modules for the given path. """ diff -r b6692c800dd434d1b6abca3e4b4bb261b59911eb -r 6d5db6fbe405aacc5b828ec1f461f7699fa25664 setup.py --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.0.dev1', + version='2.3.0.dev2', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -r b6692c800dd434d1b6abca3e4b4bb261b59911eb -r 6d5db6fbe405aacc5b828ec1f461f7699fa25664 testing/test_conftest.py --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -15,7 +15,8 @@ d.ensure("adir/__init__.py") d.ensure("adir/b/__init__.py") return d - return request.cached_setup(lambda: basedirmaker(request), extrakey=request.param) + return request.cached_setup( + lambda: basedirmaker(request), extrakey=request.param) def ConftestWithSetinitial(path): conftest = Conftest() @@ -106,6 +107,17 @@ l = conftest.getconftestmodules(None) assert len(l) == 0 +def test_issue151_load_all_conftests(testdir): + names = "code proj src".split() + for name in names: + p = testdir.mkdir(name) + p.ensure("conftest.py") + + conftest = Conftest() + conftest.setinitial(names) + d = list(conftest._conftestpath2mod.values()) + assert len(d) == len(names) + def test_conftest_global_import(testdir): testdir.makeconftest("x=3") p = testdir.makepyfile(""" Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ py-svn mailing list py-svn@codespeak.net http://codespeak.net/mailman/listinfo/py-svn