Skip to content

Commit 5bd3507

Browse files
[3.11] gh-116491: Improve test_win32_ver (GH-116506) (#116709)
gh-116491: Improve `test_win32_ver` (GH-116506) (cherry picked from commit ee0dbbc) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 7e8578c commit 5bd3507

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
@@ -317,8 +317,36 @@ def test_java_ver(self):
317317
if sys.platform == 'java':
318318
self.assertTrue(all(res))
319319

320+
@unittest.skipUnless(support.MS_WINDOWS, 'This test only makes sense on Windows')
320321
def test_win32_ver(self):
321-
res = platform.win32_ver()
322+
release1, version1, csd1, ptype1 = 'a', 'b', 'c', 'd'
323+
res = platform.win32_ver(release1, version1, csd1, ptype1)
324+
self.assertEqual(len(res), 4)
325+
release, version, csd, ptype = res
326+
if release:
327+
# Currently, release names always come from internal dicts,
328+
# but this could change over time. For now, we just check that
329+
# release is something different from what we have passed.
330+
self.assertNotEqual(release, release1)
331+
if version:
332+
# It is rather hard to test explicit version without
333+
# going deep into the details.
334+
self.assertIn('.', version)
335+
for v in version.split('.'):
336+
int(v) # should not fail
337+
if csd:
338+
self.assertTrue(csd.startswith('SP'), msg=csd)
339+
if ptype:
340+
if os.cpu_count() > 1:
341+
self.assertIn('Multiprocessor', ptype)
342+
else:
343+
self.assertIn('Uniprocessor', ptype)
344+
345+
@unittest.skipIf(support.MS_WINDOWS, 'This test only makes sense on non Windows')
346+
def test_win32_ver_on_non_windows(self):
347+
release, version, csd, ptype = 'a', '1.0', 'c', 'd'
348+
res = platform.win32_ver(release, version, csd, ptype)
349+
self.assertSequenceEqual(res, (release, version, csd, ptype), seq_type=tuple)
322350

323351
def test_mac_ver(self):
324352
res = platform.mac_ver()

0 commit comments

Comments
 (0)