Skip Montanaro | 8c91337 | 2002-08-15 01:28:54 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | """test script for a few new invalid token catches""" |
| 3 | |
| 4 | import os |
| 5 | import unittest |
| 6 | from test import test_support |
| 7 | |
| 8 | class EOFTestCase(unittest.TestCase): |
| 9 | def test_EOFC(self): |
Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 10 | expect = "EOL while scanning single-quoted string (<string>, line 1)" |
Skip Montanaro | 8c91337 | 2002-08-15 01:28:54 +0000 | [diff] [blame] | 11 | try: |
| 12 | eval("""'this is a test\ |
| 13 | """) |
| 14 | except SyntaxError, msg: |
Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 15 | self.assertEqual(str(msg), expect) |
Skip Montanaro | 8c91337 | 2002-08-15 01:28:54 +0000 | [diff] [blame] | 16 | else: |
| 17 | raise test_support.TestFailed |
| 18 | |
| 19 | def test_EOFS(self): |
Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 20 | expect = "EOF while scanning triple-quoted string (<string>, line 1)" |
Skip Montanaro | 8c91337 | 2002-08-15 01:28:54 +0000 | [diff] [blame] | 21 | try: |
| 22 | eval("""'''this is a test""") |
| 23 | except SyntaxError, msg: |
Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 24 | self.assertEqual(str(msg), expect) |
Skip Montanaro | 8c91337 | 2002-08-15 01:28:54 +0000 | [diff] [blame] | 25 | else: |
| 26 | raise test_support.TestFailed |
| 27 | |
| 28 | def test_main(): |
| 29 | test_support.run_unittest(EOFTestCase) |
| 30 | |
| 31 | if __name__ == "__main__": |
| 32 | test_main() |