Staging
v0.8.1
https://github.com/python/cpython
Raw File
Tip revision: 50d55ff8c73f484708225d492a2167b82c8c8bb8 authored by Martin v. Löwis on 11 March 2008, 17:59:53 UTC
Prepare for 2.4.5
Tip revision: 50d55ff
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