我用于运行在Makefile中我的包测试,以此来在一个执行三项任务:建立一个虚拟的环境,安装要求和调用测试套件与相应的参数:与Makefile中集成setup.py运行测试
test: venv
env/bin/pip install -r test_requirements.txt
env/bin/nosetests --rednose --with-coverage --cover-pagacke my_module
然后我读了requirements.txt文件支持setup.py的气馁,所以我修改了setup.py文件旨在获得相同的结果:
setup(
...
tests_require=['nose', 'rednose', 'coverage'],
test_suite=['nose.collector'])
现在我能修改Makefile文件与
test: venv
coverage run --source=my_module/ setup.py test
但需要在运行setup.py文件,然后再安装测试的依赖。我也不确定如何包含其他参数,如rednose。做这个的最好方式是什么?
“在一个执行三项任务:建立一个虚拟的环境,安装要求和调用测试套件” - 这是究竟是什么[tox](https://tox.readthedocs.io)。 – jwodder
requirements.txt没有错,他们并不气馁。 setup.py和requirements.txt只是有不同的[角色](https://caremad.io/posts/2013/07/setup-vs-requirement/)。说了我也推荐使用tox。 – phd