mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
31 lines
592 B
Python
31 lines
592 B
Python
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:")
|