File: test_coverup_106.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-- 900 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:282-288
# lines [282, 283, 288]
# branches []

import pytest
import signal
from scalene.scalene_profiler import Scalene

@pytest.fixture(scope="function")
def cleanup_signals():
    # Store the original signal state
    original_signals = Scalene.get_timer_signals()
    yield
    # Restore the original signal state after the test
    signal.signal(original_signals[0], signal.SIG_IGN)

def test_get_timer_signals(cleanup_signals):
    # Set a timer signal to test
    signal.signal(signal.SIGVTALRM, signal.SIG_IGN)
    # Call the method to test
    timer_signals = Scalene.get_timer_signals()
    # Check if the signal.SIGVTALRM is in the returned tuple
    assert signal.SIGVTALRM in timer_signals
    # Check if the returned tuple only contains timer signals
    assert isinstance(timer_signals[0], int)
    assert isinstance(timer_signals[1], signal.Signals)