File: test_coverup_113.py

package info (click to toggle)
scalene 1.5.51-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,528 kB
  • sloc: cpp: 22,930; python: 13,403; javascript: 11,769; ansic: 817; makefile: 196; sh: 45
file content (28 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download
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()