您如何编写产生/返回参数化测试参数的夹具(一种方法)?
例如,我有一个测试如下:
@pytest.mark.parametrize(
"input,expected",
[("hello", "hello"),
("world", "world")])
def test_get_message(self, input, expected):
assert expected == MyClass.get_message(input)
我对以下方法感兴趣,而不是通过input和expected传递:@pytest.mark.parametrize
@pytest.fixture(scope="session")
def test_messages(self):
# what should I write here to return multiple
# test case with expected value for each?
pass
def test_get_message(self, test_messages):
expected = test_messages["expected"] # somehow extracted from test_messages?
input = test_messages["input"] # somehow extracted from test message?
assert expected == MyClass.get_message(input)
不负相思意
烙印99
相关分类