diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2017-11-28 05:12:28 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-28 11:28:09 -0500 |
| commit | 7a6fbf36b1fdb8978ea0842075ccce83bcd63789 (patch) | |
| tree | a48e72be7e31066d92de43a85458b0bfb7e2cfcd /tests/backends/sqlite | |
| parent | 3308085838f520db49f606b72345a301c1cf2a3e (diff) | |
| download | django-7a6fbf36b1fdb8978ea0842075ccce83bcd63789.tar.gz | |
Fixed #28853 -- Updated connection.cursor() uses to use a context manager.
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index 0c07f95e6f..0fbb139278 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -82,11 +82,11 @@ class LastExecutedQueryTest(TestCase): # If SQLITE_MAX_VARIABLE_NUMBER (default = 999) has been changed to be # greater than SQLITE_MAX_COLUMN (default = 2000), last_executed_query # can hit the SQLITE_MAX_COLUMN limit (#26063). - cursor = connection.cursor() - sql = "SELECT MAX(%s)" % ", ".join(["%s"] * 2001) - params = list(range(2001)) - # This should not raise an exception. - cursor.db.ops.last_executed_query(cursor.cursor, sql, params) + with connection.cursor() as cursor: + sql = "SELECT MAX(%s)" % ", ".join(["%s"] * 2001) + params = list(range(2001)) + # This should not raise an exception. + cursor.db.ops.last_executed_query(cursor.cursor, sql, params) @unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests') @@ -97,9 +97,9 @@ class EscapingChecks(TestCase): """ def test_parameter_escaping(self): # '%s' escaping support for sqlite3 (#13648). - cursor = connection.cursor() - cursor.execute("select strftime('%s', date('now'))") - response = cursor.fetchall()[0][0] + with connection.cursor() as cursor: + cursor.execute("select strftime('%s', date('now'))") + response = cursor.fetchall()[0][0] # response should be an non-zero integer self.assertTrue(int(response)) |
