Skip to content

Commit

Permalink
Skip the tests that use scipy if scipy is missing
Browse files Browse the repository at this point in the history
Some tests requires scipy. Scipy is an optional dependency, so it can be
missing leading to the tests to fail.

This commit decorate the tests that need scipy with the dec.skipif
decorator. This follows the guideline discussed in MDAnalysis#124.
  • Loading branch information
jbarnoud committed Dec 7, 2015
1 parent 5a3d2b3 commit 6c531e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions testsuite/MDAnalysisTests/analysis/test_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
from __future__ import print_function

import MDAnalysis
import MDAnalysis.analysis.distances
from MDAnalysisTests import module_not_found

from numpy.testing import TestCase, assert_equal
from numpy.testing import TestCase, assert_equal, dec
import numpy as np


class TestContactMatrix(TestCase):

@dec.skipif(module_not_found('scipy'),
"Test skipped because scipy is not available.")
def setUp(self):
import MDAnalysis.analysis.distances
self.coord = np.array([[1, 1, 1],
[5, 5, 5],
[1.1, 1.1, 1.1],
Expand Down
7 changes: 5 additions & 2 deletions testsuite/MDAnalysisTests/analysis/test_leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
import MDAnalysis
from MDAnalysis.analysis.leaflet import LeafletFinder
from MDAnalysisTests import module_not_found

from numpy.testing import TestCase, assert_equal
from numpy.testing import TestCase, assert_equal, dec
import numpy as np

from MDAnalysisTests.datafiles import Martini_membrane_gro

class TestLeafletFinder(TestCase):
@dec.skipif(module_not_found('scipy'),
"Test skipped because scipy is not available.")
def setUp(self):
self.universe = MDAnalysis.Universe(Martini_membrane_gro, Martini_membrane_gro)
self.lipid_heads = self.universe.select_atoms("name PO4")
Expand All @@ -30,6 +32,7 @@ def tearDown(self):
del self.universe

def test_leaflet_finder(self):
from MDAnalysis.analysis.leaflet import LeafletFinder
lfls = LeafletFinder(self.universe, self.lipid_heads, pbc=True)
top_heads, bottom_heads = lfls.groups()
# Make top be... on top.
Expand Down

0 comments on commit 6c531e2

Please sign in to comment.