Reputation: 3620
I have a few carefully configured conda
environments created using Anaconda. I have written a Python package that uses some of the packages and libraries installed in these environments. Now I would like to run the tests with each test file being executed for each environment to make sure the package can handle working with different Python versions and different set of 3rd party packages available.
Using a tox
did not work for me because it tries to recreate those environments locally to run tests against. This is how my tox.ini
file looks:
[tox]
envlist = py36, py27
skipsdist = True
[testenv]
basepython =
py36: C:\Users\user\AppData\Local\Continuum\Anaconda2\envs\Env1\python.exe
py27: C:\Users\user\AppData\Local\Continuum\Anaconda2\envs\Env2\python.exe
commands =
{envpython} -m unittest discover
However, it is not possible to do just plain pip install
into the environments tox
creates on each run mainly because there are some compiled libraries and workarounds involved (which are solved in a conda
environment - so I have to use those as they are).
I currently have a dummy .bat
file with the following content:
"C:\Users\user\AppData\Local\Continuum\Anaconda2\envs\Env1\python.exe" -m unittest discover
"C:\Users\user\AppData\Local\Continuum\Anaconda2\envs\Env2\python.exe" -m unittest discover
which I execute in a Windows cmd
to see the results. It does work, but I wonder whether there is any more Pythonic way to run these tests such using py.test
or tox
. I do not want to recreate the conda
environments I already have; I just want to use different Python interpreters accessed at different locations to run my tests.
Upvotes: 3
Views: 2529