import testutils
+#: Unless an opcode is included in the following list it must have a result
+#: check of some sort
+MISSING_RESULT_CHECK = frozenset([
+ opcodes.OpBackupExport,
+ opcodes.OpBackupQuery,
+ opcodes.OpBackupRemove,
+ opcodes.OpClusterQuery,
+ opcodes.OpGroupQuery,
+ opcodes.OpInstanceQuery,
+ opcodes.OpInstanceQueryData,
+ opcodes.OpNodeQuery,
+ opcodes.OpNodeQueryStorage,
+ opcodes.OpOsDiagnose,
+ opcodes.OpQuery,
+ opcodes.OpQueryFields,
+ opcodes.OpTagsDel,
+ opcodes.OpTagsGet,
+ opcodes.OpTagsSearch,
+ opcodes.OpTagsSet,
+ opcodes.OpTestAllocator,
+ opcodes.OpTestDelay,
+ opcodes.OpTestDummy,
+ opcodes.OpTestJqueue,
+ ])
+
+
class TestOpcodes(unittest.TestCase):
def test(self):
self.assertRaises(ValueError, opcodes.OpCode.LoadOpCode, None)
self.assertEqual(cls.OP_ID, opcodes._NameToId(cls.__name__))
self.assertFalse(compat.any(cls.OP_ID.startswith(prefix)
for prefix in opcodes._SUMMARY_PREFIX.keys()))
- self.assertTrue(cls.OP_RESULT is None or callable(cls.OP_RESULT))
+ if cls in MISSING_RESULT_CHECK:
+ self.assertTrue(cls.OP_RESULT is None,
+ msg=("%s is listed to not have a result check" %
+ cls.OP_ID))
+ else:
+ self.assertTrue(callable(cls.OP_RESULT),
+ msg=("%s should have a result check" % cls.OP_ID))
self.assertRaises(TypeError, cls, unsupported_parameter="some value")