[Python-checkins] cpython: Issue #12158: Move linux_version() from test_socket to test.support

victor.stinner python-checkins at python.org
Tue May 24 00:24:25 CEST 2011


http://hg.python.org/cpython/rev/d585a6d548a3
changeset: 70324:d585a6d548a3
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Tue May 24 00:24:19 2011 +0200
summary:
 Issue #12158: Move linux_version() from test_socket to test.support
files:
 Lib/test/support.py | 8 ++++++++
 Lib/test/test_socket.py | 14 +++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -291,6 +291,14 @@
 msg = "Use of the `%s' resource not enabled" % resource
 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'
 
 def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -24,14 +24,6 @@
 except ImportError:
 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
 MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8') ## test unicode string and carriage return
 
@@ -1032,7 +1024,7 @@
 
 if hasattr(socket, "SOCK_NONBLOCK"):
 def testInitNonBlocking(self):
- v = linux_version()
+ v = support.linux_version()
 if v < (2, 6, 28):
 self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
 % ".".join(map(str, v)))
@@ -2010,7 +2002,7 @@
 @unittest.skipUnless(fcntl, "module fcntl not available")
 class CloexecConstantTest(unittest.TestCase):
 def test_SOCK_CLOEXEC(self):
- v = linux_version()
+ v = support.linux_version()
 if v < (2, 6, 28):
 self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
 % ".".join(map(str, v)))
@@ -2032,7 +2024,7 @@
 self.assertEqual(s.gettimeout(), None)
 
 def test_SOCK_NONBLOCK(self):
- v = linux_version()
+ v = support.linux_version()
 if v < (2, 6, 28):
 self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
 % ".".join(map(str, v)))
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /