LupoA / lsdensities

Smeared spectral densities from lattice correlators
GNU General Public License v3.0
3 stars 0 forks source link

Use pytest #42

Closed edbennett closed 5 months ago

edbennett commented 6 months ago

Currently the tests directory contains programs with a main() function that outputs the result of a check; it would be better to use an automated testing tool like pytest for this instead—this will reduce the amount of code, make it more easily automated, and make it easier to read for others who are already familiar with pytest.

edbennett commented 5 months ago

This is still open: currently running pytest gives the message "no tests ran".

Current issues:

If anything's unclear, I'd suggest having a read of an introductory tutorial on using pytest (e.g. this one)

LupoA commented 5 months ago

pytest fails finding modules for me on all tests ( ModuleNotFoundError: No module named 'lsdensities')

while python -m pytest works

LupoA commented 5 months ago

Indeed the tests should have assertions. I am planning to write a new bunch of them in the close future, the ones that we have now are very basic.

test_periodicity is I think one of the most useful and was badly set up to produce plots for visual inspection, no assertions. We can put one on the values of f_t at large t matching f_t at infinite t.

It seems to be this test was broken since the S_matrix plot has now more content than it should have. EDIT: it is just pytest breakin the plots, not the program itself. I guess it's bad design. I'll put an assertion :)

LupoA commented 5 months ago

possibly solved by 4f2f701

LupoA commented 5 months ago

pytest fails finding modules for me on all tests ( ModuleNotFoundError: No module named 'lsdensities')

while python -m pytest works

this persists but I don't think it is a problem

edbennett commented 5 months ago

If pytest does not work but python -m pytest does, then this is an issue with your setup—you have pytest installed in your PATH somewhere that has higher precedence than your current virtual environment, and so it runs with the environment it's installed in rather than the one you want.

(Using python -m pytest by default is frequently a good idea for this reason.)

nickforce989 commented 5 months ago

Is this issue still to be completed?

edbennett commented 5 months ago
nickforce989 commented 5 months ago

Ok, I should have addressed your points, and there are asserts and pytest succeed in running too.

edbennett commented 5 months ago

I've checked off the bullets that have been addressed from my previous message—looks like there's one test that still doesn't test anything?

nickforce989 commented 5 months ago

Woops, sorry I didn't notice that. I corrected it now.