diff options
| author | José Padilla | 2014-09-05 15:34:16 -0700 |
|---|---|---|
| committer | José Padilla | 2014-09-05 15:34:16 -0700 |
| commit | d44a8f24ff56d65705580f9c2373175c93c2f4d8 (patch) | |
| tree | 0d8653e27dab1fddf2b79d6bcc1346bec37ddbc3 /tests | |
| parent | f4e02446f99cef42f18f57a2712c435a84451868 (diff) | |
| parent | 3e93c96ece8af010185e1fe1188dd2df569d4528 (diff) | |
| download | django-rest-framework-d44a8f24ff56d65705580f9c2373175c93c2f4d8.tar.bz2 | |
Merge remote-tracking branch 'poswald/view-description-as-promise' into view-description-as-promise
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_description.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_description.py b/tests/test_description.py index 1e481f06..25bee19b 100644 --- a/tests/test_description.py +++ b/tests/test_description.py @@ -98,6 +98,28 @@ 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(u"a gettext string") + + self.assertEqual(MockView().get_view_description(), u'a gettext string') + def test_markdown(self): """ Ensure markdown to HTML works as expected. |
