Switch to test_support.get_attribute.

This commit is contained in:
Eric Smith 2010-01-27 01:21:15 +00:00
parent 514e77e0ae
commit 59529e1ef6
1 changed files with 23 additions and 22 deletions

View File

@ -204,29 +204,30 @@ class SysModuleTest(unittest.TestCase):
sys.setrecursionlimit(oldlimit) sys.setrecursionlimit(oldlimit)
def test_getwindowsversion(self): def test_getwindowsversion(self):
if hasattr(sys, "getwindowsversion"): # Raise SkipTest if sys doesn't have getwindowsversion attribute
v = sys.getwindowsversion() test.test_support.get_attribute(sys, "getwindowsversion")
self.assertEqual(len(v), 5) v = sys.getwindowsversion()
self.assertIsInstance(v[0], int) self.assertEqual(len(v), 5)
self.assertIsInstance(v[1], int) self.assertIsInstance(v[0], int)
self.assertIsInstance(v[2], int) self.assertIsInstance(v[1], int)
self.assertIsInstance(v[3], int) self.assertIsInstance(v[2], int)
self.assertIsInstance(v[4], str) self.assertIsInstance(v[3], int)
self.assertRaises(IndexError, operator.getitem, v, 5) self.assertIsInstance(v[4], str)
self.assertIsInstance(v.major, int) self.assertRaises(IndexError, operator.getitem, v, 5)
self.assertIsInstance(v.minor, int) self.assertIsInstance(v.major, int)
self.assertIsInstance(v.build, int) self.assertIsInstance(v.minor, int)
self.assertIsInstance(v.platform, int) self.assertIsInstance(v.build, int)
self.assertIsInstance(v.service_pack, str) self.assertIsInstance(v.platform, int)
self.assertEqual(v[0], v.major) self.assertIsInstance(v.service_pack, str)
self.assertEqual(v[1], v.minor) self.assertEqual(v[0], v.major)
self.assertEqual(v[2], v.build) self.assertEqual(v[1], v.minor)
self.assertEqual(v[3], v.platform) self.assertEqual(v[2], v.build)
self.assertEqual(v[4], v.service_pack) self.assertEqual(v[3], v.platform)
self.assertEqual(v[4], v.service_pack)
# This is how platform.py calls it. Make sure tuple # This is how platform.py calls it. Make sure tuple
# still has 5 elements # still has 5 elements
maj, min, buildno, plat, csd = sys.getwindowsversion() maj, min, buildno, plat, csd = sys.getwindowsversion()
def test_dlopenflags(self): def test_dlopenflags(self):
if hasattr(sys, "setdlopenflags"): if hasattr(sys, "setdlopenflags"):