Skip to content

Commit 3515039

Browse files
Ryan P Kilbycarltongibson
authored andcommitted
Add exception translation test (#5700)
1 parent b659677 commit 3515039

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/test_exceptions.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import unicode_literals
22

33
from django.test import TestCase
4-
from django.utils import six
4+
from django.utils import six, translation
55
from django.utils.translation import ugettext_lazy as _
66

77
from rest_framework.exceptions import (
8-
ErrorDetail, Throttled, _get_error_details
8+
APIException, ErrorDetail, Throttled, _get_error_details
99
)
1010

1111

@@ -51,3 +51,12 @@ def test_get_full_details_with_throttling(self):
5151
assert exception.get_full_details() == {
5252
'message': 'Slow down! Expected available in {} seconds.'.format(2 if six.PY3 else 2.),
5353
'code': 'throttled'}
54+
55+
56+
class TranslationTests(TestCase):
57+
58+
@translation.override('fr')
59+
def test_message(self):
60+
# this test largely acts as a sanity test to ensure the translation files are present.
61+
self.assertEqual(_('A server error occurred.'), 'Une erreur du serveur est survenue.')
62+
self.assertEqual(six.text_type(APIException()), 'Une erreur du serveur est survenue.')

0 commit comments

Comments
 (0)