def test_warning(self): """Warning error (message with variable)""" pass_ = Error(msg="a {variable}", action="warn") pass_.property_set["variable"] = "message" with self.assertWarns(Warning) as warn: pass_.run(None) self.assertEqual(warn.warning.args[-1], "a message")
def test_raise(self): """Raise error with a message with variables""" pass_ = Error(msg="a {variable}", action="raise") pass_.property_set["variable"] = "message" with self.assertRaises(TranspilerError) as excep: pass_.run(None) self.assertEqual(excep.exception.message, "a message")
def test_warning(self): """Warning error (message with variable)""" pass_ = Error(msg='a {variable}', action='warn') pass_.property_set['variable'] = 'message' with self.assertWarns(Warning) as warn: pass_.run(None) self.assertEqual(warn.warning.args[-1], 'a message')
def test_raise(self): """Raise error with a message with variables""" pass_ = Error(msg='a {variable}', action='raise') pass_.property_set['variable'] = 'message' with self.assertRaises(TranspilerError) as excep: pass_.run(None) self.assertEqual(excep.exception.message, 'a message')
def test_logger(self): """Logger error (message with variable)""" pass_ = Error(msg="a {variable}", action="log") pass_.property_set["variable"] = "message" with self.assertLogs("qiskit.transpiler.passes.utils.error", level="INFO") as log: pass_.run(None) self.assertEqual( log.output, ["INFO:qiskit.transpiler.passes.utils.error:a message"])
def test_logger(self): """Logger error (message with variable)""" pass_ = Error(msg='a {variable}', action='log') pass_.property_set['variable'] = 'message' with self.assertLogs('qiskit.transpiler.passes.utils.error', level='INFO') as log: pass_.run(None) self.assertEqual( log.output, ['INFO:qiskit.transpiler.passes.utils.error:a message'])
def test_default(self): """Raise error with a message (default)""" pass_ = Error(msg="a message") with self.assertRaises(TranspilerError) as excep: pass_.run(None) self.assertEqual(excep.exception.message, "a message")