Skip to content

Commit 977d09b

Browse files
committed
Suppresses warnings in tests
1 parent bb59bbd commit 977d09b

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

RATapi/project.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def discriminate_contrasts(contrast_input):
6262
"resolutions.value_4": "resolution_parameters",
6363
"resolutions.value_5": "resolution_parameters",
6464
"resolutions.constant.source": "resolution_parameters",
65-
"resolutions.data.source": "data",
6665
"resolutions.function.source": "custom_files",
6766
"layers.thickness": "parameters",
6867
"layers.SLD": "parameters",
@@ -90,7 +89,6 @@ def discriminate_contrasts(contrast_input):
9089
"data": [
9190
AllFields("contrasts", ["data"]),
9291
AllFields("backgrounds", ["source"]),
93-
AllFields("resolutions", ["source"]),
9492
],
9593
"custom_files": [AllFields("backgrounds", ["source"]), AllFields("resolutions", ["source"])],
9694
"backgrounds": [AllFields("contrasts", ["background"])],

tests/test_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def mock_load(ignored_filename, **ignored_settings):
102102
def test_invalid_constraints():
103103
"""Test that invalid constraints are fixed where necessary."""
104104
with pytest.warns(
105-
match="The parameter Background parameter 1 has invalid constraints,"
105+
match=r"The parameter (.+) has invalid constraints,"
106106
" these have been adjusted to satisfy the current value of the parameter."
107107
):
108108
output_project = r1_to_project_class(pathlib.Path(TEST_DIR_PATH, "R1DoubleBilayerVolumeModel.mat"))

tests/test_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ def test_contrast_bad_ratio():
335335

336336

337337
@pytest.mark.parametrize("model", [RATapi.models.Background, RATapi.models.Resolution])
338+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
338339
def test_type_change_clear(model):
339340
"""If the type of a background or resolution is changed, it should wipe the other fields and warn the user."""
340341

tests/test_project.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def test_check_protected_parameters(delete_operation) -> None:
630630
("background_parameters", ["source"]),
631631
("resolution_parameters", ["source"]),
632632
("parameters", ["roughness"]),
633-
("data", ["data", "source", "source"]),
633+
("data", ["data", "source"]),
634634
("custom_files", ["source", "source"]),
635635
("backgrounds", ["background"]),
636636
("bulk_in", ["bulk_in"]),
@@ -645,7 +645,6 @@ def test_rename_models(test_project, model: str, fields: list[str]) -> None:
645645
"""
646646
if model == "data":
647647
test_project.backgrounds[0] = RATapi.models.Background(type="data", source="Simulation")
648-
test_project.resolutions[0] = RATapi.models.Resolution(type="data", source="Simulation")
649648
if model == "custom_files":
650649
test_project.backgrounds[0] = RATapi.models.Background(type="function", source="Test Custom File")
651650
# workaround until function resolutions are added
@@ -753,7 +752,6 @@ def test_allowed_absorption_layers(field: str) -> None:
753752
"resolution_type, expected_field",
754753
[
755754
[TypeOptions.Constant, "resolution_parameters"],
756-
[TypeOptions.Data, "data"],
757755
# uncomment when function resolutions are added!
758756
# [TypeOptions.Function, "custom_files"],
759757
],
@@ -1168,6 +1166,7 @@ def test_write_script_wrong_extension(test_project, extension: str) -> None:
11681166
("contrasts", "", "resolution"),
11691167
],
11701168
)
1169+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
11711170
def test_wrap_set(test_project, class_list: str, model_type: str, field: str) -> None:
11721171
"""If we set the field values of a model in a ClassList as undefined values, we should raise a ValidationError."""
11731172
test_attribute = getattr(test_project, class_list)
@@ -1246,6 +1245,7 @@ def test_wrap_del(test_project, class_list: str, parameter: str, field: str) ->
12461245
("contrasts", "", "resolution", {}),
12471246
],
12481247
)
1248+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
12491249
def test_wrap_iadd(test_project, class_list: str, model_type: str, field: str, model_params: dict) -> None:
12501250
"""If we add a model containing undefined values to a ClassList, we should raise a ValidationError."""
12511251
test_attribute = getattr(test_project, class_list)
@@ -1292,6 +1292,7 @@ def test_wrap_iadd(test_project, class_list: str, model_type: str, field: str, m
12921292
("contrasts", "", "resolution", {}),
12931293
],
12941294
)
1295+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
12951296
def test_wrap_append(test_project, class_list: str, model_type: str, field: str, model_params: dict) -> None:
12961297
"""If we append a model containing undefined values to a ClassList, we should raise a ValidationError."""
12971298
test_attribute = getattr(test_project, class_list)
@@ -1339,6 +1340,7 @@ def test_wrap_append(test_project, class_list: str, model_type: str, field: str,
13391340
("contrasts", "", "resolution", {}),
13401341
],
13411342
)
1343+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
13421344
def test_wrap_insert(test_project, class_list: str, model_type: str, field: str, model_params: dict) -> None:
13431345
"""If we insert a model containing undefined values into a ClassList, we should raise a ValidationError."""
13441346
test_attribute = getattr(test_project, class_list)
@@ -1382,6 +1384,7 @@ def test_wrap_insert(test_project, class_list: str, model_type: str, field: str,
13821384
("contrasts", "resolution"),
13831385
],
13841386
)
1387+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
13851388
def test_wrap_insert_type_error(test_project, class_list: str, field: str) -> None:
13861389
"""If we raise a TypeError using the wrapped insert routine, we should re-raise the error."""
13871390
test_attribute = getattr(test_project, class_list)
@@ -1518,6 +1521,7 @@ def test_wrap_clear(test_project, class_list: str, parameter: str, field: str) -
15181521
("contrasts", "", "resolution", {}),
15191522
],
15201523
)
1524+
@pytest.mark.filterwarnings("ignore:The following values are not recognised by this*:UserWarning")
15211525
def test_wrap_extend(test_project, class_list: str, model_type: str, field: str, model_params: dict) -> None:
15221526
"""If we extend a ClassList with model containing undefined values, we should raise a ValidationError."""
15231527
test_attribute = getattr(test_project, class_list)

0 commit comments

Comments
 (0)