From 8513d7d929f0a36b1d0e72dc5a0388afd5c38e86 Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 15 Jul 2021 11:57:33 -0400 Subject: [PATCH 1/3] Remove unused imports --- tests/test_cloudevent_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cloudevent_functions.py b/tests/test_cloudevent_functions.py index 061bb945..237225cd 100644 --- a/tests/test_cloudevent_functions.py +++ b/tests/test_cloudevent_functions.py @@ -16,9 +16,9 @@ import pytest -from cloudevents.http import CloudEvent, from_http, to_binary, to_structured +from cloudevents.http import CloudEvent, to_binary, to_structured -from functions_framework import LazyWSGIApp, create_app, exceptions +from functions_framework import create_app TEST_FUNCTIONS_DIR = pathlib.Path(__file__).resolve().parent / "test_functions" TEST_DATA_DIR = pathlib.Path(__file__).resolve().parent / "test_data" From 52579003f9e0dd23d8331a163884e19af4158f8f Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 15 Jul 2021 11:57:53 -0400 Subject: [PATCH 2/3] Add failing test --- tests/test_functions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_functions.py b/tests/test_functions.py index ad16c15b..e17df452 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -25,7 +25,7 @@ import functions_framework -from functions_framework import LazyWSGIApp, create_app, exceptions +from functions_framework import LazyWSGIApp, create_app, errorhandler, exceptions TEST_FUNCTIONS_DIR = pathlib.Path.cwd() / "tests" / "test_functions" @@ -454,6 +454,12 @@ def test_lazy_wsgi_app(monkeypatch, target, source, signature_type): ] +def test_dummy_error_handler(): + @errorhandler("foo", bar="baz") + def function(): + pass + + def test_class_in_main_is_in_right_module(): source = TEST_FUNCTIONS_DIR / "module_is_correct" / "main.py" target = "function" From 890df8ed184fb78a30273175e77af7c75532e8ae Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 15 Jul 2021 11:58:04 -0400 Subject: [PATCH 3/3] Add DummyErrorHandler --- src/functions_framework/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/functions_framework/__init__.py b/src/functions_framework/__init__.py index 36cde34b..246dcbb2 100644 --- a/src/functions_framework/__init__.py +++ b/src/functions_framework/__init__.py @@ -348,3 +348,14 @@ def __call__(self, *args, **kwargs): app = LazyWSGIApp() + + +class DummyErrorHandler: + def __init__(self): + pass + + def __call__(self, *args, **kwargs): + return self + + +errorhandler = DummyErrorHandler()