From 204d0c4d7649a47ea8968f74815460a5c90860ae Mon Sep 17 00:00:00 2001 From: Marco Bonetti Date: Fri, 15 Nov 2024 09:05:49 +0100 Subject: [PATCH] chore: remove dead code --- captcha/fields.py | 10 ---------- captcha/tests/tests.py | 5 +---- captcha/tests/urls.py | 2 -- captcha/tests/views.py | 14 -------------- 4 files changed, 1 insertion(+), 30 deletions(-) diff --git a/captcha/fields.py b/captcha/fields.py index 443da65..2f8d637 100644 --- a/captcha/fields.py +++ b/captcha/fields.py @@ -124,16 +124,6 @@ def get_context(self, name, value, attrs): context["audio"] = self.audio_url() return context - def format_output(self, rendered_widgets): - # hidden_field, text_field = rendered_widgets - if self.output_format: - ret = self.output_format % { - "image": self.image_and_audio, - "hidden_field": self.hidden_field, - "text_field": self.text_field, - } - return ret - def render(self, name, value, attrs=None, renderer=None): self.fetch_captcha_store(name, value, attrs, self.generator) diff --git a/captcha/tests/tests.py b/captcha/tests/tests.py index 8ed3b20..4e395d0 100644 --- a/captcha/tests/tests.py +++ b/captcha/tests/tests.py @@ -58,10 +58,7 @@ def tearDown(self): settings.CAPTCHA_PUNCTUATION = self.__current_settings_punctuation def _assertFormError(self, response, form_name, *args, **kwargs): - if django.VERSION >= (4, 1): - self.assertFormError(response.context.get(form_name), *args, **kwargs) - else: - self.assertFormError(response, form_name, *args, **kwargs) + self.assertFormError(response.context.get(form_name), *args, **kwargs) def __extract_hash_and_response(self, r): hash_ = re.findall(r'value="([0-9a-f]+)"', str(r.content))[0] diff --git a/captcha/tests/urls.py b/captcha/tests/urls.py index 86d25f2..f742dd7 100644 --- a/captcha/tests/urls.py +++ b/captcha/tests/urls.py @@ -8,7 +8,6 @@ test_model_form, test_model_serializer, test_non_required, - test_per_form_format, test_serializer, ) @@ -25,7 +24,6 @@ re_path( r"test2/$", test_custom_error_message, name="captcha-test-custom-error-message" ), - re_path(r"test3/$", test_per_form_format, name="test_per_form_format"), re_path(r"custom-generator/$", test_custom_generator, name="test_custom_generator"), re_path( r"test-non-required/$", test_non_required, name="captcha-test-non-required" diff --git a/captcha/tests/views.py b/captcha/tests/views.py index e037fea..25e85ed 100644 --- a/captcha/tests/views.py +++ b/captcha/tests/views.py @@ -99,20 +99,6 @@ class CaptchaTestErrorMessageForm(forms.Form): return _test(request, CaptchaTestErrorMessageForm) -def test_per_form_format(request): - class CaptchaTestFormatForm(forms.Form): - captcha = CaptchaField( - help_text="asdasd", - error_messages=dict(invalid="TEST CUSTOM ERROR MESSAGE"), - output_format=( - "%(image)s testPerFieldCustomFormatString " - "%(hidden_field)s %(text_field)s" - ), - ) - - return _test(request, CaptchaTestFormatForm) - - def test_non_required(request): class CaptchaTestForm(forms.Form): sender = forms.EmailField()