lundi 12 juin 2017

Integrating setup.py with Makefile to run tests

I used to run the tests for my packages from the Makefile as a way to perform three tasks in one: setup a virtual environment, install requirements and call the testing suite with the corresponding arguments:

test: venv
  env/bin/pip install -r test_requirements.txt
  env/bin/nosetests --rednose --with-coverage --cover-pagacke my_module

Then I read that requirements.txt files are discouraged in favor of setup.py, so I modified the setup.py file aiming to get the same result:

setup(
    ...
    tests_require=['nose', 'rednose', 'coverage'],
    test_suite=['nose.collector'])

Now I could change the Makefile with

test: venv
    coverage run --source=my_module/ setup.py test

But that requires installing the testing dependencies before running the setup.py file. I'm also not sure how to include other arguments such as rednose. What is the best way to do this?

Aucun commentaire:

Enregistrer un commentaire