From dee4d23f7e703aec2d1244e4facbf7f4c88deed5 Mon Sep 17 00:00:00 2001 From: Gavin Wahl Date: Tue, 2 Dec 2014 18:52:58 -0700 Subject: Fixed #23950 -- Prevented calling deconstruct on classes in MigrationWriter. --- tests/migrations/test_writer.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index 1dcc8e641a..618f8df925 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)") -- cgit v1.3