Skip to content

Commit 9ea8dd2

Browse files
authored
fix: Add a DummyErrorHandler (GoogleCloudPlatform#137)
* Remove unused imports * Add failing test * Add DummyErrorHandler
1 parent 54d87d0 commit 9ea8dd2

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/functions_framework/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,14 @@ def __call__(self, *args, **kwargs):
348348

349349

350350
app = LazyWSGIApp()
351+
352+
353+
class DummyErrorHandler:
354+
def __init__(self):
355+
pass
356+
357+
def __call__(self, *args, **kwargs):
358+
return self
359+
360+
361+
errorhandler = DummyErrorHandler()

tests/test_cloudevent_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
import pytest
1818

19-
from cloudevents.http import CloudEvent, from_http, to_binary, to_structured
19+
from cloudevents.http import CloudEvent, to_binary, to_structured
2020

21-
from functions_framework import LazyWSGIApp, create_app, exceptions
21+
from functions_framework import create_app
2222

2323
TEST_FUNCTIONS_DIR = pathlib.Path(__file__).resolve().parent / "test_functions"
2424
TEST_DATA_DIR = pathlib.Path(__file__).resolve().parent / "test_data"

tests/test_functions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import functions_framework
2727

28-
from functions_framework import LazyWSGIApp, create_app, exceptions
28+
from functions_framework import LazyWSGIApp, create_app, errorhandler, exceptions
2929

3030
TEST_FUNCTIONS_DIR = pathlib.Path.cwd() / "tests" / "test_functions"
3131

@@ -454,6 +454,12 @@ def test_lazy_wsgi_app(monkeypatch, target, source, signature_type):
454454
]
455455

456456

457+
def test_dummy_error_handler():
458+
@errorhandler("foo", bar="baz")
459+
def function():
460+
pass
461+
462+
457463
def test_class_in_main_is_in_right_module():
458464
source = TEST_FUNCTIONS_DIR / "module_is_correct" / "main.py"
459465
target = "function"

0 commit comments

Comments
 (0)