Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 35af158d2801eccfc5beda06aba390e08621954c authored by cvs2svn on 20 September 2005, 20:53:24 UTC
This commit was manufactured by cvs2svn to create tag 'r242c1'.
Tip revision: 35af158
test_tokenize.py
from test.test_support import verbose, findfile, TestFailed
import tokenize, os, sys

if verbose:
    print 'starting...'

f = file(findfile('tokenize_tests' + os.extsep + 'txt'))
tokenize.tokenize(f.readline)
f.close()

if verbose:
    print 'finished'

###### Test detecton of IndentationError ######################

from cStringIO import StringIO

sampleBadText = """
def foo():
    bar
  baz
"""

try:
    for tok in tokenize.generate_tokens(StringIO(sampleBadText).readline):
        pass
except IndentationError:
    pass
else:
    raise TestFailed("Did not detect IndentationError:")
back to top