django-rest-framework/tests/test_exceptions.py
2016-02-07 19:26:37 +03:00

22 lines
731 B
Python

from __future__ import unicode_literals
from django.test import TestCase
from django.utils.translation import ugettext_lazy as _
from rest_framework.exceptions import _force_text_recursive
class ExceptionTestCase(TestCase):
def test_force_text_recursive(self):
s = "sfdsfggiuytraetfdlklj"
self.assertEqual(_force_text_recursive(_(s)), s)
self.assertEqual(type(_force_text_recursive(_(s))), type(s))
self.assertEqual(_force_text_recursive({'a': _(s)})['a'], s)
self.assertEqual(type(_force_text_recursive({'a': _(s)})['a']), type(s))
self.assertEqual(_force_text_recursive([[_(s)]])[0][0], s)
self.assertEqual(type(_force_text_recursive([[_(s)]])[0][0]), type(s))