diff options
| author | Theron Luhn <theron@luhn.com> | 2021-02-17 14:08:42 -0800 |
|---|---|---|
| committer | Theron Luhn <theron@luhn.com> | 2021-02-17 14:08:42 -0800 |
| commit | f510281a09ce500dcb51bf5fd3cbca4d97a56cb2 (patch) | |
| tree | 581b663e1838321558cf80b6d1a67a413e4ba4d8 /tests | |
| parent | 7a055e7862e98a56ae6eb1801dec5ebe2e76f320 (diff) | |
| download | pyramid-f510281a09ce500dcb51bf5fd3cbca4d97a56cb2.tar.gz pyramid-f510281a09ce500dcb51bf5fd3cbca4d97a56cb2.tar.bz2 pyramid-f510281a09ce500dcb51bf5fd3cbca4d97a56cb2.zip | |
Write tests.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_config/test_views.py | 15 | ||||
| -rw-r--r-- | tests/test_decorator.py | 23 |
2 files changed, 23 insertions, 15 deletions
diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py index 65271f0d6..fcccbfba3 100644 --- a/tests/test_config/test_views.py +++ b/tests/test_config/test_views.py @@ -4289,21 +4289,6 @@ class Test_view_description(unittest.TestCase): self.assertEqual(result, 'function tests.test_config.test_views.view') -class Test_viewdefaults(unittest.TestCase): - def _makeOne(self, wrapped): - from pyramid.decorator import reify - - return reify(wrapped) - - def test_dunder_attrs_copied(self): - from pyramid.config.views import viewdefaults - - decorator = self._makeOne(viewdefaults) - self.assertEqual(decorator.__doc__, viewdefaults.__doc__) - self.assertEqual(decorator.__name__, viewdefaults.__name__) - self.assertEqual(decorator.__module__, viewdefaults.__module__) - - class DummyRegistry: utility = None diff --git a/tests/test_decorator.py b/tests/test_decorator.py index b9a1f1e9d..a9a16ba93 100644 --- a/tests/test_decorator.py +++ b/tests/test_decorator.py @@ -1,3 +1,4 @@ +import inspect import unittest @@ -25,6 +26,28 @@ class TestReify(unittest.TestCase): result = decorator.__get__(None) self.assertEqual(result, decorator) + def test_copy_docstring(self): + def wrapped(inst): + """Test doc""" + return 'a' # pragma: no cover + + decorator = self._makeOne(wrapped) + assert decorator.__doc__ == 'Test doc' + + def test_not_function(self): + """ + Because reify'd methods act as attributes, it's important that they + aren't recognized as a function. Otherwise tools like Sphinx may + misbehave, like in https://github.com/Pylons/pyramid/issues/3655 + + """ + + def wrapped(inst): + return 'a' # pragma: no cover + + decorator = self._makeOne(wrapped) + assert not inspect.isfunction(inspect.unwrap(decorator)) + class Dummy: pass |
