'Check that createsuperuser does not break when no locale is set. See
ticket #16017.'

@mock_inputs({u'password': u'nopasswd'})
def test_createsuperuser_nolocale(self):

    old_getdefaultlocale = locale.getdefaultlocale
    try:
        locale.getdefaultlocale = (lambda : (None, None))
        call_command(u'createsuperuser', interactive=True, username=u'nolocale@somewhere.org', email=u'nolocale@somewhere.org', verbosity=0)
    except TypeError:
        self.fail(u'createsuperuser    fails    if    the    OS    provides    no    information    about    the    current    locale')
    finally:
        locale.getdefaultlocale = old_getdefaultlocale
    u = User.objects.get(username=u'nolocale@somewhere.org')
    self.assertEqual(u.email, u'nolocale@somewhere.org')
