Skip to content

Commit

Permalink
fix: Add a DummyErrorHandler (#137)
Browse files Browse the repository at this point in the history
* Remove unused imports

* Add failing test

* Add DummyErrorHandler
  • Loading branch information
di authored Jul 21, 2021
1 parent 54d87d0 commit 9ea8dd2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/functions_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions tests/test_cloudevent_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 9ea8dd2

Please sign in to comment.