Py学习  »  pycharm

如何使pycharm从pyscaffold创建的setup.cfg中获取测试配置?

Robert Calceanu • 5 年前 • 801 次点击  

如何使pycharm从由pyscaffold创建的文件setup.cfg中获取测试配置?

我在设置中启用了pytest->工具->python集成工具->测试


到目前为止,我所拥有的是保存在Python测试部分的配置,其中包括:

目标:脚本路径=c:…\setup.py

附加参数:测试


但这就是我运行它时得到的:

[...] ERROR: file not found: test

或者,我如何在pycharm中复制与在setup.cfg中相同的测试配置?

console_scripts =
program = program.main:run

[test]
# py.test options when running `python setup.py test`
# addopts = --verbose
extras = True

[tool:pytest]
# Options for py.test:
# Specify command line options as you would do when invoking py.test directly.
# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml
# in order to write a coverage file that can be read by Jenkins.
addopts =
--cov reddit_users_info --cov-report term-missing
--verbose

[...]

testpaths = tests
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/30791
 
801 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Laurențiu Andronache
Reply   •   1 楼
Laurențiu Andronache    5 年前
  1. 打开项目目录并将其配置为使用创建的venv。在脚本路径中 src\program\program.py , 在参数上可以添加 -vv .

  2. 从启用Pytest Settings -> Tools -> Python Integrated Tools -> Testing

  3. 添加一个运行配置,但也添加一个用于测试: Edit Configurations -> + -> Python tests -> pytest .

  4. 运行测试。如果您已经安装了测试所需的软件包,它就会工作(请检查上面的“to test”部分)。 进程将在项目目录中创建.coverage文件。

  5. 如果你有Pycharm专业人士而不是Pycharm社区,你也应该这样做:

Ctrl + Alt + F6 (Choose coverage suite to display) -> + -> select any of the created files -> Show selected . 这将在脚本中添加花哨的颜色,这取决于测试覆盖代码的位置。