Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce4601a

Browse files
committedAug 25, 2020
check for STATUS_CONTROL_C_EXIT on windows
1 parent 78ba11c commit ce4601a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎Lib/test/test_runpy.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pathlib
66
import py_compile
77
import re
8+
import signal
89
import subprocess
910
import sys
1011
import tempfile
@@ -755,6 +756,12 @@ def test_encoding(self):
755756

756757

757758
class TestExit(unittest.TestCase):
759+
STATUS_CONTROL_C_EXIT = 0xC000013A
760+
EXPECTED_CODE = (
761+
STATUS_CONTROL_C_EXIT
762+
if sys.platform == "win32"
763+
else -signal.SIGINT
764+
)
758765
@staticmethod
759766
@contextlib.contextmanager
760767
def tmp_path(*args, **kwargs):
@@ -777,7 +784,7 @@ def run(self, *args, **kwargs):
777784
def assertSigInt(self, *args, **kwargs):
778785
proc = subprocess.run(*args, **kwargs, text=True, stderr=subprocess.PIPE)
779786
self.assertTrue(proc.stderr.endswith("\nKeyboardInterrupt\n"))
780-
self.assertEqual(proc.returncode, -2)
787+
self.assertEqual(proc.returncode, self.EXPECTED_CODE)
781788

782789
def test_pymain_run_file(self):
783790
self.assertSigInt([sys.executable, self.ham])

0 commit comments

Comments
 (0)
Please sign in to comment.