From 70a500247bb68f158bad3f316ad453c39aad800d Mon Sep 17 00:00:00 2001 From: Theelx <43764914+Theelx@users.noreply.github.com> Date: Tue, 15 Nov 2022 16:40:18 -0500 Subject: [PATCH] Add test and adjust version --- kernprof.py | 2 +- line_profiler/line_profiler.py | 2 +- tests/test_line_profiler.py | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/kernprof.py b/kernprof.py index 0d89a5f8..62e939a7 100755 --- a/kernprof.py +++ b/kernprof.py @@ -13,7 +13,7 @@ # NOTE: This version needs to be manually maintained with the line_profiler # __version__ for now. -__version__ = '4.0.0' +__version__ = '4.0.1' # Guard the import of cProfile such that 3.x people # without lsprof can still use this script. diff --git a/line_profiler/line_profiler.py b/line_profiler/line_profiler.py index b77aceea..10369a1f 100755 --- a/line_profiler/line_profiler.py +++ b/line_profiler/line_profiler.py @@ -16,7 +16,7 @@ f'Has it been compiled? Underlying error is ex={ex!r}' ) -__version__ = '4.0.0' +__version__ = '4.0.1' def load_ipython_extension(ip): diff --git a/tests/test_line_profiler.py b/tests/test_line_profiler.py index f9a33b39..3d5dae55 100644 --- a/tests/test_line_profiler.py +++ b/tests/test_line_profiler.py @@ -12,6 +12,12 @@ def g(x): y = yield x + 10 yield y + 20 +class C: + @classmethod + def c(self, value): + print(value) + return 0 + def test_init(): lp = LineProfiler() @@ -86,3 +92,13 @@ def test_gen_decorator(): with pytest.raises(StopIteration): next(i) assert profile.enable_count == 0 + +def test_classmethod_decorator(): + profile = LineProfiler() + c_wrapped = profile(C.c) + assert c_wrapped.__name__ == 'c' + assert profile.enable_count == 0 + val = c_wrapped('test') + assert profile.enable_count == 0 + assert val == C.c('test') + assert profile.enable_count == 0