|
@@ -181,55 +181,68 @@ class TestFixtures(TestCase):
|
|
|
"""
|
|
|
Test for ticket
|
|
|
using explicit filename.
|
|
|
- Validate that error conditions are caught correctly
|
|
|
+ Test for ticket
|
|
|
"""
|
|
|
- with six.assertRaisesRegex(self, management.CommandError,
|
|
|
- "No fixture data found for 'bad_fixture2'. \(File format may be invalid.\)"):
|
|
|
+ with warnings.catch_warnings(record=True) as warning_list:
|
|
|
+ warnings.simplefilter("always")
|
|
|
management.call_command(
|
|
|
'loaddata',
|
|
|
'bad_fixture2.xml',
|
|
|
verbosity=0,
|
|
|
)
|
|
|
+ warning = warning_list.pop()
|
|
|
+ self.assertEqual(warning.category, RuntimeWarning)
|
|
|
+ self.assertEqual(str(warning.message), "No fixture data found for 'bad_fixture2'. (File format may be invalid.)")
|
|
|
|
|
|
def test_invalid_data_no_ext(self):
|
|
|
"""
|
|
|
Test for ticket
|
|
|
without file extension.
|
|
|
- Validate that error conditions are caught correctly
|
|
|
+ Test for ticket
|
|
|
"""
|
|
|
- with six.assertRaisesRegex(self, management.CommandError,
|
|
|
- "No fixture data found for 'bad_fixture2'. \(File format may be invalid.\)"):
|
|
|
+ with warnings.catch_warnings(record=True) as warning_list:
|
|
|
+ warnings.simplefilter("always")
|
|
|
management.call_command(
|
|
|
'loaddata',
|
|
|
'bad_fixture2',
|
|
|
verbosity=0,
|
|
|
)
|
|
|
+ warning = warning_list.pop()
|
|
|
+ self.assertEqual(warning.category, RuntimeWarning)
|
|
|
+ self.assertEqual(str(warning.message), "No fixture data found for 'bad_fixture2'. (File format may be invalid.)")
|
|
|
|
|
|
def test_empty(self):
|
|
|
"""
|
|
|
- Test for ticket
|
|
|
- Validate that error conditions are caught correctly
|
|
|
+ Test for ticket
|
|
|
+ Previously empty fixture raises an error exception, see ticket
|
|
|
"""
|
|
|
- with six.assertRaisesRegex(self, management.CommandError,
|
|
|
- "No fixture data found for 'empty'. \(File format may be invalid.\)"):
|
|
|
+ with warnings.catch_warnings(record=True) as warning_list:
|
|
|
+ warnings.simplefilter("always")
|
|
|
management.call_command(
|
|
|
'loaddata',
|
|
|
'empty',
|
|
|
verbosity=0,
|
|
|
)
|
|
|
+ warning = warning_list.pop()
|
|
|
+ self.assertEqual(warning.category, RuntimeWarning)
|
|
|
+ self.assertEqual(str(warning.message), "No fixture data found for 'empty'. (File format may be invalid.)")
|
|
|
|
|
|
def test_error_message(self):
|
|
|
"""
|
|
|
- (Regression for
|
|
|
+ Regression for
|
|
|
+ Change from error to warning for ticket
|
|
|
"""
|
|
|
- with six.assertRaisesRegex(self, management.CommandError,
|
|
|
- "^No fixture data found for 'bad_fixture2'. \(File format may be invalid.\)$"):
|
|
|
+ with warnings.catch_warnings(record=True) as warning_list:
|
|
|
+ warnings.simplefilter("always")
|
|
|
management.call_command(
|
|
|
'loaddata',
|
|
|
'bad_fixture2',
|
|
|
'animal',
|
|
|
verbosity=0,
|
|
|
)
|
|
|
+ warning = warning_list.pop()
|
|
|
+ self.assertEqual(warning.category, RuntimeWarning)
|
|
|
+ self.assertEqual(str(warning.message), "No fixture data found for 'bad_fixture2'. (File format may be invalid.)")
|
|
|
|
|
|
def test_pg_sequence_resetting_checks(self):
|
|
|
"""
|