Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 8022feed57dfb3ef54771fcf752f8ae85a28635f authored by Anthony Baxter on 18 October 2006, 07:02:36 UTC
regenerating tag.
Tip revision: 8022fee
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