Skip to content

Commit 685b5f8

Browse files
authored
Merge pull request #300 from staftermath/use_wraps
Use functools.wraps in profile decorator
2 parents bd6da91 + fbee01d commit 685b5f8

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

memory_profiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,13 +1130,15 @@ def profile(func=None, stream=None, precision=1, backend='psutil'):
11301130
show_results, stream=stream, precision=precision
11311131
)
11321132
if iscoroutinefunction(func):
1133+
@wraps(wrapped=func)
11331134
@coroutine
11341135
def wrapper(*args, **kwargs):
11351136
prof = get_prof()
11361137
val = yield from prof(func)(*args, **kwargs)
11371138
show_results_bound(prof)
11381139
return val
11391140
else:
1141+
@wraps(wrapped=func)
11401142
def wrapper(*args, **kwargs):
11411143
prof = get_prof()
11421144
val = prof(func)(*args, **kwargs)

test/test_attributes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from memory_profiler import profile
2+
3+
4+
@profile
5+
def test_with_profile(arg1):
6+
"""dummy doc"""
7+
return None
8+
9+
10+
if __name__ == '__main__':
11+
assert test_with_profile.__doc__ == "dummy doc"
12+
assert test_with_profile.__name__ == "test_with_profile"

0 commit comments

Comments
 (0)