python buildPythonPackage: check and run correct test command#11715
python buildPythonPackage: check and run correct test command#11715FRidh wants to merge 4 commits intoNixOS:masterfrom
Conversation
The default command for running tests is `python setup.py test`. Many packages use a test runner that needs to be invoked, e.g. `nosetests` or `py.test`. It would be nice if `buildPythonPackage` automatically determines which command to run. We can check in the `buildInputs` whether `nose` or `pytest` is included, and if so, do either 1) or 2) 1. Run the appropriate command, `nosetests` or `py.test`. 2. Apply a patch to enable `python setup.py test`. For [py.test](http://pytest.org/latest/goodpractises.html#integrating-with- setuptools-python-setup-py-test-pytest-runner) and [nose](http://nose.readthedocs.org/en/latest/api/commands.html) Option 2) could get complicated/messy and therefore I'm in favor of option 1). This commit implements option 1. --- Reference to NixOS#1819
If I am correct any future modifications to the comments wouldn't require a rebuild.
|
By analyzing the blame information on this pull request, we identified @domenkozar, @civodul and @offlinehacker to be potential reviewers |
There was a problem hiding this comment.
Why is this comment removed?
EDIT oh nevermind, you're putting it outside of bash, which seems like a good thing
There was a problem hiding this comment.
its moved a couple of lines up.
There was a problem hiding this comment.
I know I sometimes use py.test and call it within the python setup.py test after some set-up have been done (something like being sure that database schema are deployed). Would not that change break such behavior ? I have no idea how much this kind of setup is used.
|
@lancelotsix indeed, I was just about to write a note on that. |
|
That's my underlying question : how common is that ? I do it this way in some projects because running the entire migration history takes a lot of time when my cleanup phases can only make sure the tables are empty. Anyway, this not even that much a good example because unless I test against I also use either the wrapper in the |
|
Indeed, so we either
The latter we might be able to find out by doing a full rebuild. Most packages that have
I just randomly checked the source of a couple of packages, and quite often I've encountered also the So actually I'm thinking now of closing this PR and keeping it the way it was. |
The default command for running tests is
python setup.py test. Manypackages use a test runner that needs to be invoked, e.g.
nosetestsorpy.test. It would be nice ifbuildPythonPackageautomaticallydetermines which command to run.
We can check in the
buildInputswhethernoseorpytestisincluded, and if so, do either 1) or 2)
nosetestsorpy.test.python setup.py test. For[py.test](http://pytest.org/latest/goodpractises.html#integrating-with-
setuptools-python-setup-py-test-pytest-runner) and
nose
Option 2) could get complicated/messy and therefore I'm in favor of
option 1).
This commit implements option 1.
Reference to #1819
Furthermore, comments in buildPythonPackage are moved out of the arguments, and explicit calls to the test runners that are not necessary anymore are removed.