summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tokenize.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-06-21 07:43:58 (GMT)
committerRaymond Hettinger <python@rcn.com>2005-06-21 07:43:58 (GMT)
commitda99d1cbfeedafd41263ac2d1b397d57c14ab28e (patch)
tree998e22dfe11672ffa2d7c6ee69b4af1e59914349 /Lib/test/test_tokenize.py
parent8fa7eb563bb9a14651bcdc8ee60c5e45302c2f59 (diff)
downloadcpython-da99d1cbfeedafd41263ac2d1b397d57c14ab28e.zip
cpython-da99d1cbfeedafd41263ac2d1b397d57c14ab28e.tar.gz
cpython-da99d1cbfeedafd41263ac2d1b397d57c14ab28e.tar.bz2
SF bug #1224621: tokenize module does not detect inconsistent dedents
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r--Lib/test/test_tokenize.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 2ce435f..d3c1cc4 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -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 @@ for f in testfiles:
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 ###############################