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

line_profiler as a pytest plugin #57

Open
mgaitan opened this issue Apr 13, 2021 · 3 comments
Open

line_profiler as a pytest plugin #57

mgaitan opened this issue Apr 13, 2021 · 3 comments

Comments

@mgaitan
Copy link

mgaitan commented Apr 13, 2021

I frequently want to execute line_profiler for some function/code under a particular context already defined in a unittest.

So I would like to instrument something equivalent to the %lprun magic as a pytest's extension, where I can pass a list of functions to inspect in the command line before the

For instance

$ pytest --line-profiler foo.function1 --line-profiler bar.another_function_called_by_function1  tests/test_module::test_that_call_foo_function1 

would something like this be desirable?

@Erotemic
Copy link
Member

If you would like to write that plugin, I think it would make a lot of sense to write is as a separate package (maybe pytest-line-profiler?) that depends on line_profiler. Because I'm not the original author, I want to keep the complexity of new additions to a minimum.

If you ensure that your package is tested, on a CI, and published on pypi, I can either give a shout-out to it in the README of this repo, or if your package is really good or becomes popular then I can add it as an optional dependency in extras_require. Thus if someone was to pip install line_profiler[pytest] that would include your package.

Let me know if you want to give it a shot, or if you don't have experience in any creating a new python package, running tests on a CI, or publishing on pypi.

@mgaitan
Copy link
Author

mgaitan commented Apr 14, 2021

@Erotemic pretty clear, thansk. I'll try to get some time from my employer (@Shiphero) to implement this idea as an external package. I'll keep u posted.

@mgaitan mgaitan closed this as completed Apr 14, 2021
@mgaitan
Copy link
Author

mgaitan commented May 3, 2021

I've just pushed a first version of this idea https://github.com/mgaitan/pytest-line-profiler. It would be awesome if you can try it and give me some feedback.

@mgaitan mgaitan reopened this May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants