File tree Expand file tree Collapse file tree
tests/ert/unit_tests/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from io import BytesIO
55from pathlib import Path
66from typing import Any , cast
7+ from warnings import WarningMessage
78
89import numpy as np
910import polars as pl
@@ -1526,19 +1527,22 @@ def test_that_wildcard_well_with_wildcard_time_without_any_response_is_warned_ab
15261527 assert any (all (e_w in str (w ) for e_w in expected_warnings ) for w in warnings )
15271528
15281529
1529- def _collect_rft_response_warnings (
1530- well : str , time : str
1531- ) -> list [warnings .WarningMessage ]:
1530+ def _collect_rft_response_warnings (well : str , time : str ) -> list [WarningMessage ]:
15321531 rft_config = RFTConfig (
15331532 input_files = ["BASE.RFT" ],
15341533 data_to_read = {
15351534 well : {time : ["PRESSURE" , "SWAT" ]},
15361535 },
15371536 )
1538- with warnings .catch_warnings (record = True ) as w :
1537+ with warnings .catch_warnings (record = True ) as ws :
15391538 rft_config .read_from_file ("/tmp/does_not_exist" , 1 , 1 )
15401539
1541- return w
1540+ return [
1541+ w
1542+ for w in ws
1543+ if issubclass (w .category , PostExperimentWarning )
1544+ and "Could not find response" in str (w .message )
1545+ ]
15421546
15431547
15441548def test_that_wildcard_well_with_wildcard_time_with_any_response_is_not_warned_about (
Original file line number Diff line number Diff line change 44from datetime import datetime
55from pathlib import Path
66from textwrap import dedent
7+ from warnings import WarningMessage
78
89import hypothesis .strategies as st
910import polars as pl
@@ -274,13 +275,18 @@ def mock_read_summary(*args):
274275
275276def _collect_summary_response_warnings (
276277 response_key : str , simulated_response_key : str
277- ) -> list [warnings . WarningMessage ]:
278+ ) -> list [WarningMessage ]:
278279 summary_config = SummaryConfig (keys = [response_key ])
279- with warnings .catch_warnings (record = True ) as w :
280+ with warnings .catch_warnings (record = True ) as ws :
280281 summary_config ._warn_about_missing_summary_responses (
281282 response_keys = [simulated_response_key ], filename = "foo"
282283 )
283- return w
284+ return [
285+ w
286+ for w in ws
287+ if issubclass (w .category , PostExperimentWarning )
288+ and "Could not find response" in str (w .message )
289+ ]
284290
285291
286292def test_that_key_with_wildcard_with_response_is_not_warned_about ():
You can’t perform that action at this time.
0 commit comments