From 190771d003de51af28d29bdd0e0f2bc25f9d85a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sun, 19 May 2013 20:51:59 +0300 Subject: [PATCH] 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. --- tests/fixtures/tests.py | 1 + tests/fixtures_model_package/tests.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index e32522b929..4bf60e988a 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -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) diff --git a/tests/fixtures_model_package/tests.py b/tests/fixtures_model_package/tests.py index fbd0271336..e0a35e300d 100644 --- a/tests/fixtures_model_package/tests.py +++ b/tests/fixtures_model_package/tests.py @@ -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(), [