Example #1
0
    def test_clean_username(self):
        # Create a player so that this username we're testing is already taken
        Profile.objects.create_user(username='******')

        # set up the form for testing
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': '******'}

        # use a context manager to watch for the validation error being raised
        form.clean_username()
Example #2
0
    def test_clean_username_exception(self):
        # Create a player so that this username we're testing is already taken
        Player.objects.create_user(username='******')

        # set up the form for testing
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': '******'}

        # use a context manager to watch for the validation error being raised
        with self.assertRaises(ValidationError):
            form.clean_username()