Skip to content

Commit bbd1d58

Browse files
Adjust tests
1 parent 03c08c4 commit bbd1d58

10 files changed

+466
-707
lines changed

tests/conftest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from vtk_utils.compare_grids import compare_grids
3939

4040
from meshpy.core.conf import mpy
41+
from meshpy.core.mesh import Mesh
4142
from meshpy.four_c.input_file import InputFile
4243
from meshpy.four_c.yaml_dumper import MeshPyDumper as _MeshPyDumper
4344
from meshpy.utils.environment import fourcipp_is_available
@@ -274,8 +275,8 @@ def assert_results_equal(get_string, tmp_path, current_test_name) -> Callable:
274275
"""
275276

276277
def _assert_results_equal(
277-
reference: Union[Path, str, dict],
278-
result: Union[Path, str, dict, InputFile],
278+
reference: Union[Path, str, dict, InputFile, Mesh],
279+
result: Union[Path, str, dict, InputFile, Mesh],
279280
rtol: Optional[float] = None,
280281
atol: Optional[float] = None,
281282
input_file_kwargs: dict = {"add_header_information": False, "check_nox": False},
@@ -331,10 +332,20 @@ def get_dictionary(data) -> dict:
331332
compare_dicts(reference_dict, result_dict, rtol=rtol, atol=atol)
332333
return
333334

334-
if isinstance(reference, InputFile) or isinstance(result, InputFile):
335+
if isinstance(reference, (InputFile, Mesh)) or isinstance(
336+
result, (InputFile, Mesh)
337+
):
335338

336339
def get_dictionary(data) -> dict:
337340
"""Get the dictionary representation of the data object."""
341+
342+
# Internally convert Mesh to InputFile to allow for simple comparison via dictionary
343+
# TODO this should be improved in the future
344+
if isinstance(data, Mesh):
345+
input_file = InputFile()
346+
input_file.add(data)
347+
data = input_file
348+
338349
if isinstance(data, InputFile):
339350
if fourcipp_is_available():
340351
raise ValueError(

tests/reference-files/test_meshpy_comments_in_solid.4C.yaml

Lines changed: 0 additions & 159 deletions
This file was deleted.

tests/reference-files/test_meshpy_comments_in_solid_initial.4C.yaml

Lines changed: 0 additions & 112 deletions
This file was deleted.

tests/test_cosserat_curve.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def create_beam_solid_input_file(get_corresponding_reference_file_path):
6060
yaml_file=get_corresponding_reference_file_path(
6161
reference_file_base_name="test_cosserat_curve_mesh"
6262
)
63-
)
63+
).mesh
64+
6465
create_beam_mesh_helix(
6566
mesh,
6667
Beam3rHerm2Line3,
@@ -205,7 +206,7 @@ def test_cosserat_curve_mesh_warp(
205206
Rotation([0, 0, 1], -0.5 * np.pi) * Rotation([0, 1, 0], -0.5 * np.pi)
206207
),
207208
)
208-
209+
print("###", type(mesh), mesh)
209210
assert_results_equal(get_corresponding_reference_file_path(), mesh, rtol=1e-10)
210211

211212

0 commit comments

Comments
 (0)