Skip to content

Commit 519fd6d

Browse files
committed
Replace platform test for darwin with support.MACOS
1 parent 66ecefc commit 519fd6d

33 files changed

+63
-62
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def test_many_processes(self):
501501
join_process(p)
502502
if os.name != 'nt':
503503
exitcodes = [-signal.SIGTERM]
504-
if sys.platform == 'darwin':
504+
if support.MACOS:
505505
# bpo-31510: On macOS, killing a freshly started process with
506506
# SIGTERM sometimes kills the process with SIGKILL.
507507
exitcodes.append(-signal.SIGKILL)

Lib/test/eintrdata/eintr_tester.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ def test_open(self):
348348
self._test_open("fp = open(path, 'r')\nfp.close()",
349349
self.python_open)
350350

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

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

437-
@unittest.skipIf(sys.platform == "darwin",
437+
@unittest.skipIf(support.MACOS,
438438
"poll may fail on macOS; see issue #28087")
439439
@unittest.skipUnless(hasattr(select, 'poll'), 'need select.poll')
440440
def test_poll(self):

Lib/test/libregrtest/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def setup_tests(ns):
6666
# fix is to set the stack limit to 2048.
6767
# This approach may also be useful for other Unixy platforms that
6868
# suffer from small default stack limits.
69-
if sys.platform == 'darwin':
69+
if support.MACOS:
7070
try:
7171
import resource
7272
except ImportError:

Lib/test/test__osx_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import _osx_support
1414

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

1818
def setUp(self):

Lib/test/test_asynchat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, terminator, server_port):
7777
def handle_connect(self):
7878
pass
7979

80-
if sys.platform == 'darwin':
80+
if support.MACOS:
8181
# select.poll returns a select.POLLHUP at the end of the tests
8282
# on darwin, so just ignore it
8383
def handle_expt(self):

Lib/test/test_asyncio/test_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def tearDownModule():
4343

4444
def osx_tiger():
4545
"""Return True if the platform is Mac OS 10.4 or older."""
46-
if sys.platform != 'darwin':
46+
if not support.MACOS:
4747
return False
4848
version = platform.mac_ver()[0]
4949
version = tuple(map(int, version.split('.')))

Lib/test/test_asyncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def test_handle_expt(self):
658658
if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX:
659659
self.skipTest("Not applicable to AF_UNIX sockets.")
660660

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

664664
class TestClient(BaseClient):

Lib/test/test_c_locale_coercion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# AIX uses iso8859-1 in the C locale, other *nix platforms use ASCII
4242
EXPECTED_C_LOCALE_STREAM_ENCODING = "iso8859-1"
4343
EXPECTED_C_LOCALE_FS_ENCODING = "iso8859-1"
44-
elif sys.platform == "darwin":
44+
elif test.support.MACOS:
4545
# FS encoding is UTF-8 on macOS
4646
EXPECTED_C_LOCALE_FS_ENCODING = "utf-8"
4747
elif sys.platform == "cygwin":
@@ -75,7 +75,7 @@
7575
# `locale.nl_langinfo(locale.CODESET)` works, as if it fails, the interpreter
7676
# will skip locale coercion for that particular target locale
7777
_check_nl_langinfo_CODESET = bool(
78-
sys.platform not in ("darwin", "linux") and
78+
(not test.support.MACOS) and sys.platform != "linux" and
7979
hasattr(locale, "nl_langinfo") and
8080
hasattr(locale, "CODESET")
8181
)

Lib/test/test_cmath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.support import requires_IEEE_754, cpython_only
1+
from test.support import requires_IEEE_754, cpython_only, MACOS
22
from test.test_math import parse_testfile, test_file
33
import test.test_math as test_math
44
import unittest
@@ -339,7 +339,7 @@ def test_specific_values(self):
339339
SKIP_ON_TIGER = {'tan0064'}
340340

341341
osx_version = None
342-
if sys.platform == 'darwin':
342+
if MACOS:
343343
version_txt = platform.mac_ver()[0]
344344
try:
345345
osx_version = tuple(map(int, version_txt.split('.')))

Lib/test/test_cmd_line_script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def test_non_ascii(self):
494494
# Windows allows creating a name with an arbitrary bytes name, but
495495
# Python cannot a undecodable bytes argument to a subprocess.
496496
if (support.TESTFN_UNDECODABLE
497-
and sys.platform not in ('win32', 'darwin')):
497+
and not support.MS_WINDOWS and not support.MACOS):
498498
name = os.fsdecode(support.TESTFN_UNDECODABLE)
499499
elif support.TESTFN_NONASCII:
500500
name = support.TESTFN_NONASCII

