add a hook called when a Module is successfully created
This commit is contained in:
parent
411e9b136b
commit
241ff0b43a
|
@ -104,6 +104,9 @@ def pytest_pycollect_makemodule(path, parent):
|
||||||
"""
|
"""
|
||||||
pytest_pycollect_makemodule.firstresult = True
|
pytest_pycollect_makemodule.firstresult = True
|
||||||
|
|
||||||
|
def pytest_pycollect_onmodule(mod):
|
||||||
|
""" Called when a module is collected."""
|
||||||
|
|
||||||
def pytest_pycollect_before_module_import(mod):
|
def pytest_pycollect_before_module_import(mod):
|
||||||
"""Called before a module is imported."""
|
"""Called before a module is imported."""
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,11 @@ def pytest_collect_file(path, parent):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
return parent.ihook.pytest_pycollect_makemodule(
|
mod = parent.ihook.pytest_pycollect_makemodule(
|
||||||
path=path, parent=parent)
|
path=path, parent=parent)
|
||||||
|
if mod is not None:
|
||||||
|
parent.ihook.pytest_pycollect_onmodule(mod=mod)
|
||||||
|
return mod
|
||||||
|
|
||||||
def pytest_pycollect_makemodule(path, parent):
|
def pytest_pycollect_makemodule(path, parent):
|
||||||
return Module(path, parent)
|
return Module(path, parent)
|
||||||
|
|
Loading…
Reference in New Issue