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:22:29 -0500 |
| commit | dee4d23f7e703aec2d1244e4facbf7f4c88deed5 (patch) | |
| tree | c448025ad1c702bdbab7c65a0bd7a434165c3a81 /tests | |
| parent | 9d1a69579b996eaa208f141b409141be63f597ec (diff) | |
Fixed #23950 -- Prevented calling deconstruct on classes in MigrationWriter.
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 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)") |
