From 5b23d6666e7166a797f423c7b2c74aa85feb3d63 Mon Sep 17 00:00:00 2001 From: Marcelo Galigniana Date: Mon, 13 Feb 2023 21:19:21 -0300 Subject: [PATCH] Completed test coverage for django.forms.utils. --- tests/forms_tests/tests/test_utils.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py index a921a924b6..2e5672f93c 100644 --- a/tests/forms_tests/tests/test_utils.py +++ b/tests/forms_tests/tests/test_utils.py @@ -2,7 +2,13 @@ import copy import json from django.core.exceptions import ValidationError -from django.forms.utils import ErrorDict, ErrorList, flatatt +from django.forms.utils import ( + ErrorDict, + ErrorList, + RenderableMixin, + flatatt, + pretty_name, +) from django.test import SimpleTestCase from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy @@ -245,3 +251,14 @@ class FormsUtilsTestCase(SimpleTestCase): ], }, ) + + def test_get_context_must_be_implemented(self): + mixin = RenderableMixin() + msg = "Subclasses of RenderableMixin must provide a get_context() method." + with self.assertRaisesMessage(NotImplementedError, msg): + mixin.get_context() + + def test_pretty_name(self): + self.assertEqual(pretty_name("john_doe"), "John doe") + self.assertEqual(pretty_name(None), "") + self.assertEqual(pretty_name(""), "")