Skip to content

Commit

Permalink
Fixed fixtures loading isolation in tests.
Browse files Browse the repository at this point in the history
fixture1.json and fixture2.json exist in both "fixtures" and
"fixtures_model_package". Both apps are listed in "INSTALLED_APPS". The
loaddata management command loads from installed apps, thus loads both
fixtures when a test runs loaddata with any of these fixtures.
  • Loading branch information
francoisfreitag authored and felixxm committed May 15, 2020
1 parent 099bce1 commit 2e48cf6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/fixtures_model_package/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class SampleTestCase(TestCase):
fixtures = ['fixture1.json', 'fixture2.json']
fixtures = ['model_package_fixture1.json', 'model_package_fixture2.json']

def test_class_fixtures(self):
"Test cases can load fixture objects into models defined in packages"
Expand All @@ -25,7 +25,7 @@ class FixtureTestCase(TestCase):
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', 'model_package_fixture1.json', verbosity=0)
self.assertQuerysetEqual(
Article.objects.all(), [
"Time to reform copyright",
Expand All @@ -36,7 +36,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', 'model_package_fixture2.json', verbosity=0)
self.assertQuerysetEqual(
Article.objects.all(), [
"Django conquers world!",
Expand Down

0 comments on commit 2e48cf6

Please sign in to comment.