Skip to content

Commit

Permalink
Fix issues with base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
utkbansal committed Feb 15, 2017
1 parent a8559b9 commit dea36df
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 13 deletions.
1 change: 1 addition & 0 deletions testsuite/MDAnalysisTests/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class _SingleFrameReader(TestCase, RefAdKSmall):
# see TestPDBReader how to set up!
__test__ = False

def tearDown(self):
del self.universe
Expand Down
7 changes: 5 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_dcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def test_OtherWriter(self):


class _TestDCDReader_TriclinicUnitcell(TestCase):

__test__ = False

def setUp(self):
self.u = mda.Universe(self.topology, self.trajectory)
self.tempdir = tempdir.TempDir()
Expand Down Expand Up @@ -386,12 +389,12 @@ def test_write_triclinic(self):

class TestDCDReader_CHARMM_Unitcell(_TestDCDReader_TriclinicUnitcell,
RefCHARMMtriclinicDCD):
pass
__test__ = True


class TestDCDReader_NAMD_Unitcell(_TestDCDReader_TriclinicUnitcell,
RefNAMDtriclinicDCD):
pass
__test__ = True


class TestNCDF2DCD(TestCase):
Expand Down
21 changes: 19 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_dlpoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from unittest import TestCase

class _DLPConfig(TestCase):
__test__ = False
def setUp(self):
self.r = mda.coordinates.DLPoly.ConfigReader
rd = self.rd = self.r(self.f)
Expand Down Expand Up @@ -41,17 +42,20 @@ def test_forces(self):


class TestConfigReader(_DLPConfig):
__test__ = True
f = DLP_CONFIG

def test_read(self):
assert_equal(self.rd.title, "DL_POLY: Potassium Chloride Test Case")


class TestConfigOrder(_DLPConfig):
__test__ = True
f = DLP_CONFIG_order


class TestConfigMinimal(_DLPConfig):
__test__ = True
f = DLP_CONFIG_minimal

def test_read_unitcell(self):
Expand All @@ -64,7 +68,10 @@ def test_forces(self):
assert_raises(AttributeError, getattr, self.ts, "_forces")


class _DLPConfig2(object):
class _DLPConfig2(TestCase):

__test__ = False

def setUp(self):
self.u = mda.Universe(self.f, format='CONFIG')

Expand Down Expand Up @@ -93,10 +100,14 @@ def test_number(self):


class TestConfigReader2(_DLPConfig2):

__test__ = True
f = DLP_CONFIG_order


class TestConfigReaderMinimal2(_DLPConfig2):

__test__ = True
f = DLP_CONFIG_minimal

def test_vel(self):
Expand All @@ -106,7 +117,10 @@ def test_for(self):
pass


class _DLHistory(object):
class _DLHistory(TestCase):

__test__ = False

def setUp(self):
self.u = mda.Universe(self.f, format='HISTORY')

Expand Down Expand Up @@ -166,14 +180,17 @@ def test_unitcell(self):


class TestDLPolyHistory(_DLHistory):
__test__ = True
f = DLP_HISTORY


class TestDLPolyHistoryOrder(_DLHistory):
__test__ = True
f = DLP_HISTORY_order


class TestDLPolyHistoryMinimal(_DLHistory):
__test__ = True
f = DLP_HISTORY_minimal

def test_velocity(self):
Expand Down
8 changes: 6 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_gms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from numpy.testing import (assert_equal, assert_almost_equal)

from MDAnalysisTests.datafiles import (GMS_ASYMOPT, GMS_ASYMSURF, GMS_SYMOPT)
from unittest import TestCase


class _GMSBase(object):
class _GMSBase(TestCase):
__test__ = False
def tearDown(self):
del self.u
del self.n_frames
Expand Down Expand Up @@ -68,20 +69,23 @@ def test_step5distances(self):


class TestGMSReader(_GMSBase):
__test__ = True
def setUp(self):
self.u = mda.Universe(GMS_ASYMOPT)
self.n_frames = 21
self.flavour = "GAMESS C1 optimization"
self.step5d = -0.0484664

class TestGMSReaderSO(_GMSBase):
__test__ = True
def setUp(self):
self.u = mda.Universe(GMS_SYMOPT)
self.n_frames = 8
self.flavour = "GAMESS D4H optimization"
self.step5d = 0.227637

