def _run_in_browser(example, url, report, verbose=False):
    start = time.time()
    result = run_in_chrome(url)
    end = time.time()

    info("Example rendered in %s" % white("%.3fs" % (end - start)))

    success = result["success"]
    timeout = result["timeout"]
    errors = result["errors"]

    image = result["image"]
    example.store_img(image["data"])
    report.append(example)

    no_errors = len(errors) == 0

    if timeout:
        warn("%s %s" % (red("TIMEOUT:"), "bokehjs did not finish"))

    if verbose:
        _print_webengine_output(result)

    assert success, "%s failed to load" % example.relpath

    assert no_errors, "%s failed with %d errors" % (example.relpath,
                                                    len(errors))
Beispiel #2
0
def _assert_snapshot(example, url, example_type):
    screenshot_path = example.img_path

    width = 1000
    height = 2000 if example_type == 'notebook' else 1000

    local_wait = 100
    global_wait = 15000

    start = time.time()
    result = get_screenshot(url, screenshot_path, local_wait, global_wait,
                            width, height)
    end = time.time()

    info("Example rendered in %s" % white("%.3fs" % (end - start)))

    success = result['success']
    timeout = result['timeout']
    errors = result['errors']

    no_errors = len(errors) == 0

    if timeout:
        warn(
            "%s %s" %
            (red("TIMEOUT:"), "bokehjs did not finish in %s ms" % global_wait))

    if pytest.config.option.verbose:
        _print_webengine_output(result)

    assert success, "%s failed to load" % example.relpath
    assert no_errors, "%s failed with %d errors" % (example.relpath,
                                                    len(errors))
Beispiel #3
0
def _run_in_browser(example, url, verbose=False):
    start = time.time()
    result = run_in_chrome(url)
    end = time.time()

    info("Example rendered in %s" % white("%.3fs" % (end - start)))

    success = result["success"]
    timeout = result["timeout"]
    errors = result["errors"]
    state = result["state"]
    image = result["image"]

    no_errors = len(errors) == 0

    if timeout:
        warn("%s %s" % (red("TIMEOUT:"), "bokehjs did not finish"))

    if verbose:
        _print_webengine_output(result)

    assert success, "%s failed to load" % example.relpath

    has_image = image is not None
    has_state = state is not None
    has_baseline = example.has_baseline
    baseline_ok = True

    if not has_state:
        fail("no state data was produced for comparison with the baseline")
    else:
        new_baseline = _create_baseline(state)
        example.store_baseline(new_baseline)

        if not has_baseline:
            fail("%s baseline doesn't exist" % example.baseline_path)
        else:
            result = example.diff_baseline()

            if result is not None:
                baseline_ok = False
                fail("BASELINE DOESN'T MATCH (make sure to update baselines before running tests):")

                for line in result.split("\n"):
                    fail(line)

    example.store_img(image["data"])

    if example.no_diff:
        warn("skipping image diff for %s" % example.relpath)
    elif not has_image:
        fail("no image data was produced for comparison with the reference image")

    assert no_errors, "%s failed with %d errors" % (example.relpath, len(errors))
    assert has_state, "%s didn't produce state data" % example.relpath
    assert has_baseline, "%s doesn't have a baseline" % example.relpath
    assert baseline_ok, "%s's baseline differs" % example.relpath
Beispiel #4
0
def _run_in_browser(example, url):
    start = time.time()
    result = run_in_chrome(url)
    end = time.time()

    info("Example rendered in %s" % white("%.3fs" % (end - start)))

    success = result["success"]
    timeout = result["timeout"]
    errors = result["errors"]
    image = result["image"]

    _store_binary(example.img_path, b64decode(image["data"]))

    no_errors = len(errors) == 0

    if timeout:
        warn("%s %s" % (red("TIMEOUT:"), "bokehjs did not finish"))

    if pytest.config.option.verbose:
        _print_webengine_output(result)

    assert success, "%s failed to load" % example.relpath
    assert no_errors, "%s failed with %d errors" % (example.relpath, len(errors))
Beispiel #5
0
def _run_in_browser(example, url, verbose=False):
    start = time.time()
    result = run_in_chrome(url)
    end = time.time()

    info("Example rendered in %s" % white("%.3fs" % (end - start)))

    success = result["success"]
    timeout = result["timeout"]
    errors = result["errors"]
    state = result["state"]
    image = result["image"]

    no_errors = len(errors) == 0

    if timeout:
        warn("%s %s" % (red("TIMEOUT:"), "bokehjs did not finish"))

    if verbose:
        _print_webengine_output(result)

    assert success, "%s failed to load" % example.relpath

    has_image = image is not None
    has_state = state is not None
    has_baseline = example.has_baseline
    baseline_ok = True

    if not has_state:
        fail("no state data was produced for comparison with the baseline")
    else:
        new_baseline = _create_baseline(state)
        example.store_baseline(new_baseline)

        if not has_baseline:
            fail("%s baseline doesn't exist" % example.baseline_path)
        else:
            result = example.diff_baseline()

            if result is not None:
                baseline_ok = False
                fail("BASELINE DOESN'T MATCH (make sure to update baselines before running tests):")

                for line in result.split("\n"):
                    fail(line)

    example.store_img(image["data"])
    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)

    if example.no_diff:
        warn("skipping image diff for %s" % example.relpath)
    elif not has_image:
        fail("no image data was produced for comparison with the reference image")
    elif ref:
        pixels = example.image_diff()
        if pixels != 0:
            comment = white("%.02f%%" % pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")

    assert no_errors, "%s failed with %d errors" % (example.relpath, len(errors))
    assert has_state, "%s didn't produce state data" % example.relpath
    assert has_baseline, "%s doesn't have a baseline" % example.relpath
    assert baseline_ok, "%s's baseline differs" % example.relpath