blob: fb4ac9a639fbc1d1db69347e2d8b07163794a2e0 [file] [log] [blame]
Benjamin Peterson90f5ba52010-03-11 22:53:45 +00001#! /usr/bin/env python3
Skip Montanaro8c913372002-08-15 01:28:54 +00002"""test script for a few new invalid token catches"""
3
Skip Montanaro8c913372002-08-15 01:28:54 +00004import unittest
Benjamin Petersonee8712c2008-05-20 21:35:26 +00005from test import support
Skip Montanaro8c913372002-08-15 01:28:54 +00006
7class EOFTestCase(unittest.TestCase):
8 def test_EOFC(self):
Alexandre Vassalotti8ae3e052008-05-16 00:41:41 +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 """)
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:
Benjamin Petersonee8712c2008-05-20 21:35:26 +000016 raise support.TestFailed
Skip Montanaro8c913372002-08-15 01:28:54 +000017
18 def test_EOFS(self):
Alexandre Vassalotti8ae3e052008-05-16 00:41:41 +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""")
Guido van Rossumb940e112007-01-10 16:19:56 +000023 except SyntaxError as msg:
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000024 self.assertEqual(str(msg), expect)
Skip Montanaro8c913372002-08-15 01:28:54 +000025 else:
Benjamin Petersonee8712c2008-05-20 21:35:26 +000026 raise support.TestFailed
Skip Montanaro8c913372002-08-15 01:28:54 +000027
28def test_main():
Benjamin Petersonee8712c2008-05-20 21:35:26 +000029 support.run_unittest(EOFTestCase)
Skip Montanaro8c913372002-08-15 01:28:54 +000030
31if __name__ == "__main__":
32 test_main()