summaryrefslogtreecommitdiff
path: root/tests/admin_scripts
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-12-28 18:10:12 +0100
committerClaude Paroz <claude@2xlibre.net>2014-12-29 19:02:45 +0100
commit1d24f073e65113c8c6d974db0504ef7d083809f7 (patch)
treedae0eb0284deedc859b63ffb4f64d14ae2df4da2 /tests/admin_scripts
parentbae404dea30e8bb0843db94a45d011d637ff2869 (diff)
Fixed #21255 -- Closed connections after management command ran
Thanks kabakov.as@gmail.com for the report, and Aymeric Augustin, Simon Charette for the reviews.
Diffstat (limited to 'tests/admin_scripts')
-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']