'Test that ``RegistrationFormUniqueEmail`` validates uniqueness
of email addresses.'

def test_registration_form_unique_email(self):

    UserModel().objects.create_user(u'alice', u'alice@example.com', u'secret')
    form = forms.RegistrationFormUniqueEmail(data={u'username': u'foo', u'email': u'alice@example.com', u'password1': u'foo', u'password2': u'foo'})
    self.failIf(form.is_valid())
    self.assertEqual(form.errors[u'email'], [u'This    email    address    is    already    in    use.    Please    supply    a    different    email    address.'])
    form = forms.RegistrationFormUniqueEmail(data={u'username': u'foo', u'email': u'foo@example.com', u'password1': u'foo', u'password2': u'foo'})
    self.failUnless(form.is_valid())
