简体   繁体   English

conda 环境中的 pytest/pylint

[英]pytest/pylint in conda environment

I know how to run a pytest and pylint in python using a requirements.txt file (containing pytest and pylint):我知道如何使用 requirements.txt 文件(包含 pytest 和 pylint)在 python 中运行 pytest 和 pylint:

python -m venv .
.\scripts\activate
pip install -r requirements.txt
pytest <filename>

However I'm not sure on how to do this on conda, so far I have:但是我不确定如何在 conda 上执行此操作,到目前为止我有:

conda create --name testenv --file requirements.txt
conda activate testenv
??

I'm not sure what to put next in order to run a pylint or pytest. I've taken a look at this which uses pylint filename.py after.我不确定接下来要放什么才能运行 pylint 或 pytest。我看过这个之后使用pylint filename.py的内容。 Or would conda install -c anaconda pylint and then pylint <filename.py> ?或者conda conda install -c anaconda pylint然后pylint <filename.py>

I assume it would be similar steps for pytest.我假设 pytest 的步骤类似。

The process in general is the same - or it might be more precise to say it's analogous.这个过程大体上是相同的——或者说它是类似的可能更准确。 Conda is not an analogous tool in all respects, but for this, the steps should look familiar. Conda 在所有方面都不是一个类似的工具,但为此,这些步骤看起来应该很熟悉。

# create your virtual environment
conda create --name testenv
# activate your virtual environment
conda activate testenv
# install your tools
conda install pytest pylint -c conda-forge --yes
# run your tools
pytest path/to/tests/
pylint path/to/files/

I'm not sure what "in multiple directories" in your title refers to.我不确定您标题中的“在多个目录中”指的是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM