test_web__responses.py 877 B

12345678910111213141516171819202122232425262728
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. The L{_response} module contains constants for all standard HTTP codes, along
  5. with a mapping to the corresponding phrases.
  6. """
  7. from __future__ import division, absolute_import
  8. import string
  9. from twisted.trial import unittest
  10. from twisted.web import _responses
  11. class ResponseTests(unittest.TestCase):
  12. def test_constants(self):
  13. """
  14. All constants besides C{RESPONSES} defined in L{_response} are
  15. integers and are keys in C{RESPONSES}.
  16. """
  17. for sym in dir(_responses):
  18. if sym == 'RESPONSES':
  19. continue
  20. if all((c == '_' or c in string.ascii_uppercase) for c in sym):
  21. val = getattr(_responses, sym)
  22. self.assertIsInstance(val, int)
  23. self.assertIn(val, _responses.RESPONSES)