Coverage for tests/import_test/two/three/success.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-25 09:27 +0000

1# A module that always works 

2 

3 

4def okay() -> bool: 

5 """Return `True`.""" 

6 return True 

7 

8 

9class Container: 

10 """Class for testing stacklevel.""" 

11 

12 def inside() -> str: 

13 """Return 1.""" 

14 return "1" 

15 

16 @classmethod 

17 def level(cls) -> int: 

18 """Return the stacklevel of the caller relative to this method.""" 

19 import warnings 

20 

21 from lsst.utils.introspection import find_outside_stacklevel 

22 

23 stacklevel = find_outside_stacklevel("import_test") 

24 warnings.warn(f"Using stacklevel={stacklevel} in Container class", stacklevel=stacklevel) 

25 return stacklevel 

26 

27 @classmethod 

28 def indirect_level(cls): 

29 """Return the stacklevel of the caller relative to this method. 

30 

31 Deliberately includes an additional level. 

32 """ 

33 return cls.level()