Permalink
Browse files

CP #32786: Add CPython's tests for sys.implementation.

  • Loading branch information...
1 parent a2073fd commit 071f405cbe914aef2cf3a1d50d0c9dbc522f92e8 @jdhardy jdhardy committed Jun 9, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 External.LCA_RESTRICTED/Languages/IronPython/27/Lib/test/test_sys.py
View
23 External.LCA_RESTRICTED/Languages/IronPython/27/Lib/test/test_sys.py
@@ -482,6 +482,29 @@ def test_executable(self):
executable = p.communicate()[0].strip()
p.wait()
self.assertIn(executable, ["''", repr(sys.executable)])
+
+ 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)
+
+ # PEP 421 requires that .name be lower case.
+ self.assertEqual(sys.implementation.name,
+ sys.implementation.name.lower())
+
@unittest.skipIf(sys.platform == 'cli', 'No module _testcapi.')
class SizeofTest(unittest.TestCase):

0 comments on commit 071f405

Please sign in to comment.