smarie / python-pytest-harvest

Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.
https://smarie.github.io/python-pytest-harvest/
BSD 3-Clause "New" or "Revised" License
63 stars 9 forks source link

[Improvement Request] Only import pandas if needed #49

Closed jmrgibson closed 3 years ago

jmrgibson commented 3 years ago

Firstly, thanks for the great plugin, especially the documentation!

I'm trying to speed up the init time of our pytest suite (ie, speed up the time before we actually start running tests), because our users often iterate on one test at a time, which typically take 1-3 seconds to run. Importing pandas is currently ~0.5sec of our boot up time, coming from pytest-harvest. A small fraction of our tests use pandas, and where we use it, we've been careful to delay the import until the functions that use it, so that we don't pay this penalty across all tests.

From a cursory glance, this line and this line could be moved inside the get_session_results_df() function definition, and the error message re-worked, so that you only pay the import cost if you use the function, rather than every time you load the plugin.

If this sounds OK, I can put up a PR changing this.

smarie commented 3 years ago

This seems reasonable @jmrgibson thanks ! I'll check for your PR

smarie commented 3 years ago

Fixed by fe5860a Will be available in 1.10.3 in a few minutes. Thanks again @jmrgibson !