blob: 84f7ba42b08f7267dd6416de4f26f8b78aef5d6c [file] [log] [blame]
Guido van Rossum07b78a82001-01-09 21:47:44 +00001from test_support import verbose
2
3class XReader:
4 def __init__(self):
5 self.count = 5
6
7 def readlines(self, sizehint = None):
8 self.count = self.count - 1
9 return map(lambda x: "%d\n" % x, range(self.count))
10
11class Null: pass
12
13import xreadlines
14
15
16lineno = 0
17
18try:
19 xreadlines.xreadlines(Null())[0]
20except AttributeError, detail:
21 print "AttributeError"
22else:
23 print "Did not throw attribute error"
24
25try:
26 xreadlines.xreadlines(XReader)[0]
27except TypeError, detail:
28 print "TypeError"
29else:
30 print "Did not throw type error"
31
32try:
33 xreadlines.xreadlines(XReader())[1]
34except RuntimeError, detail:
35 print "RuntimeError", detail
36else:
37 print "Did not throw runtime error"
38
39xresult = ['0\n', '1\n', '2\n', '3\n', '0\n', '1\n', '2\n', '0\n', '1\n', '0\n']
40for line in xreadlines.xreadlines(XReader()):
41 if line != xresult[lineno]: print "line %d differs" % lineno
42 lineno = lineno + 1