Skip to content

Commit

Permalink
Pass commit=False to loaddata in tests, which will keep the DB connec…
Browse files Browse the repository at this point in the history
…tion 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.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
kmtracey committed Sep 10, 2010
1 parent 76249c3 commit 6ad4b32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/modeltests/fixtures_model_package/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_initial_data(self):
def test_loaddata(self):
"Fixtures can load data into models defined in packages"
# Load fixture 1. Single JSON file, with two objects
management.call_command("loaddata", "fixture1.json", verbosity=0)
management.call_command("loaddata", "fixture1.json", verbosity=0, commit=False)
self.assertQuerysetEqual(
Article.objects.all(), [
"Time to reform copyright",
Expand All @@ -47,7 +47,7 @@ def test_loaddata(self):

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

# Load a fixture that doesn't exist
management.call_command("loaddata", "unknown.json", verbosity=0)
management.call_command("loaddata", "unknown.json", verbosity=0, commit=False)
self.assertQuerysetEqual(
Article.objects.all(), [
"Django conquers world!",
Expand Down

0 comments on commit 6ad4b32

Please sign in to comment.