cpython (2.7): Issue #18094: test_uuid no more reports skipped tests as passed.
http://hg.python.org/cpython/rev/6ceb5bf24da8 changeset: 83995:6ceb5bf24da8 branch: 2.7 parent: 83989:6159916c712e user: Serhiy Storchaka <storchaka@gmail.com> date: Fri May 31 22:34:53 2013 +0300 summary: Issue #18094: test_uuid no more reports skipped tests as passed. files: Lib/test/test_uuid.py | 69 +++++++++++------------------- Misc/NEWS | 2 + 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -1,5 +1,6 @@ -from unittest import TestCase +import unittest from test import test_support +import os import uuid def importable(name): @@ -9,7 +10,7 @@ except: return False -class TestUUID(TestCase): +class TestUUID(unittest.TestCase): last_node = None source2node = {} @@ -299,24 +300,22 @@ else: TestUUID.last_node = node + @unittest.skipUnless(os.name == 'posix', 'requires Posix') def test_ifconfig_getnode(self): - import sys - import os - if os.name == 'posix': - node = uuid._ifconfig_getnode() - if node is not None: - self.check_node(node, 'ifconfig') + node = uuid._ifconfig_getnode() + if node is not None: + self.check_node(node, 'ifconfig') + @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_ipconfig_getnode(self): - import os - if os.name == 'nt': - node = uuid._ipconfig_getnode() - if node is not None: - self.check_node(node, 'ipconfig') + node = uuid._ipconfig_getnode() + if node is not None: + self.check_node(node, 'ipconfig') + @unittest.skipUnless(importable('win32wnet'), 'requires win32wnet') + @unittest.skipUnless(importable('netbios'), 'requires netbios') def test_netbios_getnode(self): - if importable('win32wnet') and importable('netbios'): - self.check_node(uuid._netbios_getnode(), 'netbios') + self.check_node(uuid._netbios_getnode(), 'netbios') def test_random_getnode(self): node = uuid._random_getnode() @@ -324,22 +323,20 @@ self.assertTrue(node & 0x010000000000) self.assertTrue(node < (1L << 48)) + @unittest.skipUnless(os.name == 'posix', 'requires Posix') + @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_unixdll_getnode(self): - import sys - import os - if importable('ctypes') and os.name == 'posix': - try: # Issues 1481, 3581: _uuid_generate_time() might be None. - self.check_node(uuid._unixdll_getnode(), 'unixdll') - except TypeError: - pass + try: # Issues 1481, 3581: _uuid_generate_time() might be None. + self.check_node(uuid._unixdll_getnode(), 'unixdll') + except TypeError: + pass + @unittest.skipUnless(os.name == 'nt', 'requires Windows') + @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_windll_getnode(self): - import os - if importable('ctypes') and os.name == 'nt': - self.check_node(uuid._windll_getnode(), 'windll') + self.check_node(uuid._windll_getnode(), 'windll') def test_getnode(self): - import sys node1 = uuid.getnode() self.check_node(node1, "getnode1") @@ -349,13 +346,8 @@ self.assertEqual(node1, node2) + @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_uuid1(self): - # uuid1 requires ctypes. - try: - import ctypes - except ImportError: - return - equal = self.assertEqual # Make sure uuid1() generates UUIDs that are actually version 1. @@ -408,13 +400,8 @@ equal(u, uuid.UUID(v)) equal(str(u), v) + @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_uuid4(self): - # uuid4 requires ctypes. - try: - import ctypes - except ImportError: - return - equal = self.assertEqual # Make sure uuid4() generates UUIDs that are actually version 4. @@ -446,12 +433,8 @@ equal(u, uuid.UUID(v)) equal(str(u), v) + @unittest.skipUnless(os.name == 'posix', 'requires Posix') def testIssue8621(self): - import os - import sys - if os.name != 'posix': - return - # On at least some versions of OSX uuid.uuid4 generates # the same sequence of UUIDs in the parent and any # children started using fork. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -58,6 +58,8 @@ Tests ----- +- Issue #18094: test_uuid no more reports skipped tests as passed. + - Issue #11995: test_pydoc doesn't import all sys.path modules anymore. Documentation -- Repository URL: http://hg.python.org/cpython
participants (1)
-
serhiy.storchaka