Fixed fixtures testing failure

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.
This commit is contained in:
Anssi Kääriäinen 2013-05-19 20:51:59 +03:00
parent e83ff42792
commit 190771d003
2 changed files with 5 additions and 1 deletions

View File

@ -142,6 +142,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
# Loading a fixture that doesn't exist emits a warning
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
management.call_command('loaddata', 'unknown.json', verbosity=0,
commit=False)
self.assertEqual(len(w), 1)

View File

@ -102,8 +102,11 @@ class FixtureTestCase(TestCase):
)
# 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)
self.assertEqual(len(w), 1)
self.assertTrue(w[0].message, "No fixture named 'unknown' found.")
self.assertQuerysetEqual(
Article.objects.all(), [