Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/pytest/collect.py : 11%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import sys
2from types import ModuleType
3from typing import Any
4from typing import List
6import pytest
9COLLECT_FAKEMODULE_ATTRIBUTES = [
10 "Collector",
11 "Module",
12 "Function",
13 "Instance",
14 "Session",
15 "Item",
16 "Class",
17 "File",
18 "_fillfuncargs",
19]
22class FakeCollectModule(ModuleType):
23 def __init__(self) -> None:
24 super().__init__("pytest.collect")
25 self.__all__ = list(COLLECT_FAKEMODULE_ATTRIBUTES)
26 self.__pytest = pytest
28 def __dir__(self) -> List[str]:
29 return dir(super()) + self.__all__
31 def __getattr__(self, name: str) -> Any:
32 if name not in self.__all__:
33 raise AttributeError(name)
34 # Uncomment this after 6.0 release (#7361)
35 # warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2)
36 return getattr(pytest, name)
39sys.modules["pytest.collect"] = FakeCollectModule()