Skip to content

Commit ce4601a

Browse files
committed
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

Lines changed: 8 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy