Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cached_example for test_everest_entry #9658

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions tests/everest/functional/test_main_everest_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from everest.config import EverestConfig, ServerConfig
from everest.detached import ServerStatus, everserver_status

CONFIG_FILE_MINIMAL = "config_minimal.yml"
WELL_ORDER = "everest/model/config.yml"

pytestmark = pytest.mark.xdist_group(name="starts_everest")
Expand Down Expand Up @@ -81,12 +80,13 @@ def test_everest_main_entry_bad_command():
@pytest.mark.flaky(reruns=5)
@pytest.mark.fails_on_macos_github_workflow
@pytest.mark.integration_test
def test_everest_entry_run(copy_math_func_test_data_to_tmp):
def test_everest_entry_run(cached_example):
_, config_file, _ = cached_example("math_func/config_minimal.yml")
# Setup command line arguments
with capture_streams():
start_everest(["everest", "run", CONFIG_FILE_MINIMAL])
start_everest(["everest", "run", config_file])

config = EverestConfig.load_file(CONFIG_FILE_MINIMAL)
config = EverestConfig.load_file(config_file)
status = everserver_status(
ServerConfig.get_everserver_status_path(config.output_dir)
)
Expand All @@ -103,9 +103,9 @@ def test_everest_entry_run(copy_math_func_test_data_to_tmp):
assert best_settings.objective_value == pytest.approx(0.0, abs=0.0005)

with capture_streams():
start_everest(["everest", "monitor", CONFIG_FILE_MINIMAL])
start_everest(["everest", "monitor", config_file])

config = EverestConfig.load_file(CONFIG_FILE_MINIMAL)
config = EverestConfig.load_file(config_file)
status = everserver_status(
ServerConfig.get_everserver_status_path(config.output_dir)
)
Expand All @@ -114,11 +114,12 @@ def test_everest_entry_run(copy_math_func_test_data_to_tmp):


@pytest.mark.integration_test
def test_everest_entry_monitor_no_run(copy_math_func_test_data_to_tmp):
def test_everest_entry_monitor_no_run(cached_example):
_, config_file, _ = cached_example("math_func/config_minimal.yml")
with capture_streams():
start_everest(["everest", "monitor", CONFIG_FILE_MINIMAL])
start_everest(["everest", "monitor", config_file])

config = EverestConfig.load_file(CONFIG_FILE_MINIMAL)
config = EverestConfig.load_file(config_file)
status = everserver_status(
ServerConfig.get_everserver_status_path(config.output_dir)
)
Expand All @@ -127,32 +128,34 @@ def test_everest_entry_monitor_no_run(copy_math_func_test_data_to_tmp):


@pytest.mark.integration_test
def test_everest_main_export_entry(copy_math_func_test_data_to_tmp):
def test_everest_main_export_entry(cached_example):
# Setup command line arguments
_, config_file, _ = cached_example("math_func/config_minimal.yml")
with capture_streams():
start_everest(["everest", "export", CONFIG_FILE_MINIMAL])
start_everest(["everest", "export", config_file])
assert os.path.exists(os.path.join("everest_output", "config_minimal.csv"))


@pytest.mark.integration_test
def test_everest_main_lint_entry(copy_math_func_test_data_to_tmp):
def test_everest_main_lint_entry(cached_example):
# Setup command line arguments
_, config_file, _ = cached_example("math_func/config_minimal.yml")
with capture_streams() as (out, err):
start_everest(["everest", "lint", CONFIG_FILE_MINIMAL])
start_everest(["everest", "lint", config_file])
assert "config_minimal.yml is valid" in out.getvalue()

# Make the config invalid
with open(CONFIG_FILE_MINIMAL, encoding="utf-8") as f:
with open(config_file, encoding="utf-8") as f:
raw_config = YAML(typ="safe", pure=True).load(f)
raw_config["controls"][0]["initial_guess"] = "invalid"
with open(CONFIG_FILE_MINIMAL, "w", encoding="utf-8") as f:
with open(config_file, "w", encoding="utf-8") as f:
yaml = YAML(typ="safe", pure=True)
yaml.indent = 2
yaml.default_flow_style = False
yaml.dump(raw_config, f)

with capture_streams() as (out, err), pytest.raises(SystemExit):
start_everest(["everest", "lint", CONFIG_FILE_MINIMAL])
start_everest(["everest", "lint", config_file])

type_ = "(type=float_parsing)"
validation_msg = dedent(
Expand All @@ -166,7 +169,6 @@ def test_everest_main_lint_entry(copy_math_func_test_data_to_tmp):
assert validation_msg in err.getvalue()


@pytest.mark.fails_on_macos_github_workflow
@skipif_no_everest_models
@pytest.mark.everest_models_test
@pytest.mark.integration_test
Expand Down
Loading