@@ -1138,3 +1138,55 @@ def test_succeed():
1138
1138
testdir .makepyfile (test_file )
1139
1139
rr = testdir .run (* cmd_opts , timeout = timeout )
1140
1140
assert_outcomes (rr , {"passed" : 1 })
1141
+
1142
+
1143
+ def test_sigint_for_regular_tests (testdir , cmd_opts ):
1144
+ test_file = """
1145
+ import os
1146
+ import signal
1147
+ import time
1148
+
1149
+ import twisted.internet
1150
+ import twisted.internet.task
1151
+
1152
+ def test_self_cancel():
1153
+ os.kill(os.getpid(), signal.SIGINT)
1154
+ time.sleep(10)
1155
+
1156
+ def test_should_not_run():
1157
+ assert False
1158
+ """
1159
+ testdir .makepyfile (test_file )
1160
+ rr = testdir .run (* cmd_opts , timeout = timeout )
1161
+ assert_outcomes (rr , {})
1162
+ rr .stdout .re_match_lines (lines2 = [r".* no tests ran in .*" ])
1163
+
1164
+
1165
+ def test_sigint_for_inline_callbacks_tests (testdir , cmd_opts ):
1166
+ test_file = """
1167
+ import os
1168
+ import signal
1169
+
1170
+ import twisted.internet
1171
+ import twisted.internet.task
1172
+
1173
+ import pytest_twisted
1174
+
1175
+ @pytest_twisted.inlineCallbacks
1176
+ def test_self_cancel():
1177
+ os.kill(os.getpid(), signal.SIGINT)
1178
+ yield twisted.internet.task.deferLater(
1179
+ twisted.internet.reactor,
1180
+ 9999,
1181
+ lambda: None,
1182
+ )
1183
+
1184
+ @pytest_twisted.inlineCallbacks
1185
+ def test_should_not_run():
1186
+ assert False
1187
+ yield
1188
+ """
1189
+ testdir .makepyfile (test_file )
1190
+ rr = testdir .run (* cmd_opts , timeout = timeout )
1191
+ assert_outcomes (rr , {})
1192
+ rr .stdout .re_match_lines (lines2 = [r".* no tests ran in .*" ])
0 commit comments