def _check_eq_add_constraint(self, drv):
        self.asm.add('driver', drv)

        self.assertEqual(len(drv.get_eq_constraints()), 0)
        self.assertEqual(len(drv.get_eq_constraints()), 0)
        drv.add_constraint('comp1.c =      comp1.d ')
        self.assertEqual(len(drv.get_eq_constraints()), 1)

        try:
            drv.add_constraint('comp1.c=comp1.d')
        except Exception as err:
            self.assertEqual(str(err),
                             'driver: A constraint of the form "comp1.c=comp1.d" already exists '
                             'in the driver. Add failed.')
        else:
            self.fail("Exception Expected")

        drv.remove_constraint(' comp1.c=comp1.d')
        self.assertEqual(len(drv.get_eq_constraints()), 0)
        try:
            drv.remove_constraint('comp1.bogus = comp1.d')
        except Exception as err:
            self.assertEqual(str(err),
                "driver: Constraint 'comp1.bogus=comp1.d' was not found. Remove failed.")
        else:
            self.fail("Exception expected")
        self.assertEqual(len(drv.get_eq_constraints()), 0)

        drv.add_constraint('comp1.c =comp1.d ')
        self.assertEqual(len(drv.get_eq_constraints()), 1)

        drv.add_constraint('comp1.b = comp1.c', name='foobar')
        self.assertEqual(len(drv.get_eq_constraints()), 2)

        try:
            drv.add_constraint('comp1.b = comp1.a', name='foobar')
        except Exception as err:
            self.assertEqual(str(err), 'driver: A constraint named "foobar" already exists in the driver. Add failed.')
        else:
            self.fail("Exception expected")

        drv.remove_constraint('foobar')
        self.assertEqual(len(drv.get_eq_constraints()), 1)

        drv.clear_constraints()

        self.assertEqual(len(drv.get_eq_constraints()), 0)
        try:
            drv.add_constraint('comp1.qq = comp1.b')
        except __HOLE__ as err:
            self.assertEqual(str(err),
               "Left hand side of constraint 'comp1.qq = comp1.b' has invalid variables 'comp1.qq'")
        else:
            self.fail('expected ValueError')
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/test/test_hasconstraints.py/HasConstraintsTestCase._check_eq_add_constraint