File: test_coverup_26.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 (26 lines) | stat: -rw-r--r-- 983 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
# file scalene/scalene_profiler.py:565-579
# lines [565, 566, 567, 568, 569, 570, 571, 574, 575, 576, 577, 578, 579]
# branches []

import pytest
import sys
import threading
from unittest.mock import patch
from scalene.scalene_profiler import Scalene

@pytest.fixture(scope="function")
def scalene_cleanup():
    # Fixture to clean up state after tests
    yield
    Scalene.__windows_queue = None
    Scalene.timer_signals = False

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_enable_signals_win32(scalene_cleanup):
    with patch.object(Scalene, '_Scalene__orig_signal') as mock_orig_signal:
        with patch.object(Scalene, 'cpu_signal_handler'):
            with patch.object(Scalene, 'windows_timer_loop'):
                with patch.object(Scalene, 'start_signal_queues'):
                    Scalene.enable_signals_win32()
                    mock_orig_signal.assert_called_once()
                    assert Scalene.timer_signals is True