diff options
| author | Gavin Wahl <gwahl@fusionbox.com> | 2014-12-02 18:52:58 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-03 08:32:59 -0500 |
| commit | e9975ed3cd3243d78b89fe2b44a152263ba5a602 (patch) | |
| tree | 555b380100602566c0e343ce6fc7717f13575583 /tests | |
| parent | de92c61e4043dc0d9cd9f7ea3725798e2017a8a5 (diff) | |
[1.7.x] Fixed #23950 -- Prevented calling deconstruct on classes in MigrationWriter.
Backport of dee4d23f7e703aec2d1244e4facbf7f4c88deed5 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_writer.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index cb9ed5d0d5..dc551acc6b 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -340,3 +340,14 @@ class WriterTests(TestCase): fixed_offset_datetime = datetime.datetime(2014, 1, 1, 1, 1, tzinfo=FixedOffset(180)) self.assertEqual(MigrationWriter.serialize_datetime(fixed_offset_datetime), "datetime.datetime(2013, 12, 31, 22, 1, tzinfo=utc)") + + def test_deconstruct_class_arguments(self): + # Yes, it doesn't make sense to use a class as a default for a + # CharField. It does make sense for custom fields though, for example + # an enumfield that takes the enum class as an argument. + class DeconstructableInstances(object): + def deconstruct(self): + return ('DeconstructableInstances', [], {}) + + string = MigrationWriter.serialize(models.CharField(default=DeconstructableInstances))[0] + self.assertEqual(string, "models.CharField(default=migrations.test_writer.DeconstructableInstances)") |
