summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-03-13 07:29:13 (GMT)
committerGitHub <noreply@github.com>2024-03-13 07:29:13 (GMT)
commit9ef84b46dbd9a38e722485a6a772e40ce28b4411 (patch)
treef63f0da64e449b80309957fb86753d2089271490 /Lib
parente5c1456bbd11b7ceb4a26e23cf1b55b0631ca149 (diff)
downloadcpython-9ef84b46dbd9a38e722485a6a772e40ce28b4411.zip
cpython-9ef84b46dbd9a38e722485a6a772e40ce28b4411.tar.gz
cpython-9ef84b46dbd9a38e722485a6a772e40ce28b4411.tar.bz2
[3.12] gh-116491: Improve `test_win32_ver` (GH-116506) (#116708)
gh-116491: Improve `test_win32_ver` (GH-116506) (cherry picked from commit ee0dbbc04504e0e0f1455e2bab8801ce0a682afd) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_platform.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 2169733..b62a9e3 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -322,8 +322,36 @@ class PlatformTest(unittest.TestCase):
if sys.platform == 'java': # Is never actually checked in CI
self.assertTrue(all(res))
+ @unittest.skipUnless(support.MS_WINDOWS, 'This test only makes sense on Windows')
def test_win32_ver(self):
- res = platform.win32_ver()
+ release1, version1, csd1, ptype1 = 'a', 'b', 'c', 'd'
+ res = platform.win32_ver(release1, version1, csd1, ptype1)
+ self.assertEqual(len(res), 4)
+ release, version, csd, ptype = res
+ if release:
+ # Currently, release names always come from internal dicts,
+ # but this could change over time. For now, we just check that
+ # release is something different from what we have passed.
+ self.assertNotEqual(release, release1)
+ if version:
+ # It is rather hard to test explicit version without
+ # going deep into the details.
+ self.assertIn('.', version)
+ for v in version.split('.'):
+ int(v) # should not fail
+ if csd:
+ self.assertTrue(csd.startswith('SP'), msg=csd)
+ if ptype:
+ if os.cpu_count() > 1:
+ self.assertIn('Multiprocessor', ptype)
+ else:
+ self.assertIn('Uniprocessor', ptype)
+
+ @unittest.skipIf(support.MS_WINDOWS, 'This test only makes sense on non Windows')
+ def test_win32_ver_on_non_windows(self):
+ release, version, csd, ptype = 'a', '1.0', 'c', 'd'
+ res = platform.win32_ver(release, version, csd, ptype)
+ self.assertSequenceEqual(res, (release, version, csd, ptype), seq_type=tuple)
def test_mac_ver(self):
res = platform.mac_ver()