introduce new pytest_pycollect_makemodule(path, parent) hook for

allowing customization of the Module collection object for a matching test module.

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-04-29 16:53:29 +02:00
parent 811408959f
commit 962d0fe2be
4 changed files with 33 additions and 1 deletions

View File

@@ -313,6 +313,23 @@ class TestSorting:
class TestConftestCustomization:
def test_pytest_pycollect_module(self, testdir):
testdir.makeconftest("""
import py
class MyModule(py.test.collect.Module):
pass
def pytest_pycollect_makemodule(path, parent):
if path.basename == "test_xyz.py":
return MyModule(path, parent)
""")
testdir.makepyfile("def some(): pass")
testdir.makepyfile(test_xyz="")
result = testdir.runpytest("--collectonly")
result.stdout.fnmatch_lines([
"*<Module*test_pytest*",
"*<MyModule*xyz*",
])
def test_pytest_pycollect_makeitem(self, testdir):
testdir.makeconftest("""
import py