本文整理汇总了Python中tests.functional.MagicMock.tab_title方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.tab_title方法的具体用法?Python MagicMock.tab_title怎么用?Python MagicMock.tab_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.functional.MagicMock
的用法示例。
在下文中一共展示了MagicMock.tab_title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insert_tab_not_visible_test
# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import tab_title [as 别名]
def insert_tab_not_visible_test(self):
"""
Test that the insert_tab() method works correctly when a tab that should not be visible is inserted
"""
# GIVEN: A general tab and a Settings Form
settings_form = SettingsForm(None)
general_tab = MagicMock()
general_tab.tab_title = 'mock'
# WHEN: We insert the general tab
with patch.object(settings_form.stacked_layout, 'addWidget') as mocked_add_widget, \
patch.object(settings_form.setting_list_widget, 'addItem') as mocked_add_item:
settings_form.insert_tab(general_tab, is_visible=False)
# THEN: The general tab should have been inserted, but no list item should have been inserted into the list
mocked_add_widget.assert_called_with(general_tab)
self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called')
示例2: insert_tab_visible_test
# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import tab_title [as 别名]
def insert_tab_visible_test(self):
"""
Test that the insert_tab() method works correctly when a visible tab is inserted
"""
# GIVEN: A mocked tab and a Settings Form
settings_form = SettingsForm(None)
general_tab = MagicMock()
general_tab.tab_title = 'mock'
general_tab.tab_title_visible = 'Mock'
general_tab.icon_path = ':/icon/openlp-logo-16x16.png'
# WHEN: We insert the general tab
with patch.object(settings_form.stacked_layout, 'addWidget') as mocked_add_widget, \
patch.object(settings_form.setting_list_widget, 'addItem') as mocked_add_item:
settings_form.insert_tab(general_tab, is_visible=True)
# THEN: The general tab should have been inserted into the stacked layout and an item inserted into the list
mocked_add_widget.assert_called_with(general_tab)
self.assertEqual(1, mocked_add_item.call_count, 'addItem should have been called')