blob: 4284d11d08698a0ceed34c2c33ba73c38b63bf40 [file] [log] [blame]
Skip Montanaro8c913372002-08-15 01:28:54 +00001#! /usr/bin/env python
2"""test script for a few new invalid token catches"""
3
Skip Montanaro8c913372002-08-15 01:28:54 +00004import unittest
5from test import test_support
6
7class EOFTestCase(unittest.TestCase):
8 def test_EOFC(self):
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00009 expect = "EOL while scanning single-quoted string (<string>, line 1)"
Skip Montanaro8c913372002-08-15 01:28:54 +000010 try:
11 eval("""'this is a test\
12 """)
Guido van Rossumb940e112007-01-10 16:19:56 +000013 except SyntaxError as msg:
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000014 self.assertEqual(str(msg), expect)
Skip Montanaro8c913372002-08-15 01:28:54 +000015 else:
16 raise test_support.TestFailed
17
18 def test_EOFS(self):
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000019 expect = "EOF while scanning triple-quoted string (<string>, line 1)"
Skip Montanaro8c913372002-08-15 01:28:54 +000020 try:
21 eval("""'''this is a test""")
Guido van Rossumb940e112007-01-10 16:19:56 +000022 except SyntaxError as msg:
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000023 self.assertEqual(str(msg), expect)
Skip Montanaro8c913372002-08-15 01:28:54 +000024 else:
25 raise test_support.TestFailed
26
27def test_main():
28 test_support.run_unittest(EOFTestCase)
29
30if __name__ == "__main__":
31 test_main()