Skip to content

Commit fe25e12

Browse files
committed
Skip certain tests on Windows
Sending signals on Windows is surprisingly difficult. CTRL-C is handled by `SIGINT`, which is tested on other platforms and should behave the same. Improving test coverage for Windows will be a future task.
1 parent a80f789 commit fe25e12

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/tests/test_database_backend.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,7 @@ def test_run_subprocess(self) -> None:
12301230

12311231
self.assertEqual(result.status, ResultStatus.COMPLETE)
12321232

1233+
@skipIf(sys.platform == "win32", "Terminate is always forceful on Windows")
12331234
def test_interrupt_no_tasks(self) -> None:
12341235
process = self.start_worker()
12351236

@@ -1240,6 +1241,7 @@ def test_interrupt_no_tasks(self) -> None:
12401241
process.wait(timeout=0.5)
12411242
self.assertEqual(process.returncode, 0)
12421243

1244+
@skipIf(sys.platform == "win32", "Cannot emulate CTRL-C on Windows")
12431245
def test_interrupt_signals(self) -> None:
12441246
for sig in [
12451247
signal.SIGINT, # ctrl-c
@@ -1266,6 +1268,7 @@ def test_interrupt_signals(self) -> None:
12661268

12671269
self.assertEqual(result.status, ResultStatus.COMPLETE)
12681270

1271+
@skipIf(sys.platform == "win32", "Cannot emulate CTRL-C on Windows")
12691272
def test_repeat_ctrl_c(self) -> None:
12701273
result = test_tasks.hang.enqueue()
12711274

@@ -1346,15 +1349,14 @@ def test_keyboard_interrupt_task(self) -> None:
13461349
self.assertIsInstance(result.exception, KeyboardInterrupt)
13471350

13481351
def test_multiple_workers(self) -> None:
1349-
results = [test_tasks.noop_task.enqueue() for _ in range(10)]
1352+
results = [test_tasks.sleep_for.enqueue(0.1) for _ in range(10)]
13501353

13511354
for _ in range(3):
1352-
self.start_worker()
1355+
self.start_worker(["--batch"])
13531356

13541357
time.sleep(self.WORKER_STARTUP_TIME)
13551358

13561359
for process in self.processes:
1357-
process.terminate()
13581360
process.wait(timeout=5)
13591361
self.assertIsNotNone(process.returncode)
13601362

@@ -1367,7 +1369,7 @@ def test_multiple_workers(self) -> None:
13671369
for process in self.processes:
13681370
stdout_text = process.stdout.read() # type:ignore[union-attr]
13691371
all_output += stdout_text
1370-
self.assertIn("shutting down gracefully", stdout_text)
1372+
self.assertIn("gracefully", stdout_text)
13711373

13721374
for result in results:
13731375
# Running and complete

0 commit comments

Comments
 (0)