Skip to content

Commit

Permalink
Replace object with TestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
utkbansal committed Feb 14, 2017
1 parent 180f314 commit a8559b9
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def test_write_not_changing_ts(self):
assert_timestep_almost_equal(copy_ts, ts)


class BaseTimestepTest(object):
class BaseTimestepTest(TestCase):
"""Test all the base functionality of a Timestep
All Timesteps must pass these tests!
Expand Down
3 changes: 2 additions & 1 deletion testsuite/MDAnalysisTests/coordinates/test_crd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from MDAnalysisTests.datafiles import CRD
from MDAnalysisTests import tempdir, make_Universe

from unittest import TestCase

class TestCRDWriter(object):
class TestCRDWriter(TestCase):
def setUp(self):
self.u = mda.Universe(CRD)
self.tmpdir = tempdir.TempDir()
Expand Down
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/coordinates/test_dcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_with_statement(self):
err_msg="with_statement: DCDReader does not read all frames")


class TestDCDReader(object):
class TestDCDReader(TestCase):
def setUp(self):
self.universe = mda.Universe(PSF, DCD)
self.dcd = self.universe.trajectory
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_dlpoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
DLP_CONFIG_order, DLP_HISTORY,
DLP_HISTORY_minimal, DLP_HISTORY_order)
from MDAnalysisTests.coordinates.base import BaseTimestepTest
from unittest import TestCase


class _DLPConfig(object):
class _DLPConfig(TestCase):
def setUp(self):
self.r = mda.coordinates.DLPoly.ConfigReader
rd = self.rd = self.r(self.f)
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_volume(self):
err_msg="wrong volume for unitcell (rhombic dodecahedron)")


class TestGROIncompleteVels(object):
class TestGROIncompleteVels(TestCase):
def setUp(self):
self.u = mda.Universe(GRO_incomplete_vels)

Expand Down Expand Up @@ -341,7 +341,7 @@ def test_writer_large_residue_count(self):



class TestGROWriterVels(object):
class TestGROWriterVels(TestCase):
def setUp(self):
self.tmpdir = tempdir.TempDir()
self.outfile = self.tmpdir.name + '/gro-writervels.gro'
Expand Down
11 changes: 6 additions & 5 deletions testsuite/MDAnalysisTests/coordinates/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
LAMMPScnt, LAMMPShyd, LAMMPSdata, LAMMPSdata_mini
)

from unittest import TestCase

def test_datareader_ValueError():
from MDAnalysis.coordinates.LAMMPS import DATAReader
assert_raises(ValueError, DATAReader, 'filename')


class _TestLammpsData_Coords(object):
class _TestLammpsData_Coords(TestCase):
"""Tests using a .data file for loading single frame.
All topology loading from MDAnalysisTests.data is done in test_topology
Expand Down Expand Up @@ -67,7 +68,7 @@ class TestLammpsData_Coords(_TestLammpsData_Coords, RefLAMMPSData):
class TestLammpsDataMini_Coords(_TestLammpsData_Coords, RefLAMMPSDataMini):
pass

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

Expand Down Expand Up @@ -293,7 +294,7 @@ def test_OtherWriter(self):
self.u.trajectory[0].positions,
6, err_msg="coordinate mismatch between corresponding frames")

class TestLAMMPSDCDWriterClass(object):
class TestLAMMPSDCDWriterClass(TestCase):
flavor = 'LAMMPS'

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


class TestLammpsDataTriclinic(object):
class TestLammpsDataTriclinic(TestCase):
def setUp(self):
self.u = mda.Universe(LAMMPScnt)

Expand All @@ -351,7 +352,7 @@ def test_triclinicness(self):
assert_(self.u.dimensions[4] == 90.)
assert_(self.u.dimensions[5] == 120.)

class TestDataWriterErrors(object):
class TestDataWriterErrors(TestCase):
def setUp(self):
self.tmpdir = tempdir.TempDir()
self.outfile = os.path.join(self.tmpdir.name, 'out.data')
Expand Down
6 changes: 3 additions & 3 deletions testsuite/MDAnalysisTests/coordinates/test_mmtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from MDAnalysisTests.datafiles import MMTF, MMTF_gz

from MDAnalysis.coordinates.MMTF import MMTFReader
from numpy.testing import TestCase


class TestMMTFReader(object):
class TestMMTFReader(TestCase):
def setUp(self):
self.r = MMTFReader(MMTF)

Expand Down Expand Up @@ -37,7 +37,7 @@ def test_len(self):
# should be single frame
assert_(len(self.r) == 1)

class TestMMTFReaderGZ(object):
class TestMMTFReaderGZ(TestCase):
def setUp(self):
self.r = MMTFReader(MMTF_gz)

Expand Down
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/coordinates/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_import_netcdfwriter(self):
raise AssertionError


class TestNCDFWriterErrors(object):
class TestNCDFWriterErrors(TestCase):
@dec.skipif(module_not_found("netCDF4"), "Test skipped because netCDF is not available.")
def setUp(self):
self.tmpdir = tempdir.TempDir()
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_null.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import MDAnalysis as mda

from MDAnalysisTests.datafiles import (TPR, XTC)
from numpy.testing import TestCase


