Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(32452)

Side by Side Diff: Lib/test/test_platform.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_pep380.py ('k') | Lib/test/test_poplib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import platform 2 import platform
3 import subprocess 3 import subprocess
4 import sys 4 import sys
5 import unittest 5 import unittest
6 import warnings 6 import warnings
7 7
8 from test import support 8 from test import support
9 9
10 class PlatformTest(unittest.TestCase): 10 class PlatformTest(unittest.TestCase):
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if platform.uname().system == 'Darwin': 175 if platform.uname().system == 'Darwin':
176 # We're on a MacOSX system, check that 176 # We're on a MacOSX system, check that
177 # the right version information is returned 177 # the right version information is returned
178 fd = os.popen('sw_vers', 'r') 178 fd = os.popen('sw_vers', 'r')
179 real_ver = None 179 real_ver = None
180 for ln in fd: 180 for ln in fd:
181 if ln.startswith('ProductVersion:'): 181 if ln.startswith('ProductVersion:'):
182 real_ver = ln.strip().split()[-1] 182 real_ver = ln.strip().split()[-1]
183 break 183 break
184 fd.close() 184 fd.close()
185 self.assertFalse(real_ver is None) 185 self.assertIsNotNone(real_ver)
186 result_list = res[0].split('.') 186 result_list = res[0].split('.')
187 expect_list = real_ver.split('.') 187 expect_list = real_ver.split('.')
188 len_diff = len(result_list) - len(expect_list) 188 len_diff = len(result_list) - len(expect_list)
189 # On Snow Leopard, sw_vers reports 10.6.0 as 10.6 189 # On Snow Leopard, sw_vers reports 10.6.0 as 10.6
190 if len_diff > 0: 190 if len_diff > 0:
191 expect_list.extend(['0'] * len_diff) 191 expect_list.extend(['0'] * len_diff)
192 self.assertEqual(result_list, expect_list) 192 self.assertEqual(result_list, expect_list)
193 193
194 # res[1] claims to contain 194 # res[1] claims to contain
195 # (version, dev_stage, non_release_version) 195 # (version, dev_stage, non_release_version)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 self.assertEqual(returncode, len(data)) 283 self.assertEqual(returncode, len(data))
284 284
285 285
286 def test_main(): 286 def test_main():
287 support.run_unittest( 287 support.run_unittest(
288 PlatformTest 288 PlatformTest
289 ) 289 )
290 290
291 if __name__ == '__main__': 291 if __name__ == '__main__':
292 test_main() 292 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_pep380.py ('k') | Lib/test/test_poplib.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+