[Python-checkins] CVS: python/dist/src/Lib/test test_file.py,1.6,1.7

Neal Norwitz nnorwitz@users.sourceforge.net
Sun, 31 Mar 2002 16:09:02 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv21852/Lib/test

Modified Files:
	test_file.py 
Log Message:
Convert file.readinto() to stop using METH_OLDARGS & PyArg_Parse.
Add test for file.readinto().


Index: test_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_file.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_file.py	1 Jan 2002 19:11:13 -0000	1.6
--- test_file.py	1 Apr 2002 00:09:00 -0000	1.7
***************
*** 1,3 ****
--- 1,4 ----
  import os
+ from array import array
  
  from test_support import verify, TESTFN
***************
*** 14,17 ****
--- 15,25 ----
  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')
***************
*** 69,72 ****
--- 77,87 ----
  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()