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

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

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 5 years, 10 months ago
Right Patch Set: Created 5 years, 7 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_multiprocessing.py ('k') | Lib/test/test_ossaudiodev.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 # As a test suite for the os module, this is woefully inadequate, but this 1 # As a test suite for the os module, this is woefully inadequate, but this
2 # does add tests for a few functions which have been determined to be more 2 # does add tests for a few functions which have been determined to be more
3 # portable than they had been thought to be. 3 # portable than they had been thought to be.
4 4
5 import os 5 import os
6 import errno 6 import errno
7 import unittest 7 import unittest
8 import warnings 8 import warnings
9 import sys 9 import sys
10 import signal 10 import signal
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 t1 = 5000000000 # some day in 2128 501 t1 = 5000000000 # some day in 2128
502 os.utime(self.fname, (t1, t1)) 502 os.utime(self.fname, (t1, t1))
503 self.assertEqual(os.stat(self.fname).st_mtime, t1) 503 self.assertEqual(os.stat(self.fname).st_mtime, t1)
504 504
505 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") 505 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
506 def test_1686475(self): 506 def test_1686475(self):
507 # Verify that an open file can be stat'ed 507 # Verify that an open file can be stat'ed
508 try: 508 try:
509 os.stat(r"c:\pagefile.sys") 509 os.stat(r"c:\pagefile.sys")
510 except FileNotFoundError: 510 except FileNotFoundError:
511 pass # file does not exist; cannot run test 511 self.skipTest(r'c:\pagefile.sys does not exist')
512 except OSError as e: 512 except OSError as e:
513 self.fail("Could not stat pagefile.sys") 513 self.fail("Could not stat pagefile.sys")
514 514
515 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") 515 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
516 @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()") 516 @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
517 def test_15261(self): 517 def test_15261(self):
518 # Verify that stat'ing a closed fd does not cause crash 518 # Verify that stat'ing a closed fd does not cause crash
519 r, w = os.pipe() 519 r, w = os.pipe()
520 try: 520 try:
521 os.stat(r) # should not raise error 521 os.stat(r) # should not raise error
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 self.check(os.ftruncate, 0) 1260 self.check(os.ftruncate, 0)
1261 1261
1262 @unittest.skipUnless(hasattr(os, 'lseek'), 'test needs os.lseek()') 1262 @unittest.skipUnless(hasattr(os, 'lseek'), 'test needs os.lseek()')
1263 def test_lseek(self): 1263 def test_lseek(self):
1264 self.check(os.lseek, 0, 0) 1264 self.check(os.lseek, 0, 0)
1265 1265
1266 @unittest.skipUnless(hasattr(os, 'read'), 'test needs os.read()') 1266 @unittest.skipUnless(hasattr(os, 'read'), 'test needs os.read()')
1267 def test_read(self): 1267 def test_read(self):
1268 self.check(os.read, 1) 1268 self.check(os.read, 1)
1269 1269
1270 @unittest.skipUnless(hasattr(os, 'readv'), 'test needs os.readv()')
1271 def test_readv(self):
1272 buf = bytearray(10)
1273 self.check(os.readv, [buf])
1274
1270 @unittest.skipUnless(hasattr(os, 'tcsetpgrp'), 'test needs os.tcsetpgrp()') 1275 @unittest.skipUnless(hasattr(os, 'tcsetpgrp'), 'test needs os.tcsetpgrp()')
1271 def test_tcsetpgrpt(self): 1276 def test_tcsetpgrpt(self):
1272 self.check(os.tcsetpgrp, 0) 1277 self.check(os.tcsetpgrp, 0)
1273 1278
1274 @unittest.skipUnless(hasattr(os, 'write'), 'test needs os.write()') 1279 @unittest.skipUnless(hasattr(os, 'write'), 'test needs os.write()')
1275 def test_write(self): 1280 def test_write(self):
1276 self.check(os.write, b" ") 1281 self.check(os.write, b" ")
1282
1283 @unittest.skipUnless(hasattr(os, 'writev'), 'test needs os.writev()')
1284 def test_writev(self):
1285 self.check(os.writev, [b'abc'])
1277 1286
1278 1287
1279 class LinkTests(unittest.TestCase): 1288 class LinkTests(unittest.TestCase):
1280 def setUp(self): 1289 def setUp(self):
1281 self.file1 = support.TESTFN 1290 self.file1 = support.TESTFN
1282 self.file2 = os.path.join(support.TESTFN + "2") 1291 self.file2 = os.path.join(support.TESTFN + "2")
1283 1292
1284 def tearDown(self): 1293 def tearDown(self):
1285 for file in (self.file1, self.file2): 1294 for file in (self.file1, self.file2):
1286 if os.path.exists(file): 1295 if os.path.exists(file):
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 Win32DeprecatedBytesAPI, 2499 Win32DeprecatedBytesAPI,
2491 TermsizeTests, 2500 TermsizeTests,
2492 OSErrorTests, 2501 OSErrorTests,
2493 RemoveDirsTests, 2502 RemoveDirsTests,
2494 CPUCountTests, 2503 CPUCountTests,
2495 FDInheritanceTests, 2504 FDInheritanceTests,
2496 ) 2505 )
2497 2506
2498 if __name__ == "__main__": 2507 if __name__ == "__main__":
2499 test_main() 2508 test_main()
LEFTRIGHT

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