gpt4 book ai didi

python - pytest不跳过未标记的测试

转载 作者:太空宇宙 更新时间:2023-11-04 06:15:43 25 4
gpt4 key购买 nike

我们有一个标记测试,我们希望它不会被执行,因为 py.test 是用另一个标记调用的,但测试正在执行。

例如

@pytest.mark.stress
def test_one(some_fixture):
pass

@pytest.mark.myplatform
def test_two(some_fixture):
pass

如果我用 --colleclonly -m "myplatform and (not stress)"作为实验运行 pytest,我发现我可以解决这个问题。我假设使用 fixture 在某种程度上改变了标记的评估方式,但我们假设使用 fixture 不会影响使用标记收集测试的方式。 fixture 中有代码可以查看标记,但我们不会以任何方式更改 pytest args。克里斯

最佳答案

尝试使用 -k 标志,并保持相同的过滤逻辑“myplatform and not stress”。

https://pytest.org/en/latest/example/markers.html#using-k-expr-to-select-tests-based-on-their-name

关于python - pytest不跳过未标记的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15837761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com