| 1 | from test.test_support import verbose, findfile, TestFailed |
| 2 | import tokenize, os, sys |
| 3 | |
| 4 | if verbose: |
| 5 | print 'starting...' |
| 6 | |
| 7 | f = file(findfile('tokenize_tests' + os.extsep + 'txt')) |
| 8 | tokenize.tokenize(f.readline) |
| 9 | f.close() |
| 10 | |
| 11 | if verbose: |
| 12 | print 'finished' |
| 13 | |
| 14 | ###### Test detecton of IndentationError ###################### |
| 15 | |
| 16 | from cStringIO import StringIO |
| 17 | |
| 18 | sampleBadText = """ |
| 19 | def foo(): |
| 20 | bar |
| 21 | baz |
| 22 | """ |
| 23 | |
| 24 | try: |
| 25 | for tok in tokenize.generate_tokens(StringIO(sampleBadText).readline): |
| 26 | pass |
| 27 | except IndentationError: |
| 28 | pass |
| 29 | else: |
| 30 | raise TestFailed("Did not detect IndentationError:") |