def __exit__(self, exc_type, exc_value, tb):
        self.warnings_manager.__exit__(exc_type, exc_value, tb)
        if exc_type is not None:
            # let unexpected exceptions pass through
            return
        try:
            exc_name = self.expected.__name__
        except __HOLE__:
            exc_name = str(self.expected)
        first_matching = None
        for m in self.warnings:
            w = m.message
            if not isinstance(w, self.expected):
                continue
            if first_matching is None:
                first_matching = w
            if (self.expected_regex is not None and
                    not self.expected_regex.search(str(w))):
                continue
            # store warning for later retrieval
            self.warning = w
            self.filename = m.filename
            self.lineno = m.lineno
            return
        # Now we simply try to choose a helpful failure message
        if first_matching is not None:
            raise self.failureException(
                '%r does not match %r'
                % (self.expected_regex.pattern, str(first_matching)))
        if self.obj_name:
            raise self.failureException('%s not triggered by %s'
                                        % (exc_name, self.obj_name))
        else:
            raise self.failureException('%s not triggered'
                                        % exc_name)
dataset/ETHPy150Open celery/cell/cell/tests/utils.py/_AssertWarnsContext.__exit__