Skip to content

Commit a8489c1

Browse files
sobolevnpull[bot]
authored andcommitted
gh-116491: Improve test_win32_ver (#116506)
1 parent 3ec4279 commit a8489c1

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Lib/test/test_platform.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +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)
333+
self.assertEqual(len(res), 4)
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)
331359

332360
def test_mac_ver(self):
333361
res = platform.mac_ver()

0 commit comments

Comments
 (0)