Skip to content

Commit

Permalink
replace caplog level setting with context manager option
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmig committed Oct 2, 2023
1 parent 0e5054b commit bece87e
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions tests/test_integration/test_cellfinder_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,23 @@ def prep_json(obj):


def test_run_with_predefined_default_config(config_from_dict, caplog):
caplog.set_level(logging.INFO)

# run setup and workflow
cfg = setup_workflow(config_from_dict)
run_workflow_from_cellfinder_run(cfg)
with caplog.at_level(logging.INFO):
cfg = setup_workflow(config_from_dict)
run_workflow_from_cellfinder_run(cfg)

# check log
assert "Using default configuration" in caplog.text


def test_run_with_env_var_defined_config(config_from_env_var, caplog):
caplog.set_level(logging.INFO)

# check environment variable exists
assert "CELLFINDER_CONFIG_PATH" in os.environ.keys()

# run setup and workflow
cfg = setup_workflow()
run_workflow_from_cellfinder_run(cfg)
with caplog.at_level(logging.INFO):
cfg = setup_workflow()
run_workflow_from_cellfinder_run(cfg)

# check log
assert (
Expand All @@ -118,8 +116,6 @@ def test_run_with_env_var_defined_config(config_from_env_var, caplog):


def test_setup_with_missing_signal_data(config_from_dict, caplog):
caplog.set_level(logging.ERROR)

# check neither signal or background data exist locally,
assert not Path(config_from_dict["signal_parent_dir"]).exists()
assert not Path(config_from_dict["background_parent_dir"]).exists()
Expand All @@ -130,7 +126,8 @@ def test_setup_with_missing_signal_data(config_from_dict, caplog):
)

# run setup
cfg = setup_workflow(config_from_dict)
with caplog.at_level(logging.ERROR):
cfg = setup_workflow(config_from_dict)

# check log
assert (
Expand All @@ -140,8 +137,6 @@ def test_setup_with_missing_signal_data(config_from_dict, caplog):


def test_setup_with_missing_background_data(config_from_dict, caplog):
caplog.set_level(logging.ERROR)

# check neither signal or background data exist locally,
assert not Path(config_from_dict["signal_parent_dir"]).exists()
assert not Path(config_from_dict["background_parent_dir"]).exists()
Expand All @@ -152,7 +147,8 @@ def test_setup_with_missing_background_data(config_from_dict, caplog):
)

# run setup
cfg = setup_workflow(config_from_dict)
with caplog.at_level(logging.ERROR):
cfg = setup_workflow(config_from_dict)

# check log
assert (
Expand All @@ -162,14 +158,13 @@ def test_setup_with_missing_background_data(config_from_dict, caplog):


def test_setup_fetching_from_GIN(config_from_dict, caplog):
caplog.set_level(logging.INFO)

# check neither signal or background data exist locally before setup
assert not Path(config_from_dict["signal_parent_dir"]).exists()
assert not Path(config_from_dict["background_parent_dir"]).exists()

# run setup
setup_workflow(config_from_dict)
with caplog.at_level(logging.INFO):
setup_workflow(config_from_dict)

# check log
assert (
Expand Down

0 comments on commit bece87e

Please sign in to comment.