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

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

Issue 18876: Problems with files opened in append mode with io module
Left Patch Set: Created 6 years, 4 months ago
Right Patch Set: Created 6 years, 4 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 | « no previous file | Modules/_io/fileio.c » ('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 # Adapted from test_file.py by Daniel Stutzbach 1 # Adapted from test_file.py by Daniel Stutzbach
2 2
3 import sys 3 import sys
4 import os 4 import os
5 import io 5 import io
6 import errno 6 import errno
7 import unittest 7 import unittest
8 from array import array 8 from array import array
9 from weakref import proxy 9 from weakref import proxy
10 from functools import wraps 10 from functools import wraps
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 def testModeStrings(self): 318 def testModeStrings(self):
319 # test that the mode attribute is correct for various mode strings 319 # test that the mode attribute is correct for various mode strings
320 # given as init args 320 # given as init args
321 try: 321 try:
322 for modes in [('w', 'wb'), ('wb', 'wb'), ('wb+', 'rb+'), 322 for modes in [('w', 'wb'), ('wb', 'wb'), ('wb+', 'rb+'),
323 ('w+b', 'rb+'), ('a', 'ab'), ('ab', 'ab'), 323 ('w+b', 'rb+'), ('a', 'ab'), ('ab', 'ab'),
324 ('ab+', 'ab+'), ('a+b', 'ab+'), ('r', 'rb'), 324 ('ab+', 'ab+'), ('a+b', 'ab+'), ('r', 'rb'),
325 ('rb', 'rb'), ('rb+', 'rb+'), ('r+b', 'rb+')]: 325 ('rb', 'rb'), ('rb+', 'rb+'), ('r+b', 'rb+')]:
326 # read modes are last so that TESTFN will exist first 326 # read modes are last so that TESTFN will exist first
327 self.assertEqual(_FileIO(TESTFN, modes[0]).mode, modes[1]) 327 with _FileIO(TESTFN, modes[0]) as f:
AntoinePitrou 2013/08/31 21:08:11 Not closing the FileIO object explicitly will prin
328 self.assertEqual(f.mode, modes[1])
328 finally: 329 finally:
329 if os.path.exists(TESTFN): 330 if os.path.exists(TESTFN):
330 os.unlink(TESTFN) 331 os.unlink(TESTFN)
331 332
332 def testUnicodeOpen(self): 333 def testUnicodeOpen(self):
333 # verify repr works for unicode too 334 # verify repr works for unicode too
334 f = _FileIO(str(TESTFN), "w") 335 f = _FileIO(str(TESTFN), "w")
335 f.close() 336 f.close()
336 os.unlink(TESTFN) 337 os.unlink(TESTFN)
337 338
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 # Historically, these tests have been sloppy about removing TESTFN. 469 # Historically, these tests have been sloppy about removing TESTFN.
469 # So get rid of it no matter what. 470 # So get rid of it no matter what.
470 try: 471 try:
471 run_unittest(AutoFileTests, OtherFileTests) 472 run_unittest(AutoFileTests, OtherFileTests)
472 finally: 473 finally:
473 if os.path.exists(TESTFN): 474 if os.path.exists(TESTFN):
474 os.unlink(TESTFN) 475 os.unlink(TESTFN)
475 476
476 if __name__ == '__main__': 477 if __name__ == '__main__':
477 test_main() 478 test_main()
LEFTRIGHT

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