-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python buildPythonPackage: check and run correct test command #11715
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 |
configurePhase = attrs.configurePhase or '' | ||
runHook preConfigure | ||
|
||
# patch python interpreter to write null timestamps when compiling python files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its moved a couple of lines up.
nosetests | ||
else | ||
${python.interpreter} nix_run_setup.py test | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
nosetests
orpy.test
. It would be nice ifbuildPythonPackage
automaticallydetermines which command to run.
We can check in the
buildInputs
whethernose
orpytest
isincluded, and if so, do either 1) or 2)
nosetests
orpy.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.