#NEWLINE# def test_eq_ineq_error_messages( self ) : #NEWLINE# #INDENT# prob = Problem ( ) #NEWLINE# root = prob . root = SellarDerivatives ( ) #NEWLINE# prob . driver = MySimpleDriver ( ) #NEWLINE# with self . assertRaises ( RuntimeError ) as cm : #NEWLINE# #INDENT# prob . driver . add_constraint ( 'con1' ) #NEWLINE# #UNINDENT# self . assertEqual ( str ( cm . exception ) , "Constraint 'con1' needs to define lower, upper, or equals." ) #NEWLINE# with self . assertRaises ( RuntimeError ) as cm : #NEWLINE# #INDENT# prob . driver . add_constraint ( 'con1' , lower = 0.0 , upper = 1.1 , equals = 2.2 ) #NEWLINE# #UNINDENT# self . assertEqual ( str ( cm . exception ) , "Constraint 'con1' cannot be both equality and inequality." ) #NEWLINE# prob . driver . supports [ 'two_sided_constraints' ] = False #NEWLINE# with self . assertRaises ( RuntimeError ) as cm : #NEWLINE# #INDENT# prob . driver . add_constraint ( 'con1' , lower = 0.0 , upper = 1.1 ) #NEWLINE# #UNINDENT# self . assertEqual ( str ( cm . exception ) , "Driver does not support 2-sided constraint 'con1'." ) #NEWLINE# prob . driver . supports [ 'equality_constraints' ] = False #NEWLINE# with self . assertRaises ( RuntimeError ) as cm : #NEWLINE# #INDENT# prob . driver . add_constraint ( 'con1' , equals = 0.0 ) #NEWLINE# #UNINDENT# self . assertEqual ( str ( cm . exception ) , "Driver does not support equality constraint 'con1'." ) #NEWLINE# prob . driver . supports [ 'inequality_constraints' ] = False #NEWLINE# with self . assertRaises ( RuntimeError ) as cm : #NEWLINE# #INDENT# prob . driver . add_constraint ( 'con1' , upper = 0.0 ) #NEWLINE# #UNINDENT# self . assertEqual ( str ( cm . exception ) , "Driver does not support inequality constraint 'con1'." )