コード例 #1
0
def test_build_show_options_w_missing_ini_props():
    final_options = build_show_options()
    assert final_options["allow_cell_edits"]

    options = dict(allow_cell_edits=False)
    final_options = build_show_options(options)
    assert not final_options["allow_cell_edits"]

    ini_path = os.path.join(os.path.dirname(__file__), "dtale_missing_props.ini")
    os.environ["DTALE_CONFIG"] = ini_path
    final_options = build_show_options()
    assert final_options["allow_cell_edits"]

    final_options = build_show_options(options)
    assert not final_options["allow_cell_edits"]

    del os.environ["DTALE_CONFIG"]

    set_config(ini_path)
    final_options = build_show_options()
    assert final_options["allow_cell_edits"]

    set_config(None)
    final_options = build_show_options(options)
    assert not final_options["allow_cell_edits"]
コード例 #2
0
def test_build_show_options(unittest):
    final_options = build_show_options()
    assert final_options["allow_cell_edits"]

    options = dict(allow_cell_edits=False)
    final_options = build_show_options(options)
    assert not final_options["allow_cell_edits"]

    ini_path = os.path.join(os.path.dirname(__file__), "dtale.ini")
    os.environ["DTALE_CONFIG"] = ini_path
    final_options = build_show_options()
    assert final_options["allow_cell_edits"]
    assert final_options["precision"] == 6
    unittest.assertEqual(final_options["show_columns"], ["a", "b"])
    unittest.assertEqual(final_options["hide_columns"], ["c"])
    unittest.assertEqual(
        final_options["column_formats"], {"a": {"fmt": {"html": True}}}
    )
    unittest.assertEqual(final_options["sort"], [("a", "ASC")])
    unittest.assertEqual(final_options["locked"], ["a", "b"])

    final_options = build_show_options(options)
    assert not final_options["allow_cell_edits"]

    del os.environ["DTALE_CONFIG"]

    set_config(ini_path)
    final_options = build_show_options()
    assert final_options["allow_cell_edits"]

    set_config(None)
    final_options = build_show_options(options)
    assert not final_options["allow_cell_edits"]