8000 fix: Add functools.wraps decorator by svleeuwen · Pull Request #179 · GoogleCloudPlatform/functions-framework-python · GitHub
[go: up one dir, main page]

Skip to content
8000

fix: Add functools.wraps decorator #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/functions_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def setup_logging():


def _http_view_func_wrapper(function, request):
@functools.wraps(function)
def view_func(path):
return function(request._get_current_object())

Expand Down
11 changes: 11 additions & 0 deletions tests/test_view_functions.py
Original file line number
Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ def test_http_view_func_wrapper():
assert function.calls == [pretend.call(request_object)]


def test_http_view_func_wrapper_attribute_copied():
def function(_):
pass

function.attribute = "foo"
view_func = functions_framework._http_view_func_wrapper(function, pretend.stub())

assert view_func.__name__ == "function"
assert view_func.attribute == "foo"


def test_event_view_func_wrapper(monkeypatch):
data = pretend.stub()
json = {
Expand Down
0