summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_file.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-04-01 00:09:00 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-04-01 00:09:00 (GMT)
commit62f5a9d6c2e99b688e388d33c226e41174640082 (patch)
treef1aae8d0036b1b68ad2eb465a3f7fcb6fc4b6c3f /Lib/test/test_file.py
parentb955d6c41e80806c8390dba47323ef7fc41f05aa (diff)
downloadcpython-62f5a9d6c2e99b688e388d33c226e41174640082.zip
cpython-62f5a9d6c2e99b688e388d33c226e41174640082.tar.gz
cpython-62f5a9d6c2e99b688e388d33c226e41174640082.tar.bz2
Convert file.readinto() to stop using METH_OLDARGS & PyArg_Parse.
Add test for file.readinto().
Diffstat (limited to 'Lib/test/test_file.py')
-rw-r--r--Lib/test/test_file.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index c00874d..33a923d 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -1,4 +1,5 @@
import os
+from array import array
from test_support import verify, TESTFN
from UserList import UserList
@@ -13,6 +14,13 @@ buf = f.read()
f.close()
verify(buf == '12')
+# verify readinto
+a = array('c', 'x'*10)
+f = open(TESTFN, 'rb')
+n = f.readinto(a)
+f.close()
+verify(buf == a.tostring()[:n])
+
# verify writelines with integers
f = open(TESTFN, 'wb')
try:
@@ -69,6 +77,13 @@ if f.isatty():
if f.closed:
raise TestError, 'file.closed should be false'
+try:
+ f.readinto("")
+except TypeError:
+ pass
+else:
+ raise TestError, 'file.readinto("") should raise a TypeError'
+
f.close()
if not f.closed:
raise TestError, 'file.closed should be true'