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/backends/sqlite | |
| parent | f48f671223a20b161ca819cf7d6298e43b8ba5fe (diff) | |
| download | django-3259983f569151232d8e3b0c3d0de3a858c2b265.tar.gz | |
Fixed #31233 -- Closed database connections and cursors after use.
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index fc02671ca5..c26377c8af 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -197,7 +197,8 @@ class LastExecutedQueryTest(TestCase): def test_no_interpolation(self): # This shouldn't raise an exception (#17158) query = "SELECT strftime('%Y', 'now');" - connection.cursor().execute(query) + with connection.cursor() as cursor: + cursor.execute(query) self.assertEqual(connection.queries[-1]['sql'], query) def test_parameter_quoting(self): @@ -205,7 +206,8 @@ class LastExecutedQueryTest(TestCase): # worth testing that parameters are quoted (#14091). query = "SELECT %s" params = ["\"'\\"] - connection.cursor().execute(query, params) + with connection.cursor() as cursor: + cursor.execute(query, params) # Note that the single quote is repeated substituted = "SELECT '\"''\\'" self.assertEqual(connection.queries[-1]['sql'], substituted) |
