本文整理汇总了Python中mock.PropertyMock.reset_mock方法的典型用法代码示例。如果您正苦于以下问题:Python PropertyMock.reset_mock方法的具体用法?Python PropertyMock.reset_mock怎么用?Python PropertyMock.reset_mock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.PropertyMock
的用法示例。
在下文中一共展示了PropertyMock.reset_mock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_change_xrange
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import reset_mock [as 别名]
def test_change_xrange(self):
view_x_range_mock = PropertyMock()
type(self.view).x_range = view_x_range_mock
model_x_range_mock = PropertyMock(return_value=(1, 5))
type(self.model).x_range = model_x_range_mock
# passed model -> view
self.presenter1 = SlicePlotOptionsPresenter(self.view, self.model)
model_x_range_mock.assert_called_with()
view_x_range_mock.assert_called_once_with((1, 5))
# passed view -> model through slice presenter
model_x_range_mock.reset_mock()
view_x_range_mock.return_value = (2, 10)
self.presenter1._xy_config_modified('x_range')
self.presenter1.get_new_config()
model_x_range_mock.assert_called_once_with((2, 10))
# passed view -> model through cut presenter
self.presenter2 = CutPlotOptionsPresenter(self.view, self.model)
self.presenter2._xy_config_modified('x_range')
self.presenter2.get_new_config()
self.model.change_axis_scale.assert_called_once()
示例2: test_change_grid
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import reset_mock [as 别名]
def test_change_grid(self):
view_x_grid_mock = PropertyMock()
view_y_grid_mock = PropertyMock()
model_x_grid_mock = PropertyMock(return_value=False)
model_y_grid_mock = PropertyMock(return_value=False)
type(self.view).x_grid = view_x_grid_mock
type(self.view).y_grid = view_y_grid_mock
type(self.model).x_grid = model_x_grid_mock
type(self.model).y_grid = model_y_grid_mock
# labels passed model -> view
self.presenter = SlicePlotOptionsPresenter(self.view, self.model)
model_x_grid_mock.assert_called_once_with()
model_y_grid_mock.assert_called_once_with()
view_x_grid_mock.assert_called_once_with(False)
view_y_grid_mock.assert_called_once_with(False)
# labels passed view -> model
model_x_grid_mock.reset_mock()
model_y_grid_mock.reset_mock()
view_x_grid_mock.reset_mock()
view_y_grid_mock.reset_mock()
view_x_grid_mock.return_value = True
view_y_grid_mock.return_value = True
self.presenter._value_modified('x_grid')
self.presenter._value_modified('y_grid')
self.presenter.get_new_config()
view_x_grid_mock.assert_called_once_with()
view_y_grid_mock.assert_called_once_with()
model_x_grid_mock.assert_called_once_with(True)
model_y_grid_mock.assert_called_once_with(True)
示例3: test_change_axis
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import reset_mock [as 别名]
def test_change_axis(self):
view_x_label_mock = PropertyMock()
view_y_label_mock = PropertyMock()
model_x_label_mock = PropertyMock(return_value='x0')
model_y_label_mock = PropertyMock(return_value='y0')
type(self.view).x_label = view_x_label_mock
type(self.view).y_label = view_y_label_mock
type(self.model).x_label = model_x_label_mock
type(self.model).y_label = model_y_label_mock
# labels passed model -> view
self.presenter = SlicePlotOptionsPresenter(self.view, self.model)
model_x_label_mock.assert_called_once_with()
model_y_label_mock.assert_called_once_with()
view_x_label_mock.assert_called_once_with('x0')
view_y_label_mock.assert_called_once_with('y0')
# labels passed view -> model
model_x_label_mock.reset_mock()
model_y_label_mock.reset_mock()
view_x_label_mock.reset_mock()
view_y_label_mock.reset_mock()
view_x_label_mock.return_value = 'x1'
view_y_label_mock.return_value = 'y1'
self.presenter._value_modified('x_label')
self.presenter._value_modified('y_label')
self.presenter.get_new_config()
view_x_label_mock.assert_called_once_with()
view_y_label_mock.assert_called_once_with()
model_x_label_mock.assert_called_once_with('x1')
model_y_label_mock.assert_called_once_with('y1')
示例4: test_change_title
# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import reset_mock [as 别名]
def test_change_title(self):
mock_view_title = PropertyMock()
type(self.view).title = mock_view_title
mock_model_title = PropertyMock(return_value='Title 0')
type(self.model).title = mock_model_title
# title passed model -> view
self.presenter = CutPlotOptionsPresenter(self.view, self.model)
mock_model_title.assert_called_once_with()
mock_view_title.assert_called_once_with('Title 0')
# title passed view -> model
mock_view_title.reset_mock()
mock_model_title.reset_mock()
mock_view_title.return_value = 'Title 1'
self.presenter._value_modified('title')
self.presenter.get_new_config()
mock_view_title.assert_called_once_with()
mock_model_title.assert_called_once_with('Title 1')