Esempio n. 1
0
def test_ma_schools():
  with session(MASCHOOLS_DIR):
    msglimit = None if pytest.config.option.verbose else 1000
    vn.run_and_verify_notebook(
      os.path.join(MASCHOOLS_DIR, "MASchoolDistricts"),
      msglimit=msglimit,
      required=[('schools2.quick_explore_vars\(\[',
                 [vn.allow_warns('matplotlib.*backend'),
                  vn.allow_warns('VisibleDeprecationWarning')]),
                ('ESTIMATE DEPENDENCE PROBABILITY',
                 [vn.assert_has_png(), vn.allow_warns('FutureWarning'),
                  vn.allow_warns('VisibleDeprecationWarning')]),
                ('schools0.quick_describe_variables()',
                 [r'categorical', vn.allow_warns(
                     'Invalid value encountered in percentile')]),
                ('schools1.quick_describe_variables()',
                 [r'categorical', vn.allow_warns(
                     'Invalid value encountered in percentile')]),
                # Once solved, this will not contain categorical, but as
                # set up to be solved, it does:
                ('schools2.quick_describe_variables()',
                 [r'categorical', vn.allow_warns(
                     'Invalid value encountered in percentile')]),
                # As set up, this should have "cannot convert" messages,
                # Not once it's solved though.
                ('df.applymap', [vn.assert_stream_matches('Cannot convert')]),
                (r'schools2.quick_explore_vars',
                 [vn.allow_warns('VisibleDeprecationWarning')])
                ])
Esempio n. 2
0
def test_index():
    os.chdir(INDEX_DIR)
    with session(INDEX_DIR):
        run_and_verify_notebook(os.path.join(INDEX_DIR, "Index"))
        optfile = os.path.join(INDEX_DIR, OPTFILE)
        assert os.path.exists(optfile)
        if 'DEBUG_TESTS' not in os.environ:
            with open(optfile, 'r') as opt:
                assert " <>\n" == opt.read()
Esempio n. 3
0
def test_index():
  os.chdir(INDEX_DIR)
  with session(INDEX_DIR):
    run_and_verify_notebook(os.path.join(INDEX_DIR, "Index"))
    optfile = os.path.join(INDEX_DIR, OPTFILE)
    assert os.path.exists(optfile)
    if 'DEBUG_TESTS' not in os.environ:
      with open(optfile, 'r') as opt:
        assert " <>\n" == opt.read()
Esempio n. 4
0
def test_index():
  os.chdir(INDEX_DIR)
  optfile = os.path.join(INDEX_DIR, 'bayesdb-session-capture-opt.txt')
  if 'DEBUG_TESTS' not in os.environ:
    if os.path.exists(optfile):
      os.remove(optfile)
  run_and_verify_notebook(os.path.join(INDEX_DIR, "Index"))
  assert os.path.exists(optfile), optfile
  with open(optfile, 'r') as opt:
    assert " <>\n" == opt.read()
Esempio n. 5
0
def test_satellites():
    with session(SATELLITES_DIR):
        if ("DEBUG_TESTS" not in os.environ or not os.path.exists(
                os.path.join(SATELLITES_DIR, "satellites.bdb"))):
            remove_bdb_files(SATELLITES_DIR)  # Just in case.
            rebuild_bdb(SATELLITES_DIR)
        msglimit = None if pytest.config.option.verbose else 1000
        run_and_verify_notebook(os.path.join(SATELLITES_DIR, "Satellites"),
                                exhaustive=EXPECTED,
                                msglimit=msglimit)
        if "DEBUG_TESTS" not in os.environ:
            remove_bdb_files(SATELLITES_DIR)
Esempio n. 6
0
def test_satellites():
  with session(SATELLITES_DIR):
    if ("DEBUG_TESTS" not in os.environ or
        not os.path.exists(os.path.join(SATELLITES_DIR, "satellites.bdb"))):
      remove_bdb_files(SATELLITES_DIR) # Just in case.
      rebuild_bdb(SATELLITES_DIR)
    msglimit = None if pytest.config.option.verbose else 1000
    run_and_verify_notebook(
      os.path.join(SATELLITES_DIR, "Satellites"),
      exhaustive=EXPECTED,
      msglimit=msglimit)
    if "DEBUG_TESTS" not in os.environ:
      remove_bdb_files(SATELLITES_DIR)
Esempio n. 7
0
def test_ma_schools():
  with session(PARENT_DIR):
    msglimit = None if pytest.config.option.verbose else 1000
    vn.run_and_verify_notebook(
      os.path.join(PARENT_DIR, "querying-and-plotting"),
      msglimit=msglimit,
      required=[('pairplot_vars\(', [vn.assert_has_png()]),
                ('pairplot\(', [vn.assert_has_png()]),
                ('barplot\(', [vn.assert_has_png()]),
                ('histogram\(', [vn.assert_has_png()]),
                ('heatmap\(', [vn.assert_has_png()]),
                ],
      warnings_are_errors=False)
Esempio n. 8
0
def test_ma_schools():
  do_not_track(MASCHOOLS_DIR)
  msglimit = None if pytest.config.option.verbose else 1000
  vn.run_and_verify_notebook(
      os.path.join(MASCHOOLS_DIR, "MASchoolDistricts"),
      msglimit=msglimit,
      required=[('schools2.quick_explore_vars\(\[',
                 [vn.assert_warns('matplotlib.*backend')]),
                ('schools0.quick_describe_columns()', [r'categorical']),
                ('schools1.quick_describe_columns()', [r'categorical']),
                # Once solved, this will not contain categorical, but as
                # set up to be solved, it does:
                ('schools2.quick_describe_columns()', [r'categorical']),
                # As set up, this should have "cannot convert" messages,
                # Not once it's solved though.
                ('df.applymap', [vn.assert_stream_matches('Cannot convert')]),
                ])