[Python-checkins] python/dist/src/Lib/test test_tokenize.py, 1.10, 1.11
rhettinger@users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Jun 21 09:44:15 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25473/Lib/test
Modified Files:
test_tokenize.py
Log Message:
SF bug #1224621: tokenize module does not detect inconsistent dedents
Index: test_tokenize.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tokenize.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- test_tokenize.py 10 Jun 2005 11:05:19 -0000 1.10
+++ test_tokenize.py 21 Jun 2005 07:43:58 -0000 1.11
@@ -1,4 +1,4 @@
-from test.test_support import verbose, findfile, is_resource_enabled
+from test.test_support import verbose, findfile, is_resource_enabled, TestFailed
import os, glob, random
from tokenize import (tokenize, generate_tokens, untokenize,
NUMBER, NAME, OP, STRING)
@@ -41,6 +41,24 @@
test_roundtrip(f)
+###### Test detecton of IndentationError ######################
+
+from cStringIO import StringIO
+
+sampleBadText = """
+def foo():
+ bar
+ baz
+"""
+
+try:
+ for tok in generate_tokens(StringIO(sampleBadText).readline):
+ pass
+except IndentationError:
+ pass
+else:
+ raise TestFailed("Did not detect IndentationError:")
+
###### Test example in the docs ###############################
More information about the Python-checkins
mailing list