ini文件中文乱码 python_pytest.ini文件未正确设置值

尝试在pytest.ini文件动态归档。testpaths选项决定pytest将从哪个目录收集测试。我想让用户能够选择测试目录a或{}。在

conftest.py

第一个钩子创建一个解析器选项。

第二个钩子拉动解析器选项读取值,并将testpath添加到config对象下的testpaths选项中。在@pytest.hookimpl()

def pytest_addoption(parser):

"""Creates a parser option"""

# Allows the user to select the test suite they want to run

parser.addoption("--suite", action="store", default="None"

, choices=['a', 'b']

, help="Choose which test suite to run.")

@pytest.hookimpl()

def pytest_configure(config):

print("Determining test directory")

suite = config.getoption("--suite")

if suite == "a":

config.addinivalue_line("testpaths", "tests/a")

elif suite == "b":

config.addinivalue_line("testpaths", "tests/b")

因此,如果我运行pytest --suite a,它应该加载a测试套件下的所有测试。它没有。它加载所有测试,就像选项不存在一样。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值