]> granicus.if.org Git - python/commitdiff
Added some tests for the truncate() method; one is commented out because
authorFred Drake <fdrake@acm.org>
Thu, 28 Sep 2000 04:25:33 +0000 (04:25 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 28 Sep 2000 04:25:33 +0000 (04:25 +0000)
cStringIO does not get it right (reported as SF bug #115531).

Added test for ValueError when write() is called on a closed StringIO
object.  Commented out because cStringIO does not get it right
(reported as SF bug #115530).

Lib/test/output/test_StringIO
Lib/test/test_StringIO.py

index 505023a7bc4b30b2911c6844e9c0fbae2e148165..ce983c03d1b8f4f7dbdc6773df44399143f561b8 100644 (file)
@@ -3,7 +3,9 @@ abcdefghij
 klmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
 
 2
+'abcdefghij'
 abcdefghij
 klmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
 
 2
+'abcdefghij'
index 6e321e930f7e023c8a33202a1f903779cdc0e261..2d9f2c1ded8758b140bb09ab1a8ca2ac85041ea5 100644 (file)
@@ -9,6 +9,29 @@ def do_test(module):
     print f.readline()
     print len(f.readlines(60))
 
+    f = module.StringIO()
+    f.write(s)
+    f.seek(10)
+    f.truncate()
+    print `f.getvalue()`
+    # This test fails for cStringIO; reported as SourceForge bug #115531;
+    # please uncomment this test when that bug is fixed.
+    # http://sourceforge.net/bugs/?func=detailbug&bug_id=115531&group_id=5470
+##     f.seek(0)
+##     f.truncate(5)
+##     print `f.getvalue()`
+
+    # This test fails for cStringIO; reported as SourceForge bug #115530;
+    # please uncomment this test when that bug is fixed.
+    # http://sourceforge.net/bugs/?func=detailbug&bug_id=115530&group_id=5470
+##     try:
+##         f.write("frobnitz")
+##     except ValueError, e:
+##         print "Caught expected ValueError writing to closed StringIO:"
+##         print e
+##     else:
+##         print "Failed to catch ValueError writing to closed StringIO."
+
 # Don't bother testing cStringIO without
 import StringIO, cStringIO
 do_test(StringIO)