Index: Lib/test/test_uuid.py =================================================================== --- Lib/test/test_uuid.py (revision 77817) +++ Lib/test/test_uuid.py (working copy) @@ -1,6 +1,7 @@ -from unittest import TestCase +import unittest from test import support import builtins +import os import uuid def importable(name): @@ -10,7 +11,7 @@ except: return False -class TestUUID(TestCase): +class TestUUID(unittest.TestCase): last_node = None source2node = {} @@ -316,55 +317,39 @@ else: TestUUID.last_node = node + @unittest.skipUnless(os.name == "posix", "posix specific") def test_ifconfig_getnode(self): - import sys - print(""" WARNING: uuid._ifconfig_getnode is unreliable on many platforms. - It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) - return + node = uuid._ifconfig_getnode() + if node is not None: + self.check_node(node, 'ifconfig') - import os - if os.name == 'posix': - node = uuid._ifconfig_getnode() - if node is not None: - self.check_node(node, 'ifconfig') - + @unittest.skipUnless(os.name == "nt", "nt specific") 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") and importable("netbios"), + "win32wnet and netbios specific") 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() self.assertTrue(0 <= node) self.assertTrue(node < (1 <<48)) - + + @unittest.skipUnless(importable("ctypes") and os.name == "posix", + "ctypes and posix specific") def test_unixdll_getnode(self): - import sys - print(""" WARNING: uuid._unixdll_getnode is unreliable on many platforms. - It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) - return + self.check_node(uuid._unixdll_getnode(), 'unixdll') - import os - if importable('ctypes') and os.name == 'posix': - self.check_node(uuid._unixdll_getnode(), 'unixdll') - + @unittest.skipUnless(importable("ctypes") and os.name == "nt", + "ctypes and nt specific") 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 - print(""" WARNING: uuid.getnode is unreliable on many platforms. - It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) - return - node1 = uuid.getnode() self.check_node(node1, "getnode1") @@ -374,13 +359,8 @@ self.assertEqual(node1, node2) + @unittest.skipUnless(importable("ctypes"), "ctypes required") 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. @@ -433,13 +413,8 @@ equal(u, uuid.UUID(v)) equal(str(u), v) + @unittest.skipUnless(importable("ctypes"), "ctypes required") 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.