Open utterances-bot opened 3 years ago
可以使用 xfail
来代替有点傻的类型判断
class TestUtils:
@pytest.mark.parametrize(
"input, expected",
[
pytest.param("abc", "", marks=pytest.mark.xfail(raises=ValueError)),
],
)
def test_some_content(self, input, expected, make_fake_resp):
"""测试某些内容"""
with mock.patch('some-need-patching-refrences') as _patch:
_patch.side_effect = make_fake_resp(input)
assert call_test(input) == expected
看起来虚浮多了 🥴
善用 pytest fixture factory 构建结构优秀的单元测试
https://emergencyexit.xyz/use-pytest-fixture-factory.html