Skip to content

Add support.MS_WINDOWS constant #110446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/_test_embed_set_config.py
Original file line number Diff line number Diff line change
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
3 changes: 2 additions & 1 deletion Lib/test/libregrtest/logger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import time

from test.support import MS_WINDOWS
from .results import TestResults
from .runtests import RunTests
from .utils import print_warning, MS_WINDOWS
from .utils import print_warning

if MS_WINDOWS:
from .win_utils import WindowsLoadTracker
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time

from test import support
from test.support import os_helper
from test.support import os_helper, MS_WINDOWS

from .cmdline import _parse_args, Namespace
from .findtests import findtests, split_test_packages, list_cases
Expand All @@ -24,7 +24,7 @@
printlist, get_temp_dir, get_work_dir, exit_timeout,
display_header, cleanup_temp_dir, print_warning,
is_cross_compiled, get_host_runner,
MS_WINDOWS, EXIT_TIMEOUT)
EXIT_TIMEOUT)


class Regrtest:
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/libregrtest/run_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
from typing import Literal, TextIO

from test import support
from test.support import os_helper
from test.support import os_helper, MS_WINDOWS

from .logger import Logger
from .result import TestResult, State
from .results import TestResults
from .runtests import RunTests, JsonFile, JsonFileType
from .single import PROGRESS_MIN_TIME
from .utils import (
StrPath, TestName, MS_WINDOWS,
StrPath, TestName,
format_duration, print_warning, count, plural, get_signal_name)
from .worker import create_worker_process, USE_PROCESS_GROUP

Expand Down
2 changes: 0 additions & 2 deletions Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from test.support import threading_helper


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

# All temporary files and temporary directories created by libregrtest should
# use TMP_PREFIX so cleanup_temp_dir() can remove them all.
TMP_PREFIX = 'test_python_'
Expand Down
1 change: 1 addition & 0 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ def collect_support(info_add):
return

attributes = (
'MS_WINDOWS',
'has_fork_support',
'has_socket_support',
'has_strftime_extensions',
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"check_disallow_instantiation", "check_sanitizer", "skip_if_sanitizer",
"requires_limited_api", "requires_specialization",
# 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",
# os
"get_pagesize",
Expand Down Expand Up @@ -509,6 +509,8 @@ def has_no_debug_ranges():
def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
return unittest.skipIf(has_no_debug_ranges(), reason)

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

# Is not actually used in tests, but is kept for compatibility.
is_jython = sys.platform.startswith('java')

Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_asyncio/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,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 @@ -283,7 +282,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
3 changes: 1 addition & 2 deletions Lib/test/test_cppext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from test import support


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

Expand All @@ -30,7 +29,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
6 changes: 2 additions & 4 deletions Lib/test/test_cppext/setup.py
Original file line number Diff line number Diff line change
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 = '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
7 changes: 2 additions & 5 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
@@ -1,8 +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 requires_specialization
from test.support import import_helper, os_helper, MS_WINDOWS
import unittest

from collections import namedtuple
Expand All @@ -21,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')
PYMEM_ALLOCATOR_NOT_SET = 0
PYMEM_ALLOCATOR_DEBUG = 2
Expand Down Expand Up @@ -348,7 +345,7 @@ def test_simple_initialization_api(self):
out, err = self.run_embedded_interpreter("test_repeated_simple_init")
self.assertEqual(out, 'Finalized\n' * INIT_LOOPS)

@requires_specialization
@support.requires_specialization
def test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE(self):
# https://github.com/python/cpython/issues/92031

Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_faulthandler.py
Original file line number Diff line number Diff line change
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
import tempfile
import unittest
from textwrap import dedent
Expand All @@ -22,7 +21,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
Original file line number Diff line number Diff line change
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
4 changes: 1 addition & 3 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
EXITCODE_RERUN_FAIL = 5
EXITCODE_INTERRUPTED = 130

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

TEST_INTERRUPTED = textwrap.dedent("""
from signal import SIGINT, raise_signal
try:
Expand Down Expand Up @@ -2072,7 +2070,7 @@ def test_crash(self):
self.check_executed_tests(output, testname,
failed=[testname],
stats=0, parallel=True)
if not MS_WINDOWS:
if not support.MS_WINDOWS:
exitcode = -int(signal.SIGSEGV)
self.assertIn(f"Exit code {exitcode} (SIGSEGV)", output)
self.check_line(output, "just before crash!", full=True, regex=False)
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_utf8_mode.py
Original file line number Diff line number Diff line change
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