dipc-cc / hubbard

Python tools for mean-field Hubbard models
https://dipc-cc.github.io/hubbard/
GNU Lesser General Public License v3.0
21 stars 8 forks source link

WIP pytest #66

Closed tfrederiksen closed 3 years ago

tfrederiksen commented 4 years ago

I was playing a bit around with pytest and introduced a quick check of some key functions.

More stuff could/should probably be added before merging into master.

Remember to stick to the naming scheme of (sub)directories called tests containing files test_*.py.

To run all tests simply execute:

pytest --pyargs Hubbard

See also #5 .

sofiasanz commented 4 years ago

Looks good! Then we can use this format for the other test files. I guess that there is an option to run each test separately?

zerothi commented 4 years ago

What I typically do is to mark a test, then one can run individual tests using:

@pytest.mark.only
def test_*(...):
    ...

then do

pytest --pyargs Hubbard -m only

one can also run by name, but that requires full path + test names. A bit more verbose. The above I use frequently for testing purposes and I also group tests together, say pytest --pyarg sisl -m hamiltonain to test only stuff related to the Hamiltonian.

tfrederiksen commented 4 years ago

Thanks for the feedback. Another simple way to run a subset of tests of sislis to use pytest --pyargs sisl.physics etc. But this is not as fine-grained as the mark method, I guess.

zerothi commented 4 years ago

Thanks for the feedback. Another simple way to run a subset of tests of sislis to use pytest --pyargs sisl.physics etc. But this is not as fine-grained as the mark method, I guess.

Yeah exactly, it isn't really necessary to do any of these things, one can customize pytest a lot! ;)

I actually think you should just put this PR in Hubbard, tests can always be added. :)