diff options
| author | Michael Merickel <michael@merickel.org> | 2024-01-27 17:33:26 -0700 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2024-01-27 17:33:26 -0700 |
| commit | 19ae96b97ea055c2e36c8fb86819c426b37ab6af (patch) | |
| tree | 437540b467bd1a2af90409145935742537b3699e /tests | |
| parent | 8a9d78106fd3b6d6dc44fabd205ee2c58fffef08 (diff) | |
| download | pyramid-19ae96b97ea055c2e36c8fb86819c426b37ab6af.tar.gz pyramid-19ae96b97ea055c2e36c8fb86819c426b37ab6af.tar.bz2 pyramid-19ae96b97ea055c2e36c8fb86819c426b37ab6af.zip | |
revert restriction to eventonly predicates, allow a predicate to receive all args
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/pkgs/eventonly/__init__.py | 19 | ||||
| -rw-r--r-- | tests/test_integration.py | 8 |
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/pkgs/eventonly/__init__.py b/tests/pkgs/eventonly/__init__.py index e45a5691f..f7a9270dc 100644 --- a/tests/pkgs/eventonly/__init__.py +++ b/tests/pkgs/eventonly/__init__.py @@ -15,6 +15,19 @@ class Yup: return getattr(event.response, 'yup', False) +class YupWithAllArgs: + def __init__(self, val, config): + self.val = val + + def text(self): + return f'yup_with_extra_args = {self.val}' + + phash = text + + def __call__(self, event, *args): + return getattr(event.response, 'yup', False) + + class Foo: def __init__(self, response): self.response = response @@ -54,6 +67,11 @@ def foobaryup2(event, context): event.response.text += 'foobaryup2 ' +@subscriber([Foo, Bar], yup=True, yup_with_all_args=True) +def foobaryup3(event, context): + event.response.text += 'foobaryup3 ' + + @view_config(name='sendfoo') def sendfoo(request): response = request.response @@ -72,4 +90,5 @@ def sendfoobar(request): def includeme(config): config.add_subscriber_predicate('yup', Yup) + config.add_subscriber_predicate('yup_with_all_args', YupWithAllArgs) config.scan('tests.pkgs.eventonly') diff --git a/tests/test_integration.py b/tests/test_integration.py index 63a7088e9..7ca11e81e 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -213,7 +213,13 @@ class TestEventOnlySubscribers(IntegrationBase, unittest.TestCase): res = self.testapp.get('/sendfoobar', status=200) self.assertEqual( sorted(res.body.split()), - [b'foobar', b'foobar2', b'foobaryup', b'foobaryup2'], + [ + b'foobar', + b'foobar2', + b'foobaryup', + b'foobaryup2', + b'foobaryup3', + ], ) |
