There was an error while loading. Please reload this page.
1 parent 78ba11c commit ce4601aCopy full SHA for ce4601a
1 file changed
Lib/test/test_runpy.py
@@ -5,6 +5,7 @@
5
import pathlib
6
import py_compile
7
import re
8
+import signal
9
import subprocess
10
import sys
11
import tempfile
@@ -755,6 +756,12 @@ def test_encoding(self):
755
756
757
758
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
+ )
765
@staticmethod
766
@contextlib.contextmanager
767
def tmp_path(*args, **kwargs):
@@ -777,7 +784,7 @@ def run(self, *args, **kwargs):
777
784
def assertSigInt(self, *args, **kwargs):
778
785
proc = subprocess.run(*args, **kwargs, text=True, stderr=subprocess.PIPE)
779
786
self.assertTrue(proc.stderr.endswith("\nKeyboardInterrupt\n"))
780
- self.assertEqual(proc.returncode, -2)
787
+ self.assertEqual(proc.returncode, self.EXPECTED_CODE)
781
788
782
789
def test_pymain_run_file(self):
783
790
self.assertSigInt([sys.executable, self.ham])
0 commit comments