ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

Pipenv环境配置+Pytest运行

2026/9/16 1:04:27 拓冰建站 浏览量
Pipenv环境配置+Pytest运行

环境配置

使用Pipenv进行虚拟环境管理,Pipfile为依赖模块管理文件。

  1. 安装pipenv:brew install pipenv
  2. 根项目根目录下执行命令创建虚拟环境: pipenv install
  3. 在Pycharm中指定项目运行的虚拟环境 :File->Settings->Project:->Project Interpreter

执行用例

  • 配置PyCharm的default test runner为pytest

  • 打开PyCharm的run/debug configurations窗口,指定运行文件

  • pytest.ini文件中指定配置的config文件

addopts = -rsxX --color=yes --env=test --config=folder/xx_config.yaml --alluredir allure-results --json-report

  • 运行