mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-29 08:30:17 -05:00
Treat pytest warnings as errors
Wrap calls to deprecated rips API in pytest.warns so the suite runs warning-free.
This commit is contained in:
1 parent
281214124a
commit
095a5a52b5
8 files changed
+64
-51
No files matched your search
@@ -52,6 +52,9 @@ Homepage = "http://www.resinsight.org"
|
||||
# setting is only discovered when uv runs from this directory.
|
||||
exclude-newer = "1 week"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
filterwarnings = ["error"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {attr = "rips._version.__version__"}
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ def test_replaceCase(rips_instance, initialize_test):
|
||||
cases = rips_instance.project.cases()
|
||||
assert len(cases) == 1
|
||||
|
||||
case.replace(new_grid_file=case_path)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.replace(new_grid_file=case_path)
|
||||
# Check that the case object has been changed
|
||||
assert case.name == "BRUGGE_0000"
|
||||
assert case.id == 0
|
||||
|
||||
@@ -21,14 +21,15 @@ def test_create_lgr_well(rips_instance, initialize_test):
|
||||
|
||||
time_step = 5
|
||||
well_path_names = ["Well Path A"]
|
||||
case.create_lgr_for_completion(
|
||||
time_step,
|
||||
well_path_names,
|
||||
refinement_i=2,
|
||||
refinement_j=3,
|
||||
refinement_k=1,
|
||||
split_type="LGR_PER_WELL",
|
||||
)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.create_lgr_for_completion(
|
||||
time_step,
|
||||
well_path_names,
|
||||
refinement_i=2,
|
||||
refinement_j=3,
|
||||
refinement_k=1,
|
||||
split_type="LGR_PER_WELL",
|
||||
)
|
||||
assert len(case.grids()) == 3
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import pytest
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
||||
|
||||
@@ -105,15 +106,16 @@ def test_export_completion_files_unified(rips_instance, initialize_test):
|
||||
|
||||
well_names_to_use = ["Well-1"]
|
||||
|
||||
case.export_well_path_completions(
|
||||
time_step=0, # Use time step 0 instead of 1
|
||||
well_path_names=well_names_to_use,
|
||||
file_split="UNIFIED_FILE",
|
||||
include_perforations=True,
|
||||
include_fishbones=True,
|
||||
export_welspec=True,
|
||||
export_comments=False,
|
||||
)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.export_well_path_completions(
|
||||
time_step=0, # Use time step 0 instead of 1
|
||||
well_path_names=well_names_to_use,
|
||||
file_split="UNIFIED_FILE",
|
||||
include_perforations=True,
|
||||
include_fishbones=True,
|
||||
export_welspec=True,
|
||||
export_comments=False,
|
||||
)
|
||||
|
||||
# Compare exported files with reference data
|
||||
reference_folder = (
|
||||
@@ -145,14 +147,15 @@ def test_export_completion_files_split_by_well(rips_instance, initialize_test):
|
||||
# Use Well-1 for all tests
|
||||
test_wells = ["Well-1"]
|
||||
|
||||
case.export_well_path_completions(
|
||||
time_step=0, # Use time step 0 instead of 1
|
||||
well_path_names=test_wells,
|
||||
file_split="SPLIT_ON_WELL",
|
||||
include_perforations=True,
|
||||
include_fishbones=False, # This matches the reference generation script
|
||||
export_comments=False,
|
||||
)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.export_well_path_completions(
|
||||
time_step=0, # Use time step 0 instead of 1
|
||||
well_path_names=test_wells,
|
||||
file_split="SPLIT_ON_WELL",
|
||||
include_perforations=True,
|
||||
include_fishbones=False, # This matches the reference generation script
|
||||
export_comments=False,
|
||||
)
|
||||
|
||||
# Compare exported files with reference data
|
||||
reference_folder = case_root_path + "/completion_export_reference/split_by_well"
|
||||
@@ -195,15 +198,16 @@ def test_export_completion_well_entering_lgr_twice(rips_instance, initialize_tes
|
||||
os.remove(os.path.join(export_folder, old_file))
|
||||
|
||||
rips_instance.set_export_folder(export_type="COMPLETIONS", path=export_folder)
|
||||
case.export_well_path_completions(
|
||||
time_step=0,
|
||||
well_path_names=["LgrWell"],
|
||||
file_split="UNIFIED_FILE",
|
||||
include_perforations=True,
|
||||
include_fishbones=False,
|
||||
export_welspec=True,
|
||||
export_comments=False,
|
||||
)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.export_well_path_completions(
|
||||
time_step=0,
|
||||
well_path_names=["LgrWell"],
|
||||
file_split="UNIFIED_FILE",
|
||||
include_perforations=True,
|
||||
include_fishbones=False,
|
||||
export_welspec=True,
|
||||
export_comments=False,
|
||||
)
|
||||
|
||||
lgr_files = [
|
||||
f for f in os.listdir(export_folder) if f.endswith("_LGR") and "_MSW_" not in f
|
||||
@@ -244,14 +248,15 @@ def test_export_completion_dual_porosity_model(rips_instance, initialize_test):
|
||||
# Use Well-1 for all tests
|
||||
test_wells = ["PH", "PV"]
|
||||
|
||||
case.export_well_path_completions(
|
||||
time_step=0, # Use time step 0 instead of 1
|
||||
well_path_names=test_wells,
|
||||
file_split="SPLIT_ON_WELL",
|
||||
include_perforations=True,
|
||||
include_fishbones=False, # This matches the reference generation script
|
||||
export_comments=False,
|
||||
)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.export_well_path_completions(
|
||||
time_step=0, # Use time step 0 instead of 1
|
||||
well_path_names=test_wells,
|
||||
file_split="SPLIT_ON_WELL",
|
||||
include_perforations=True,
|
||||
include_fishbones=False, # This matches the reference generation script
|
||||
export_comments=False,
|
||||
)
|
||||
|
||||
# Compare exported files with reference data
|
||||
reference_folder = case_root_path + "/completion_export_reference"
|
||||
|
||||
@@ -187,7 +187,8 @@ def test_msw_export(rips_instance, initialize_test):
|
||||
rips_instance.set_export_folder(export_type="COMPLETIONS", path=export_folder)
|
||||
|
||||
# Export MSW data
|
||||
case.export_msw(well_path=well_y1.name)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.export_msw(well_path=well_y1.name)
|
||||
|
||||
# Note: The actual file creation validation would require checking
|
||||
# the export folder, which may be platform-dependent and require
|
||||
|
||||
@@ -285,7 +285,7 @@ def test_scale_fracture_template_and_set_containment(rips_instance, initialize_t
|
||||
assert after_scale.width_scale_factor == 1.5
|
||||
assert after_scale.conductivity_factor == 4.5
|
||||
|
||||
with pytest.raises(rips.RipsError):
|
||||
with pytest.raises(rips.RipsError), pytest.warns(DeprecationWarning):
|
||||
project.scale_fracture_template(
|
||||
template_id=999, half_length=1, height=1, d_factor=1, conductivity=1
|
||||
)
|
||||
|
||||
@@ -252,7 +252,8 @@ def test_exportPropertyInView(rips_instance, initialize_test):
|
||||
rips_instance.set_export_folder(export_type="PROPERTIES", path=tmpdirname)
|
||||
case = rips_instance.project.cases()[0]
|
||||
view = case.views()[0]
|
||||
view.export_property()
|
||||
with pytest.warns(DeprecationWarning):
|
||||
view.export_property()
|
||||
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
|
||||
full_path = tmpdirname + "/" + expected_file_name
|
||||
assert os.path.exists(full_path)
|
||||
|
||||
@@ -19,11 +19,12 @@ def test_10k(rips_instance, initialize_test):
|
||||
rips_instance.set_export_folder(export_type="COMPLETIONS", path=export_folder)
|
||||
|
||||
case = project.cases()[0]
|
||||
case.export_well_path_completions(
|
||||
time_step=1,
|
||||
well_path_names=["Well-1"],
|
||||
file_split="UNIFIED_FILE",
|
||||
)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
case.export_well_path_completions(
|
||||
time_step=1,
|
||||
well_path_names=["Well-1"],
|
||||
file_split="UNIFIED_FILE",
|
||||
)
|
||||
|
||||
|
||||
def test_export_completions(rips_instance, initialize_test):
|
||||
|
||||
Reference in new issue
Block a user