test_StateMachineDevice.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:lewis 作者: DMSC-Instrument-Data 项目源码 文件源码
def test_not_implemented_errors(self):
        # Construction of the base class should not be possible
        self.assertRaises(NotImplementedError, StateMachineDevice)

        mandatory_methods = {
            '_get_state_handlers': Mock(return_value={'test': MagicMock()}),
            '_get_initial_state': Mock(return_value='test'),
            '_get_transition_handlers': Mock(
                return_value={('test', 'test'): Mock(return_value=True)})
        }

        # If any of the mandatory methods is missing, a NotImplementedError must be raised
        for methods in itertools.combinations(mandatory_methods.items(), 2):
            with patch.multiple('lewis.devices.StateMachineDevice', **dict(methods)):
                self.assertRaises(NotImplementedError, StateMachineDevice)

        # If all are implemented, no exception should be raised
        with patch.multiple('lewis.devices.StateMachineDevice', **mandatory_methods):
            assertRaisesNothing(self, StateMachineDevice)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号