tests.py 638 B

12345678910111213141516171819
  1. from django import __version__
  2. from django.core.management import call_command
  3. from django.test import SimpleTestCase
  4. from django.test.utils import patch_logger
  5. class ShellCommandTestCase(SimpleTestCase):
  6. def test_command_option(self):
  7. with patch_logger('test', 'info') as logger:
  8. call_command(
  9. 'shell',
  10. command=(
  11. 'import django; from logging import getLogger; '
  12. 'getLogger("test").info(django.__version__)'
  13. ),
  14. )
  15. self.assertEqual(len(logger), 1)
  16. self.assertEqual(logger[0], __version__)