diff options
author | Ronny Pfannschmidt <ronny.pfannschmidt@redhat.com> | 2017-02-28 17:31:34 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <ronny.pfannschmidt@redhat.com> | 2017-03-28 11:45:06 +0200 |
commit | 9b58d6eaca17758551929f0ebb390ad900e03581 (patch) | |
tree | a0c474f0b29570a31038d72a3d6c223368abe018 /_pytest/compat.py | |
parent | 839c9361539aec8bf90a56cdea89ddccc8c40754 (diff) | |
download | pytest-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.py | 23 |
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: |