Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9543833

Browse files
committed
Added some tests for the truncate() method; one is commented out because
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).
1 parent e0a7f4f commit 9543833

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lib/test/output/test_StringIO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ abcdefghij
33
klmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
44

55
2
6+
'abcdefghij'
67
abcdefghij
78
klmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
89

910
2
11+
'abcdefghij'

Lib/test/test_StringIO.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ def do_test(module):
99
print f.readline()
1010
print len(f.readlines(60))
1111

12+
f = module.StringIO()
13+
f.write(s)
14+
f.seek(10)
15+
f.truncate()
16+
print `f.getvalue()`
17+
# This test fails for cStringIO; reported as SourceForge bug #115531;
18+
# please uncomment this test when that bug is fixed.
19+
# http://sourceforge.net/bugs/?func=detailbug&bug_id=115531&group_id=5470
20+
## f.seek(0)
21+
## f.truncate(5)
22+
## print `f.getvalue()`
23+
24+
# This test fails for cStringIO; reported as SourceForge bug #115530;
25+
# please uncomment this test when that bug is fixed.
26+
# http://sourceforge.net/bugs/?func=detailbug&bug_id=115530&group_id=5470
27+
## try:
28+
## f.write("frobnitz")
29+
## except ValueError, e:
30+
## print "Caught expected ValueError writing to closed StringIO:"
31+
## print e
32+
## else:
33+
## print "Failed to catch ValueError writing to closed StringIO."
34+
1235
# Don't bother testing cStringIO without
1336
import StringIO, cStringIO
1437
do_test(StringIO)

0 commit comments

Comments
 (0)