我试图在我的代码中模拟 3 个函数并参数化另外两个变量。
这里有一个例子:
@pytest.mark.parametrize('a, b', [
(5, 8),
])
@mock.patch('path_to_mocked_function3')
@mock.patch('path_to_mocked_function2')
@mock.patch('path_to_mocked_function1')
def test_function(self, mocked1, mocked2,
mocked3, a, b):
mocked1.return_value = a
mocked2.return_value = None
mocked3.return_value = b
output = export(**self.args).to_json()
self.assertEqual(output, 5)
现在我想参数化 a,b 变量,这样我就可以用几个不同的测试用例运行代码。
我收到此错误:
TypeError: test_function() takes exactly 6 arguments (4 given)
有谁知道为什么?