Skip to content
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

bpo-33671: Replace platform test for darwin with support.MACOS #7875

Closed
wants to merge 1 commit into from
Closed
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_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def test_many_processes(self):
join_process(p)
if os.name != 'nt':
exitcodes = [-signal.SIGTERM]
if sys.platform == 'darwin':
if support.MACOS:
# bpo-31510: On macOS, killing a freshly started process with
# SIGTERM sometimes kills the process with SIGKILL.
exitcodes.append(-signal.SIGKILL)
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/eintrdata/eintr_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ def test_open(self):
self._test_open("fp = open(path, 'r')\nfp.close()",
self.python_open)

@unittest.skipIf(sys.platform == 'darwin', "hangs under OS X; see issue #25234")
@unittest.skipIf(support.MACOS, "hangs under OS X; see issue #25234")
def os_open(self, path):
fd = os.open(path, os.O_WRONLY)
os.close(fd)

@unittest.skipIf(sys.platform == "darwin", "hangs under OS X; see issue #25234")
@unittest.skipIf(support.MACOS, "hangs under OS X; see issue #25234")
def test_os_open(self):
self._test_open("fd = os.open(path, os.O_RDONLY)\nos.close(fd)",
self.os_open)
Expand Down Expand Up @@ -434,7 +434,7 @@ def test_select(self):
self.stop_alarm()
self.assertGreaterEqual(dt, self.sleep_time)

@unittest.skipIf(sys.platform == "darwin",
@unittest.skipIf(support.MACOS,
"poll may fail on macOS; see issue #28087")
@unittest.skipUnless(hasattr(select, 'poll'), 'need select.poll')
def test_poll(self):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/libregrtest/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def setup_tests(ns):
# fix is to set the stack limit to 2048.
# This approach may also be useful for other Unixy platforms that
# suffer from small default stack limits.
if sys.platform == 'darwin':
if support.MACOS:
try:
import resource
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test__osx_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import _osx_support

@unittest.skipUnless(sys.platform.startswith("darwin"), "requires OS X")
@unittest.skipUnless(test.support.MACOS, "requires OS X")
class Test_OSXSupport(unittest.TestCase):

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asynchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, terminator, server_port):
def handle_connect(self):
pass

if sys.platform == 'darwin':
if support.MACOS:
# select.poll returns a select.POLLHUP at the end of the tests
# on darwin, so just ignore it
def handle_expt(self):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def tearDownModule():

def osx_tiger():
"""Return True if the platform is Mac OS 10.4 or older."""
if sys.platform != 'darwin':
if not support.MACOS:
return False
version = platform.mac_ver()[0]
version = tuple(map(int, version.split('.')))
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ def test_handle_expt(self):
if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX:
self.skipTest("Not applicable to AF_UNIX sockets.")

if sys.platform == "darwin" and self.use_poll:
if support.MACOS and self.use_poll:
self.skipTest("poll may fail on macOS; see issue #28087")

class TestClient(BaseClient):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_c_locale_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# AIX uses iso8859-1 in the C locale, other *nix platforms use ASCII
EXPECTED_C_LOCALE_STREAM_ENCODING = "iso8859-1"
EXPECTED_C_LOCALE_FS_ENCODING = "iso8859-1"
elif sys.platform == "darwin":
elif test.support.MACOS:
# FS encoding is UTF-8 on macOS
EXPECTED_C_LOCALE_FS_ENCODING = "utf-8"
elif sys.platform == "cygwin":
Expand Down Expand Up @@ -75,7 +75,7 @@
# `locale.nl_langinfo(locale.CODESET)` works, as if it fails, the interpreter
# will skip locale coercion for that particular target locale
_check_nl_langinfo_CODESET = bool(
sys.platform not in ("darwin", "linux") and
(not test.support.MACOS) and sys.platform != "linux" and
hasattr(locale, "nl_langinfo") and
hasattr(locale, "CODESET")
)
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_cmath.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test.support import requires_IEEE_754, cpython_only
from test.support import requires_IEEE_754, cpython_only, MACOS
from test.test_math import parse_testfile, test_file
import test.test_math as test_math
import unittest
Expand Down Expand Up @@ -339,7 +339,7 @@ def test_specific_values(self):
SKIP_ON_TIGER = {'tan0064'}

