Skip to content

Commit

Permalink
netCDF tests now skipped if library missing (closes #124)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmelo committed Oct 10, 2015
1 parent a626960 commit 1bf2db0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion testsuite/MDAnalysisTests/coordinates/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from nose.plugins.attrib import attr
from numpy.testing import (assert_equal, assert_array_almost_equal,
assert_almost_equal, assert_raises)
assert_almost_equal, assert_raises, dec)
import tempdir
from unittest import TestCase

Expand All @@ -14,8 +14,16 @@
from MDAnalysisTests.coordinates.test_trj import _TRJReaderTest
from MDAnalysisTests.coordinates.reference import (RefVGV,)

def netcdf_missing():
try:
import netCDF4
except ImportError:
return True
else:
return False

class TestNCDFReader(_TRJReaderTest, RefVGV):
@dec.skipif(netcdf_missing(), "Test skipped because netCDF is not available.")
def setUp(self):
self.universe = mda.Universe(PRMncdf, NCDF)
self.prec = 3
Expand All @@ -38,6 +46,7 @@ class TestNCDFReader2(TestCase):
Contributed by Albert Solernou
"""

@dec.skipif(netcdf_missing(), "Test skipped because netCDF is not available.")
def setUp(self):
self.u = mda.Universe(PFncdf_Top, PFncdf_Trj)
self.prec = 3
Expand Down Expand Up @@ -94,6 +103,7 @@ def test_time_2(self):


class TestNCDFWriter(TestCase, RefVGV):
@dec.skipif(netcdf_missing(), "Test skipped because netCDF is not available.")
def setUp(self):
self.universe = mda.Universe(PRMncdf, NCDF)
self.prec = 6
Expand Down Expand Up @@ -211,6 +221,7 @@ def test_write_AtomGroup(self):
class TestNCDFWriterVelsForces(TestCase):
"""Test writing NCDF trajectories with a mixture of options"""

@dec.skipif(netcdf_missing(), "Test skipped because netCDF is not available.")
def setUp(self):
self.tmpdir = tempdir.TempDir()
self.outfile = self.tmpdir.name + '/ncdf-write-vels-force.ncdf'
Expand Down

0 comments on commit 1bf2db0

Please sign in to comment.