Skip to content

Commit e9fbeb3

Browse files
Also mock preCICE dependency for unittests to avoid dependency.
1 parent 6e8ece7 commit e9fbeb3

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

tests/unit/test_adapter_core.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from unittest.mock import MagicMock
1+
from unittest.mock import MagicMock, patch
22
from unittest import TestCase
3+
from tests import MockedPrecice
34
import numpy as np
45
from fenics import FunctionSpace, VectorFunctionSpace, UnitSquareMesh, SubDomain, near, vertices, Expression, interpolate
56

67

8+
@patch.dict('sys.modules', {'precice': MockedPrecice})
79
class TestAdapterCore(TestCase):
810
def test_get_coupling_boundary_edges(self):
911
"""

tests/unit/test_checkpointing.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
from unittest.mock import MagicMock
1+
from unittest.mock import MagicMock, patch
22
from unittest import TestCase
3+
from tests import MockedPrecice
34
from fenics import FunctionSpace, UnitSquareMesh, Expression, interpolate
4-
from fenicsprecice.solverstate import SolverState
55

66

7+
@patch.dict('sys.modules', {'precice': MockedPrecice})
78
class TestCheckpointing(TestCase):
89
def test_solverstate_basic(self):
910
"""
1011
Check if correct values are read from the checkpoint, while the state of the object that is copied is not changed
1112
"""
13+
from fenicsprecice.solverstate import SolverState
14+
1215
n = 1
1316
size = 5
1417
mesh = UnitSquareMesh(size, size)
@@ -37,6 +40,8 @@ def test_solverstate_modification_vector(self):
3740
3841
Motivation for this test: Related to https://github.com/precice/fenics-adapter/pull/172 and https://github.com/precice/tutorials/pull/554
3942
"""
43+
from fenicsprecice.solverstate import SolverState
44+
4045
n = 1
4146
size = 5
4247
mesh = UnitSquareMesh(size, size)
@@ -67,6 +72,8 @@ def test_solverstate_modification_assign(self):
6772
Check if correct values are read from the checkpoint, if the dof of the dolfin functions are changed with the assign function
6873
and not directly via the dof vector
6974
"""
75+
from fenicsprecice.solverstate import SolverState
76+
7077
n = 1
7178
size = 5
7279
mesh = UnitSquareMesh(size, size)

0 commit comments

Comments
 (0)