CrossHair icon indicating copy to clipboard operation
CrossHair copied to clipboard

Consider moving tests outside of application code

Open mmtj opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. Currently there are both code and test files included in module directory. I find it a little unusual when looking at first glance and personally think that tests outside of application code make project structure clearer.

Also that way you could quite easily choose whether to bundle tests within source distribution, wheel distribution, etc.

Describe the solution you'd like Move *_test.py files into it's own directory, see https://docs.pytest.org/en/6.2.x/goodpractices.html#tests-outside-application-code

I could create PR, if you are in favor of such change.

Describe alternatives you've considered I see that there are also tests in docstrings, so the proposed separation of code and tests still won't be complete. Alternative is to keep it the same way as it already is, i.e. keep tests in one place.

Note This issue is slightly related to #53

mmtj avatar Oct 29 '21 17:10 mmtj

Ah. Yeah, I think in the abstract, I have a slightly contrarian preference about putting tests close to the code they test.

BUT, particularly as CrossHair becomes a more distributed project, it makes more sense to bias for "least surprise," and I think having isolated tests is more common. So ... I am open to this idea if you want to give the refactor a try.

FWIW, I think it's ok to have doctests in the distribution - they are intended to be part of the documentation, and I've been trying to write them as what you'd want to see for X when you type help(X) in the REPL.

One thing to note - this might involve some more work than you'd expect. This test, for instance, looks up example code based on the position of the test file itself!

On a practical note, you might want to wait for us to resolve https://github.com/pschanely/CrossHair/pull/125 to avoid conflicts.

pschanely avatar Oct 30 '21 12:10 pschanely