[svn r62613] introduced a pytest_collect_directory hook.

--HG--
branch : trunk
This commit is contained in:
hpk
2009-03-05 23:15:42 +01:00
parent 27a501d171
commit ad06cfdc9d
3 changed files with 45 additions and 21 deletions

View File

@@ -153,6 +153,24 @@ class TestCollectPluginHooks:
assert len(wascalled) == 1
assert wascalled[0].ext == '.abc'
def test_pytest_collect_directory(self, testdir):
tmpdir = testdir.tmpdir
wascalled = []
class Plugin:
def pytest_collect_directory(self, path, parent):
wascalled.append(path.basename)
return parent.Directory(path, parent)
testdir.plugins.append(Plugin())
testdir.mkdir("hello")
testdir.mkdir("world")
evrec = testdir.inline_run()
assert "hello" in wascalled
assert "world" in wascalled
# make sure the directories do not get double-appended
colreports = evrec.getnamed("collectionreport")
names = [rep.colitem.name for rep in colreports]
assert names.count("hello") == 1
class TestCustomConftests:
def test_non_python_files(self, testdir):
testdir.makepyfile(conftest="""