Updated the test_clean_username test to also test for the custom validation message raised in case username already exists in the db

This commit is contained in:
Arnav Choudhury 2021-01-30 11:41:16 +05:30
parent 0a241a8f75
commit e8996ef281

View File

@ -1,4 +1,5 @@
import pytest
from django.utils.translation import ugettext_lazy as _
from {{ cookiecutter.project_slug }}.users.forms import UserCreationForm
from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory
@ -37,3 +38,4 @@ class TestUserCreationForm:
assert not form.is_valid()
assert len(form.errors) == 1
assert "username" in form.errors
assert form.errors["username"][0] == _("This username has already been taken.")