def METHOD_NAME(module):
    """Hook function registered for the pytest module."""
    @decorator.decorator
    def _fixture_func_decorator(fixture_func, *args, **kargs):
        logging.info("-" * 20 + (" fixture %s setup starts " % fixture_func.__name__) + "-" * 20)
        try:
            return fixture_func(*args, **kargs)
        except Exception as detail:
            logging.exception("\n%r", detail)
            raise
        finally:
            logging.info("-" * 20 + (" fixture %s setup ends " % fixture_func.__name__) + "-" * 20)
    @decorator.decorator
    def _fixture_generator_decorator(fixture_generator, *args, **kargs):
        # setup, to the first yield in fixture
        logging.info("-" * 20 + (" fixture %s setup starts " % fixture_generator.__name__) + "-" * 20)
        it = fixture_generator(*args, **kargs)
        try:
            res = next(it)
            logging.info("-" * 20 + (" fixture %s setup ends " % fixture_generator.__name__) + "-" * 20)
            yield res
        except Exception as detail:
            logging.exception("\n%r", detail)
            logging.info("-" * 20 + (" fixture %s setup ends " % fixture_generator.__name__) + "-" * 20)
            raise
        # teardown, fixture will raise StopIteration
        logging.info("-" * 20 + (" fixture %s teardown starts " % fixture_generator.__name__) + "-" * 20)
        try:
            next(it)
        except StopIteration:
            return
        except Exception as detail:
            logging.exception("\n%r", detail)
            raise
        finally:
            logging.info("-" * 20 + (" fixture %s teardown ends " % fixture_generator.__name__) + "-" * 20)
    def build_custom_fixture_decorator(original_fixture):
        def _fixture(*args, **kargs):
            """Decorator to replace the original pytest.fixture."""
            def _decorate(func):
                if inspect.isgeneratorfunction(func):
                    return original_fixture(*args, **kargs)(_fixture_generator_decorator(func))
                else:
                    return original_fixture(*args, **kargs)(_fixture_func_decorator(func))
            # check if the pytest.fixture is directly called
            func = None
            if len(args) == 1 and callable(args[0]) and not kargs:
                func = args[0]
            elif len(kargs) == 1 and callable(list(kargs.values())[0]) and not args:
                func = list(kargs.values())[0]
            if func is not None:
                args = ()
                kargs = {}
                return _decorate(func)
            return _decorate
        return _fixture
    original_fixture = getattr(module, "fixture")
    setattr(module, "fixture", build_custom_fixture_decorator(original_fixture))