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