class TestNullWriter(object):
class TestNullWriter(TestCase):
def setUp(self):
self.universe = mda.Universe(TPR, XTC)

Expand Down
6 changes: 3 additions & 3 deletions testsuite/MDAnalysisTests/coordinates/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def test_first_residue(self):
assert_(len(self.universe.residues[0].atoms) == 19)


class TestIncompletePDB(object):
class TestIncompletePDB(TestCase):
"""Tests for Issue #396
Reads an incomplete (but still intelligible) PDB file
Expand Down Expand Up @@ -689,7 +689,7 @@ def test_reading_trajectory(self):
pass


class TestPDBXLSerial(object):
class TestPDBXLSerial(TestCase):
"""For Issue #446"""

def setUp(self):
Expand Down Expand Up @@ -735,7 +735,7 @@ def test_uses_PDBReader(self):
"failed to choose PDBReader")


class TestPDBWriterOccupancies(object):
class TestPDBWriterOccupancies(TestCase):
"""Tests for Issue #620"""
def setUp(self):
self.tempdir = tempdir.TempDir()
Expand Down
6 changes: 3 additions & 3 deletions testsuite/MDAnalysisTests/coordinates/test_pdbqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

import os
from MDAnalysisTests import tempdir, make_Universe
from numpy.testing import TestCase


class TestPDBQT(object):
class TestPDBQT(TestCase):
def setUp(self):
"""Set up the standard AdK system in implicit solvent."""
self.universe = mda.Universe(PDBQT_input) # PDBQT
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_frame(self):
"wrong frame number (0-based, should be 0 for single frame readers)")


class TestPDBQTWriter(object):
class TestPDBQTWriter(TestCase):
def setUp(self):
self.reqd_attributes = ['names', 'types', 'resids', 'resnames', 'radii', 'charges']
self.tmpdir = tempdir.TempDir()
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_pqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from MDAnalysisTests.coordinates.base import _SingleFrameReader
from MDAnalysisTests.datafiles import PQR
from MDAnalysisTests import tempdir, make_Universe

from numpy.testing import TestCase

class TestPQRReader(_SingleFrameReader):
def setUp(self):
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_total_charge(self):
u.atoms.total_charge(), self.ref_charmm_totalcharge, 3,
"Total charge (in CHARMM) does not match expected value.")

class TestPQRWriterMissingAttrs(object):
class TestPQRWriterMissingAttrs(TestCase):
# pqr requires names, resids, resnames, segids, radii, charges
def setUp(self):
self.reqd_attributes = ['names', 'resids', 'resnames', 'radii', 'charges']
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_reader_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from numpy.testing import assert_equal, assert_raises
import numpy as np

from numpy.testing import TestCase
"""
Isolate the API definitions of Readers independent of implementations
"""
Expand Down Expand Up @@ -69,7 +69,7 @@ def _read_first_frame(self):
self.ts.frame = 0


class _TestReader(object):
class _TestReader(TestCase):
"""Basic API readers"""
def setUp(self):
self.reader = self.readerclass('test.txt')
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_timestep_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
NCDF, TRZ_psf, TRZ)

from MDAnalysisTests.coordinates.base import BaseTimestepTest

from numpy.testing import TestCase

# Can add in custom tests for a given Timestep here!
class TestBaseTimestep(BaseTimestepTest):
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_other_timestep(self):
# TODO: Merge this into generic Reader tests
# These tests are all included in BaseReaderTest
# Once Readers use that TestClass, delete this one
class BaseTimestepInterfaceTest(object):
class BaseTimestepInterfaceTest(TestCase):
"""Test the Timesteps created by Readers
This checks that Readers are creating correct Timestep objects,
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_trj.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from MDAnalysisTests.coordinates.reference import RefACHE, RefCappedAla
from MDAnalysisTests.datafiles import (PRM, TRJ, TRJ_bz2, PRMpbc, TRJpbc_bz2)
from MDAnalysisTests.coordinates.base import BaseTimestepTest
from numpy.testing import TestCase


class _TRJReaderTest(object):
class _TRJReaderTest(TestCase):
# use as a base class (override setUp()) and mixin a reference
def tearDown(self):
del self.universe
Expand Down
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/coordinates/test_trz.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def test_long_title(self):
self.Writer, self.outfile, self.ref_n_atoms, title=title)


class TestTRZWriter2(object):
class TestTRZWriter2(TestCase):
def setUp(self):
self.u = mda.Universe(two_water_gro)

Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from MDAnalysisTests.coordinates.base import (BaseReaderTest, BaseReference,
BaseWriterTest)
from MDAnalysisTests import tempdir, make_Universe

from numpy.testing import TestCase

class XYZReference(BaseReference):
def __init__(self):
Expand Down Expand Up @@ -101,7 +101,7 @@ def __init__(self):
super(Test_XYZBZWriter, self).__init__(XYZ_BZ_Reference())


class TestXYZWriterNames(object):
class TestXYZWriterNames(TestCase):
def setUp(self):
self.tmpdir = tempdir.TempDir()
self.outfile = self.tmpdir.name + '/outfile.xyz'
Expand Down

0 comments on commit a8559b9

Please sign in to comment.