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

Unified Diff: Lib/test/test_fileio.py

Issue 18876: Problems with files opened in append mode with io module
Patch Set: Created 6 years, 5 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Modules/_io/fileio.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_fileio.py Thu Aug 29 13:39:44 2013 -0700
+++ b/Lib/test/test_fileio.py Wed Sep 04 12:19:31 2013 -0400
@@ -304,7 +304,7 @@
finally:
os.unlink(TESTFN)
- def testModeStrings(self):
+ def testInvalidModeStrings(self):
# check invalid mode strings
for mode in ("", "aU", "wU+", "rw", "rt"):
try:
@@ -315,6 +315,21 @@
f.close()
self.fail('%r is an invalid file mode' % mode)
+ def testModeStrings(self):
+ # test that the mode attribute is correct for various mode strings
+ # given as init args
+ try:
+ for modes in [('w', 'wb'), ('wb', 'wb'), ('wb+', 'rb+'),
+ ('w+b', 'rb+'), ('a', 'ab'), ('ab', 'ab'),
+ ('ab+', 'ab+'), ('a+b', 'ab+'), ('r', 'rb'),
+ ('rb', 'rb'), ('rb+', 'rb+'), ('r+b', 'rb+')]:
+ # read modes are last so that TESTFN will exist first
+ with _FileIO(TESTFN, modes[0]) as f:
+ self.assertEqual(f.mode, modes[1])
+ finally:
+ if os.path.exists(TESTFN):
+ os.unlink(TESTFN)
+
def testUnicodeOpen(self):
# verify repr works for unicode too
f = _FileIO(str(TESTFN), "w")
« no previous file with comments | « no previous file | Modules/_io/fileio.c » ('j') | no next file with comments »

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