Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
 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")
Ejemplo n.º 3
0
 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')
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
 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"])
Ejemplo n.º 6
0
 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'])
Ejemplo n.º 7
0
 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")