Coverage for conftest.py: 89%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-12-24 08:16 +0100

1import sys 

2 

3import pytest 

4from benchman import BenchmarkManager 

5 

6 

7def pytest_addoption(parser) -> None: 

8 """Add an optional command line arguments to pytest. 

9 

10 This `--benchmarks` flag is then used to enable benchmarks using the 

11 `@benchmark` decorator. 

12 """ 

13 parser.addoption("--benchmarks", action="store_true") 

14 

15 

16#: '@benchmark' decorator to skip test unless `--benchmarks` is set. 

17benchmark = pytest.mark.skipif( 

18 "--benchmarks" not in sys.argv, 

19 reason="`--benchmarks` not set", 

20) 

21 

22 

23#: Define a fixture to provide a singleton instance of the BenchmarkManager. 

24#: This uses dependency injection to provide the `benchman` fixture to tests. 

25@pytest.fixture(scope="session") 

26def benchman() -> BenchmarkManager: 

27 return BenchmarkManager.singleton()