| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import pytest |
| 6 |
import sys |
| 7 |
import threading |
| 8 |
from unittest.mock import patch |
| 9 |
from scalene.scalene_profiler import Scalene |
| 10 |
|
| 11 |
|
| 12 |
@pytest.fixture(scope="function") |
| 13 |
def scalene_cleanup(): |
| 14 |
|
| 15 |
yield |
| 16 |
Scalene.__windows_queue = None |
| 17 |
Scalene.timer_signals = False |
| 18 |
|
| 19 |
|
| 20 |
@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows") |
| 21 |
def test_enable_signals_win32(scalene_cleanup): |
| 22 |
with patch.object(Scalene, "_Scalene__orig_signal") as mock_orig_signal: |
| 23 |
with patch.object(Scalene, "cpu_signal_handler"): |
| 24 |
with patch.object(Scalene, "windows_timer_loop"): |
| 25 |
with patch.object(Scalene, "start_signal_queues"): |
| 26 |
Scalene.enable_signals_win32() |
| 27 |
mock_orig_signal.assert_called_once() |
| 28 |
assert Scalene.timer_signals is True |