[Python-checkins] bpo-26544: Add test for platform._comparable_version(). (GH-8973)

Serhiy Storchaka webhook-mailer at python.org
Tue Sep 4 08:04:36 EDT 2018


https://github.com/python/cpython/commit/7917aadb3edb7616d6164c5eaba24df6ac0a5fc6
commit: 7917aadb3edb7616d6164c5eaba24df6ac0a5fc6
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-09-04T15:04:25+03:00
summary:

bpo-26544: Add test for platform._comparable_version(). (GH-8973)

files:
M Lib/test/test_platform.py

diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 9ecd5d904e30..fd6da313206d 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -275,6 +275,42 @@ def test_libc_ver(self):
         self.assertEqual(platform.libc_ver(support.TESTFN),
                          ('glibc', '1.23.4'))
 
+    @support.cpython_only
+    def test__comparable_version(self):
+        from platform import _comparable_version as V
+        self.assertEqual(V('1.2.3'), V('1.2.3'))
+        self.assertLess(V('1.2.3'), V('1.2.10'))
+        self.assertEqual(V('1.2.3.4'), V('1_2-3+4'))
+        self.assertLess(V('1.2spam'), V('1.2dev'))
+        self.assertLess(V('1.2dev'), V('1.2alpha'))
+        self.assertLess(V('1.2dev'), V('1.2a'))
+        self.assertLess(V('1.2alpha'), V('1.2beta'))
+        self.assertLess(V('1.2a'), V('1.2b'))
+        self.assertLess(V('1.2beta'), V('1.2c'))
+        self.assertLess(V('1.2b'), V('1.2c'))
+        self.assertLess(V('1.2c'), V('1.2RC'))
+        self.assertLess(V('1.2c'), V('1.2rc'))
+        self.assertLess(V('1.2RC'), V('1.2.0'))
+        self.assertLess(V('1.2rc'), V('1.2.0'))
+        self.assertLess(V('1.2.0'), V('1.2pl'))
+        self.assertLess(V('1.2.0'), V('1.2p'))
+
+        self.assertLess(V('1.5.1'), V('1.5.2b2'))
+        self.assertLess(V('3.10a'), V('161'))
+        self.assertEqual(V('8.02'), V('8.02'))
+        self.assertLess(V('3.4j'), V('1996.07.12'))
+        self.assertLess(V('3.1.1.6'), V('3.2.pl0'))
+        self.assertLess(V('2g6'), V('11g'))
+        self.assertLess(V('0.9'), V('2.2'))
+        self.assertLess(V('1.2'), V('1.2.1'))
+        self.assertLess(V('1.1'), V('1.2.2'))
+        self.assertLess(V('1.1'), V('1.2'))
+        self.assertLess(V('1.2.1'), V('1.2.2'))
+        self.assertLess(V('1.2'), V('1.2.2'))
+        self.assertLess(V('0.4'), V('0.4.0'))
+        self.assertLess(V('1.13++'), V('5.5.kw'))
+        self.assertLess(V('0.960923'), V('2.2beta29'))
+
     def test_popen(self):
         mswindows = (sys.platform == "win32")
 



More information about the Python-checkins mailing list