

def test_signup_form(self):
    '\n        Test that the ``SignupForm`` checks for unique usernames and unique\n        e-mail addresses.\n\n        '
    invalid_data_dicts = [{
        'data': {
            'username': 'foo@bar',
            'email': 'foo@example.com',
            'password': 'foo',
            'password2': 'foo',
            'tos': 'on',
        },
        'error': ('username', [_('Username must contain only letters, numbers, dots and underscores.')]),
    }, {
        'data': {
            'username': 'katy-',
            'email': 'katy@newexample.com',
            'password1': 'foo',
            'password2': 'foo2',
            'tos': 'on',
        },
        'error': ('__all__', [_("The two password fields didn't match.")]),
    }, {
        'data': {
            'username': 'john',
            'email': 'john@newexample.com',
            'password1': 'foo',
            'password2': 'foo',
            'tos': 'on',
        },
        'error': ('username', [_('This username is already taken.')]),
    }, {
        'data': {
            'username': 'SignUp',
            'email': 'foo@example.com',
            'password': 'foo',
            'password2': 'foo2',
            'tos': 'on',
        },
        'error': ('username', [_('This username is not allowed.')]),
    }, {
        'data': {
            'username': 'alice',
            'email': 'john@example.com',
            'password': 'foo',
            'password2': 'foo',
            'tos': 'on',
        },
        'error': ('email', [_('This email is already in use. Please supply a different email.')]),
    }]
    with override('en'):
        for invalid_dict in invalid_data_dicts:
            form = forms.SignupForm(data=invalid_dict['data'])
            self.assertFalse(form.is_valid())
            self.assertEqual(invalid_dict.errors[invalid_dict['error'][0]], invalid_dict['error'][1])
    form = forms.SignupForm(data={
        'username': 'foo.bla',
        'email': 'foo@example.com',
        'password1': 'foo',
        'password2': 'foo',
        'tos': 'on',
    })
    self.assertTrue(form.is_valid())

dataset/ETHPy150Open bread-and-pepper/django-userena/userena/tests/tests_forms.py SignupFormTests.test_signup_form/VarMisuse@310/625 `form`->`invalid_dict`