From a196ba96fea9ee0b8db484a9562446d8ba64d9f2 Mon Sep 17 00:00:00 2001 From: Michael Merickel <michael@merickel.org> Date: Sat, 08 Jul 2017 19:44:51 +0200 Subject: [PATCH] Merge pull request #3123 from mmerickel/backport-3122-to-1.9-branch --- pyramid/tests/test_view.py | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 41 insertions(+), 4 deletions(-) diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index 7a1c90d..0124ce6 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -91,6 +91,18 @@ self.assertEqual(settings[0]['attr'], 'view') self.assertEqual(settings[0]['_info'], 'codeinfo') + def test_call_with_venusian_args(self): + decorator = self._makeOne(_depth=1, _category='foo') + venusian = DummyVenusian() + decorator.venusian = venusian + def foo(): pass + decorator(foo) + attachments = venusian.attachments + category = attachments[0][2] + depth = attachments[0][3] + self.assertEqual(depth, 2) + self.assertEqual(category, 'foo') + class Test_forbidden_view_config(BaseTest, unittest.TestCase): def _makeOne(self, **kw): from pyramid.view import forbidden_view_config @@ -132,6 +144,18 @@ self.assertEqual(settings[0]['view'], None) # comes from call_venusian self.assertEqual(settings[0]['attr'], 'view') self.assertEqual(settings[0]['_info'], 'codeinfo') + + def test_call_with_venusian_args(self): + decorator = self._makeOne(_depth=1, _category='foo') + venusian = DummyVenusian() + decorator.venusian = venusian + def foo(): pass + decorator(foo) + attachments = venusian.attachments + category = attachments[0][2] + depth = attachments[0][3] + self.assertEqual(depth, 2) + self.assertEqual(category, 'foo') class Test_exception_view_config(BaseTest, unittest.TestCase): def _makeOne(self, *args, **kw): @@ -183,6 +207,18 @@ self.assertEqual(settings[0]['view'], None) # comes from call_venusian self.assertEqual(settings[0]['attr'], 'view') self.assertEqual(settings[0]['_info'], 'codeinfo') + + def test_call_with_venusian_args(self): + decorator = self._makeOne(_depth=1, _category='foo') + venusian = DummyVenusian() + decorator.venusian = venusian + def foo(): pass + decorator(foo) + attachments = venusian.attachments + category = attachments[0][2] + depth = attachments[0][3] + self.assertEqual(depth, 2) + self.assertEqual(category, 'foo') class RenderViewToResponseTests(BaseTest, unittest.TestCase): def _callFUT(self, *arg, **kw): @@ -564,7 +600,9 @@ decorator.venusian = venusian def foo(): pass decorator(foo) - self.assertEqual(venusian.depth, 2) + attachments = venusian.attachments + depth = attachments[0][3] + self.assertEqual(depth, 2) def test_call_withoutcategory(self): decorator = self._makeOne() @@ -1000,8 +1038,7 @@ self.attachments = [] def attach(self, wrapped, callback, category=None, depth=1): - self.attachments.append((wrapped, callback, category)) - self.depth = depth + self.attachments.append((wrapped, callback, category, depth)) return self.info class DummyRegistry(object): @@ -1028,7 +1065,7 @@ def call_venusian(venusian, context=None): if context is None: context = DummyVenusianContext() - for wrapped, callback, category in venusian.attachments: + for wrapped, callback, category, depth in venusian.attachments: callback(context, None, None) return context.config -- Gitblit v1.9.3