diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 437ddb35ed..2e0d1ae607 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -917,11 +917,11 @@ class LoginFailures(models.Model): def __str__(self): """Str -> Username: count - date.""" - return six.text_type('{username}: {count} - {date}'.format( + return u'{username}: {count} - {date}'.format( username=self.user.username, count=self.failure_count, date=self.lockout_until.isoformat() if self.lockout_until else '-' - )) + ) class Meta: verbose_name = 'Login Failure' diff --git a/common/djangoapps/student/tests/test_admin_views.py b/common/djangoapps/student/tests/test_admin_views.py index 59429b254c..636dccd164 100644 --- a/common/djangoapps/student/tests/test_admin_views.py +++ b/common/djangoapps/student/tests/test_admin_views.py @@ -1,3 +1,4 @@ +# coding=UTF-8 """ Tests student admin.py """ @@ -324,7 +325,7 @@ class LoginFailuresAdminTest(TestCase): """Setup.""" super(LoginFailuresAdminTest, self).setUp() self.client.login(username=self.user.username, password='test') - self.user2 = UserFactory.create() + self.user2 = UserFactory.create(username=u'Zażółć gęślą jaźń') LoginFailures.objects.create(user=self.user, failure_count=10, lockout_until=datetime.datetime.now()) LoginFailures.objects.create(user=self.user2, failure_count=2) @@ -338,11 +339,8 @@ class LoginFailuresAdminTest(TestCase): Test if `__str__` method behaves correctly for unicode username. It shouldn't raise `TypeError`. """ - try: - str(LoginFailures.objects.get(user=self.user)) - str(LoginFailures.objects.get(user=self.user2)) - except TypeError as e: - self.fail("Failed executing `__str__` with unicode: {0}".format(e)) + str(LoginFailures.objects.get(user=self.user)) + str(LoginFailures.objects.get(user=self.user2)) @ddt.data( reverse('admin:student_loginfailures_changelist'),