Beispiel #1
0
  def check_fig(fig, fixture_name):
    actual_path = os.path.join(TEST_TEMPDIR, 'actual_' + fixture_name)
    util.log.info("Saving actual plot to %s" % actual_path)
    pl.save_bokeh_fig(fig, actual_path, title=fixture_name)
    
    actual_png_path = actual_path.replace('html', 'png')
    util.log.info("Saving screenshot of plot to %s" % actual_png_path)
    from bokeh.io import export_png
    export_png(fig, actual_png_path)

    expected_path = get_fixture_path(fixture_name)
    expected_png_path = expected_path.replace('html', 'png')

    # Compare using PNGs because writing real selenium tests is too much effort
    # for the value at this time.  We tried comparing the raw HTML but bokeh
    # appears to write non-deterministically and/or includes timestamped
    # material.
    import imageio
    actual = imageio.imread(actual_png_path)
    expected = imageio.imread(expected_png_path)
    util.log.info('Comparing against expected at %s' % expected_png_path)

    np.testing.assert_array_equal(
      actual, expected,
      err_msg=(
        "Page mismatch, actual %s != expected %s, check HTML and PNGs" % (
          actual_path, expected_path)))
Beispiel #2
0
def test_spark_script_in_standalone_lib():
    # We must run this test in a subprocess in order for it to have an isolated
    # Spark session
    SCRIPT_PATH = testutil.get_fixture_path(
        'test_spark_script_in_standalone_lib.py')

    from oarphpy import util
    out = util.run_cmd(sys.executable + ' ' + SCRIPT_PATH, collect=True)
    assert b'test_spark_script_in_standalone_lib success!' in out
Beispiel #3
0
def test_spark_with_custom_library_in_notebook():
    pytest.importorskip("jupyter")

    import re
    from oarphpy import util

    NB_PATH = testutil.get_fixture_path(
        'test_spark_ships_custom_library_in_notebook.ipynb')

    # We need to fork off nbconvert to run the test
    TEST_CMD = """
    cd /tmp && 
    jupyter-nbconvert --ExecutePreprocessor.timeout=3600 \
      --to notebook --execute --output /tmp/out \
      {notebook_path}
  """.format(notebook_path=NB_PATH)
    out = util.run_cmd(TEST_CMD, collect=True)
    assert re.search('Writing .* bytes to /tmp/out.ipynb', out.decode())
Beispiel #4
0
def get_imagenet_fixture(fname):
    return testutil.get_fixture_path(os.path.join('images/imagenet', fname))