# file scalene/scalene_profiler.py:1629-1645 # lines [1643, 1644, 1645] # branches ['1643->1644', '1643->1645'] import os import signal import pytest from scalene.scalene_profiler import Scalene @pytest.fixture def scalene_setup_and_teardown(): # Setup code Scalene.start = lambda: None Scalene.__orig_kill = os.kill Scalene.__signals = type("Signals", (), {"start_profiling_signal": signal.SIGCONT}) Scalene.child_pids = set() # Create a child process and add its PID to the set pid = os.fork() if pid == 0: # Child process: wait for a signal signal.pause() else: # Parent process: add child PID to the set Scalene.child_pids.add(pid) yield # Teardown code if pid > 0: os.kill(pid, signal.SIGKILL) # Terminate the child process Scalene.child_pids.remove(pid) Scalene.child_pids.clear() def test_start_signal_handler(scalene_setup_and_teardown): # Test that the signal handler sends the start_profiling_signal to child processes Scalene.start_signal_handler(None, None) # No direct postconditions to assert; the test is for coverage of the signal sending