Commit 9c3de4a8 authored by Victor Stinner's avatar Victor Stinner

Issue #12326: don't test the major version of sys.platform

Use startswith, instead of ==, when testing sys.platform to support
new platforms like Linux 3 or OpenBSD 5.
parent c7723961
...@@ -47,7 +47,7 @@ class BuildRpmTestCase(support.TempdirManager, ...@@ -47,7 +47,7 @@ class BuildRpmTestCase(support.TempdirManager,
# XXX I am unable yet to make this test work without # XXX I am unable yet to make this test work without
# spurious sdtout/stderr output under Mac OS X # spurious sdtout/stderr output under Mac OS X
if sys.platform != 'linux2': if not sys.platform.startswith('linux'):
return return
# this test will run only if the rpm commands are found # this test will run only if the rpm commands are found
...@@ -87,7 +87,7 @@ class BuildRpmTestCase(support.TempdirManager, ...@@ -87,7 +87,7 @@ class BuildRpmTestCase(support.TempdirManager,
# XXX I am unable yet to make this test work without # XXX I am unable yet to make this test work without
# spurious sdtout/stderr output under Mac OS X # spurious sdtout/stderr output under Mac OS X
if sys.platform != 'linux2': if not sys.platform.startswith('linux'):
return return
# http://bugs.python.org/issue1533164 # http://bugs.python.org/issue1533164
......
...@@ -1391,8 +1391,8 @@ def printlist(x, width=70, indent=4): ...@@ -1391,8 +1391,8 @@ def printlist(x, width=70, indent=4):
# Tests that are expected to be skipped everywhere except on one platform # Tests that are expected to be skipped everywhere except on one platform
# are also handled separately. # are also handled separately.
_expectations = { _expectations = (
'win32': ('win32',
""" """
test__locale test__locale
test_crypt test_crypt
...@@ -1420,15 +1420,15 @@ _expectations = { ...@@ -1420,15 +1420,15 @@ _expectations = {
test_threadsignals test_threadsignals
test_wait3 test_wait3
test_wait4 test_wait4
""", """),
'linux2': ('linux',
""" """
test_curses test_curses
test_largefile test_largefile
test_kqueue test_kqueue
test_ossaudiodev test_ossaudiodev
""", """),
'unixware7': ('unixware',
""" """
test_epoll test_epoll
test_largefile test_largefile
...@@ -1438,8 +1438,8 @@ _expectations = { ...@@ -1438,8 +1438,8 @@ _expectations = {
test_pyexpat test_pyexpat
test_sax test_sax
test_sundry test_sundry
""", """),
'openunix8': ('openunix',
""" """
test_epoll test_epoll
test_largefile test_largefile
...@@ -1449,8 +1449,8 @@ _expectations = { ...@@ -1449,8 +1449,8 @@ _expectations = {
test_pyexpat test_pyexpat
test_sax test_sax
test_sundry test_sundry
""", """),
'sco_sv3': ('sco_sv',
""" """
test_asynchat test_asynchat
test_fork1 test_fork1
...@@ -1469,8 +1469,8 @@ _expectations = { ...@@ -1469,8 +1469,8 @@ _expectations = {
test_threaded_import test_threaded_import
test_threadedtempfile test_threadedtempfile
test_threading test_threading
""", """),
'darwin': ('darwin',
""" """
test__locale test__locale
test_curses test_curses
...@@ -1482,8 +1482,8 @@ _expectations = { ...@@ -1482,8 +1482,8 @@ _expectations = {
test_minidom test_minidom
test_ossaudiodev test_ossaudiodev
test_poll test_poll
""", """),
'sunos5': ('sunos',
""" """
test_curses test_curses
test_dbm test_dbm
...@@ -1494,8 +1494,8 @@ _expectations = { ...@@ -1494,8 +1494,8 @@ _expectations = {
test_openpty test_openpty
test_zipfile test_zipfile
test_zlib test_zlib
""", """),
'hp-ux11': ('hp-ux',
""" """
test_curses test_curses
test_epoll test_epoll
...@@ -1510,8 +1510,8 @@ _expectations = { ...@@ -1510,8 +1510,8 @@ _expectations = {
test_sax test_sax
test_zipfile test_zipfile
test_zlib test_zlib
""", """),
'cygwin': ('cygwin',
""" """
test_curses test_curses
test_dbm test_dbm
...@@ -1522,8 +1522,8 @@ _expectations = { ...@@ -1522,8 +1522,8 @@ _expectations = {
test_locale test_locale
test_ossaudiodev test_ossaudiodev
test_socketserver test_socketserver
""", """),
'os2emx': ('os2emx',
""" """
test_audioop test_audioop
test_curses test_curses
...@@ -1536,8 +1536,8 @@ _expectations = { ...@@ -1536,8 +1536,8 @@ _expectations = {
test_pty test_pty
test_resource test_resource
test_signal test_signal
""", """),
'freebsd4': ('freebsd',
""" """
test_epoll test_epoll
test_dbm_gnu test_dbm_gnu
...@@ -1553,8 +1553,8 @@ _expectations = { ...@@ -1553,8 +1553,8 @@ _expectations = {
test_timeout test_timeout
test_urllibnet test_urllibnet
test_multiprocessing test_multiprocessing
""", """),
'aix5': ('aix',
""" """
test_bz2 test_bz2
test_epoll test_epoll
...@@ -1568,8 +1568,8 @@ _expectations = { ...@@ -1568,8 +1568,8 @@ _expectations = {
test_ttk_textonly test_ttk_textonly
test_zipimport test_zipimport
test_zlib test_zlib
""", """),
'openbsd3': ('openbsd',
""" """
test_ctypes test_ctypes
test_epoll test_epoll
...@@ -1583,8 +1583,8 @@ _expectations = { ...@@ -1583,8 +1583,8 @@ _expectations = {
test_ttk_guionly test_ttk_guionly
test_ttk_textonly test_ttk_textonly
test_multiprocessing test_multiprocessing
""", """),
'netbsd3': ('netbsd',
""" """
test_ctypes test_ctypes
test_curses test_curses
...@@ -1598,12 +1598,8 @@ _expectations = { ...@@ -1598,12 +1598,8 @@ _expectations = {
test_ttk_guionly test_ttk_guionly
test_ttk_textonly test_ttk_textonly
test_multiprocessing test_multiprocessing
""", """),
} )
_expectations['freebsd5'] = _expectations['freebsd4']
_expectations['freebsd6'] = _expectations['freebsd4']
_expectations['freebsd7'] = _expectations['freebsd4']
_expectations['freebsd8'] = _expectations['freebsd4']
class _ExpectedSkips: class _ExpectedSkips:
def __init__(self): def __init__(self):
...@@ -1611,9 +1607,13 @@ class _ExpectedSkips: ...@@ -1611,9 +1607,13 @@ class _ExpectedSkips:
from test import test_timeout from test import test_timeout
self.valid = False self.valid = False
if sys.platform in _expectations: expected = None
s = _expectations[sys.platform] for item in _expectations:
self.expected = set(s.split()) if sys.platform.startswith(item[0]):
expected = item[1]
break
if expected is not None:
self.expected = set(expected.split())
# These are broken tests, for now skipped on every platform. # These are broken tests, for now skipped on every platform.
# XXX Fix these! # XXX Fix these!
......
...@@ -23,12 +23,9 @@ def get_lockdata(): ...@@ -23,12 +23,9 @@ def get_lockdata():
else: else:
start_len = "qq" start_len = "qq"
if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3', if (any(sys.platform.startswith(prefix)
'Darwin1.2', 'darwin', for prefix in ('netbsd', 'freebsd', 'openbsd', 'bsdos'))
'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', or sys.platform in ('Darwin1.2', 'darwin')):
'freebsd6', 'freebsd7', 'freebsd8',
'bsdos2', 'bsdos3', 'bsdos4',
'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
if struct.calcsize('l') == 8: if struct.calcsize('l') == 8:
off_t = 'l' off_t = 'l'
pid_t = 'i' pid_t = 'i'
......
...@@ -527,7 +527,7 @@ class HandlerTest(BaseTest): ...@@ -527,7 +527,7 @@ class HandlerTest(BaseTest):
def test_builtin_handlers(self): def test_builtin_handlers(self):
# We can't actually *use* too many handlers in the tests, # We can't actually *use* too many handlers in the tests,
# but we can try instantiating them with various options # but we can try instantiating them with various options
if sys.platform in ('linux2', 'darwin'): if sys.platform.startswith('linux') or sys.platform == 'darwin':
for existing in (True, False): for existing in (True, False):
fd, fn = tempfile.mkstemp() fd, fn = tempfile.mkstemp()
os.close(fd) os.close(fd)
......
...@@ -2074,7 +2074,7 @@ def test_main(): ...@@ -2074,7 +2074,7 @@ def test_main():
]) ])
if hasattr(socket, "socketpair"): if hasattr(socket, "socketpair"):
tests.append(BasicSocketPairTest) tests.append(BasicSocketPairTest)
if sys.platform == 'linux2': if sys.platform.startswith('linux'):
tests.append(TestLinuxAbstractNamespace) tests.append(TestLinuxAbstractNamespace)
if isTipcAvailable(): if isTipcAvailable():
tests.append(TIPCTest) tests.append(TIPCTest)
......
...@@ -703,7 +703,7 @@ class GNUReadTest(LongnameTest): ...@@ -703,7 +703,7 @@ class GNUReadTest(LongnameTest):
# Return True if the platform knows the st_blocks stat attribute and # Return True if the platform knows the st_blocks stat attribute and
# uses st_blocks units of 512 bytes, and if the filesystem is able to # uses st_blocks units of 512 bytes, and if the filesystem is able to
# store holes in files. # store holes in files.
if sys.platform == "linux2": if sys.platform.startswith("linux"):
# Linux evidentially has 512 byte st_blocks units. # Linux evidentially has 512 byte st_blocks units.
name = os.path.join(TEMPDIR, "sparse-test") name = os.path.join(TEMPDIR, "sparse-test")
with open(name, "wb") as fobj: with open(name, "wb") as fobj:
......
...@@ -20,7 +20,7 @@ has_spawnl = hasattr(os, 'spawnl') ...@@ -20,7 +20,7 @@ has_spawnl = hasattr(os, 'spawnl')
# TEST_FILES may need to be tweaked for systems depending on the maximum # TEST_FILES may need to be tweaked for systems depending on the maximum
# number of files that can be opened at one time (see ulimit -n) # number of files that can be opened at one time (see ulimit -n)
if sys.platform in ('openbsd3', 'openbsd4'): if sys.platform.startswith('openbsd'):
TEST_FILES = 48 TEST_FILES = 48
else: else:
TEST_FILES = 100 TEST_FILES = 100
......
...@@ -1381,9 +1381,8 @@ class PyBuildExt(build_ext): ...@@ -1381,9 +1381,8 @@ class PyBuildExt(build_ext):
# End multiprocessing # End multiprocessing
# Platform-specific libraries # Platform-specific libraries
if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', if any(platform.startswith(prefix)
'freebsd7', 'freebsd8') for prefix in ("linux", "freebsd", "gnukfreebsd")):
or platform.startswith("gnukfreebsd")):
exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
else: else:
missing.append('ossaudiodev') missing.append('ossaudiodev')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment