<s> from __future__ import unicode_literals <EOL> from distutils . version import StrictVersion <EOL> try : <EOL> from importlib import reload <EOL> except ImportError : <EOL> try : <EOL> from imp import reload <EOL> except : <EOL> pass <EOL> from django import get_version <EOL> from django . conf import settings <EOL> from django . test import TestCase <EOL> from registration import forms <EOL> from registration . users import UsernameField <EOL> DJANGO_VERSION = StrictVersion ( get_version ( ) ) <EOL> class RegistrationFormTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . old_auth_model = getattr ( settings , '<STR_LIT>' , None ) <EOL> settings . AUTH_USER_MODEL = '<STR_LIT>' <EOL> reload ( forms ) <EOL> def tearDown ( self ) : <EOL> settings . AUTH_USER_MODEL = self . old_auth_model <EOL> def test_registration_form_adds_custom_user_name_field ( self ) : <EOL> """<STR_LIT>""" <EOL> form = forms . RegistrationForm ( ) <EOL> self . assertTrue ( UsernameField ( ) in form . fields ) <EOL> def test_registration_form_subclass_is_valid_for_django_18 ( self ) : <EOL> """<STR_LIT>""" <EOL> if DJANGO_VERSION >= StrictVersion ( '<STR_LIT>' ) : <EOL> data = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' } <EOL> form = forms . RegistrationForm ( data = data ) <EOL> self . assertTrue ( form . is_valid ( ) ) </s>