osx_version = None
if sys.platform == 'darwin':
if MACOS:
version_txt = platform.mac_ver()[0]
try:
osx_version = tuple(map(int, version_txt.split('.')))
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_cmd_line_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def test_non_ascii(self):
# Windows allows creating a name with an arbitrary bytes name, but
# Python cannot a undecodable bytes argument to a subprocess.
if (support.TESTFN_UNDECODABLE
and sys.platform not in ('win32', 'darwin')):
and not support.MS_WINDOWS and not support.MACOS):
name = os.fsdecode(support.TESTFN_UNDECODABLE)
elif support.TESTFN_NONASCII:
name = support.TESTFN_NONASCII
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_fcntl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import unittest
from test.support import (verbose, TESTFN, unlink, run_unittest, import_module,
cpython_only)
MACOS, cpython_only)

# Skip test if no fcntl module.
fcntl = import_module('fcntl')
Expand All @@ -23,7 +23,7 @@ def get_lockdata():
start_len = "qq"

if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd'))
or sys.platform == 'darwin'):
or MACOS):
if struct.calcsize('l') == 8:
off_t = 'l'
pid_t = 'i'
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from functools import wraps

from test.support import (TESTFN, TESTFN_UNICODE, check_warnings, run_unittest,
make_bad_fd, cpython_only, swap_attr)
MACOS, make_bad_fd, cpython_only, swap_attr)
from collections import UserList

import _io # C implementation of io
Expand Down Expand Up @@ -382,7 +382,7 @@ def testAbles(self):
else:
self.assertEqual(f.readable(), False)
self.assertEqual(f.writable(), True)
if sys.platform != "darwin" and \
if not MACOS and \
'bsd' not in sys.platform and \
not sys.platform.startswith(('sunos', 'aix')):
# Somehow /dev/tty appears seekable on some BSDs
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_genericpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def test_nonascii_abspath(self):
# UTF-8 name. Windows allows creating a directory with an
# arbitrary bytes name, but fails to enter this directory
# (when the bytes name is used).
and sys.platform not in ('win32', 'darwin')):
and not support.MACOS and not support.MS_WINDOWS):
name = support.TESTFN_UNDECODABLE
elif support.TESTFN_NONASCII:
name = support.TESTFN_NONASCII
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def close_conn():
reader.close()
return body

@unittest.skipIf(sys.platform == 'darwin',
@unittest.skipIf(support.MACOS,
'undecodable name cannot always be decoded on macOS')
@unittest.skipIf(sys.platform == 'win32',
'undecodable name cannot be decoded on win32')
Expand All @@ -396,7 +396,7 @@ def test_undecodable_filename(self):
with open(os.path.join(self.tempdir, filename), 'wb') as f:
f.write(support.TESTFN_UNDECODABLE)
response = self.request(self.base_url + '/')
if sys.platform == 'darwin':
if support.MACOS:
# On Mac OS the HFS+ filesystem replaces bytes that aren't valid
# UTF-8 into a percent-encoded value.
for name in os.listdir(self.tempdir):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_issue5604(self):
'cp1258' : b'\xc0',
}

if sys.platform == 'darwin':
if support.MACOS:
self.assertEqual(fs_encoding, 'utf-8')
# Mac OS X uses the Normal Form D decomposition
# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def test_name(self):
def test_builtin_handlers(self):
# We can't actually *use* too many handlers in the tests,
# but we can try instantiating them with various options
if sys.platform in ('linux', 'darwin'):
if support.MACOS or sys.platform == 'linux':
for existing in (True, False):
fd, fn = tempfile.mkstemp()
os.close(fd)
Expand All @@ -572,7 +572,7 @@ def test_builtin_handlers(self):
h.close()
if existing:
os.unlink(fn)
if sys.platform == 'darwin':
if support.MACOS:
sockname = '/var/run/syslog'
else:
sockname = '/dev/log'
Expand Down Expand Up @@ -613,7 +613,7 @@ def test_path_objects(self):
(logging.handlers.RotatingFileHandler, (pfn, 'a')),
(logging.handlers.TimedRotatingFileHandler, (pfn, 'h')),
)
if sys.platform in ('linux', 'darwin'):
if support.MACOS or sys.platform == 'linux':
cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),)
for cls, args in cases:
h = cls(*args)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ def test_testfile(self):
SKIP_ON_TIGER = {'tan0064'}

