blob: 7de4686c4551cd782f242ed4d2d7d2194afbffc5 [file] [log] [blame]
Skip Montanaro8c913372002-08-15 01:28:54 +00001"""test script for a few new invalid token catches"""
2
Skip Montanaro8c913372002-08-15 01:28:54 +00003import unittest
4from test import test_support
5
6class EOFTestCase(unittest.TestCase):
7 def test_EOFC(self):
Georg Brandlb52a74b2008-05-11 15:07:39 +00008 expect = "EOL while scanning string literal (<string>, line 1)"
Skip Montanaro8c913372002-08-15 01:28:54 +00009 try:
10 eval("""'this is a test\
11 """)
12 except SyntaxError, msg:
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000013 self.assertEqual(str(msg), expect)
Skip Montanaro8c913372002-08-15 01:28:54 +000014 else:
15 raise test_support.TestFailed
16
17 def test_EOFS(self):
Georg Brandlb52a74b2008-05-11 15:07:39 +000018 expect = ("EOF while scanning triple-quoted string literal "
19 "(<string>, line 1)")
Skip Montanaro8c913372002-08-15 01:28:54 +000020 try:
21 eval("""'''this is a test""")
22 except SyntaxError, 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()