I am writing a long workflow for scientific data processing that uses Snakemake. Along the workflow, there are multiple scripts that use different environments. The folder looks something like this:
package
|-- scripts
| |
| -- script1.py
| -- script2.py
|-- tests
| |
| -- test1.py
| -- test2.py
|-- envs
| |
| -- env1.yml
| -- env2.yml
test1
uses conda environment in env1.yml
to test script1
and so on. Currently, I can run individual tests with:
conda activate env1 && python -m pytest tests/test1.py && conda deactivate
Is there a way I can use pytest to pair the tests with the right environment automatically? Right now I am thinking about creating a bash script to activate env and run the test with one line per test. Alternatively, I was also looking into multiple pytest configurations as described in this SO link.
I was hoping to this natively with pytest instead of bash scripts if that is possible.