示例#1
0
def benchmark_screenshot():
    client = cast.not_none(DMMClient.find())

    run_count = 10
    print_window = (
        timeit.timeit(
            lambda: screenshot_print_window(client.h_wnd),
            number=run_count,
        )
        / run_count
    )
    pil_crop = (
        timeit.timeit(
            lambda: screenshot_pil_crop(client.h_wnd),
            number=run_count,
        )
        / run_count
    )

    print("pil_crop: %.4f print_window: %.4f" % (pil_crop, print_window))
def test_not_none_with_default():
    assert cast.not_none(1, 2) == 1
def test_not_none():
    assert cast.not_none(1) == 1
def test_none_with_default():
    assert cast.not_none(None, 1) == 1
def test_none():
    with pytest.raises(CastError):
        cast.not_none(None)