add a hook called when a Module is successfully created

This commit is contained in:
Benjamin Peterson 2011-05-26 18:56:45 -05:00
parent 411e9b136b
commit 241ff0b43a
2 changed files with 7 additions and 1 deletions

View File

@ -104,6 +104,9 @@ def pytest_pycollect_makemodule(path, parent):
"""
pytest_pycollect_makemodule.firstresult = True
def pytest_pycollect_onmodule(mod):
""" Called when a module is collected."""
def pytest_pycollect_before_module_import(mod):
"""Called before a module is imported."""

View File

@ -60,8 +60,11 @@ def pytest_collect_file(path, parent):
break
else:
return
return parent.ihook.pytest_pycollect_makemodule(
mod = parent.ihook.pytest_pycollect_makemodule(
path=path, parent=parent)
if mod is not None:
parent.ihook.pytest_pycollect_onmodule(mod=mod)
return mod
def pytest_pycollect_makemodule(path, parent):
return Module(path, parent)