Skip to content

Commit

Permalink
Fixed fixtures testing failure
Browse files Browse the repository at this point in the history
The failure was caused by generating the same warning from two tests.
The second time the same warning was raised it was swallowed by the
"once" simplefilter of warnings.
  • Loading branch information
akaariai committed May 19, 2013
1 parent e83ff42 commit 190771d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/fixtures/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def test_loading_and_dumping(self):


# Loading a fixture that doesn't exist emits a warning # Loading a fixture that doesn't exist emits a warning
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
management.call_command('loaddata', 'unknown.json', verbosity=0, management.call_command('loaddata', 'unknown.json', verbosity=0,
commit=False) commit=False)
self.assertEqual(len(w), 1) self.assertEqual(len(w), 1)
Expand Down
5 changes: 4 additions & 1 deletion tests/fixtures_model_package/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ def test_loaddata(self):
) )


# Load a fixture that doesn't exist # Load a fixture that doesn't exist
with warnings.catch_warnings(record=True): with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
management.call_command("loaddata", "unknown.json", verbosity=0, commit=False) management.call_command("loaddata", "unknown.json", verbosity=0, commit=False)
self.assertEqual(len(w), 1)
self.assertTrue(w[0].message, "No fixture named 'unknown' found.")


self.assertQuerysetEqual( self.assertQuerysetEqual(
Article.objects.all(), [ Article.objects.all(), [
Expand Down

0 comments on commit 190771d

Please sign in to comment.