mirror of https://github.com/python/cpython
Issue #12158: Move linux_version() from test_socket to test.support
This commit is contained in:
parent
25000d4d31
commit
fea0f4d517
|
@ -291,6 +291,14 @@ def requires(resource, msg=None):
|
||||||
msg = "Use of the `%s' resource not enabled" % resource
|
msg = "Use of the `%s' resource not enabled" % resource
|
||||||
raise ResourceDenied(msg)
|
raise ResourceDenied(msg)
|
||||||
|
|
||||||
|
def linux_version():
|
||||||
|
try:
|
||||||
|
# platform.release() is something like '2.6.33.7-desktop-2mnb'
|
||||||
|
version_string = platform.release().split('-')[0]
|
||||||
|
return tuple(map(int, version_string.split('.')))
|
||||||
|
except ValueError:
|
||||||
|
return 0, 0, 0
|
||||||
|
|
||||||
HOST = 'localhost'
|
HOST = 'localhost'
|
||||||
|
|
||||||
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
|
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
|
||||||
|
|
|
@ -24,14 +24,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
fcntl = False
|
fcntl = False
|
||||||
|
|
||||||
def linux_version():
|
|
||||||
try:
|
|
||||||
# platform.release() is something like '2.6.33.7-desktop-2mnb'
|
|
||||||
version_string = platform.release().split('-')[0]
|
|
||||||
return tuple(map(int, version_string.split('.')))
|
|
||||||
except ValueError:
|
|
||||||
return 0, 0, 0
|
|
||||||
|
|
||||||
HOST = support.HOST
|
HOST = support.HOST
|
||||||
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8') ## test unicode string and carriage return
|
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8') ## test unicode string and carriage return
|
||||||
|
|
||||||
|
@ -1032,7 +1024,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
||||||
|
|
||||||
if hasattr(socket, "SOCK_NONBLOCK"):
|
if hasattr(socket, "SOCK_NONBLOCK"):
|
||||||
def testInitNonBlocking(self):
|
def testInitNonBlocking(self):
|
||||||
v = linux_version()
|
v = support.linux_version()
|
||||||
if v < (2, 6, 28):
|
if v < (2, 6, 28):
|
||||||
self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
|
self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
|
||||||
% ".".join(map(str, v)))
|
% ".".join(map(str, v)))
|
||||||
|
@ -2010,7 +2002,7 @@ class ContextManagersTest(ThreadedTCPSocketTest):
|
||||||
@unittest.skipUnless(fcntl, "module fcntl not available")
|
@unittest.skipUnless(fcntl, "module fcntl not available")
|
||||||
class CloexecConstantTest(unittest.TestCase):
|
class CloexecConstantTest(unittest.TestCase):
|
||||||
def test_SOCK_CLOEXEC(self):
|
def test_SOCK_CLOEXEC(self):
|
||||||
v = linux_version()
|
v = support.linux_version()
|
||||||
if v < (2, 6, 28):
|
if v < (2, 6, 28):
|
||||||
self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
|
self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
|
||||||
% ".".join(map(str, v)))
|
% ".".join(map(str, v)))
|
||||||
|
@ -2032,7 +2024,7 @@ class NonblockConstantTest(unittest.TestCase):
|
||||||
self.assertEqual(s.gettimeout(), None)
|
self.assertEqual(s.gettimeout(), None)
|
||||||
|
|
||||||
def test_SOCK_NONBLOCK(self):
|
def test_SOCK_NONBLOCK(self):
|
||||||
v = linux_version()
|
v = support.linux_version()
|
||||||
if v < (2, 6, 28):
|
if v < (2, 6, 28):
|
||||||
self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
|
self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
|
||||||
% ".".join(map(str, v)))
|
% ".".join(map(str, v)))
|
||||||
|
|
Loading…
Reference in New Issue