Pytest抱怨fixture,然后在几乎相同的cod上运行良好

2024-04-25 15:14:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图学习pytest,但我很难理解parameterize()的行为。在

import pytest

@pytest.mark.parameterize("foo", [1, 2, 3, 4, 5, 6, 7, ])
def test(foo):
    assert foo % 2 == 0

跑步py.测试返回错误:“fixture”foo“not found”。在

运行这个几乎完全相同的示例代码工作得非常好!有什么区别,为什么我使用参数化的尝试失败了?在

^{pr2}$

Tags: pytestimport示例foopytestdef错误
1条回答
网友
1楼 · 发布于 2024-04-25 15:14:04

不幸的是,这只是parametrize单词中的一个错误

import pytest

@pytest.mark.parametrize("foo", [1, 2, 3, 4, 5, 6, 7, ])
def test(foo):
    assert foo % 2 == 0

效果很好。在

相关问题 更多 >