Debian Codegraph @

tests/test_coverup_113.py

raw symbols SCIP
1 # file scalene/scalene_profiler.py:148-150
2 # lines [148, 150]
3 # branches []
4
5 import pytest
6 from scalene import scalene_profiler
7 from unittest.mock import patch
8
9 # Assuming the existence of a `Scalene` class in the `scalene_profiler` module
10 # which has a static method `stop` that needs to be tested for coverage.
11
12
13 @pytest.fixture(scope="function")
14 def scalene_cleanup():
15 # Setup code if necessary
16 yield
17 # Teardown code: ensure that the profiler is stopped after the test
18 with patch.object(scalene_profiler.Scalene, "stop", return_value=None):
19 scalene_profiler.Scalene.stop()
20
21
22 def test_scalene_stop(scalene_cleanup):
23 # Mock the start method to avoid SystemExit
24 with patch.object(scalene_profiler.Scalene, "start", return_value=None):
25 scalene_profiler.Scalene.start()
26 # Mock the stop method to avoid the actual stop logic
27 with patch.object(scalene_profiler.Scalene, "stop", return_value=None) as mock_stop:
28 # Corrected the call to the stop method
29 scalene_profiler.Scalene.stop()
30 mock_stop.assert_called_once()