From 714cf468e10ccbfca6a97095939563a52b99e2eb Mon Sep 17 00:00:00 2001 From: belegnar Date: Wed, 3 Apr 2019 08:59:08 +0200 Subject: [PATCH] Refs #30302 -- Added more tests for forms.model_to_dict(). --- tests/model_forms/tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index f4f3169bc1..495fba1fb2 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1814,6 +1814,9 @@ class ModelOneToOneFieldTests(TestCase): bw = BetterWriter.objects.create(name='Joe Better', score=10) self.assertEqual(sorted(model_to_dict(bw)), ['id', 'name', 'score', 'writer_ptr']) + self.assertEqual(sorted(model_to_dict(bw, fields=['id', 'name'])), ['id', 'name']) + self.assertEqual(sorted(model_to_dict(bw, exclude=[])), ['id', 'name', 'score', 'writer_ptr']) + self.assertEqual(sorted(model_to_dict(bw, exclude=['id', 'name'])), ['score', 'writer_ptr']) form = BetterWriterForm({'name': 'Some Name', 'score': 12}) self.assertTrue(form.is_valid())