import importlib


def has_module (name):
    """Test if given module can be imported.
    @return: flag if import is successful
    @rtype: bool
    """
    try:
        importlib.import_module(name)
        return True
    except (OSError, ImportError):
        # some modules (for example HTMLtidy) raise OSError
        return False