当前位置: 首页>>代码示例>>Python>>正文


Python PropertyMock.assert_not_called方法代码示例

本文整理汇总了Python中mock.PropertyMock.assert_not_called方法的典型用法代码示例。如果您正苦于以下问题:Python PropertyMock.assert_not_called方法的具体用法?Python PropertyMock.assert_not_called怎么用?Python PropertyMock.assert_not_called使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock.PropertyMock的用法示例。


在下文中一共展示了PropertyMock.assert_not_called方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test__disable_events__specific_names

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_not_called [as 别名]
    def test__disable_events__specific_names(self, mock_events):
        """Test disabling specific events."""
        mock_event1 = MagicMock(spec=HoudiniEvent)

        mock_enabled1 = PropertyMock(return_value=True)
        type(mock_event1).enabled = mock_enabled1

        mock_event2 = MagicMock(spec=HoudiniEvent)

        mock_enabled2 = PropertyMock(return_value=True)
        type(mock_event2).enabled = mock_enabled2

        mock_events.return_value = {
            mock_event1.name: mock_event1,
            mock_event2.name: mock_event2,
        }

        manager = ht.events.manager.HoudiniEventManager()
        manager._event_states = {}

        manager._disable_events(names=[mock_event2.name])

        # Event 1's enabled property should not have been accessed.
        mock_enabled1.assert_not_called()

        # Event 2's should have been accessed to get the current value
        # and once to disable it.
        mock_enabled2.assert_has_calls([call(), call(False)])

        self.assertTrue(manager._event_states[mock_event2.name])
        self.assertEqual(len(manager._event_states), 1)
开发者ID:captainhammy,项目名称:Houdini-Toolbox,代码行数:33,代码来源:test_manager.py


注:本文中的mock.PropertyMock.assert_not_called方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。