Skip to content

Commit

Permalink
Merge pull request #349 from mj-will/simplify-signal-handling-integra…
Browse files Browse the repository at this point in the history
…tion-test

Simplify signal handling integration tests
  • Loading branch information
mj-will authored Nov 14, 2023
2 parents 0c52766 + 9b50fd1 commit 9cd65b0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/test_flowsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def test_signal_handling(
"nessai.utils.multiprocessing.multiprocessing.get_start_method",
mp_context.get_start_method,
):
fs = FlowSampler(
FlowSampler(
integration_model,
output=output,
nlive=500,
Expand All @@ -988,7 +988,7 @@ def test_signal_handling(
pid = os.getpid()

def trigger_signal():
time.sleep(4)
time.sleep(2)
os.kill(pid, signal.SIGINT)

thread = Thread(target=trigger_signal)
Expand All @@ -997,8 +997,7 @@ def trigger_signal():

with pytest.raises(SystemExit):
try:
while True:
fs.run(save=False, plot=False)
time.sleep(4)
except SystemExit as error:
assert error.code == 5
raise
Expand All @@ -1020,7 +1019,7 @@ def test_signal_handling_disabled(tmp_path, caplog, integration_model):
output = tmp_path / "output"
output.mkdir()

fs = FlowSampler(
FlowSampler(
integration_model,
output=output,
nlive=500,
Expand All @@ -1032,7 +1031,7 @@ def test_signal_handling_disabled(tmp_path, caplog, integration_model):
pid = os.getpid()

def trigger_signal():
time.sleep(4)
time.sleep(2)
os.kill(pid, signal.SIGINT)

thread = Thread(target=trigger_signal)
Expand All @@ -1047,8 +1046,7 @@ def handler(signum=None, frame=None):

with pytest.raises(SystemExit):
try:
while True:
fs.run(save=False, plot=False)
time.sleep(4)
except SystemExit as error:
assert error.code == 10
raise
Expand Down

0 comments on commit 9cd65b0

Please sign in to comment.