diff options
| author | Tom Christie | 2014-09-06 07:05:27 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-09-06 07:05:27 +0100 | 
| commit | c419fb0f9e395e805a04b9a8c28709a0b6deba31 (patch) | |
| tree | c64605e2ea2d9138f27a604d0cacb657a527bb37 /tests/test_description.py | |
| parent | f4e02446f99cef42f18f57a2712c435a84451868 (diff) | |
| parent | 97ebd68f681961fb7e3f785e3cb84a69b3dc56aa (diff) | |
| download | django-rest-framework-c419fb0f9e395e805a04b9a8c28709a0b6deba31.tar.bz2 | |
Merge pull request #1841 from jpadilla/view-description-as-promise
Supported translated text view descriptions
Diffstat (limited to 'tests/test_description.py')
| -rw-r--r-- | tests/test_description.py | 24 | 
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.  | 
