diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-02-03 19:07:00 -0800 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-06 15:35:23 +0100 |
commit | 3259983f569151232d8e3b0c3d0de3a858c2b265 (patch) | |
tree | 4f1f19368fbb9d73ea5245d8fabe5e3097f51926 /tests/fixtures | |
parent | f48f671223a20b161ca819cf7d6298e43b8ba5fe (diff) | |
download | django-3259983f569151232d8e3b0c3d0de3a858c2b265.tar.gz |
Fixed #31233 -- Closed database connections and cursors after use.
Diffstat (limited to 'tests/fixtures')
-rw-r--r-- | tests/fixtures/tests.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index 02dd38e635..16e90dea38 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -564,7 +564,8 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): # This won't affect other tests because the database connection # is closed at the end of each test. if connection.vendor == 'mysql': - connection.cursor().execute("SET sql_mode = 'TRADITIONAL'") + with connection.cursor() as cursor: + cursor.execute("SET sql_mode = 'TRADITIONAL'") with self.assertRaises(IntegrityError) as cm: management.call_command('loaddata', 'invalid.json', verbosity=0) self.assertIn("Could not load fixtures.Article(pk=1):", cm.exception.args[0]) |