Coverage for tests/import_test/two/three/success.py: 100%
15 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-17 07:53 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-17 07:53 +0000
1# A module that always works
4def okay() -> bool:
5 """Return `True`."""
6 return True
9class Container:
10 """Class for testing stacklevel."""
12 def inside() -> str:
13 """Return 1."""
14 return "1"
16 @classmethod
17 def level(cls, allow_methods=frozenset(), allow_modules=frozenset()) -> int:
18 """Return the stacklevel of the caller relative to this method."""
19 import warnings
21 from lsst.utils.introspection import find_outside_stacklevel
23 stacklevel = find_outside_stacklevel(
24 "import_test", allow_methods=allow_methods, allow_modules=allow_modules
25 )
26 warnings.warn(
27 f"Using stacklevel={stacklevel} in Container class", category=FutureWarning, stacklevel=stacklevel
28 )
29 return stacklevel
31 @classmethod
32 def indirect_level(cls, allow_methods=frozenset(), allow_modules=frozenset()):
33 """Return the stacklevel of the caller relative to this method.
35 Deliberately includes an additional level.
36 """
37 return cls.level(allow_methods=allow_methods, allow_modules=allow_modules)