mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
Support name and mode attributes on all file types.
Don't read more than one line when reading text from a tty device. Add peek() and read1() methods. Return str instead of unicode when return ASCII characters in text mode.
This commit is contained in:
parent
913dd0be52
commit
13633bb8c5
3 changed files with 83 additions and 18 deletions
|
@ -163,14 +163,7 @@ class BytesTest(unittest.TestCase):
|
|||
f.write(b)
|
||||
with open(tfn, "rb") as f:
|
||||
self.assertEqual(f.read(), sample)
|
||||
# Test writing in text mode
|
||||
with open(tfn, "w") as f:
|
||||
f.write(b)
|
||||
with open(tfn, "r") as f:
|
||||
self.assertEqual(f.read(), sample)
|
||||
# Can't use readinto in text mode
|
||||
with open(tfn, "r") as f:
|
||||
self.assertRaises(TypeError, f.readinto, b)
|
||||
# Text mode is ambiguous; don't test
|
||||
finally:
|
||||
try:
|
||||
os.remove(tfn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue