aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_description.py
diff options
context:
space:
mode:
authorEleni Lixourioti2014-11-15 14:27:41 +0000
committerEleni Lixourioti2014-11-15 14:27:41 +0000
commit1aa77830955dcdf829f65a9001b6b8900dfc8755 (patch)
tree1f6d0bea3c0fe720a298b2da177bb91e8a74a19c /tests/test_description.py
parentafaa52a378705b7f0475d5ece04a2cf49af4b7c2 (diff)
parent88008c0a687219e3104d548196915b1068536d74 (diff)
downloaddjango-rest-framework-1aa77830955dcdf829f65a9001b6b8900dfc8755.tar.bz2
Merge branch 'version-3.1' of github.com:tomchristie/django-rest-framework into oauth_as_package
Conflicts: .travis.yml
Diffstat (limited to 'tests/test_description.py')
-rw-r--r--tests/test_description.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_description.py b/tests/test_description.py
index 1e481f06..0675d209 100644
--- a/tests/test_description.py
+++ b/tests/test_description.py
@@ -98,6 +98,30 @@ class TestViewNamesAndDescriptions(TestCase):
pass
self.assertEqual(MockView().get_view_description(), '')
+ def test_view_description_can_be_promise(self):
+ """
+ Ensure a view may have a docstring that is actually a lazily evaluated
+ class that can be converted to a string.
+
+ See: https://github.com/tomchristie/django-rest-framework/issues/1708
+ """
+ # use a mock object instead of gettext_lazy to ensure that we can't end
+ # up with a test case string in our l10n catalog
+ class MockLazyStr(object):
+ def __init__(self, string):
+ self.s = string
+
+ def __str__(self):
+ return self.s
+
+ def __unicode__(self):
+ return self.s
+
+ class MockView(APIView):
+ __doc__ = MockLazyStr("a gettext string")
+
+ self.assertEqual(MockView().get_view_description(), 'a gettext string')
+
def test_markdown(self):
"""
Ensure markdown to HTML works as expected.