Exemplo n.º 1
0
def test_log_time(caplog):
    caplog.clear()
    func = log_time(sleeping_identity)
    res = func(1)

    logger_name, severity, message = caplog.record_tuples[0]
    assert res == 1
    assert logger_name == "kedro.pipeline.decorators"
    assert severity == logging.INFO
    expected = (
        f"Running '{sleeping_identity.__module__}.{sleeping_identity.__qualname__}' "
        f"took")
    assert expected in message
Exemplo n.º 2
0
def test_log_time_no_module(caplog):
    """When func module is not defined, function full name is not logged."""
    def no_module(arg):
        return sleeping_identity(arg)

    no_module.__module__ = None

    caplog.clear()
    func = log_time(no_module)
    res = func(1)

    logger_name, severity, message = caplog.record_tuples[0]
    assert res == 1
    assert logger_name == "kedro.pipeline.decorators"
    assert severity == logging.INFO
    expected = f"Running {no_module.__qualname__!r} took"
    assert expected in message