Skip to content

Commit 5655752

Browse files
committed
fix signal.SIGHUP is not available on Windows
1 parent 36263b5 commit 5655752

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

covimerage/cli.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ def run(ctx, args, wrap_profile, profile_file, write_data, data_file,
149149
try:
150150
proc = subprocess.Popen(cmd)
151151

152-
def forward_signals(signalnum, stackframe):
153-
"""Forward SIGHUP to the subprocess."""
154-
proc.send_signal(signalnum)
155-
signal.signal(signal.SIGHUP, forward_signals)
152+
# signal.SIGHUP does not exist on Windows
153+
if hasattr(signal, 'SIGHUP'):
154+
def forward_signals(signalnum, stackframe):
155+
"""Forward SIGHUP to the subprocess."""
156+
proc.send_signal(signalnum)
157+
signal.signal(signal.SIGHUP, forward_signals)
156158

157159
try:
158160
exit_code = proc.wait()

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ def test_run_report_without_data(tmpdir, runner, devnull):
773773
assert result.exit_code == 1
774774

775775

776+
@pytest.mark.skipif(sys.platform == 'win32', reason='SIGHUP is not available on Windows')
776777
def test_run_forwards_sighup(devnull):
777778
proc = subprocess.Popen([
778779
sys.executable, '-m', 'covimerage', 'run',

0 commit comments

Comments
 (0)