osx_version = None
if sys.platform == 'darwin':
if support.MACOS:
version_txt = platform.mac_ver()[0]
try:
osx_version = tuple(map(int, version_txt.split('.')))
Expand Down
7 changes: 4 additions & 3 deletions Lib/test/test_mmap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from test.support import (TESTFN, run_unittest, import_module, unlink,
requires, _2G, _4G, gc_collect, cpython_only)
from test.support import (TESTFN, run_unittest, import_module, unlink, MACOS,
MS_WINDOWS, requires, _2G, _4G,
gc_collect, cpython_only)
import unittest
import os
import re
Expand Down Expand Up @@ -751,7 +752,7 @@ def tearDown(self):
unlink(TESTFN)

def _make_test_file(self, num_zeroes, tail):
if sys.platform[:3] == 'win' or sys.platform == 'darwin':
if MS_WINDOWS or MACOS:
requires('largefile',
'test requires %s bytes and a long time to run' % str(0x180000000))
f = open(TESTFN, 'w+b')
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_osx_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Test suite for OS X interpreter environment variables.
"""

from test.support import EnvironmentVarGuard
from test.support import (EnvironmentVarGuard, MACOS)
import subprocess
import sys
import sysconfig
import unittest

@unittest.skipUnless(sys.platform == 'darwin' and
@unittest.skipUnless(MACOS and
sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'),
'unnecessary on this platform')
class OSXEnvironmentVariableTestCase(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_win32_ver(self):
def test_mac_ver(self):
res = platform.mac_ver()

if platform.uname().system == 'Darwin':
if support.MACOS:
# We're on a MacOSX system, check that
# the right version information is returned
fd = os.popen('sw_vers', 'r')
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_mac_ver(self):
self.assertEqual(res[2], 'PowerPC')


@unittest.skipUnless(sys.platform == 'darwin', "OSX only test")
@unittest.skipUnless(support.MACOS, "OSX only test")
def test_mac_ver_with_fork(self):
# Issue7895: platform.mac_ver() crashes when using fork without exec
#
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ def test_getgroups(self):
raise unittest.SkipTest("need working 'id -G'")

# Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups()
if sys.platform == 'darwin':
if support.MACOS:
import sysconfig
dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
Expand Down Expand Up @@ -1214,7 +1214,7 @@ def test_sched_priority(self):
self.assertIsInstance(hi, int)
self.assertGreaterEqual(hi, lo)
# OSX evidently just returns 15 without checking the argument.
if sys.platform != "darwin":
if not support.MACOS:
self.assertRaises(OSError, posix.sched_get_priority_min, -23)
self.assertRaises(OSError, posix.sched_get_priority_max, -23)

Expand Down Expand Up @@ -1393,7 +1393,7 @@ def setUp(self):
raise unittest.SkipTest("not enough privileges")
if not hasattr(posix, 'getgroups'):
raise unittest.SkipTest("need posix.getgroups")
if sys.platform == 'darwin':
if support.MACOS:
raise unittest.SkipTest("getgroups(2) is broken on OSX")
self.saved_groups = posix.getgroups()

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def test_above_fd_setsize(self):
try:
fds = s.select()
except OSError as e:
if e.errno == errno.EINVAL and sys.platform == 'darwin':
if e.errno == errno.EINVAL and support.MACOS:
# unexplainable errors on macOS don't need to fail the test
self.skipTest("Invalid argument error calling poll()")
raise
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def test_getuserbase(self):
self.assertEqual(site._getuserbase(), sysconfig._getuserbase())

def test_get_path(self):
if sys.platform == 'darwin' and sys._framework:
if test.support.MACOS and sys._framework:
scheme = 'osx_framework_user'
else:
scheme = os.name + '_user'
Expand Down Expand Up @@ -472,11 +472,11 @@ def test_startup_imports(self):
# http://bugs.python.org/issue19205
re_mods = {'re', '_sre', 'sre_compile', 'sre_constants', 'sre_parse'}
# _osx_support uses the re module in many placs
if sys.platform != 'darwin':
if not test.support.MACOS:
self.assertFalse(modules.intersection(re_mods), stderr)
# http://bugs.python.org/issue9548
self.assertNotIn('locale', modules, stderr)
if sys.platform != 'darwin':
if not test.support.MACOS:
# http://bugs.python.org/issue19209
self.assertNotIn('copyreg', modules, stderr)
# http://bugs.python.org/issue19218>
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from test.support import HOST, HOSTv4, HOSTv6


if sys.platform == 'darwin':
if support.MACOS:
# select.poll returns a select.POLLHUP at the end of the tests
# on darwin, so just ignore it
def handle_expt(self):
Expand Down
Loading