Skip to content

Commit 924ae1a

Browse files
committed
[1.2.X] Pass commit=False to loaddata in tests, which will keep the DB connection open. Closing the connection has the side-effect on some DBs (Postgres, MySQL/InnoDB) of rolling back the transaction that was in progress, causing these tests to fail.
r13717 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13718 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent ec8d04c commit 924ae1a

File tree

1 file changed

+3
-3
lines changed
  • tests/modeltests/fixtures_model_package

1 file changed

+3
-3
lines changed

tests/modeltests/fixtures_model_package/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_initial_data(self):
3535
def test_loaddata(self):
3636
"Fixtures can load data into models defined in packages"
3737
# Load fixture 1. Single JSON file, with two objects
38-
management.call_command("loaddata", "fixture1.json", verbosity=0)
38+
management.call_command("loaddata", "fixture1.json", verbosity=0, commit=False)
3939
self.assertQuerysetEqual(
4040
Article.objects.all(), [
4141
"Time to reform copyright",
@@ -47,7 +47,7 @@ def test_loaddata(self):
4747

4848
# Load fixture 2. JSON file imported by default. Overwrites some
4949
# existing objects
50-
management.call_command("loaddata", "fixture2.json", verbosity=0)
50+
management.call_command("loaddata", "fixture2.json", verbosity=0, commit=False)
5151
self.assertQuerysetEqual(
5252
Article.objects.all(), [
5353
"Django conquers world!",
@@ -59,7 +59,7 @@ def test_loaddata(self):
5959
)
6060

6161
# Load a fixture that doesn't exist
62-
management.call_command("loaddata", "unknown.json", verbosity=0)
62+
management.call_command("loaddata", "unknown.json", verbosity=0, commit=False)
6363
self.assertQuerysetEqual(
6464
Article.objects.all(), [
6565
"Django conquers world!",

0 commit comments

Comments
 (0)