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)
test_StateMachineDevice.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录