Debian Codegraph @

tests/test_coverup_139.py

raw symbols SCIP
1 # file scalene/scalene_profiler.py:551-563
2 # lines [562, 563]
3 # branches []
4
5 import pytest
6 import signal
7 from scalene.scalene_profiler import Scalene
8 from unittest.mock import MagicMock
9
10 # Mock the __memcpy_sigq attribute in Scalene class
11 Scalene._Scalene__memcpy_sigq = MagicMock()
12
13
14 @pytest.fixture
15 def clean_scalene_queue():
16 # Fixture to clean up the queue after the test
17 yield
18 Scalene._Scalene__memcpy_sigq.reset_mock()
19
20
21 def test_memcpy_signal_handler(clean_scalene_queue):
22 # Create a fake frame object using MagicMock
23 fake_frame = MagicMock(spec=[])
24 # Call the signal handler with a fake signal and frame
25 Scalene.memcpy_signal_handler(signal.SIGINT, fake_frame)
26 # Check if the queue put method was called with the correct arguments
27 Scalene._Scalene__memcpy_sigq.put.assert_called_once_with(
28 (signal.SIGINT, fake_frame)
29 )