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
61 stars 8 forks source link

Unable to use module_results_dct as described #37

Closed AndrewFalanga closed 4 years ago

AndrewFalanga commented 4 years ago

Hello,

Starting an issue as you'd mentioned in StackOverflow. In attempting to use these instructions, https://smarie.github.io/python-pytest-harvest/, I am not able to access the components of the pytest-harvest module as described.

As an example, the below results only in module_results_dct as being undefined.

import numpy as np
def test_abs():
    assert np.abs(-3) == 3
    print("module_results_dct keys")
    for k in module_results_dct:
        print("   - " + k)

I did pip3 install pytest-harvest to install the modules. I am sure that I'm doing something incorrectly. This morning, while perusing the git-hub sources (something I didn't do yesterday) I did find some things about installing, via pip, what's in the ci_tools subdirectory. This I have not done because I did not clone the repo.

smarie commented 4 years ago

I think you just forgot to require the fixture :)

def test_abs(module_results_dct):
    ...

See pytest documentation to better understand what are fixtures and how they should be used. pytest-harvest "just" provides new ones, but does not provide any additional/fancy mechanism, it is really plain pytest here.

AndrewFalanga commented 4 years ago

Ah, I see. Thank you for the pointer. In fact, I'm quite new to pytest. It's a research project for work.

Thank you again.

Andy

On Sat, Apr 25, 2020 at 7:34 AM smarie notifications@github.com wrote:

I think you just forgot to require the fixture :)

import numpy as np def test_abs(module_results_dct): assert np.abs(-3) == 3 print("module_results_dct keys") for k in module_results_dct: print(" - " + k)

See pytest documentation to better understand what are fixtures and how they should be used. pytest-harvest "just" provides new ones, but does not provide any additional/fancy mechanism, it is really plain pytest here.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smarie/python-pytest-harvest/issues/37#issuecomment-619380561, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5OC5KLUOYX45WWDNA4BBDROLRH5ANCNFSM4MPH2U5Q .

smarie commented 4 years ago

You're welcome. Closing the ticket now, feel free to open another one if you encounter a specific issue.