diff options
| author | Benjamin Peterson <benjamin@python.org> | 2009-03-26 18:35:37 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2009-03-26 18:35:37 (GMT) |
| commit | f521b8c6d25544456394e5cd172b6a24d5d958a6 (patch) | |
| tree | ec3b805d300d3e658f90a72e233379869199ce1d /Lib/test | |
| parent | c9301355d8e176a4ec9952a44a7728d8663bf21b (diff) | |
| download | cpython-f521b8c6d25544456394e5cd172b6a24d5d958a6.zip cpython-f521b8c6d25544456394e5cd172b6a24d5d958a6.tar.gz cpython-f521b8c6d25544456394e5cd172b6a24d5d958a6.tar.bz2 | |
add much better tests for python version information parsing
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_platform.py | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index cc1a0a9..342d7bc 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -48,25 +48,52 @@ class PlatformTest(unittest.TestCase): def test_processor(self): res = platform.processor() - def test_python_implementation(self): - res = platform.python_implementation() - - def test_python_version(self): - res1 = platform.python_version() - res2 = platform.python_version_tuple() - self.assertEqual(res1, ".".join(res2)) - - def test_python_branch(self): - res = platform.python_branch() - - def test_python_revision(self): - res = platform.python_revision() - - def test_python_build(self): - res = platform.python_build() - - def test_python_compiler(self): - res = platform.python_compiler() + def setUp(self): + self.save_version = sys.version + self.save_subversion = sys.subversion + self.save_platform = sys.platform + + def tearDown(self): + sys.version = self.save_version + sys.subversion = self.save_subversion + sys.platform = self.save_platform + + def test_python_info(self): + # Tests for python_implementation(), python_version(), python_branch(), + # python_revision(), python_build(), and python_compiler(). + sys_versions = { + ("2.6.1 (r261:67515, Dec 6 2008, 15:26:00) \n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]", + ('CPython', 'tags/r261', '67515'), self.save_platform) + : + ("CPython", "2.6.1", "tags/r261", "67515", + ('r261:67515', 'Dec 6 2008 15:26:00'), + 'GCC 4.0.1 (Apple Computer, Inc. build 5370)'), + ("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli") + : + ("IronPython", "2.0.0", "", "", ("", ""), + ".NET 2.0.50727.3053"), + ("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]", + None, "java1.5.0_16") + : + ("Jython", "2.5.0", "", "", ("", ""), + "java1.5.0_16"), + } + for (version_tag, subversion, sys_platform), info in \ + sys_versions.iteritems(): + sys.version = version_tag + if subversion is None: + if hasattr(sys, "subversion"): + del sys.subversion + else: + sys.subversion = subversion + if sys_platform is not None: + sys.platform = sys_platform + self.assertEqual(platform.python_implementation(), info[0]) + self.assertEqual(platform.python_version(), info[1]) + self.assertEqual(platform.python_branch(), info[2]) + self.assertEqual(platform.python_revision(), info[3]) + self.assertEqual(platform.python_build(), info[4]) + self.assertEqual(platform.python_compiler(), info[5]) def test_system_alias(self): res = platform.system_alias( |
