You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_dict.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. from twisted.trial import unittest
  4. from twisted.trial.unittest import SynchronousTestCase
  5. from twisted.protocols import dict
  6. paramString = b"\"This is a dqstring \\w\\i\\t\\h boring stuff like: \\\"\" and t\\hes\\\"e are a\\to\\ms"
  7. goodparams = [b"This is a dqstring with boring stuff like: \"", b"and", b"thes\"e", b"are", b"atoms"]
  8. class ParamTests(unittest.TestCase):
  9. def testParseParam(self):
  10. """Testing command response handling"""
  11. params = []
  12. rest = paramString
  13. while 1:
  14. (param, rest) = dict.parseParam(rest)
  15. if param == None:
  16. break
  17. params.append(param)
  18. self.assertEqual(params, goodparams)#, "DictClient.parseParam returns unexpected results")
  19. class DictDeprecationTests(SynchronousTestCase):
  20. """
  21. L{twisted.protocols.dict} is deprecated.
  22. """
  23. def test_dictDeprecation(self):
  24. """
  25. L{twisted.protocols.dict} is deprecated since Twisted 17.9.0.
  26. """
  27. from twisted.protocols import dict
  28. dict
  29. warningsShown = self.flushWarnings([self.test_dictDeprecation])
  30. self.assertEqual(1, len(warningsShown))
  31. self.assertEqual(
  32. ("twisted.protocols.dict was deprecated in Twisted 17.9.0:"
  33. " There is no replacement for this module."),
  34. warningsShown[0]['message'])