Skip to content
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

fix: deprecated decorator wasn't returning the value of the moved cal… #678

Merged
merged 4 commits into from May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion flexmeasures/utils/coding_utils.py
Expand Up @@ -166,7 +166,7 @@ def wrapper(*args, **kwargs):
f"The method or function {func.__name__} is deprecated and it is expected to be sunset in version {version}. Please, switch to using {inspect.getmodule(alternative).__name__}:{alternative.__name__} to suppress this warning."
)

func(*args, **kwargs)
return func(*args, **kwargs)

return wrapper

Expand Down
10 changes: 7 additions & 3 deletions flexmeasures/utils/tests/test_coding_utils.py
Expand Up @@ -2,19 +2,19 @@


def other_function():
pass
return 1


def test_deprecated_decorator(caplog, app):

# defining a function that is deprecated
@deprecated(other_function, "v14")
def deprecated_function():
pass
return other_function()

caplog.clear()

deprecated_function() # calling a deprecated function
value = deprecated_function() # calling a deprecated function
print(caplog.records)
assert len(caplog.records) == 1 # only 1 warning being printed

Expand All @@ -25,3 +25,7 @@ def deprecated_function():
assert "v14" in str(
caplog.records[0].message
) # checking that the message is correct

assert (
value == 1
) # check that the decorator is returning the value of `other_function`