Reputation: 3161
I have created some tests in Tests.py
using py.test
framework.
And I am using the following bash command to run in terminal:
py.test --junitxml result_Tests.xml Tests.py
But in this case py.test
is picking the default python installation.
How do I specify a conda environment name to py.test
so that it runs on that specific conda environment?
I could not find any specific py.test
switches in their docs.
Upvotes: 9
Views: 7860
Reputation: 721
The proper manner to specify the conda environment in which a command must run is using the conda run
command, passing the env name with the -n
flag. In your case:
conda run -n <env_name> pytest tests.py --junitxml result_Tests.xml
Upvotes: 5
Reputation: 262
This is pretty obvious and probably not what you're looking for, but - assuming 'python' is the conda environment's - using
python -m pytest
seems to work.
Upvotes: 11