Skip to content

Commit 9ef84b4

Browse files
[3.12] gh-116491: Improve test_win32_ver (GH-116506) (#116708)
gh-116491: Improve `test_win32_ver` (GH-116506) (cherry picked from commit ee0dbbc) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent e5c1456 commit 9ef84b4

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Lib/test/test_platform.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,36 @@ def test_java_ver(self):
322322
if sys.platform == 'java': # Is never actually checked in CI
323323
self.assertTrue(all(res))
324324

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

328356
def test_mac_ver(self):
329357
res = platform.mac_ver()

0 commit comments

Comments
 (0)