'Make sure the specified module, when imported, raises a
DeprecationWarning and specifies itself in the message.'

def check_removal(self, module_name, optional=False):

    if (module_name in sys.modules):
        mod = sys.modules[module_name]
        filename = getattr(mod, '__file__', '')
        mod = None
        if (not filename.endswith(('.py', '.pyc', '.pyo'))):
            if test_support.verbose:
                print ('Cannot    test    the    Python    3    DeprecationWarning    of    the    %s    module,    the    C    module    is    already    loaded' % module_name)
            return
    with CleanImport(module_name):
        with warnings.catch_warnings():
            warnings.filterwarnings('error', '.+    (module|package)    .+    removed', DeprecationWarning, __name__)
            warnings.filterwarnings('error', '.+    removed    .+    (module|package)', DeprecationWarning, __name__)
            try:
                __import__(module_name, level=0)
            except DeprecationWarning as exc:
                self.assertIn(module_name, exc.args[0], ("%s    warning    didn't    contain    module    name" % module_name))
            except ImportError:
                if (not optional):
                    self.fail('Non-optional    module    {0}    raised    an    ImportError.'.format(module_name))
            else:
                if (not check_deprecated_module(module_name)):
                    self.fail('DeprecationWarning    not    raised    for    {0}'.format(module_name))
