Skip to content

Commit

Permalink
check for STATUS_CONTROL_C_EXIT on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Aug 25, 2020
1 parent 78ba11c commit ce4601a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Lib/test/test_runpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
import py_compile
import re
import signal
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -755,6 +756,12 @@ def test_encoding(self):


class TestExit(unittest.TestCase):
STATUS_CONTROL_C_EXIT = 0xC000013A
EXPECTED_CODE = (
STATUS_CONTROL_C_EXIT
if sys.platform == "win32"
else -signal.SIGINT
)
@staticmethod
@contextlib.contextmanager
def tmp_path(*args, **kwargs):
Expand All @@ -777,7 +784,7 @@ def run(self, *args, **kwargs):
def assertSigInt(self, *args, **kwargs):
proc = subprocess.run(*args, **kwargs, text=True, stderr=subprocess.PIPE)
self.assertTrue(proc.stderr.endswith("\nKeyboardInterrupt\n"))
self.assertEqual(proc.returncode, -2)
self.assertEqual(proc.returncode, self.EXPECTED_CODE)

def test_pymain_run_file(self):
self.assertSigInt([sys.executable, self.ham])
Expand Down

0 comments on commit ce4601a

Please sign in to comment.