【问题标题】:Run single folder of pytest tests in vscode在 vscode 中运行 pytest 测试的单个文件夹
【发布时间】:2020-02-21 18:13:12
【问题描述】:

我有一种“微服务”Python 存储库,其设置类似于以下内容:

sample
├── bar
│   ├── src
│   │   └── main.py
│   └── tests
│       └── test_main.py
├── foo
│   ├── src
│   │   └── main.py
│   └── tests
│       └── test_main.py
└── shared
    ├── src
    │   └── main.py
    └── tests
        └── test_main.py

在 vscode 中,我只能选择在 foobarshared 中运行 所有 测试或在子文件夹中运行单个测试 methods。我想要做的是能够快速运行foo/tests/

有什么方法可以配置 pytest/Python 来做到这一点?我不想将每个顶级文件夹拆分为自己的工作区,因为我经常在它们之间跳转,并且不希望每个工作区打开多个窗口。

【问题讨论】:

  • 您可以在[pytest] 部分下使用addopts = foo/tests/ 创建pytest.ini

标签: python pytest vscode-settings vscode-python


【解决方案1】:

你应该可以在终端中运行命令pytest foo/tests/ pytest documentation

【讨论】:

  • 对,但我希望能够通过 vscode 中的命令来运行它。
猜你喜欢
  • 2020-12-06
  • 2020-05-09
  • 2020-04-15
  • 2020-04-08
  • 1970-01-01
  • 2019-02-28
  • 2018-12-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多