python-sortedcontainers
python-sortedcontainers copied to clipboard
Remove tests/.context shim and test as installed
Currently the tests/ folder uses a context.py shim to ensure that the sortedcontainers folder in the repository root is the one that the tests pick up. I believe this is exactly backwards from best practices, (see my blog post about it, and Hynek Schlawack's related post about the src/ layout.
This PR does two things:
-
Removes the
context.pyshim so that the package must be installed or otherwise on the PYTHONPATH via another route (less desirable) before running the tests (python -m pytestwhen run from the repo route will, unfortunately, work for this, but without switching to thesrc/layout, that is unavoidable). -
Switches the
toxconfiguration over to running the tests from a directory other than the repository root, to ensure that everything is being tested as installed. I will note that I needed to switch to using aconftest.pyfile to ignore certain files in thetests/directory, because there's no way to tellpytestthat the--ignoreoptions are relative to the repository root.
If you'd like me to add something to the contributing documentation about this, let me know.
That's an old "feature" copied from the requests module which did similarly about 5 years ago. I'm happy to remove context.py. Typically I just set my PYTHONPATH when developing with pytest and otherwise rely on tox (for other projects).
I agree it's not a best-practice. I will try to take a look this weekend.
As to "src" directories, I'm not a fan.
The failures here seem unrelated to my changes, seems like on Appveyor the Python 3.4 job is picking up an incorrect version of pytest, and on Travis the lint problems seem to already have existed (I would not be surprised if pylint just has added more rules).
The "context" shim has been removed with the adoption of GitHub Actions.