def test_clean_username(self):
    proto_user = UserFactory.build()
    form = UserCreationForm({'username': proto_user.username, 'password1': proto_user._password, 'password2': proto_user._password})
    assert form.is_valid()
    assert (form.clean_username() == proto_user.username)
    form.save()
    form = UserCreationForm({'username': proto_user.username, 'password1': proto_user._password, 'password2': proto_user._password})
    assert (not form.is_valid())
    assert (len(form.errors) == 1)
    assert ('username' in form.errors)
def test_clean_username(self):
    proto_user = UserFactory.build()
    form = UserCreationForm({'username': proto_user.username, 'password1': proto_user._password, 'password2': proto_user._password})
    assert form.is_valid()
    assert (form.clean_username() == proto_user.username)
    form.save()
    form = UserCreationForm({'username': proto_user.username, 'password1': proto_user._password, 'password2': proto_user._password})
    assert (not form.is_valid())
    assert (len(form.errors) == 1)
    assert ('username' in form.errors)