blob: 763917f0dfc5e9986c78ae7c26ba61679617c5d9 [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):
Georg Brandlb52a74b2008-05-11 15:07:39 +00009 expect = "EOL while scanning string literal (<string>, line 1)"
Skip Montanaro8c913372002-08-15 01:28:54 +000010 try:
11 eval("""'this is a test\
12 """)
13 except SyntaxError, 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):
Georg Brandlb52a74b2008-05-11 15:07:39 +000019 expect = ("EOF while scanning triple-quoted string literal "
20 "(<string>, line 1)")
Skip Montanaro8c913372002-08-15 01:28:54 +000021 try:
22 eval("""'''this is a test""")
23 except SyntaxError, msg:
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000024 self.assertEqual(str(msg), expect)
Skip Montanaro8c913372002-08-15 01:28:54 +000025 else:
26 raise test_support.TestFailed
27
28def test_main():
29 test_support.run_unittest(EOFTestCase)
30
31if __name__ == "__main__":
32 test_main()