summaryrefslogtreecommitdiff
path: root/_pytest/compat.py
diff options
context:
space:
mode:
authorRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2017-02-28 17:31:34 +0100
committerRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2017-03-28 11:45:06 +0200
commit9b58d6eaca17758551929f0ebb390ad900e03581 (patch)
treea0c474f0b29570a31038d72a3d6c223368abe018 /_pytest/compat.py
parent839c9361539aec8bf90a56cdea89ddccc8c40754 (diff)
downloadpytest-9b58d6eaca17758551929f0ebb390ad900e03581.tar.gz
prepare a own pytest.collect fake module in oder to remove the nested builtin namespaces
Diffstat (limited to '_pytest/compat.py')
-rw-r--r--_pytest/compat.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/_pytest/compat.py b/_pytest/compat.py
index b688ae509..5be7f7a2a 100644
--- a/_pytest/compat.py
+++ b/_pytest/compat.py
@@ -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: