From feebc4bce7797ad44d3863d3c804485448f964c8 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Mon, 27 Nov 2023 17:19:06 +0100 Subject: [PATCH] tests(mfa): assertFormError vs __all__ --- allauth/mfa/tests/test_views.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/allauth/mfa/tests/test_views.py b/allauth/mfa/tests/test_views.py index e02858dcd9..8638b33f86 100644 --- a/allauth/mfa/tests/test_views.py +++ b/allauth/mfa/tests/test_views.py @@ -231,18 +231,12 @@ def test_cannot_deactivate_totp(auth_client, user_with_totp, user_password): assert resp.status_code == 302 resp = auth_client.get(reverse("mfa_deactivate_totp")) # When we GET, the form validation error is already on screen - assertFormError( - resp, - "form", - "__all__", - get_adapter().error_messages["cannot_delete_authenticator"], - ) + assert resp.context["form"].errors == { + "__all__": [get_adapter().error_messages["cannot_delete_authenticator"]], + } # And, when we POST anyway, it does not work resp = auth_client.post(reverse("mfa_deactivate_totp")) assert resp.status_code == 200 - assertFormError( - resp, - "form", - "__all__", - get_adapter().error_messages["cannot_delete_authenticator"], - ) + assert resp.context["form"].errors == { + "__all__": [get_adapter().error_messages["cannot_delete_authenticator"]], + }