Skip to content

Commit 949dc4a

Browse files
committed
fixup! Fix logging of missing wildcard rft responses
Improve warning message This makes it easier to read especially wildcard warnings
1 parent 751f7ab commit 949dc4a

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/ert/config/rft_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _warn_about_missing_rft_responses(
316316
well_times_to_warn.remove(wildcard_well_time)
317317

318318
formatted_items = [
319-
f"{well}: {time}" for well, time in sorted(well_times_to_warn)
319+
f"{well=} : {time=}" for well, time in sorted(well_times_to_warn)
320320
]
321321
_warn_about_missing_responses(
322322
formatted_items, "well(s) at time(s)", rft_filename

tests/ert/unit_tests/config/test_rft_config.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ def test_that_missing_response_for_rft_well_raises_warning(setup_mock_resfo_file
13251325

13261326
expected_warnings = [
13271327
"Could not find responses for well(s) at time(s) in 'BASE.RFT':",
1328-
"NOT_A_WELL: 2000-01-01",
1328+
"well='NOT_A_WELL' : time='2000-01-01'",
13291329
]
13301330
assert any(all(m in str(w) for m in expected_warnings) for w in warnings)
13311331

@@ -1346,7 +1346,7 @@ def test_that_one_existing_and_one_missing_rft_response_warns_about_the_one_miss
13461346
rft_config.read_from_file("/tmp/does_not_exist", 1, 1)
13471347
expected_warnings = [
13481348
"Could not find responses for well(s) at time(s) in 'BASE.RFT':",
1349-
"WELL: 4000-01-01",
1349+
"well='WELL' : time='4000-01-01'",
13501350
]
13511351
assert any(all(m in str(w) for m in expected_warnings) for w in warnings)
13521352

@@ -1419,9 +1419,12 @@ def test_that_wildcard_times_are_warned_about_given_no_well_response(
14191419
with pytest.warns(PostExperimentWarning) as warnings:
14201420
rft_config.read_from_file("/tmp/does_not_exist", 1, 1)
14211421

1422-
expected_warning = ["Could not find responses for well(s) at time(s)", "WELL: *"]
1422+
expected_warnings = [
1423+
"Could not find responses for well(s) at time(s)",
1424+
"well='DIFFERENT_WELL' : time='*'",
1425+
]
14231426
# Assert one warning contains all expected warnings
1424-
assert any(all(e_w in str(w) for e_w in expected_warning) for w in warnings)
1427+
assert any(all(e_w in str(w) for e_w in expected_warnings) for w in warnings)
14251428

14261429

14271430
def test_that_wildcard_wells_are_warned_about_given_no_time_response(
@@ -1436,12 +1439,12 @@ def test_that_wildcard_wells_are_warned_about_given_no_time_response(
14361439
with pytest.warns(PostExperimentWarning) as warnings:
14371440
rft_config.read_from_file("/tmp/does_not_exist", 1, 1)
14381441

1439-
expected_warning = [
1442+
expected_warnings = [
14401443
"Could not find responses for well(s) at time(s)",
1441-
"*: 2010-10-10",
1444+
"well='*' : time='2010-10-10'",
14421445
]
14431446
# Assert one warning contains all expected warnings
1444-
assert any(all(e_w in str(w) for e_w in expected_warning) for w in warnings)
1447+
assert any(all(e_w in str(w) for e_w in expected_warnings) for w in warnings)
14451448

14461449

14471450
def test_that_wildcard_wells_with_time_response_are_not_warned_about(
@@ -1480,12 +1483,12 @@ def test_that_wildcard_well_with_wildcard_time_without_any_response_is_warned_ab
14801483
with pytest.warns(PostExperimentWarning) as warnings:
14811484
rft_config.read_from_file("/tmp/does_not_exist", 1, 1)
14821485

1483-
expected_warning = [
1486+
expected_warnings = [
14841487
"Could not find responses for well(s) at time(s)",
1485-
"*: *",
1488+
"well='*' : time='*'",
14861489
]
14871490
# Assert one warning contains all expected warnings
1488-
assert any(all(e_w in str(w) for e_w in expected_warning) for w in warnings)
1491+
assert any(all(e_w in str(w) for e_w in expected_warnings) for w in warnings)
14891492

14901493

14911494
def test_that_wildcard_well_with_wildcard_time_with_any_response_is_not_warned_about(

0 commit comments

Comments
 (0)