def test_mount(capsys: CaptureFixture) -> None:
    basename = Path(__file__).name
    client.get(f"/static/{basename}")
    out, err = capsys.readouterr()
    assert err == ""
    assert out.startswith("TIMING:")
    assert out.endswith("StaticFiles<'static'>\n")
def test_timing(capsys: CaptureFixture) -> None:
    client.get("/timed")
    out, err = capsys.readouterr()
    assert err == ""
    assert out.startswith("TIMING: Wall")
    assert "CPU:" in out
    assert out.endswith("test_timing.get_timed\n")
async def test_repeat_print_wait(capsys: CaptureFixture) -> None:
    @repeat_every(seconds=0.07, max_repetitions=3, wait_first=0.1)
    async def repeatedly_print_hello() -> None:
        print("hello")

    await repeatedly_print_hello()
    await asyncio.sleep(0.15)
    out, err = capsys.readouterr()
    assert out == "hello\n" * 1
    assert err == ""
def test_intermediate(capsys: CaptureFixture) -> None:
    client2.get("/")
    out, err = capsys.readouterr()
    assert err == ""
    out = out.strip().split("\n")
    assert len(out) == 2
    assert out[0].startswith("TIMING:")
    assert out[0].endswith("test_timing.get_with_intermediate_timing (hello)")
    assert out[1].startswith("TIMING:")
    assert out[1].endswith("test_timing.get_with_intermediate_timing")
async def test_repeat_raise_error(caplog: LogCaptureFixture,
                                  capsys: CaptureFixture) -> None:
    logger = logging.getLogger(__name__)

    @repeat_every(seconds=0.07,
                  max_repetitions=None,
                  raise_exceptions=True,
                  logger=logger)
    def raise_exc() -> NoReturn:
        raise ValueError("repeat")

    await raise_exc()
    await asyncio.sleep(0.1)
    out, err = capsys.readouterr()
    assert out == ""
    assert err == ""
    record_tuples = [x for x in caplog.record_tuples if x[0] == __name__]
    print(caplog.record_tuples)
    assert len(record_tuples) == 1
def test_missing(capsys: CaptureFixture) -> None:
    client.get("/will-404")
    out, err = capsys.readouterr()
    assert err == ""
    assert out.startswith("TIMING:")
    assert out.endswith("<Path: /will-404>\n")
def test_silent_timing(capsys: CaptureFixture) -> None:
    client.get("/untimed")
    out, err = capsys.readouterr()
    assert err == ""
    assert out == ""