Skip to content

Commit 2e9e06a

Browse files
author
amaury.forgeotdarc
committed
#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... git-svn-id: http://svn.python.org/projects/python/trunk@66994 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 4a13b14 commit 2e9e06a

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

Lib/platform.py

-33
Original file line numberDiff line numberDiff line change
@@ -268,24 +268,6 @@ def _parse_release_file(firstline):
268268
id = ''
269269
return '', version, id
270270

271-
def _test_parse_release_file():
272-
273-
for input, output in (
274-
# Examples of release file contents:
275-
('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64'))
276-
('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64'))
277-
('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586'))
278-
('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux'))
279-
('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche'))
280-
('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike'))
281-
('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant'))
282-
('CentOS release 4', ('CentOS', '4', None))
283-
('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia'))
284-
):
285-
parsed = _parse_release_file(input)
286-
if parsed != output:
287-
print (input, parsed)
288-
289271
def linux_distribution(distname='', version='', id='',
290272

291273
supported_dists=_supported_dists,
@@ -1381,21 +1363,6 @@ def _sys_version(sys_version=None):
13811363
_sys_version_cache[sys_version] = result
13821364
return result
13831365

1384-
def _test_sys_version():
1385-
1386-
_sys_version_cache.clear()
1387-
for input, output in (
1388-
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
1389-
('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
1390-
('IronPython 1.0.60816 on .NET 2.0.50727.42',
1391-
('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
1392-
('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
1393-
('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
1394-
):
1395-
parsed = _sys_version(input)
1396-
if parsed != output:
1397-
print (input, parsed)
1398-
13991366
def python_implementation():
14001367

14011368
""" Returns a string identifying the Python implementation.

Lib/test/test_platform.py

+34
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,40 @@ def test_libc_ver(self):
122122
executable = executable + '.exe'
123123
res = platform.libc_ver(sys.executable)
124124

125+
def test_parse_release_file(self):
126+
127+
for input, output in (
128+
# Examples of release file contents:
129+
('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')),
130+
('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')),
131+
('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')),
132+
('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')),
133+
('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')),
134+
('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')),
135+
('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')),
136+
('CentOS release 4', ('CentOS', '4', None)),
137+
('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')),
138+
):
139+
self.assertEqual(platform._parse_release_file(input), output)
140+
141+
def test_sys_version(self):
142+
143+
platform._sys_version_cache.clear()
144+
for input, output in (
145+
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
146+
('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
147+
('IronPython 1.0.60816 on .NET 2.0.50727.42',
148+
('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
149+
('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
150+
('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
151+
):
152+
# branch and revision are not "parsed", but fetched
153+
# from sys.subversion. Ignore them
154+
(name, version, branch, revision, buildno, builddate, compiler) \
155+
= platform._sys_version(input)
156+
self.assertEqual(
157+
(name, version, '', '', buildno, builddate, compiler), output)
158+
125159
def test_main():
126160
test_support.run_unittest(
127161
PlatformTest

0 commit comments

Comments
 (0)