Skip to content

Commit

Permalink
[3.11] Add support.MS_WINDOWS constant (#110446) (#110452) (#110464)
Browse files Browse the repository at this point in the history
[3.12] Add support.MS_WINDOWS constant (#110446) (#110452)

Add support.MS_WINDOWS constant (#110446)

(cherry picked from commit e0c4437)
(cherry picked from commit e188534)
  • Loading branch information
vstinner committed Oct 6, 2023
1 parent 4499e6c commit 88223f1
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Lib/test/_test_embed_set_config.py
Expand Up @@ -9,9 +9,9 @@
import os
import sys
import unittest
from test.support import MS_WINDOWS


MS_WINDOWS = (os.name == 'nt')
MAX_HASH_SEED = 4294967295

class SetConfigTests(unittest.TestCase):
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/pythoninfo.py
Expand Up @@ -713,6 +713,19 @@ def collect_test_support(info_add):
attributes = ('IPV6_ENABLED',)
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.python_is_optimized', support, 'python_is_optimized')

Expand Down
4 changes: 3 additions & 1 deletion Lib/test/support/__init__.py
Expand Up @@ -48,7 +48,7 @@
"check__all__", "skip_if_buggy_ucrt_strfptime",
"check_disallow_instantiation", "check_sanitizer", "skip_if_sanitizer",
# 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",
# network
"open_urlresource",
Expand Down Expand Up @@ -501,6 +501,8 @@ def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
requires_legacy_unicode_capi = unittest.skipUnless(unicode_legacy_string,
'requires legacy Unicode C API')

MS_WINDOWS = (sys.platform == 'win32')

is_jython = sys.platform.startswith('java')

is_android = hasattr(sys, 'getandroidapilevel')
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_asyncio/test_subprocess.py
Expand Up @@ -15,8 +15,7 @@
from test.support import os_helper


MS_WINDOWS = (sys.platform == 'win32')
if MS_WINDOWS:
if support.MS_WINDOWS:
import msvcrt
else:
from asyncio import unix_events
Expand Down Expand Up @@ -266,7 +265,7 @@ def test_stdin_broken_pipe(self):
rfd, wfd = os.pipe()
self.addCleanup(os.close, rfd)
self.addCleanup(os.close, wfd)
if MS_WINDOWS:
if support.MS_WINDOWS:
handle = msvcrt.get_osfhandle(rfd)
os.set_handle_inheritable(handle, True)
code = textwrap.dedent(f'''
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_cppext/__init__.py
Expand Up @@ -9,7 +9,6 @@
from test.support import os_helper


MS_WINDOWS = (sys.platform == 'win32')
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')


Expand All @@ -25,7 +24,7 @@ def test_build_cpp03(self):

# With MSVC, the linker fails with: cannot open file 'python311.lib'
# 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
# straightforward
@unittest.skipIf(
Expand Down Expand Up @@ -53,7 +52,7 @@ def _check_build(self, std_cpp03, extension_name):
python_exe = 'python'
if sys.executable.endswith('.exe'):
python_exe += '.exe'
if MS_WINDOWS:
if support.MS_WINDOWS:
python = os.path.join(venv_dir, 'Scripts', python_exe)
else:
python = os.path.join(venv_dir, 'bin', python_exe)
Expand Down
6 changes: 2 additions & 4 deletions Lib/test/test_cppext/setup.py
Expand Up @@ -4,15 +4,13 @@
import shlex
import sys
import sysconfig
from test import support

from setuptools import setup, Extension


MS_WINDOWS = (sys.platform == 'win32')


SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
if not MS_WINDOWS:
if not support.MS_WINDOWS:
# C++ compiler flags for GCC and clang
CPPFLAGS = [
# gh-91321: The purpose of _testcppext extension is to check that building
Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_embed.py
@@ -1,7 +1,6 @@
# Run the tests in Programs/_testembed.c (tests for the CPython embedding APIs)
from test import support
from test.support import import_helper
from test.support import os_helper
from test.support import import_helper, os_helper, MS_WINDOWS
import unittest

from collections import namedtuple
Expand All @@ -20,7 +19,6 @@
if not support.has_subprocess_support:
raise unittest.SkipTest("test module requires subprocess")

MS_WINDOWS = (os.name == 'nt')
MACOS = (sys.platform == 'darwin')
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
PYMEM_ALLOCATOR_NOT_SET = 0
Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_faulthandler.py
Expand Up @@ -7,8 +7,7 @@
import subprocess
import sys
from test import support
from test.support import os_helper
from test.support import script_helper, is_android
from test.support import os_helper, script_helper, is_android, MS_WINDOWS
from test.support import skip_if_sanitizer
import tempfile
import unittest
Expand All @@ -23,7 +22,6 @@
raise unittest.SkipTest("test module requires subprocess")

TIMEOUT = 0.5
MS_WINDOWS = (os.name == 'nt')


def expected_traceback(lineno1, lineno2, header, min_count=1):
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_gdb/__init__.py
Expand Up @@ -9,8 +9,7 @@
from test import support


MS_WINDOWS = (os.name == 'nt')
if MS_WINDOWS:
if support.MS_WINDOWS:
# 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
# debug symbol files.
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_utf8_mode.py
Expand Up @@ -9,10 +9,9 @@
import unittest
from test import support
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')
VXWORKS = (sys.platform == "vxworks")

Expand Down

0 comments on commit 88223f1

Please sign in to comment.