mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Add support.MS_WINDOWS constant (#110446)
(cherry picked from commit e0c4437793
)
This commit is contained in:
parent
67028f0c15
commit
e188534607
10 changed files with 27 additions and 23 deletions
|
@ -9,9 +9,9 @@ import _testinternalcapi
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
from test.support import MS_WINDOWS
|
||||||
|
|
||||||
|
|
||||||
MS_WINDOWS = (os.name == 'nt')
|
|
||||||
MAX_HASH_SEED = 4294967295
|
MAX_HASH_SEED = 4294967295
|
||||||
|
|
||||||
class SetConfigTests(unittest.TestCase):
|
class SetConfigTests(unittest.TestCase):
|
||||||
|
|
|
@ -704,6 +704,19 @@ def collect_test_support(info_add):
|
||||||
attributes = ('IPV6_ENABLED',)
|
attributes = ('IPV6_ENABLED',)
|
||||||
copy_attributes(info_add, support, 'test_support.%s', attributes)
|
copy_attributes(info_add, support, 'test_support.%s', attributes)
|
||||||
|
|
||||||
|
attributes = (
|
||||||
|
'MS_WINDOWS',
|
||||||
|
'has_fork_support',
|
||||||
|
'has_socket_support',
|
||||||
|
'has_strftime_extensions',
|
||||||
|
'has_subprocess_support',
|
||||||
|
'is_android',
|
||||||
|
'is_emscripten',
|
||||||
|
'is_jython',
|
||||||
|
'is_wasi',
|
||||||
|
)
|
||||||
|
copy_attributes(info_add, support, 'support.%s', attributes)
|
||||||
|
|
||||||
call_func(info_add, 'test_support._is_gui_available', support, '_is_gui_available')
|
call_func(info_add, 'test_support._is_gui_available', support, '_is_gui_available')
|
||||||
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
|
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ __all__ = [
|
||||||
"check_disallow_instantiation", "check_sanitizer", "skip_if_sanitizer",
|
"check_disallow_instantiation", "check_sanitizer", "skip_if_sanitizer",
|
||||||
"requires_limited_api", "requires_specialization",
|
"requires_limited_api", "requires_specialization",
|
||||||
# sys
|
# sys
|
||||||
"is_jython", "is_android", "is_emscripten", "is_wasi",
|
"MS_WINDOWS", "is_jython", "is_android", "is_emscripten", "is_wasi",
|
||||||
"check_impl_detail", "unix_shell", "setswitchinterval",
|
"check_impl_detail", "unix_shell", "setswitchinterval",
|
||||||
# os
|
# os
|
||||||
"get_pagesize",
|
"get_pagesize",
|
||||||
|
@ -509,6 +509,8 @@ def requires_legacy_unicode_capi():
|
||||||
return unittest.skipUnless(unicode_legacy_string,
|
return unittest.skipUnless(unicode_legacy_string,
|
||||||
'requires legacy Unicode C API')
|
'requires legacy Unicode C API')
|
||||||
|
|
||||||
|
MS_WINDOWS = (sys.platform == 'win32')
|
||||||
|
|
||||||
# Is not actually used in tests, but is kept for compatibility.
|
# Is not actually used in tests, but is kept for compatibility.
|
||||||
is_jython = sys.platform.startswith('java')
|
is_jython = sys.platform.startswith('java')
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ from test import support
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
|
|
||||||
|
|
||||||
MS_WINDOWS = (sys.platform == 'win32')
|
if support.MS_WINDOWS:
|
||||||
if MS_WINDOWS:
|
|
||||||
import msvcrt
|
import msvcrt
|
||||||
else:
|
else:
|
||||||
from asyncio import unix_events
|
from asyncio import unix_events
|
||||||
|
@ -283,7 +282,7 @@ class SubprocessMixin:
|
||||||
rfd, wfd = os.pipe()
|
rfd, wfd = os.pipe()
|
||||||
self.addCleanup(os.close, rfd)
|
self.addCleanup(os.close, rfd)
|
||||||
self.addCleanup(os.close, wfd)
|
self.addCleanup(os.close, wfd)
|
||||||
if MS_WINDOWS:
|
if support.MS_WINDOWS:
|
||||||
handle = msvcrt.get_osfhandle(rfd)
|
handle = msvcrt.get_osfhandle(rfd)
|
||||||
os.set_handle_inheritable(handle, True)
|
os.set_handle_inheritable(handle, True)
|
||||||
code = textwrap.dedent(f'''
|
code = textwrap.dedent(f'''
|
||||||
|
|
|
@ -10,7 +10,6 @@ from test import support
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
|
|
||||||
|
|
||||||
MS_WINDOWS = (sys.platform == 'win32')
|
|
||||||
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
|
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
|
||||||
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
|
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ class TestCPPExt(unittest.TestCase):
|
||||||
|
|
||||||
# With MSVC, the linker fails with: cannot open file 'python311.lib'
|
# With MSVC, the linker fails with: cannot open file 'python311.lib'
|
||||||
# https://github.com/python/cpython/pull/32175#issuecomment-1111175897
|
# https://github.com/python/cpython/pull/32175#issuecomment-1111175897
|
||||||
@unittest.skipIf(MS_WINDOWS, 'test fails on Windows')
|
@unittest.skipIf(support.MS_WINDOWS, 'test fails on Windows')
|
||||||
# Building and running an extension in clang sanitizing mode is not
|
# Building and running an extension in clang sanitizing mode is not
|
||||||
# straightforward
|
# straightforward
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
|
|
|
@ -4,15 +4,13 @@ import os
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
from test import support
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
|
|
||||||
MS_WINDOWS = (sys.platform == 'win32')
|
|
||||||
|
|
||||||
|
|
||||||
SOURCE = 'extension.cpp'
|
SOURCE = 'extension.cpp'
|
||||||
if not MS_WINDOWS:
|
if not support.MS_WINDOWS:
|
||||||
# C++ compiler flags for GCC and clang
|
# C++ compiler flags for GCC and clang
|
||||||
CPPFLAGS = [
|
CPPFLAGS = [
|
||||||
# gh-91321: The purpose of _testcppext extension is to check that building
|
# gh-91321: The purpose of _testcppext extension is to check that building
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
# Run the tests in Programs/_testembed.c (tests for the CPython embedding APIs)
|
# Run the tests in Programs/_testembed.c (tests for the CPython embedding APIs)
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import import_helper
|
from test.support import import_helper, os_helper, MS_WINDOWS
|
||||||
from test.support import os_helper
|
|
||||||
from test.support import requires_specialization
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
@ -21,7 +19,6 @@ import textwrap
|
||||||
if not support.has_subprocess_support:
|
if not support.has_subprocess_support:
|
||||||
raise unittest.SkipTest("test module requires subprocess")
|
raise unittest.SkipTest("test module requires subprocess")
|
||||||
|
|
||||||
MS_WINDOWS = (os.name == 'nt')
|
|
||||||
MACOS = (sys.platform == 'darwin')
|
MACOS = (sys.platform == 'darwin')
|
||||||
PYMEM_ALLOCATOR_NOT_SET = 0
|
PYMEM_ALLOCATOR_NOT_SET = 0
|
||||||
PYMEM_ALLOCATOR_DEBUG = 2
|
PYMEM_ALLOCATOR_DEBUG = 2
|
||||||
|
@ -347,7 +344,7 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
out, err = self.run_embedded_interpreter("test_repeated_simple_init")
|
out, err = self.run_embedded_interpreter("test_repeated_simple_init")
|
||||||
self.assertEqual(out, 'Finalized\n' * INIT_LOOPS)
|
self.assertEqual(out, 'Finalized\n' * INIT_LOOPS)
|
||||||
|
|
||||||
@requires_specialization
|
@support.requires_specialization
|
||||||
def test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE(self):
|
def test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE(self):
|
||||||
# https://github.com/python/cpython/issues/92031
|
# https://github.com/python/cpython/issues/92031
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import os_helper
|
from test.support import os_helper, script_helper, is_android, MS_WINDOWS
|
||||||
from test.support import script_helper, is_android
|
|
||||||
from test.support import skip_if_sanitizer
|
from test.support import skip_if_sanitizer
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -23,7 +22,6 @@ if not support.has_subprocess_support:
|
||||||
raise unittest.SkipTest("test module requires subprocess")
|
raise unittest.SkipTest("test module requires subprocess")
|
||||||
|
|
||||||
TIMEOUT = 0.5
|
TIMEOUT = 0.5
|
||||||
MS_WINDOWS = (os.name == 'nt')
|
|
||||||
|
|
||||||
|
|
||||||
def expected_traceback(lineno1, lineno2, header, min_count=1):
|
def expected_traceback(lineno1, lineno2, header, min_count=1):
|
||||||
|
|
|
@ -9,8 +9,7 @@ import unittest
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
|
|
||||||
MS_WINDOWS = (os.name == 'nt')
|
if support.MS_WINDOWS:
|
||||||
if MS_WINDOWS:
|
|
||||||
# On Windows, Python is usually built by MSVC. Passing /p:DebugSymbols=true
|
# On Windows, Python is usually built by MSVC. Passing /p:DebugSymbols=true
|
||||||
# option to MSBuild produces PDB debug symbols, but gdb doesn't support PDB
|
# option to MSBuild produces PDB debug symbols, but gdb doesn't support PDB
|
||||||
# debug symbol files.
|
# debug symbol files.
|
||||||
|
|
|
@ -9,10 +9,9 @@ import textwrap
|
||||||
import unittest
|
import unittest
|
||||||
from test import support
|
from test import support
|
||||||
from test.support.script_helper import assert_python_ok, assert_python_failure
|
from test.support.script_helper import assert_python_ok, assert_python_failure
|
||||||
from test.support import os_helper
|
from test.support import os_helper, MS_WINDOWS
|
||||||
|
|
||||||
|
|
||||||
MS_WINDOWS = (sys.platform == 'win32')
|
|
||||||
POSIX_LOCALES = ('C', 'POSIX')
|
POSIX_LOCALES = ('C', 'POSIX')
|
||||||
VXWORKS = (sys.platform == "vxworks")
|
VXWORKS = (sys.platform == "vxworks")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue