diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2014-09-08 03:01:42 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-09-08 15:41:14 -0400 |
| commit | b0def3bcac1a2e1117050e00fa1b187a897f0c2e (patch) | |
| tree | 1fb5180b17a02aa636aa80f69d7f87a8f4809452 /tests | |
| parent | 9c4fb019cb76eb3314357a18e225a63e113dc1fd (diff) | |
[1.7.x] Fixed #23418 -- Fail when migration deconstruct produces invalid import
Backport of d28b5f13b3 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_writer.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index 3839f78cbd..f6c866d725 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -167,9 +167,17 @@ class WriterTests(TestCase): self.assertEqual(string, "django.core.validators.EmailValidator(message='hello')") self.serialize_round_trip(validator) - validator = deconstructible(path="custom.EmailValidator")(EmailValidator)(message="hello") + validator = deconstructible(path="migrations.test_writer.EmailValidator")(EmailValidator)(message="hello") string = MigrationWriter.serialize(validator)[0] - self.assertEqual(string, "custom.EmailValidator(message='hello')") + self.assertEqual(string, "migrations.test_writer.EmailValidator(message='hello')") + + validator = deconstructible(path="custom.EmailValidator")(EmailValidator)(message="hello") + with self.assertRaisesMessage(ImportError, "No module named 'custom'"): + MigrationWriter.serialize(validator) + + validator = deconstructible(path="django.core.validators.EmailValidator2")(EmailValidator)(message="hello") + with self.assertRaisesMessage(ValueError, "Could not find object EmailValidator2 in django.core.validators."): + MigrationWriter.serialize(validator) def test_serialize_empty_nonempty_tuple(self): """ |