class TestGMSReaderASS(_GMSBase):
__test__ = True
def setUp(self):
self.u = mda.Universe(GMS_ASYMSURF)
self.n_frames = 10
Expand Down
16 changes: 12 additions & 4 deletions testsuite/MDAnalysisTests/coordinates/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class _TestLammpsData_Coords(TestCase):
All topology loading from MDAnalysisTests.data is done in test_topology
"""

__test__ = False

def setUp(self):
self.u = mda.Universe(self.filename)

Expand Down Expand Up @@ -62,13 +64,14 @@ def test_iter(self):


class TestLammpsData_Coords(_TestLammpsData_Coords, RefLAMMPSData):
pass
__test__ = True


class TestLammpsDataMini_Coords(_TestLammpsData_Coords, RefLAMMPSDataMini):
pass
__test__ = True

class _TestLAMMPSDATAWriter(TestCase):
__test__ = False
all_attrs = set(['types', 'bonds', 'angles', 'dihedrals', 'impropers'])
all_numerical_attrs = set(['masses', 'charges', 'velocities', 'positions'])

Expand Down Expand Up @@ -124,18 +127,23 @@ def test_Writer_atoms(self):


class TestLAMMPSDATAWriter_data(_TestLAMMPSDATAWriter):
__test__ = True
filename = LAMMPSdata

class TestLAMMPSDATAWriter_mini(_TestLAMMPSDATAWriter):
__test__ = True
filename = LAMMPSdata_mini

class TestLAMMPSDATAWriter_cnt(_TestLAMMPSDATAWriter):
__test__ = True
filename = LAMMPScnt

class TestLAMMPSDATAWriter_hyd(_TestLAMMPSDATAWriter):
__test__ = True
filename = LAMMPShyd

class TestLAMMPSDATAWriter_data_partial(_TestLAMMPSDATAWriter):
__test__ = True
filename = LAMMPSdata
N_kept = 5

Expand Down Expand Up @@ -170,7 +178,7 @@ def test_Writer_atoms(self):

# need more tests of the LAMMPS DCDReader

class TestLAMMPSDCDReader(RefLAMMPSDataDCD):
class TestLAMMPSDCDReader(TestCase, RefLAMMPSDataDCD):
flavor = 'LAMMPS'

def setUp(self):
Expand Down Expand Up @@ -232,7 +240,7 @@ def wrong_load(unit="GARBAGE"):
assert_raises(ValueError, wrong_load)


class TestLAMMPSDCDWriter(RefLAMMPSDataDCD):
class TestLAMMPSDCDWriter(TestCase, RefLAMMPSDataDCD):
flavor = 'LAMMPS'

def setUp(self):
Expand Down
6 changes: 4 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@


class _NCDFReaderTest(_TRJReaderTest):
__test__ = False

@dec.skipif(module_not_found("netCDF4"), "Test skipped because netCDF is not available.")
def setUp(self):
self.universe = mda.Universe(self.topology, self.filename)
Expand Down Expand Up @@ -60,10 +62,10 @@ def test_read_on_closed(self):


class TestNCDFReader(_NCDFReaderTest, RefVGV):
pass
__test__ = True

class TestNCDFReaderTZ2(_NCDFReaderTest, RefTZ2):
pass
__test__ = True


class TestNCDFReader2(TestCase):
Expand Down
4 changes: 4 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


class TestPDBReader(_SingleFrameReader):
__test__ = True
def setUp(self):
# can lead to race conditions when testing in parallel
self.universe = mda.Universe(RefAdKSmall.filename)
Expand Down Expand Up @@ -54,6 +55,7 @@ def test_ENT(self):

class _PDBMetadata(TestCase, Ref4e43):

__test__ = False

def setUp(self):
self.universe = mda.Universe(self.filename)
Expand Down Expand Up @@ -116,6 +118,7 @@ def test_REMARK(self):


class TestExtendedPDBReader(_SingleFrameReader):
__test__ = True
def setUp(self):
self.universe = mda.Universe(PDB_small,
topology_format="XPDB",
Expand Down Expand Up @@ -716,6 +719,7 @@ def test_serials(self):


class TestPSF_CRDReader(_SingleFrameReader):
__test__ = True
def setUp(self):
self.universe = mda.Universe(PSF, CRD)
self.prec = 5 # precision in CRD (at least we are writing %9.5f)
Expand Down
3 changes: 2 additions & 1 deletion testsuite/MDAnalysisTests/coordinates/test_pqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from numpy.testing import TestCase

class TestPQRReader(_SingleFrameReader):
__test__ = True
def setUp(self):
self.universe = mda.Universe(PQR)
# 3 decimals in PDB spec
Expand Down Expand Up @@ -46,7 +47,7 @@ def test_ProNCharges(self):
"Charges for N atoms in Pro residues do not match.")


class TestPQRWriter(RefAdKSmall):
class TestPQRWriter(TestCase, RefAdKSmall):
def setUp(self):
self.universe = mda.Universe(PQR)
self.prec = 3
Expand Down
3 changes: 3 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_reader_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def _read_first_frame(self):


class _TestReader(TestCase):
__test__ = False
"""Basic API readers"""
def setUp(self):
self.reader = self.readerclass('test.txt')
Expand Down Expand Up @@ -125,6 +126,7 @@ class _Multi(_TestReader):


class TestMultiFrameReader(_Multi):
__test__ = True
def _check_slice(self, start, stop, step):
"""Compare the slice applied to trajectory, to slice of list"""
res = [ts.frame for ts in self.reader[start:stop:step]]
Expand Down Expand Up @@ -232,6 +234,7 @@ class _Single(_TestReader):


class TestSingleFrameReader(_Single):
__test__ = True
def test_next(self):
assert_raises(StopIteration, self.reader.next)

Expand Down
Loading

0 comments on commit dea36df

Please sign in to comment.