summaryrefslogtreecommitdiff
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2012-06-03 16:18:47 -0400
committerBarry Warsaw <barry@python.org>2012-06-03 16:18:47 -0400
commit409da157d7ff2a49892e20a94a3fc83475845d22 (patch)
tree734314ff314990b3f3b9bb6f8de2e2f4ee0b54dc /Lib/test/test_sys.py
parent82ffabdfa4de985690c76fd7498a77e9604e1747 (diff)
downloadcpython-git-409da157d7ff2a49892e20a94a3fc83475845d22.tar.gz
Eric Snow's implementation of PEP 421.
Issue 14673: Add sys.implementation
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index b024d9a261..a9c3616645 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -581,6 +581,24 @@ class SysModuleTest(unittest.TestCase):
expected = None
self.check_fsencoding(fs_encoding, expected)
+ def test_implementation(self):
+ # This test applies to all implementations equally.
+
+ levels = {'alpha': 0xA, 'beta': 0xB, 'candidate': 0xC, 'release': 0xF}
+
+ self.assertTrue(hasattr(sys.implementation, 'name'))
+ self.assertTrue(hasattr(sys.implementation, 'version'))
+ self.assertTrue(hasattr(sys.implementation, 'hexversion'))
+ self.assertTrue(hasattr(sys.implementation, 'cache_tag'))
+
+ version = sys.implementation.version
+ self.assertEqual(version[:2], (version.major, version.minor))
+
+ hexversion = (version.major << 24 | version.minor << 16 |
+ version.micro << 8 | levels[version.releaselevel] << 4 |
+ version.serial << 0)
+ self.assertEqual(sys.implementation.hexversion, hexversion)
+
class SizeofTest(unittest.TestCase):