File: test_coverup_139.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 (25 lines) | stat: -rw-r--r-- 859 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
# file scalene/scalene_profiler.py:551-563
# lines [562, 563]
# branches []

import pytest
import signal
from scalene.scalene_profiler import Scalene
from unittest.mock import MagicMock

# Mock the __memcpy_sigq attribute in Scalene class
Scalene._Scalene__memcpy_sigq = MagicMock()

@pytest.fixture
def clean_scalene_queue():
    # Fixture to clean up the queue after the test
    yield
    Scalene._Scalene__memcpy_sigq.reset_mock()

def test_memcpy_signal_handler(clean_scalene_queue):
    # Create a fake frame object using MagicMock
    fake_frame = MagicMock(spec=[])
    # Call the signal handler with a fake signal and frame
    Scalene.memcpy_signal_handler(signal.SIGINT, fake_frame)
    # Check if the queue put method was called with the correct arguments
    Scalene._Scalene__memcpy_sigq.put.assert_called_once_with((signal.SIGINT, fake_frame))