test_eof.py 871 B

12345678910111213141516171819202122232425262728293031
  1. """test script for a few new invalid token catches"""
  2. import unittest
  3. from test import test_support
  4. class EOFTestCase(unittest.TestCase):
  5. def test_EOFC(self):
  6. expect = "EOL while scanning string literal (<string>, line 1)"
  7. try:
  8. eval("""'this is a test\
  9. """)
  10. except SyntaxError, msg:
  11. self.assertEqual(str(msg), expect)
  12. else:
  13. raise test_support.TestFailed
  14. def test_EOFS(self):
  15. expect = ("EOF while scanning triple-quoted string literal "
  16. "(<string>, line 1)")
  17. try:
  18. eval("""'''this is a test""")
  19. except SyntaxError, msg:
  20. self.assertEqual(str(msg), expect)
  21. else:
  22. raise test_support.TestFailed
  23. def test_main():
  24. test_support.run_unittest(EOFTestCase)
  25. if __name__ == "__main__":
  26. test_main()