【发布时间】:2018-07-24 20:10:22
【问题描述】:
我需要将类成员作为参数传递给pytest.mark.parametrize。
以下代码不起作用(我使用了简单的成员字符串,但在我的情况下,它们是复杂且构造的):
import pytest
class TestSmth(object):
def setup_class(cls):
cls.a = "a"
cls.b = "b"
cls.c = "c"
@pytest.mark.parametrize("test_input,expected", [
(self.a, "a"),
(self.b, "b"),
(self.c, "c")
])
def test_members(test_input, expected):
assert test_input == expected
有可能达到这样的结果吗? 还是类似的?
【问题讨论】: