mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #31233 -- Closed database connections and cursors after use.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f48f671223
commit
3259983f56
3
tests/fixtures/tests.py
vendored
3
tests/fixtures/tests.py
vendored
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user