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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 10 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:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_platform.py ('k') | Lib/test/test_property.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 "Test posix functions" 1 "Test posix functions"
2 2
3 from test import support 3 from test import support
4 4
5 # Skip these tests if there is no posix module. 5 # Skip these tests if there is no posix module.
6 posix = support.import_module('posix') 6 posix = support.import_module('posix')
7 7
8 import errno 8 import errno
9 import sys 9 import sys
10 import time 10 import time
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 os.symlink(_DUMMY_SYMLINK, support.TESTFN) 533 os.symlink(_DUMMY_SYMLINK, support.TESTFN)
534 self._test_all_chown_common(posix.lchown, support.TESTFN, 534 self._test_all_chown_common(posix.lchown, support.TESTFN,
535 getattr(posix, 'lstat', None)) 535 getattr(posix, 'lstat', None))
536 536
537 @unittest.skipUnless(hasattr(posix, 'chdir'), 'test needs posix.chdir()') 537 @unittest.skipUnless(hasattr(posix, 'chdir'), 'test needs posix.chdir()')
538 def test_chdir(self): 538 def test_chdir(self):
539 posix.chdir(os.curdir) 539 posix.chdir(os.curdir)
540 self.assertRaises(OSError, posix.chdir, support.TESTFN) 540 self.assertRaises(OSError, posix.chdir, support.TESTFN)
541 541
542 def test_listdir(self): 542 def test_listdir(self):
543 self.assertTrue(support.TESTFN in posix.listdir(os.curdir)) 543 self.assertIn(support.TESTFN, posix.listdir(os.curdir))
544 544
545 def test_listdir_default(self): 545 def test_listdir_default(self):
546 # When listdir is called without argument, 546 # When listdir is called without argument,
547 # it's the same as listdir(os.curdir). 547 # it's the same as listdir(os.curdir).
548 self.assertTrue(support.TESTFN in posix.listdir()) 548 self.assertIn(support.TESTFN, posix.listdir())
549 549
550 def test_listdir_bytes(self): 550 def test_listdir_bytes(self):
551 # When listdir is called with a bytes object, 551 # When listdir is called with a bytes object,
552 # the returned strings are of type bytes. 552 # the returned strings are of type bytes.
553 self.assertTrue(os.fsencode(support.TESTFN) in posix.listdir(b'.')) 553 self.assertIn(os.fsencode(support.TESTFN), posix.listdir(b'.'))
554 554
555 @unittest.skipUnless(posix.listdir in os.supports_fd, 555 @unittest.skipUnless(posix.listdir in os.supports_fd,
556 "test needs fd support for posix.listdir()") 556 "test needs fd support for posix.listdir()")
557 def test_listdir_fd(self): 557 def test_listdir_fd(self):
558 f = posix.open(posix.getcwd(), posix.O_RDONLY) 558 f = posix.open(posix.getcwd(), posix.O_RDONLY)
559 self.addCleanup(posix.close, f) 559 self.addCleanup(posix.close, f)
560 self.assertEqual( 560 self.assertEqual(
561 sorted(posix.listdir('.')), 561 sorted(posix.listdir('.')),
562 sorted(posix.listdir(f)) 562 sorted(posix.listdir(f))
563 ) 563 )
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 self.assertListEqual(groups, posix.getgroups()) 1157 self.assertListEqual(groups, posix.getgroups())
1158 1158
1159 def test_main(): 1159 def test_main():
1160 try: 1160 try:
1161 support.run_unittest(PosixTester, PosixGroupsTester) 1161 support.run_unittest(PosixTester, PosixGroupsTester)
1162 finally: 1162 finally:
1163 support.reap_children() 1163 support.reap_children()
1164 1164
1165 if __name__ == '__main__': 1165 if __name__ == '__main__':
1166 test_main() 1166 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_platform.py ('k') | Lib/test/test_property.py » ('j') | no next file with comments »

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