Skip to content

Commit

Permalink
Merge 583bd28 into da37b01
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgarcia98 committed May 11, 2023
2 parents da37b01 + 583bd28 commit ecea555
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flexmeasures/utils/coding_utils.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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`

0 comments on commit ecea555

Please sign in to comment.