From 167df9feb9025d86159a5df945e2fbae8c3c871b Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 14 Jun 2021 10:09:19 +0200 Subject: [PATCH] test pickling also non-empty mesh --- tests/pytest/test_pickling.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/pytest/test_pickling.py b/tests/pytest/test_pickling.py index 17f22163..3e15f806 100644 --- a/tests/pytest/test_pickling.py +++ b/tests/pytest/test_pickling.py @@ -87,19 +87,23 @@ def test_pickle_geom2d(): def test_pickle_mesh(): import netgen.csg as csg - geo = csg.CSGeometry() + geo1 = csg.CSGeometry() + geo2 = csg.CSGeometry() brick = csg.OrthoBrick(csg.Pnt(-3,-3,-3), csg.Pnt(3,3,3)) - mesh = geo.GenerateMesh(maxh=0.2) - assert geo == mesh.GetGeometry() - dump = pickle.dumps([geo,mesh]) - geo2, mesh2 = pickle.loads(dump) - assert geo2 == mesh2.GetGeometry() - mesh.Save("msh1.vol.gz") - mesh2.Save("msh2.vol.gz") - import filecmp, os - assert filecmp.cmp("msh1.vol.gz", "msh2.vol.gz") - os.remove("msh1.vol.gz") - os.remove("msh2.vol.gz") + geo2.Add(brick) + + for geo in [geo1, geo2]: + mesh = geo.GenerateMesh(maxh=2) + assert geo == mesh.GetGeometry() + dump = pickle.dumps([geo,mesh]) + geo2, mesh2 = pickle.loads(dump) + assert geo2 == mesh2.GetGeometry() + mesh.Save("msh1.vol.gz") + mesh2.Save("msh2.vol.gz") + import filecmp, os + assert filecmp.cmp("msh1.vol.gz", "msh2.vol.gz") + os.remove("msh1.vol.gz") + os.remove("msh2.vol.gz") if __name__ == "__main__": test_pickle_mesh()