Skip to content

Commit 9345789

Browse files
committed
Address review
1 parent 8001a10 commit 9345789

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

Lib/test/test_platform.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -326,29 +326,36 @@ def test_java_ver(self):
326326
res = platform.java_ver()
327327
self.assertEqual(len(res), 4)
328328

329+
@unittest.skipUnless(support.MS_WINDOWS, 'This test only makes sense on Windows')
329330
def test_win32_ver(self):
330-
res = platform.win32_ver()
331+
release1, version1, csd1, ptype1 = 'a', 'b', 'c', 'd'
332+
res = platform.win32_ver(release1, version1, csd1, ptype1)
331333
self.assertEqual(len(res), 4)
332-
if support.MS_WINDOWS:
333-
release, version, csd, ptype = res
334-
if release:
335-
releases = []
336-
releases.extend(r for _k, r in platform._WIN32_CLIENT_RELEASES)
337-
releases.extend(r for _k, r in platform._WIN32_SERVER_RELEASES)
338-
self.assertIn(release, releases)
339-
if version:
340-
# It is rather hard to test explicit version without
341-
# going deep into the details.
342-
self.assertIn('.', version)
343-
if csd:
344-
self.assertTrue(csd.startswith('SP'), msg=csd)
345-
if ptype:
346-
if os.cpu_count() > 1:
347-
self.assertIn('Multiprocessor', ptype)
348-
else:
349-
self.assertIn('Uniprocessor', ptype)
350-
else:
351-
self.assertTrue(all(part == '' for part in res), msg=res)
334+
release, version, csd, ptype = res
335+
if release:
336+
# Currently, release names always come from internal dicts,
337+
# but this could change over time. For now, we just check that
338+
# release is something different from what we have passed.
339+
self.assertNotEqual(release, release1)
340+
if version:
341+
# It is rather hard to test explicit version without
342+
# going deep into the details.
343+
self.assertIn('.', version)
344+
for v in version.split('.'):
345+
int(v) # should not fail
346+
if csd:
347+
self.assertTrue(csd.startswith('SP'), msg=csd)
348+
if ptype:
349+
if os.cpu_count() > 1:
350+
self.assertIn('Multiprocessor', ptype)
351+
else:
352+
self.assertIn('Uniprocessor', ptype)
353+
354+
@unittest.skipIf(support.MS_WINDOWS, 'This test only makes sense on non Windows')
355+
def test_win32_ver_on_non_windows(self):
356+
release, version, csd, ptype = 'a', '1.0', 'c', 'd'
357+
res = platform.win32_ver(release, version, csd, ptype)
358+
self.assertSequenceEqual(res, (release, version, csd, ptype), seq_type=tuple)
352359

353360
def test_mac_ver(self):
354361
res = platform.mac_ver()

0 commit comments

Comments
 (0)