-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
bpo-26544: Add test for platform._comparable_version(). #8973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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')) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understood correctly, the function has been added to compare correctly 2.7.9 to 2.7.10 (or a similar issue). Maybe add also a test for that? Maybe also add a test comparing 2.0 and 2.0.0?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Next line.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done. Although this is a case for which the result is different from distutils.version.StrictVersion. I don't think this will add problems in practice (in addition to existing problems of using such guessing function).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oops, I missed it, sorry ;-) |
||
| 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") | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of also adding tests checking directly the result of the function? Compare to a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would expose too much implementation details. For example the initial versions converted '1.2.3' to
[(100, 1), (100, 2), (100, 3)], but now it converts to[100, 1, 100, 2, 100, 3]. I thought also for converting to[1, 2, 3]and using negative numbers for pre-release versions andfloat('inf')for "pl". If this function be public, I would return a tuple, but a list is enough in this case. Of course magic numbers like 100 are arbitrary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's up to you.