Updated the test_clean_username test to also test for the custom validation message raised in case username already exists in the db
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.")
