test_html.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. from twisted.trial import unittest
  4. from twisted.web import html
  5. class WebHtmlTests(unittest.TestCase):
  6. """
  7. Unit tests for L{twisted.web.html}.
  8. """
  9. def test_deprecation(self):
  10. """
  11. Calls to L{twisted.web.html} members emit a deprecation warning.
  12. """
  13. def assertDeprecationWarningOf(method):
  14. """
  15. Check that a deprecation warning is present.
  16. """
  17. warningsShown = self.flushWarnings([self.test_deprecation])
  18. self.assertEqual(len(warningsShown), 1)
  19. self.assertIdentical(
  20. warningsShown[0]['category'], DeprecationWarning)
  21. self.assertEqual(
  22. warningsShown[0]['message'],
  23. 'twisted.web.html.%s was deprecated in Twisted 15.3.0; '
  24. 'please use twisted.web.template instead' % (
  25. method,),
  26. )
  27. html.PRE('')
  28. assertDeprecationWarningOf('PRE')
  29. html.UL([])
  30. assertDeprecationWarningOf('UL')
  31. html.linkList([])
  32. assertDeprecationWarningOf('linkList')
  33. html.output(lambda: None)
  34. assertDeprecationWarningOf('output')