Staging
v0.8.1
https://github.com/python/cpython
Raw File
Tip revision: 7d42c22d6d77add480ff415014614d270cfc37df authored by Hye-Shik Chang on 28 March 2006, 08:36:44 UTC
Relocate the misplaced heading.
Tip revision: 7d42c22
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