Lib/test/test_fcntl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import unittest
88
from test.support import (verbose, TESTFN, unlink, run_unittest, import_module,
9-
cpython_only)
9+
MACOS, cpython_only)
1010

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

2525
if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd'))
26-
or sys.platform == 'darwin'):
26+
or MACOS):
2727
if struct.calcsize('l') == 8:
2828
off_t = 'l'
2929
pid_t = 'i'

Lib/test/test_fileio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from functools import wraps
1111

1212
from test.support import (TESTFN, TESTFN_UNICODE, check_warnings, run_unittest,
13-
make_bad_fd, cpython_only, swap_attr)
13+
MACOS, make_bad_fd, cpython_only, swap_attr)
1414
from collections import UserList
1515

1616
import _io # C implementation of io
@@ -382,7 +382,7 @@ def testAbles(self):
382382
else:
383383
self.assertEqual(f.readable(), False)
384384
self.assertEqual(f.writable(), True)
385-
if sys.platform != "darwin" and \
385+
if not MACOS and \
386386
'bsd' not in sys.platform and \
387387
not sys.platform.startswith(('sunos', 'aix')):
388388
# Somehow /dev/tty appears seekable on some BSDs

Lib/test/test_genericpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def test_nonascii_abspath(self):
461461
# UTF-8 name. Windows allows creating a directory with an
462462
# arbitrary bytes name, but fails to enter this directory
463463
# (when the bytes name is used).
464-
and sys.platform not in ('win32', 'darwin')):
464+
and not support.MACOS and not support.MS_WINDOWS):
465465
name = support.TESTFN_UNDECODABLE
466466
elif support.TESTFN_NONASCII:
467467
name = support.TESTFN_NONASCII

Lib/test/test_httpservers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def close_conn():
384384
reader.close()
385385
return body
386386

387-
@unittest.skipIf(sys.platform == 'darwin',
387+
@unittest.skipIf(support.MACOS,
388388
'undecodable name cannot always be decoded on macOS')
389389
@unittest.skipIf(sys.platform == 'win32',
390390
'undecodable name cannot be decoded on win32')
@@ -396,7 +396,7 @@ def test_undecodable_filename(self):
396396
with open(os.path.join(self.tempdir, filename), 'wb') as f:
397397
f.write(support.TESTFN_UNDECODABLE)
398398
response = self.request(self.base_url + '/')
399-
if sys.platform == 'darwin':
399+
if support.MACOS:
400400
# On Mac OS the HFS+ filesystem replaces bytes that aren't valid
401401
# UTF-8 into a percent-encoded value.
402402
for name in os.listdir(self.tempdir):

Lib/test/test_imp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_issue5604(self):
135135
'cp1258' : b'\xc0',
136136
}
137137

138-
if sys.platform == 'darwin':
138+
if support.MACOS:
139139
self.assertEqual(fs_encoding, 'utf-8')
140140
# Mac OS X uses the Normal Form D decomposition
141141
# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html

Lib/test/test_logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def test_name(self):
547547
def test_builtin_handlers(self):
548548
# We can't actually *use* too many handlers in the tests,
549549
# but we can try instantiating them with various options
550-
if sys.platform in ('linux', 'darwin'):
550+
if support.MACOS or sys.platform == 'linux':
551551
for existing in (True, False):
552552
fd, fn = tempfile.mkstemp()
553553
os.close(fd)
@@ -572,7 +572,7 @@ def test_builtin_handlers(self):
572572
h.close()
573573
if existing:
574574
os.unlink(fn)
575-
if sys.platform == 'darwin':
575+
if support.MACOS:
576576
sockname = '/var/run/syslog'
577577
else:
578578
sockname = '/dev/log'
@@ -613,7 +613,7 @@ def test_path_objects(self):
613613
(logging.handlers.RotatingFileHandler, (pfn, 'a')),
614614
(logging.handlers.TimedRotatingFileHandler, (pfn, 'h')),
615615
)
616-
if sys.platform in ('linux', 'darwin'):
616+
if support.MACOS or sys.platform == 'linux':
617617
cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),)
618618
for cls, args in cases:
619619
h = cls(*args)

Lib/test/test_math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ def test_testfile(self):
12981298
SKIP_ON_TIGER = {'tan0064'}
12991299

13001300
osx_version = None
1301-
if sys.platform == 'darwin':
1301+
if support.MACOS:
13021302
version_txt = platform.mac_ver()[0]
13031303
try:
13041304
osx_version = tuple(map(int, version_txt.split('.')))

