check and load test*/conftest.py early from anchors -
this makes it a bit more convenient to have command line options available from a root directory of a project that does not directly contain a conftest.py --HG-- branch : trunk
This commit is contained in:
parent
33d78f41b2
commit
7bd60b5abb
|
@ -1,6 +1,9 @@
|
|||
Changes between 1.2.1 and 1.2.0
|
||||
=====================================
|
||||
|
||||
- early-load "test*/conftest.py" files, i.e. conftest.py files in
|
||||
directories starting with 'test'. allows to conveniently keep and access
|
||||
test-related options without having to put a conftest.py into the package root dir.
|
||||
- fix issue67: new super-short traceback-printing option: "--tb=line" will print a single line for each failing (python) test indicating its filename, lineno and the failure value
|
||||
- fix issue78: always call python-level teardown functions even if the
|
||||
according setup failed. This includes refinements for calling setup_module/class functions
|
||||
|
|
|
@ -39,6 +39,10 @@ class Conftest(object):
|
|||
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*"):
|
||||
self.getconftestmodules(x)
|
||||
break
|
||||
else:
|
||||
assert 0, "no root of filesystem?"
|
||||
|
|
|
@ -132,3 +132,19 @@ def test_setinitial_confcut(testdir):
|
|||
assert conftest._confcutdir == sub
|
||||
assert conftest.getconftestmodules(sub) == []
|
||||
assert conftest.getconftestmodules(conf.dirpath()) == []
|
||||
|
||||
def test_setinitial_not_considers_conftest_in_non_test_dirs(testdir):
|
||||
sub = testdir.mkdir("sub")
|
||||
sub.ensure("conftest.py")
|
||||
conftest = Conftest()
|
||||
conftest.setinitial([sub.dirpath()])
|
||||
assert not conftest._conftestpath2mod
|
||||
|
||||
@py.test.mark.multi(name='test tests testing'.split())
|
||||
def test_setinitial_considers_conftest_in_test_dirs(testdir, name):
|
||||
sub = testdir.mkdir(name)
|
||||
subconftest = sub.ensure("conftest.py")
|
||||
conftest = Conftest()
|
||||
conftest.setinitial([sub.dirpath()])
|
||||
assert subconftest in conftest._conftestpath2mod
|
||||
assert len(conftest._conftestpath2mod) == 1
|
||||
|
|
Loading…
Reference in New Issue