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

Delta Between Two Patch Sets: Lib/test/test_platform.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 5 years, 9 months ago
Right Patch Set: Created 5 years, 6 months 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_pep380.py ('k') | Lib/test/test_posix.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 from unittest import mock
1 import os 2 import os
2 import platform 3 import platform
3 import subprocess 4 import subprocess
4 import sys 5 import sys
6 import tempfile
5 import unittest 7 import unittest
6 import warnings 8 import warnings
7 9
8 from test import support 10 from test import support
9 11
10 class PlatformTest(unittest.TestCase): 12 class PlatformTest(unittest.TestCase):
11 def test_architecture(self): 13 def test_architecture(self):
12 res = platform.architecture() 14 res = platform.architecture()
13 15
14 @support.skip_unless_symlink 16 @support.skip_unless_symlink
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 with platform.popen(command, 'w') as stdin: 290 with platform.popen(command, 'w') as stdin:
289 stdout = stdin.write(data) 291 stdout = stdin.write(data)
290 ret = stdin.close() 292 ret = stdin.close()
291 self.assertIsNotNone(ret) 293 self.assertIsNotNone(ret)
292 if os.name == 'nt': 294 if os.name == 'nt':
293 returncode = ret 295 returncode = ret
294 else: 296 else:
295 returncode = ret >> 8 297 returncode = ret >> 8
296 self.assertEqual(returncode, len(data)) 298 self.assertEqual(returncode, len(data))
297 299
300 def test_linux_distribution_encoding(self):
301 # Issue #17429
302 with tempfile.TemporaryDirectory() as tempdir:
303 filename = os.path.join(tempdir, 'fedora-release')
304 with open(filename, 'w', encoding='utf-8') as f:
305 f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')
306
307 with mock.patch('platform._UNIXCONFDIR', tempdir):
308 distname, version, distid = platform.linux_distribution()
309
310 self.assertEqual(distname, 'Fedora')
311 self.assertEqual(version, '19')
312 self.assertEqual(distid, 'Schr\xf6dinger\u2019s Cat')
298 313
299 def test_main(): 314 def test_main():
300 support.run_unittest( 315 support.run_unittest(
301 PlatformTest 316 PlatformTest
302 ) 317 )
303 318
304 if __name__ == '__main__': 319 if __name__ == '__main__':
305 test_main() 320 test_main()
LEFTRIGHT

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