def assert_deprecated(self, function, num=<NUM_LIT:1>, ignore_others=False,<EOL>function_fails=False,<EOL>exceptions=(DeprecationWarning,), args=(), kwargs={}):
<EOL>self.log[:] = []<EOL>try:<EOL><INDENT>function(*args, **kwargs)<EOL><DEDENT>except (Exception if function_fails else tuple()):<EOL><INDENT>pass<EOL><DEDENT>num_found = <NUM_LIT:0><EOL>for warning in self.log:<EOL><INDENT>if warning.category is DeprecationWarning:<EOL><INDENT>num_found += <NUM_LIT:1><EOL><DEDENT>elif not ignore_others:<EOL><INDENT>raise AssertionError("<STR_LIT>"<EOL>% warning.category)<EOL><DEDENT><DEDENT>if num is not None and num_found != num:<EOL><INDENT>raise AssertionError("<STR_LIT>"<EOL>% (len(self.log), num))<EOL><DEDENT>with warnings.catch_warnings():<EOL><INDENT>warnings.filterwarnings("<STR_LIT:error>", message=self.message,<EOL>category=DeprecationWarning)<EOL>try:<EOL><INDENT>function(*args, **kwargs)<EOL>if exceptions != tuple():<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT><DEDENT>except exceptions:<EOL><INDENT>if exceptions == tuple():<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>
Test if DeprecationWarnings are given and raised.

        This first checks if the function when called gives `num`
        DeprecationWarnings, after that it tries to raise these
        DeprecationWarnings and compares them with `exceptions`.
        The exceptions can be different for cases where this code path
        is simply not anticipated and the exception is replaced.

        Parameters
        ----------
        f : callable
            The function to test
        num : int
            Number of DeprecationWarnings to expect. This should normally be 1.
        ignore_other : bool
            Whether warnings of the wrong type should be ignored (note that
            the message is not checked)
        function_fails : bool
            If the function would normally fail, setting this will check for
            warnings inside a try/except block.
        exceptions : Exception or tuple of Exceptions
            Exception to expect when turning the warnings into an error.
            The default checks for DeprecationWarnings. If exceptions is
            empty the function is expected to run successfull.
        args : tuple
            Arguments for `f`
        kwargs : dict
            Keyword arguments for `f`