prepare a own pytest.collect fake module in oder to remove the nested builtin namespaces

This commit is contained in:
Ronny Pfannschmidt 2017-02-28 17:31:34 +01:00
parent 839c936153
commit 9b58d6eaca
2 changed files with 26 additions and 0 deletions

View File

@ -254,6 +254,29 @@ else:
return v.encode('ascii', errors)
COLLECT_FAKEMODULE_ATTRIBUTES = (
'Collector',
'Module',
'Generator',
'Function',
'Instance',
'Session',
'Item',
'Class',
'File',
'_fillfuncargs',
)
def _setup_collect_fakemodule():
from types import ModuleType
import pytest
pytest.collect = ModuleType('pytest.collect')
pytest.collect.__all__ = [] # used for setns
for attr in COLLECT_FAKEMODULE_ATTRIBUTES:
setattr(pytest.collect, attr, getattr(pytest, attr))
if _PY2:
from py.io import TextIO as CaptureIO
else:

View File

@ -47,4 +47,7 @@ from _pytest.mark import MARK_GEN as mark
from _pytest.skipping import xfail
set_trace = __pytestPDB.set_trace
from _pytest.compat import _setup_collect_fakemodule
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
_setup_collect_fakemodule()