From 7f7553dd30534d606c84952a3f6dcb64b396ce37 Mon Sep 17 00:00:00 2001 From: Niels Van Och Date: Sat, 7 Nov 2015 12:07:28 +0100 Subject: Fixed #25680 -- Added django-admin shell --command option. Add a -c option to the shell command to execute a command passed as a string as Django. --- tests/shell/__init__.py | 0 tests/shell/tests.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/shell/__init__.py create mode 100644 tests/shell/tests.py (limited to 'tests/shell') diff --git a/tests/shell/__init__.py b/tests/shell/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/shell/tests.py b/tests/shell/tests.py new file mode 100644 index 0000000000..7285c968a2 --- /dev/null +++ b/tests/shell/tests.py @@ -0,0 +1,19 @@ +from django import __version__ +from django.core.management import call_command +from django.test import SimpleTestCase +from django.test.utils import patch_logger + + +class ShellCommandTestCase(SimpleTestCase): + + def test_command_option(self): + with patch_logger('test', 'info') as logger: + call_command( + 'shell', + command=( + 'import django; from logging import getLogger; ' + 'getLogger("test").info(django.__version__)' + ), + ) + self.assertEqual(len(logger), 1) + self.assertEqual(logger[0], __version__) -- cgit v1.3