Skip to content

Commit

Permalink
Fix mypy issues on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Sep 10, 2024
1 parent 345827b commit 49ce403
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/tests/test_database_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,15 @@ def start_worker(
self.processes.append(p)
return p

@staticmethod
def _get_ctrl_c_signal() -> int:
"""
Windows uses a different signal for CTRL-C than Unix.
"""
if hasattr(signal, "CTRL_C_EVENT"):
return cast(int, signal.CTRL_C_EVENT)
return signal.SIGINT

def test_run_subprocess(self) -> None:
result = test_tasks.noop_task.enqueue()
process = self.start_worker(["--batch"])
Expand All @@ -1223,7 +1232,7 @@ def test_interrupt_no_tasks(self) -> None:

def test_interrupt_signals(self) -> None:
for sig in [
signal.CTRL_C_EVENT if sys.platform == "win32" else signal.SIGINT, # type:ignore[attr-defined]
self._get_ctrl_c_signal(),
signal.SIGTERM,
]:
with self.subTest(sig):
Expand All @@ -1248,9 +1257,7 @@ def test_interrupt_signals(self) -> None:
self.assertEqual(result.status, ResultStatus.COMPLETE)

def test_repeat_ctrl_c(self) -> None:
ctrl_c_signal = (
signal.CTRL_C_EVENT if sys.platform == "win32" else signal.SIGINT # type:ignore[attr-defined]
)
ctrl_c_signal = self._get_ctrl_c_signal()

result = test_tasks.hang.enqueue()

Expand Down

0 comments on commit 49ce403

Please sign in to comment.