From 519fd6dda05c34844559ebec866b4c5c3e4a3e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Sat, 23 Jun 2018 15:40:27 +0200 Subject: [PATCH] Replace platform test for darwin with support.MACOS --- Lib/test/_test_multiprocessing.py | 2 +- Lib/test/eintrdata/eintr_tester.py | 6 +++--- Lib/test/libregrtest/setup.py | 2 +- Lib/test/test__osx_support.py | 2 +- Lib/test/test_asynchat.py | 2 +- Lib/test/test_asyncio/test_events.py | 2 +- Lib/test/test_asyncore.py | 2 +- Lib/test/test_c_locale_coercion.py | 4 ++-- Lib/test/test_cmath.py | 4 ++-- Lib/test/test_cmd_line_script.py | 2 +- Lib/test/test_fcntl.py | 4 ++-- Lib/test/test_fileio.py | 4 ++-- Lib/test/test_genericpath.py | 2 +- Lib/test/test_httpservers.py | 4 ++-- Lib/test/test_imp.py | 2 +- Lib/test/test_logging.py | 6 +++--- Lib/test/test_math.py | 2 +- Lib/test/test_mmap.py | 7 ++++--- Lib/test/test_osx_env.py | 4 ++-- Lib/test/test_platform.py | 4 ++-- Lib/test/test_posix.py | 6 +++--- Lib/test/test_selectors.py | 2 +- Lib/test/test_site.py | 6 +++--- Lib/test/test_smtplib.py | 2 +- Lib/test/test_socket.py | 12 ++++++------ Lib/test/test_subprocess.py | 3 +-- Lib/test/test_sys.py | 2 +- Lib/test/test_sysconfig.py | 6 +++--- Lib/test/test_threading.py | 2 +- Lib/test/test_unicode_file_functions.py | 6 +++--- Lib/test/test_urllib2.py | 2 +- Lib/test/test_venv.py | 8 ++++---- .../Tests/2018-06-23-23-25-25.bpo-33671.idQO24.rst | 1 + 33 files changed, 63 insertions(+), 62 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2018-06-23-23-25-25.bpo-33671.idQO24.rst diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index b202aa20890839..4bb81b1683c133 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -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) diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py index bc308fe107b311..ad2eb74b374c51 100644 --- a/Lib/test/eintrdata/eintr_tester.py +++ b/Lib/test/eintrdata/eintr_tester.py @@ -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) @@ -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): diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py index 910aca1b1a6c00..628dca558d62f7 100644 --- a/Lib/test/libregrtest/setup.py +++ b/Lib/test/libregrtest/setup.py @@ -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: diff --git a/Lib/test/test__osx_support.py b/Lib/test/test__osx_support.py index bcba8caa296484..68a8dd0ac43935 100644 --- a/Lib/test/test__osx_support.py +++ b/Lib/test/test__osx_support.py @@ -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): diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index 1d147c741961e3..aca14c5619c7fe 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -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): diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 11cd950df1cedb..0ae13911942e99 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -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('.'))) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 694ddffd6879eb..f5668d6141dbf5 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -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): diff --git a/Lib/test/test_c_locale_coercion.py b/Lib/test/test_c_locale_coercion.py index 9e68bf96ec7fa7..1ac99db17d3aaa 100644 --- a/Lib/test/test_c_locale_coercion.py +++ b/Lib/test/test_c_locale_coercion.py @@ -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": @@ -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") ) diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index 0451fb0aa22e6a..2ff7dab9ce232a 100644 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -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 @@ -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('.'))) diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index a9c1309ad6d32b..15e26ef0364f8c 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -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 diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index acd5c7cc586472..fa1afb12926a9a 100644 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -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') @@ -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' diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 57a02656206ff4..37aabca99cef6f 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -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 @@ -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 diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py index 8b291cda689ce1..82fc23c4574f71 100644 --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -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 diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py index cc829a522b88bc..a0290e743b7c04 100644 --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -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') @@ -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): diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index a115e60d4e4f08..e8929a303a78ad 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -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 diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index ba70b117d1e69c..0adf86b0b043ea 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -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) @@ -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' @@ -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) diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 44785d3e49a255..287be612217c85 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -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('.'))) diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 355af8cd58935f..b50564bb55c636 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -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 @@ -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') diff --git a/Lib/test/test_osx_env.py b/Lib/test/test_osx_env.py index 8a3bc5a46e547b..123494a5ad4ee6 100644 --- a/Lib/test/test_osx_env.py +++ b/Lib/test/test_osx_env.py @@ -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): diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index dfae4a877db32e..25402dca25ca94 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -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') @@ -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 # diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 4f6abc6f7d6fd9..162d6cf2a9ef7a 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -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): @@ -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) @@ -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() diff --git a/Lib/test/test_selectors.py b/Lib/test/test_selectors.py index 31611224dc71e1..c7a12b5dd07bbd 100644 --- a/Lib/test/test_selectors.py +++ b/Lib/test/test_selectors.py @@ -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 diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index e3c9deebf08c02..62ab89f1a2b9e4 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -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' @@ -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> diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 7991174fb5d75a..5d40720ece5bf9 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -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): diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 44966e450e18b9..ebd596fe7b18c0 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1009,7 +1009,7 @@ def testGetServBy(self): # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. if (sys.platform.startswith(('freebsd', 'netbsd', 'gnukfreebsd')) - or sys.platform in ('linux', 'darwin')): + or sys.platform == 'linux' or support.MACOS): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry services = ('daytime', 'qotd', 'domain') @@ -3169,7 +3169,7 @@ def testFDPassCMSG_LEN(self): def _testFDPassCMSG_LEN(self): self.createAndSendFDs(1) - @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") + @unittest.skipIf(support.MACOS, "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparate(self): @@ -3180,7 +3180,7 @@ def testFDPassSeparate(self): maxcmsgs=2) @testFDPassSeparate.client_skip - @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") + @unittest.skipIf(support.MACOS, "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") def _testFDPassSeparate(self): fd0, fd1 = self.newFDs(2) @@ -3193,7 +3193,7 @@ def _testFDPassSeparate(self): array.array("i", [fd1]))]), len(MSG)) - @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") + @unittest.skipIf(support.MACOS, "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparateMinSpace(self): @@ -3206,7 +3206,7 @@ def testFDPassSeparateMinSpace(self): maxcmsgs=2, ignoreflags=socket.MSG_CTRUNC) @testFDPassSeparateMinSpace.client_skip - @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") + @unittest.skipIf(support.MACOS, "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") def _testFDPassSeparateMinSpace(self): fd0, fd1 = self.newFDs(2) @@ -3230,7 +3230,7 @@ def sendAncillaryIfPossible(self, msg, ancdata): nbytes = self.sendmsgToServer([msg]) self.assertEqual(nbytes, len(msg)) - @unittest.skipIf(sys.platform == "darwin", "see issue #24725") + @unittest.skipIf(support.MACOS, "see issue #24725") def testFDPassEmpty(self): # Try to pass an empty FD array. Can receive either no array # or an empty array. diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 569e3e0aa559b2..70895289b0b377 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1788,8 +1788,7 @@ def raise_runtime_error(): if not enabled: gc.disable() - @unittest.skipIf( - sys.platform == 'darwin', 'setrlimit() seems to fail on OS X') + @unittest.skipIf(support.MACOS, 'setrlimit() seems to fail on OS X') def test_preexec_fork_failure(self): # The internal code did not preserve the previous exception when # re-enabling garbage collection diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 336ae447a8de5e..3bb4a56e4c6596 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -648,7 +648,7 @@ def check_fsencoding(self, fs_encoding, expected=None): def test_getfilesystemencoding(self): fs_encoding = sys.getfilesystemencoding() - if sys.platform == 'darwin': + if test.support.MACOS: expected = 'utf-8' else: expected = None diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 20252be0a41b00..1a2246b663730b 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -5,7 +5,7 @@ import shutil from copy import copy -from test.support import (import_module, TESTFN, unlink, check_warnings, +from test.support import (import_module, TESTFN, unlink, check_warnings, MACOS, captured_stdout, skip_unless_symlink, change_cwd) import sysconfig @@ -288,7 +288,7 @@ def test_ldshared_value(self): self.assertIn(ldflags, ldshared) - @unittest.skipUnless(sys.platform == "darwin", "test only relevant on MacOSX") + @unittest.skipUnless(MACOS, "test only relevant on MacOSX") def test_platform_in_subprocess(self): my_platform = sysconfig.get_platform() @@ -396,7 +396,7 @@ def test_triplet_in_ext_suffix(self): else: # 8 byte pointer size self.assertTrue(suffix.endswith('x86_64-linux-gnu.so'), suffix) - @unittest.skipUnless(sys.platform == 'darwin', 'OS X-specific test') + @unittest.skipUnless(MACOS, 'OS X-specific test') def test_osx_ext_suffix(self): suffix = sysconfig.get_config_var('EXT_SUFFIX') self.assertTrue(suffix.endswith('-darwin.so'), suffix) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index db70dfa95df052..f0cdaf28939464 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -970,7 +970,7 @@ def test_releasing_unacquired_lock(self): lock = threading.Lock() self.assertRaises(RuntimeError, lock.release) - @unittest.skipUnless(sys.platform == 'darwin' and test.support.python_is_optimized(), + @unittest.skipUnless(test.support.MACOS and test.support.python_is_optimized(), 'test macosx problem') def test_recursion_limit(self): # Issue 9670 diff --git a/Lib/test/test_unicode_file_functions.py b/Lib/test/test_unicode_file_functions.py index 1cd0d621cd4b3a..fd68fc9a3f8263 100644 --- a/Lib/test/test_unicode_file_functions.py +++ b/Lib/test/test_unicode_file_functions.py @@ -27,7 +27,7 @@ # these normal forms. For example, HFS Plus uses a variant of Normal Form D # in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through # U+2FAFF are not decomposed." -if sys.platform != 'darwin': +if not support.MACOS: filenames.extend([ # Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all different '11_\u0385\u03d3\u03d4', @@ -121,7 +121,7 @@ def test_open(self): # NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC, # NFKD in Python is useless, because darwin will normalize it later and so # open(), os.stat(), etc. don't raise any exception. - @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X') + @unittest.skipIf(support.MACOS, 'irrelevant test on Mac OS X') def test_normalize(self): files = set(self.files) others = set() @@ -139,7 +139,7 @@ def test_normalize(self): # Skip the test on darwin, because darwin uses a normalization different # than Python NFD normalization: filenames are different even if we use # Python NFD normalization. - @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X') + @unittest.skipIf(support.MACOS, 'irrelevant test on Mac OS X') def test_listdir(self): sf0 = set(self.files) with warnings.catch_warnings(): diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 876fcd4199fb92..b7e062a5672c53 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1423,7 +1423,7 @@ def test_proxy_https_proxy_authorization(self): self.assertEqual(req.host, "proxy.example.com:3128") self.assertEqual(req.get_header("Proxy-authorization"), "FooBar") - @unittest.skipUnless(sys.platform == 'darwin', "only relevant for OSX") + @unittest.skipUnless(support.MACOS, "only relevant for OSX") def test_osx_proxy_bypass(self): bypass = { 'exclude_simple': False, diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 9cea87e2fefa65..00d3d0c30845fe 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -14,7 +14,7 @@ import sys import tempfile from test.support import (captured_stdout, captured_stderr, requires_zlib, - can_symlink, EnvironmentVarGuard, rmtree) + can_symlink, EnvironmentVarGuard, rmtree, MACOS) import threading import unittest import venv @@ -41,7 +41,7 @@ def setUp(self): self.bindir = 'bin' self.lib = ('lib', 'python%d.%d' % sys.version_info[:2]) self.include = 'include' - if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ: + if MACOS and '__PYVENV_LAUNCHER__' in os.environ: executable = os.environ['__PYVENV_LAUNCHER__'] else: executable = sys.executable @@ -83,13 +83,13 @@ def test_defaults(self): # Issue 21197 p = self.get_env_file('lib64') conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and - (sys.platform != 'darwin')) + (False == MACOS)) if conditions: self.assertTrue(os.path.islink(p)) else: self.assertFalse(os.path.exists(p)) data = self.get_text_file_contents('pyvenv.cfg') - if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__' + if MACOS and ('__PYVENV_LAUNCHER__' in os.environ): executable = os.environ['__PYVENV_LAUNCHER__'] else: diff --git a/Misc/NEWS.d/next/Tests/2018-06-23-23-25-25.bpo-33671.idQO24.rst b/Misc/NEWS.d/next/Tests/2018-06-23-23-25-25.bpo-33671.idQO24.rst new file mode 100644 index 00000000000000..360c9b0a68e33b --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2018-06-23-23-25-25.bpo-33671.idQO24.rst @@ -0,0 +1 @@ +Replace platform test for darwin with support.MACOS