gpt4 book ai didi

python - pytest.mark.parameterize 不是 "finding"固定装置

转载 作者:行者123 更新时间:2023-11-28 20:21:10 25 4
gpt4 key购买 nike

我正在为一个小型图书馆编写测试,在听到很多关于它的好消息后我决定使用 py.test。

但是,pytest.mark.parameterize 给我带来了一些问题。起初,我想也许我只是不匹配一些 parent ,然后就去别处寻找固定装置了。所以我决定从给定的参数化示例开始:

@pytest.mark.parametrize("input,expected", [
("3+5", 8),
("2+4", 6),
("6*9", 42),
])
def test_eval(input, expected):
assert eval(input) == expected

但这给出了同样的错误:

fixture 'input' not found

available fixtures: capfd, pytestconfig, recwarn, capsys, tmpdir, monkeypatch

use 'py.test --fixtures [testpath]' for help on them.

我停止使用谷歌搜索,但找不到任何适用的答案。关于如何处理这个问题有什么想法吗?

编辑:我想知道哪个 Python/py.test 版本是有帮助的。

Python 3.4.0 和 py.test 2.6.4

最佳答案

我刚刚逐字尝试了您的示例,它在 pytest 2.6.4 中运行良好。也许您拼错了 parametrize?您在标题中拼错了,这是一个常见的错误,如 this issue 中所示.

关于python - pytest.mark.parameterize 不是 "finding"固定装置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28943211/

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