def test_clean_username_exception(self): User.objects.create_user(username='******') form = RegistrationForm() form.cleaned_data = {'username': '******'} # Use a context manager to watch for the validation error being raised with self.assertRaises(ValidationError): form.clean_username()
def test_clean_username_exception(self): User.objects.create_user(username='******') form = RegistrationForm() form.cleaned_data = {'username': '******'} # Use a context manager to watch for the validation error being raised with self.assertRaises(ValidationError): form.clean_username()
def test_clean_username(self): form = RegistrationForm() form.cleaned_data = {'username': '******'} self.assertEqual(form.cleaned_data['username'], 'test-user')