def _print_phantomjs_output(result): errors = result['errors'] messages = result['messages'] resources = result['resources'] for message in messages: msg = message['msg'] line = message.get('line') source = message.get('source') if source is None: write(msg) elif line is None: write("%s: %s" % (source, msg)) else: write("%s:%s: %s" % (source, line, msg)) # Process resources for resource in resources: url = resource['url'] if url.endswith(".png"): ok("%s: %s (%s)" % (url, yellow(resource['status']), resource['statusText'])) else: warn("Resource error:: %s: %s (%s)" % (url, red(resource['status']), resource['statusText'])) # You can have a successful test, and still have errors reported, so not failing here. for error in errors: warn("%s: %s" % (red("PhatomJS Error: "), error['msg'])) for item in error['trace']: write(" %s: %d" % (item['file'], item['line']))
def _assert_snapshot(example, url, example_type): screenshot_path = example.img_path height = 2000 if example_type == 'notebook' else 1000 wait = 30000 start = time.time() result = get_phantomjs_screenshot(url, screenshot_path, 1000, wait, 1000, height) end = time.time() info("Example rendered in %s" % white("%.3fs" % (end - start))) success = result['success'] timeout = result['timeout'] errors = result['errors'] resources = result['resources'] no_errors = len(errors) == 0 no_resources = len(resources) == 0 if timeout: warn("%s: %s" % (red("TIMEOUT: "), "bokehjs did not finish in %s ms" % wait)) if pytest.config.option.verbose: _print_phantomjs_output(result) assert success, "%s failed to load" % example.relpath assert no_resources, "%s failed with %d missing resources" % (example.relpath, len(resources)) assert no_errors, "%s failed with %d errors" % (example.relpath, len(errors))
def _assert_snapshot(example, url, example_type): screenshot_path = example.img_path height = 2000 if example_type == 'notebook' else 1000 wait = 30000 start = time.time() result = get_phantomjs_screenshot(url, screenshot_path, 1000, wait, 1000, height) end = time.time() info("Example rendered in %s" % white("%.3fs" % (end - start))) success = result['success'] timeout = result['timeout'] errors = result['errors'] resources = result['resources'] no_errors = len(errors) == 0 no_resources = len(resources) == 0 if timeout: warn("%s: %s" % (red("TIMEOUT: "), "bokehjs did not finish in %s ms" % wait)) if pytest.config.option.verbose: _print_phantomjs_output(result) assert success, "%s failed to load" % example.relpath assert no_resources, "%s failed with %d missing resources" % ( example.relpath, len(resources)) assert no_errors, "%s failed with %d errors" % (example.relpath, len(errors))
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))
def _print_phantomjs_output(result): errors = result['errors'] messages = result['messages'] resources = result['resources'] for message in messages: msg = message['msg'] line = message.get('line') source = message.get('source') if source and line: msg = "%s:%s: %s" % (source, line, msg) info(msg, label="JS") # Process resources for resource in resources: url = resource['url'] if url.endswith(".png"): ok("%s: %s (%s)" % (url, yellow(resource['status']), resource['statusText'])) else: fail("Resource error:: %s: %s (%s)" % (url, red(resource['status']), resource['statusText']), label="JS") # You can have a successful test, and still have errors reported, so not failing here. for error in errors: fail(error['msg'], label="JS") for item in error['trace']: file = item['file'] line = item['line'] if file and line: fail(" %s: %d" % (file, line), label="JS")