diff options
author | Guido van Rossum <guido@python.org> | 2001-01-09 21:47:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-01-09 21:47:44 (GMT) |
commit | 07b78a8778c42d3ff71ce3b5dd50bb57ff5c9db5 (patch) | |
tree | 37ea383607e885050d0984e4fc19b1c70607c973 /Lib/test/test_xreadline.py | |
parent | ea3375d96b35c2f2b1669da4d3e14ff7c4a189bb (diff) | |
download | cpython-07b78a8778c42d3ff71ce3b5dd50bb57ff5c9db5.zip cpython-07b78a8778c42d3ff71ce3b5dd50bb57ff5c9db5.tar.gz cpython-07b78a8778c42d3ff71ce3b5dd50bb57ff5c9db5.tar.bz2 |
Test for xreadline.
Diffstat (limited to 'Lib/test/test_xreadline.py')
-rw-r--r-- | Lib/test/test_xreadline.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Lib/test/test_xreadline.py b/Lib/test/test_xreadline.py new file mode 100644 index 0000000..84f7ba4 --- /dev/null +++ b/Lib/test/test_xreadline.py @@ -0,0 +1,42 @@ +from test_support import verbose + +class XReader: + def __init__(self): + self.count = 5 + + def readlines(self, sizehint = None): + self.count = self.count - 1 + return map(lambda x: "%d\n" % x, range(self.count)) + +class Null: pass + +import xreadlines + + +lineno = 0 + +try: + xreadlines.xreadlines(Null())[0] +except AttributeError, detail: + print "AttributeError" +else: + print "Did not throw attribute error" + +try: + xreadlines.xreadlines(XReader)[0] +except TypeError, detail: + print "TypeError" +else: + print "Did not throw type error" + +try: + xreadlines.xreadlines(XReader())[1] +except RuntimeError, detail: + print "RuntimeError", detail +else: + print "Did not throw runtime error" + +xresult = ['0\n', '1\n', '2\n', '3\n', '0\n', '1\n', '2\n', '0\n', '1\n', '0\n'] +for line in xreadlines.xreadlines(XReader()): + if line != xresult[lineno]: print "line %d differs" % lineno + lineno = lineno + 1 |