BoothGroup / Vayesta

A Python package for wave function-based quantum embedding
Apache License 2.0
32 stars 7 forks source link

Moving tests outside package #143

Open maxnus opened 1 year ago

maxnus commented 1 year ago

This PR moves the tests directory outside the package.

In this PR:

codecov[bot] commented 1 year ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (511ef48) 71.53% compared to head (1c01eae) 71.53%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #143 +/- ## ======================================= Coverage 71.53% 71.53% ======================================= Files 152 152 Lines 20159 20159 Branches 3343 3343 ======================================= Hits 14420 14420 Misses 4906 4906 Partials 833 833 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

obackhouse commented 1 year ago

Removes if name == 'main' clauses and unittest imports. We have commited to pytest now, which is the de facto standard, let's not make it confusing by seemingly (but not really) support other modes of running the tests.

I disagree with this - if we remove these clauses then we have to run python -m pytest test_x.py to run a single test file rather than python test_x.py? We also still use the unittest framework via unittest.TestCase which we subclass - mixing this with pytest is very common.

obackhouse commented 1 year ago

Will there be any path issues with the tests now effectively belonging to a package named tests? If every package did this then it would be chaos, no?

obackhouse commented 1 year ago

LGTM otherwise :smile:

maxnus commented 1 year ago

I disagree with this - if we remove these clauses then we have to run python -m pytest test_x.py to run a single test file rather than python test_x.py?

You can also type pytest test_x.py. But note that these do different things, python test_x.py does not run via pytest, which was exactly my point.

We also still use the unittest framework via unittest.TestCase which we subclass

Yes, we will need to get rid of that too, at least over time, since those subclasses cannot use fixtures and parametrization decorators, see: https://docs.pytest.org/en/latest/how-to/unittest.html At the least, new tests should best not be written in unittest style anymore.

Will there be any path issues with the tests now effectively belonging to a package named tests? If every package did this then it would be chaos, no?

I don't see any issues. A lot of packages do this: https://github.com/pydantic/pydantic/tree/main/tests, https://github.com/tiangolo/fastapi/tree/master/tests