Coverage for tests/decorator_test/disable_timer.py: 90%

10 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-16 14:40 -0700

1"""Methods used to test that the appropriate envvar disables the timing 

2decorator. 

3""" 

4 

5import logging 

6import time 

7 

8from lsst.utils.timer import timeMethod 

9 

10log = logging.getLogger("disable_timer") 

11 

12 

13@timeMethod(logger=log, logLevel=logging.INFO) 

14def sleep_and_log(self, duration: float) -> None: 

15 """Check that this does not log if the decorator was disabled on import. 

16 

17 Parameters 

18 ---------- 

19 duration : `float` 

20 Time to sleep. 

21 """ 

22 time.sleep(duration) 

23 

24 

25@timeMethod 

26def sleep_and_nothing(self, duration: float) -> None: 

27 """Check that this does not have a `__wrapped__` attribute to confirm that 

28 the decorator is disabled. 

29 

30 Parameters 

31 ---------- 

32 duration : `float` 

33 Time to sleep. 

34 """ 

35 time.sleep(duration)