Skip to content

Commit

Permalink
tests: use teardown method
Browse files Browse the repository at this point in the history
Avoids a side effect when the first test class fails, leaving the
system in an unclean state for the next test class.
  • Loading branch information
jngrad committed May 19, 2020
1 parent d395ec5 commit 7379d83
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions testsuite/python/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def stress_nonbonded_intra(particle_pairs):
@utx.skipIfMissingFeatures(['LENNARD_JONES'])
class Stress(ut.TestCase):

def tearDown(self):
system.part.clear()

def test(self):
# system parameters
system.box_l = 3 * [10.0]
Expand Down Expand Up @@ -244,12 +247,13 @@ def test(self):
sim_pressure["total"],
delta=tol)

system.part.clear()


@utx.skipIfMissingFeatures(['EXTERNAL_FORCES'])
class StressFENE(ut.TestCase):

def tearDown(self):
system.part.clear()

def get_anal_stress_fene(self, pos_1, pos_2, k, d_r_max, r_0):
stress = np.zeros([3, 3])
vec_r = pos_1 - pos_2
Expand Down Expand Up @@ -321,8 +325,6 @@ def test_fene(self):
sim_pressure["total"],
delta=tol)

system.part.clear()


if __name__ == "__main__":
ut.main()

0 comments on commit 7379d83

Please sign in to comment.