summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-10-21 22:01:38 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-10-21 22:01:38 (GMT)
commitfbc0b0ca29c0c8120bcf979bac6cb6d64cc87f60 (patch)
treee565e044badee18a68fd11b2e76cb26d235d66f5 /Lib
parent77c2f93663cc7583047d53cf7ecf9d9c5e3ebf7e (diff)
downloadcpython-fbc0b0ca29c0c8120bcf979bac6cb6d64cc87f60.zip
cpython-fbc0b0ca29c0c8120bcf979bac6cb6d64cc87f60.tar.gz
cpython-fbc0b0ca29c0c8120bcf979bac6cb6d64cc87f60.tar.bz2
#4157 move two test functions out of platform.py.
Turn them into unit tests, and correct an obvious typo: (("a", "b") ("c", "d") ("e", "f")) compiles even with the missing commas, but does not execute very well...
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/platform.py33
-rw-r--r--Lib/test/test_platform.py34
2 files changed, 34 insertions, 33 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index 29d55ec..906d918 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -268,24 +268,6 @@ def _parse_release_file(firstline):
id = ''
return '', version, id
-def _test_parse_release_file():
-
- for input, output in (
- # Examples of release file contents:
- ('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64'))
- ('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64'))
- ('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586'))
- ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux'))
- ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche'))
- ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike'))
- ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant'))
- ('CentOS release 4', ('CentOS', '4', None))
- ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia'))
- ):
- parsed = _parse_release_file(input)
- if parsed != output:
- print (input, parsed)
-
def linux_distribution(distname='', version='', id='',
supported_dists=_supported_dists,
@@ -1381,21 +1363,6 @@ def _sys_version(sys_version=None):
_sys_version_cache[sys_version] = result
return result
-def _test_sys_version():
-
- _sys_version_cache.clear()
- for input, output in (
- ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
- ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
- ('IronPython 1.0.60816 on .NET 2.0.50727.42',
- ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
- ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
- ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
- ):
- parsed = _sys_version(input)
- if parsed != output:
- print (input, parsed)
-
def python_implementation():
""" Returns a string identifying the Python implementation.
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 2fa1309..e6a1dea 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -122,6 +122,40 @@ class PlatformTest(unittest.TestCase):
executable = executable + '.exe'
res = platform.libc_ver(sys.executable)
+ def test_parse_release_file(self):
+
+ for input, output in (
+ # Examples of release file contents:
+ ('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')),
+ ('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')),
+ ('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')),
+ ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')),
+ ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')),
+ ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')),
+ ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')),
+ ('CentOS release 4', ('CentOS', '4', None)),
+ ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')),
+ ):
+ self.assertEqual(platform._parse_release_file(input), output)
+
+ def test_sys_version(self):
+
+ platform._sys_version_cache.clear()
+ for input, output in (
+ ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
+ ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
+ ('IronPython 1.0.60816 on .NET 2.0.50727.42',
+ ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
+ ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
+ ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
+ ):
+ # branch and revision are not "parsed", but fetched
+ # from sys.subversion. Ignore them
+ (name, version, branch, revision, buildno, builddate, compiler) \
+ = platform._sys_version(input)
+ self.assertEqual(
+ (name, version, '', '', buildno, builddate, compiler), output)
+
def test_main():
test_support.run_unittest(
PlatformTest