https://github.com/python/cpython/commit/ee0dbbc04504e0e0f1455e2bab8801ce0a682afd
commit: ee0dbbc04504e0e0f1455e2bab8801ce0a682afd
branch: main
author: Nikita Sobolev <[email protected]>
committer: sobolevn <[email protected]>
date: 2024-03-13T09:46:48+03:00
summary:

gh-116491: Improve `test_win32_ver` (#116506)

files:
M Lib/test/test_platform.py

diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index bbd0c06efed2c9..9f8aeeea257311 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -326,8 +326,36 @@ def test_java_ver(self):
             res = platform.java_ver()
         self.assertEqual(len(res), 4)
 
+    @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()

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to