summaryrefslogtreecommitdiff
path: root/tests/admin_scripts/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_scripts/tests.py')
-rw-r--r--tests/admin_scripts/tests.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 518c83b4be..086e5365a1 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -25,7 +25,7 @@ from django.core.management import BaseCommand, CommandError, call_command, colo
from django.utils.encoding import force_text
from django.utils._os import npath, upath
from django.utils.six import StringIO
-from django.test import LiveServerTestCase, TestCase, override_settings
+from django.test import LiveServerTestCase, TestCase, mock, override_settings
from django.test.runner import DiscoverRunner
@@ -1581,6 +1581,18 @@ class CommandTypes(AdminScriptTestCase):
with self.assertRaises(SystemExit):
command.run_from_argv(['', ''])
+ def test_run_from_argv_closes_connections(self):
+ """
+ A command called from the command line should close connections after
+ being executed (#21255).
+ """
+ command = BaseCommand(stderr=StringIO())
+ command.handle = lambda *args, **kwargs: args
+ with mock.patch('django.core.management.base.connections') as mock_connections:
+ command.run_from_argv(['', ''])
+ # Test connections have been closed
+ self.assertTrue(mock_connections.close_all.called)
+
def test_noargs(self):
"NoArg Commands can be executed"
args = ['noargs_command']