diff --git a/tests/multigrid/test_netgen_gmg.py b/tests/multigrid/test_netgen_gmg.py index 375d28f202..a8f6cf40be 100644 --- a/tests/multigrid/test_netgen_gmg.py +++ b/tests/multigrid/test_netgen_gmg.py @@ -1,6 +1,15 @@ from firedrake import * import pytest +try: + import netgen + del netgen + import ngsPETSc + del ngsPETSc +except ImportError: + # Netgen is not installed + pytest.skip("Netgen not installed", allow_module_level=True) + def create_netgen_mesh_circle(): from netgen.geom2d import Circle, CSG2d @@ -14,7 +23,6 @@ def create_netgen_mesh_circle(): @pytest.mark.skipcomplex -@pytest.mark.skipnetgen def test_netgen_mg_circle(): ngmesh = create_netgen_mesh_circle() mesh = Mesh(ngmesh) @@ -43,7 +51,6 @@ def test_netgen_mg_circle(): @pytest.mark.skipcomplex -@pytest.mark.skipnetgeun def test_netgen_mg_circle_non_uniform_degree(): ngmesh = create_netgen_mesh_circle() mesh = Mesh(ngmesh) @@ -73,7 +80,6 @@ def test_netgen_mg_circle_non_uniform_degree(): @pytest.mark.skipcomplex @pytest.mark.parallel -@pytest.mark.skipnetgen def test_netgen_mg_circle_parallel(): ngmesh = create_netgen_mesh_circle() mesh = Mesh(ngmesh) diff --git a/tests/regression/test_netgen.py b/tests/regression/test_netgen.py index 7560a77db6..bc92cb5b16 100644 --- a/tests/regression/test_netgen.py +++ b/tests/regression/test_netgen.py @@ -4,6 +4,16 @@ from petsc4py import PETSc import pytest +try: + import netgen + del netgen + import ngsPETSc + del ngsPETSc +except ImportError: + # Netgen is not installed + pytest.skip("Netgen not installed", allow_module_level=True) + + printf = lambda msg: PETSc.Sys.Print(msg) @@ -97,7 +107,6 @@ def poisson3D(h, degree=2): return S -@pytest.mark.skipnetgen def test_firedrake_Poisson_netgen(): diff = np.array([poisson(h)[0] for h in [1/2, 1/4, 1/8]]) print("l2 error norms:", diff) @@ -106,7 +115,6 @@ def test_firedrake_Poisson_netgen(): assert (np.array(conv) > 2.8).all() -@pytest.mark.skipnetgen @pytest.mark.parallel def test_firedrake_Poisson_netgen_parallel(): diff = np.array([poisson(h)[0] for h in [1/2, 1/4, 1/8]]) @@ -116,7 +124,6 @@ def test_firedrake_Poisson_netgen_parallel(): assert (np.array(conv) > 2.8).all() -@pytest.mark.skipnetgen def test_firedrake_Poisson3D_netgen(): diff = np.array([poisson3D(h) for h in [1, 1/2, 1/4]]) print("l2 error norms:", diff) @@ -125,7 +132,6 @@ def test_firedrake_Poisson3D_netgen(): assert (np.array(conv) > 2.8).all() -@pytest.mark.skipnetgen def test_firedrake_integral_2D_netgen(): from netgen.geom2d import SplineGeometry import netgen @@ -147,7 +153,6 @@ def test_firedrake_integral_2D_netgen(): assert abs(assemble(f * dx) - (5/6)) < 1.e-10 -@pytest.mark.skipnetgen def test_firedrake_integral_3D_netgen(): from netgen.csg import CSGeometry, OrthoBrick, Pnt import netgen @@ -172,7 +177,6 @@ def test_firedrake_integral_3D_netgen(): assert abs(assemble(f * ds) - (2 + 4 + 2 + 5 + 2 + 6)) < 1.e-10 -@pytest.mark.skipnetgen def test_firedrake_integral_ball_netgen(): from netgen.csg import CSGeometry, Pnt, Sphere from netgen.meshing import MeshingParameters @@ -195,7 +199,6 @@ def test_firedrake_integral_ball_netgen(): assert abs(assemble(f * dx) - 4*np.pi) < 1.e-2 -@pytest.mark.skipnetgen def test_firedrake_integral_sphere_high_order_netgen(): from netgen.csg import CSGeometry, Pnt, Sphere import netgen @@ -216,7 +219,6 @@ def test_firedrake_integral_sphere_high_order_netgen(): assert abs(assemble(f * dx) - (4/3)*np.pi) < 1.e-4 -@pytest.mark.skipnetgen @pytest.mark.parallel def test_firedrake_integral_sphere_high_order_netgen_parallel(): from netgen.csg import CSGeometry, Pnt, Sphere @@ -238,7 +240,6 @@ def test_firedrake_integral_sphere_high_order_netgen_parallel(): assert abs(assemble(f * dx) - (4/3)*np.pi) < 1.e-2 -@pytest.mark.skipnetgen @pytest.mark.skipcomplex def test_firedrake_Adaptivity_netgen(): from netgen.occ import WorkPlane, OCCGeometry, Axes @@ -313,7 +314,6 @@ def adapt(mesh, eta): assert error_estimators[-1] < 0.05 -@pytest.mark.skipnetgen @pytest.mark.skipcomplex @pytest.mark.parallel def test_firedrake_Adaptivity_netgen_parallel(): @@ -389,7 +389,6 @@ def adapt(mesh, eta): assert error_estimators[-1] < 0.05 -@pytest.mark.skipnetgen @pytest.mark.parallel @pytest.mark.skipcomplex def test_alfeld_stokes_netgen():