/Lib/test/test_eof.py

http://unladen-swallow.googlecode.com/ · Python · 32 lines · 25 code · 5 blank · 2 comment · 7 complexity · bd84194f84e981a31b5d31981baee09e MD5 · raw file

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