Commits

Anonymous committed 3ad2fd7

[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.

Comments (0)

Files changed (1)

tests/modeltests/fixtures_model_package/tests.py

     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",
 
         # 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!",
         )
 
         # 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!",