def add(self, elem, replace=False):
        """Add a requirement.

        :param elem: a string or :class:`Requirement` instance.
        :param replace: if `True`, packages in the set with the same name will
            be removed first.
        """
        if isinstance(elem, text_type):
            elem = Requirement.coerce(elem)
        if replace and elem in self:
            self.remove(elem)
        super(Requirements, self).add(elem)
def test_config_errors(self):
        Session = scoped_session(sa.orm.sessionmaker())

        s = Session()  # noqa
        assert_raises_message(
            sa.exc.InvalidRequestError,
            "Scoped session is already present",
            Session,
            bind=testing.db,
        )

        assert_warns_message(
            sa.exc.SAWarning,
            "At least one scoped session is already present. ",
            Session.configure,
            bind=testing.db,
        )