diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2014-09-08 03:01:42 +0200 |
|---|---|---|
| committer | Markus Holtermann <info@markusholtermann.eu> | 2014-09-08 21:27:34 +0200 |
| commit | d28b5f13b332bda4317949b98e33f528d30ec006 (patch) | |
| tree | 587b3353049ad8971a148a7af5af9750850c8005 /tests | |
| parent | f9419a6dc0bd0c1ec3c6b4176a1fa8cadc755cf4 (diff) | |
Fixed #23418 -- Fail when migration deconstruct produces invalid import
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): """ |
