test_deprecation.py 835 B

12345678910111213141516171819202122
  1. import warnings
  2. from django.dispatch import Signal
  3. from django.test import SimpleTestCase
  4. from django.utils.deprecation import RemovedInDjango40Warning
  5. class SignalDeprecationTests(SimpleTestCase):
  6. def test_providing_args_warning(self):
  7. msg = (
  8. 'The providing_args argument is deprecated. As it is purely '
  9. 'documentational, it has no replacement. If you rely on this '
  10. 'argument as documentation, you can move the text to a code '
  11. 'comment or docstring.'
  12. )
  13. with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
  14. Signal(providing_args=['arg1', 'arg2'])
  15. def test_without_providing_args_does_not_warn(self):
  16. with warnings.catch_warnings(record=True) as recorded:
  17. Signal()
  18. self.assertEqual(len(recorded), 0)