Skip to content

Commit fb36836

Browse files
committed
use subtest.
1 parent 8fcb9d7 commit fb36836

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

irods/test/modules/test_signal_handling_in_multithread_get.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test(test_case, signal_names=("SIGTERM", "SIGINT")):
3838
program = os.path.join(test_modules.__path__[0], os.path.basename(__file__))
3939

4040
for signal_name in signal_names:
41+
42+
test_case.subTest(f"Testing with signal {signal_name}")
43+
4144
# Call into this same module as a command. This will initiate another Python process that
4245
# performs a lengthy data object "get" operation (see the main body of the script, below.)
4346
process = subprocess.Popen(
@@ -59,7 +62,6 @@ def test(test_case, signal_names=("SIGTERM", "SIGINT")):
5962
"Parallel download from data_objects.get() probably experienced a fatal error before spawning auxiliary data transfer threads.",
6063
)
6164

62-
signal_message_info = f"While testing signal {signal_name}"
6365
sig = getattr(signal, signal_name)
6466

6567
# Interrupt the subprocess with the given signal.
@@ -70,18 +72,18 @@ def test(test_case, signal_names=("SIGTERM", "SIGINT")):
7072
test_case.assertEqual(
7173
process.wait(timeout=15),
7274
-sig,
73-
"{signal_message_info}: unexpected subprocess return code.",
75+
"Unexpected subprocess return code.",
7476
)
7577
except subprocess.TimeoutExpired as timeout_exc:
7678
test_case.fail(
77-
f"{signal_message_info}: subprocess timed out before terminating. "
79+
f"Subprocess timed out before terminating. "
7880
"Non-daemon thread(s) probably prevented subprocess's main thread from exiting."
7981
)
8082
# Assert that in the case of SIGINT, the process registered a KeyboardInterrupt.
8183
if sig == signal.SIGINT:
8284
test_case.assertTrue(
8385
re.search("KeyboardInterrupt", process.stderr.read()),
84-
"{signal_message_info}: Expected 'KeyboardInterrupt' in log output.",
86+
"Did not find expected string 'KeyboardInterrupt' in log output.",
8587
)
8688

8789

0 commit comments

Comments
 (0)