Skip to content

Commit

Permalink
Add feature guards in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Oct 11, 2019
1 parent a9f263e commit c3247bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions testsuite/python/save_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@
# set thermostat
if 'THERM.LANGEVIN' in modes:
system.thermostat.set_langevin(kT=1.0, gamma=2.0, seed=42)
elif 'THERM.NPT' in modes:
elif 'THERM.NPT' in modes and has_features('NPT'):
system.thermostat.set_npt(kT=1.0, gamma0=2.0, gammav=0.1)
elif 'THERM.DPD' in modes:
elif 'THERM.DPD' in modes and has_features('DPD'):
system.thermostat.set_dpd(kT=1.0, seed=42)
# set integrator
if 'INT.NPT' in modes:
if 'INT.NPT' in modes and has_features('NPT'):
system.integrator.set_isotropic_npt(ext_pressure=2.0, piston=0.01,
direction=[1, 0, 0])
elif 'INT.SD' in modes:
Expand Down
3 changes: 3 additions & 0 deletions testsuite/python/test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,23 @@ def test_thermostat_Langevin(self):
self.assertEqual(thmst['seed'], 42)
np.testing.assert_array_equal(thmst['gamma'], np.array(3 * [2.0]))

@utx.skipIfMissingFeatures('DPD')
@ut.skipIf('THERM.DPD' not in modes, 'DPD thermostat not in modes')
def test_thermostat_DPD(self):
thmst = system.thermostat.get_state()[0]
self.assertEqual(thmst['type'], 'DPD')
self.assertEqual(thmst['kT'], 1.0)
self.assertEqual(thmst['seed'], 42 + 6)

@utx.skipIfMissingFeatures('NPT')
@ut.skipIf('THERM.NPT' not in modes, 'NPT thermostat not in modes')
def test_thermostat_NPT(self):
thmst = system.thermostat.get_state()[0]
self.assertEqual(thmst['type'], 'NPT_ISO')
self.assertEqual(thmst['gamma0'], 2.0)
self.assertEqual(thmst['gammav'], 0.1)

@utx.skipIfMissingFeatures('NPT')
@ut.skipIf('INT.NPT' not in modes, 'NPT integrator not in modes')
def test_integrator_NPT(self):
integ = system.integrator.get_state()
Expand Down

0 comments on commit c3247bd

Please sign in to comment.