

def test_change_email_form(self):
    user = get_user_model().objects.get(pk=1)
    invalid_data_dicts = [{
        'data': {
            'email': 'john@example.com',
        },
        'error': ('email', ["You're already known under this email."]),
    }, {
        'data': {
            'email': 'jane@example.com',
        },
        '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.ChangeEmailForm(user, data=invalid_dict['data'])
            self.assertFalse(form.is_valid())
            self.assertEqual(form.errors[invalid_dict['error'][0]], invalid_dict['error'][1])
    form = forms.ChangeEmailForm(user, data={
        'email': 'john@newexample.com',
    })
    self.assertTrue(form.is_valid())

dataset/ETHPy150Open bread-and-pepper/django-userena/userena/tests/tests_forms.py ChangeEmailFormTests.test_change_email_form/original