Lib/test/test_mmap.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from test.support import (TESTFN, run_unittest, import_module, unlink,
2-
requires, _2G, _4G, gc_collect, cpython_only)
1+
from test.support import (TESTFN, run_unittest, import_module, unlink, MACOS,
2+
MS_WINDOWS, requires, _2G, _4G,
3+
gc_collect, cpython_only)
34
import unittest
45
import os
56
import re
@@ -751,7 +752,7 @@ def tearDown(self):
751752
unlink(TESTFN)
752753

753754
def _make_test_file(self, num_zeroes, tail):
754-
if sys.platform[:3] == 'win' or sys.platform == 'darwin':
755+
if MS_WINDOWS or MACOS:
755756
requires('largefile',
756757
'test requires %s bytes and a long time to run' % str(0x180000000))
757758
f = open(TESTFN, 'w+b')

Lib/test/test_osx_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
Test suite for OS X interpreter environment variables.
33
"""
44

5-
from test.support import EnvironmentVarGuard
5+
from test.support import (EnvironmentVarGuard, MACOS)
66
import subprocess
77
import sys
88
import sysconfig
99
import unittest
1010

11-
@unittest.skipUnless(sys.platform == 'darwin' and
11+
@unittest.skipUnless(MACOS and
1212
sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'),
1313
'unnecessary on this platform')
1414
class OSXEnvironmentVariableTestCase(unittest.TestCase):

Lib/test/test_platform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_win32_ver(self):
211211
def test_mac_ver(self):
212212
res = platform.mac_ver()
213213

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

243243

244-
@unittest.skipUnless(sys.platform == 'darwin', "OSX only test")
244+
@unittest.skipUnless(support.MACOS, "OSX only test")
245245
def test_mac_ver_with_fork(self):
246246
# Issue7895: platform.mac_ver() crashes when using fork without exec
247247
#

Lib/test/test_posix.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ def test_getgroups(self):
970970
raise unittest.SkipTest("need working 'id -G'")
971971

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

@@ -1393,7 +1393,7 @@ def setUp(self):
13931393
raise unittest.SkipTest("not enough privileges")
13941394
if not hasattr(posix, 'getgroups'):
13951395
raise unittest.SkipTest("need posix.getgroups")
1396-
if sys.platform == 'darwin':
1396+
if support.MACOS:
13971397
raise unittest.SkipTest("getgroups(2) is broken on OSX")
13981398
self.saved_groups = posix.getgroups()
13991399

Lib/test/test_selectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def test_above_fd_setsize(self):
484484
try:
485485
fds = s.select()
486486
except OSError as e:
487-
if e.errno == errno.EINVAL and sys.platform == 'darwin':
487+
if e.errno == errno.EINVAL and support.MACOS:
488488
# unexplainable errors on macOS don't need to fail the test
489489
self.skipTest("Invalid argument error calling poll()")
490490
raise

Lib/test/test_site.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_getuserbase(self):
184184
self.assertEqual(site._getuserbase(), sysconfig._getuserbase())
185185

186186
def test_get_path(self):
187-
if sys.platform == 'darwin' and sys._framework:
187+
if test.support.MACOS and sys._framework:
188188
scheme = 'osx_framework_user'
189189
else:
190190
scheme = os.name + '_user'
@@ -472,11 +472,11 @@ def test_startup_imports(self):
472472
# http://bugs.python.org/issue19205
473473
re_mods = {'re', '_sre', 'sre_compile', 'sre_constants', 'sre_parse'}
474474
# _osx_support uses the re module in many placs
475-
if sys.platform != 'darwin':
475+
if not test.support.MACOS:
476476
self.assertFalse(modules.intersection(re_mods), stderr)
477477
# http://bugs.python.org/issue9548
478478
self.assertNotIn('locale', modules, stderr)
479-
if sys.platform != 'darwin':
479+
if not test.support.MACOS:
480480
# http://bugs.python.org/issue19209
481481
self.assertNotIn('copyreg', modules, stderr)
482482
# http://bugs.python.org/issue19218>

Lib/test/test_smtplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from test.support import HOST, HOSTv4, HOSTv6
2323

2424

25-
if sys.platform == 'darwin':
25+
if support.MACOS:
2626
# select.poll returns a select.POLLHUP at the end of the tests
2727
# on darwin, so just ignore it
2828
def handle_expt(self):

0 commit comments

Comments
 (0)