断言导入函数的断言(Python)

时间:2018-02-08 04:56:53

标签: unit-testing testing matplotlib mocking assert

我必须编写一些测试来断言某些函数被调用,例如来自plot的{​​{1}}函数。这是我到目前为止的代码:

matplotlib.pyplot

这是为了测试从名为def test_plot_call(self): with patch("matplotlib.pyplot.plot") as plot_call: import attempt plot_call.assert_has_calls([call(attempt.X,attempt.Y1)]) 的模块以某种方式调用matplotlib.pyplot.plot

如果函数被调用为attempt,这样可以正常工作,但我需要它在matplotlib.pyplot.plot(X,Y1)模块调用attempt时也能正常工作:

plot

在这种情况下,from pylab import * X = # somethin Y1 = # somethin plot(X,Y1) 会失败 - 但我希望它通过。

0 个答案:

没有答案
相关问题