Skip to content

How to write unit test for ReCaptchaField? #281

Answered by imanhpr
imanhpr asked this question in Q&A
Discussion options

You must be logged in to vote

So my question is how can I write a test for Recaptcha or bypass it?

I found a way to bypass it but I don't know if it's good or bad.

# raw_normal_user is a pytest fixture
def test_valid_login(self, raw_normal_user):
        form = UserLoginForm(raw_normal_user)
        print(form.errors.pop('captcha')) # This line deletes the captcha error
        assert form.is_valid()
        assert form.cleaned_data == {
            "email": "[email protected]",
            "password": "test123password",
        }

If you found a better solution please suggest me.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by imanhpr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant