Skip to content

Commit 9f9a611

Browse files
committed
Skip tests when periodictable is not installed.
Display gentle warning rather than failed tests.
1 parent e08ae72 commit 9f9a611

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

diffpy/srreal/tests/testatomradiitable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import unittest
99
import cPickle
10+
from diffpy.srreal.tests.testutils import TestCasePeriodictableOptional
1011
from diffpy.srreal.atomradiitable import AtomRadiiTable, CovalentRadiiTable
1112
from diffpy.srreal.atomradiitable import ConstantRadiiTable
1213

@@ -109,7 +110,7 @@ def test_toString(self):
109110
# End of class TestAtomRadiiTable
110111

111112
##############################################################################
112-
class TestCovalentRadiiTable(unittest.TestCase):
113+
class TestCovalentRadiiTable(TestCasePeriodictableOptional):
113114

114115
def setUp(self):
115116
self.rtb = CovalentRadiiTable()

diffpy/srreal/tests/testutils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
TestCaseObjCrystOptional = object
2626
logging.warning('Compiled without ObjCryst, pyobjcryst tests skipped.')
2727

28+
# class TestCasePeriodictableOptional
29+
30+
try:
31+
import periodictable
32+
from unittest import TestCase as TestCasePeriodictableOptional
33+
except ImportError:
34+
TestCasePeriodictableOptional = object
35+
logging.warning('Cannot import periodictable, periodictable tests skipped.')
36+
except TypeError:
37+
TestCaseObjCrystOptional = object
38+
logging.warning('Compiled without ObjCryst, pyobjcryst tests skipped.')
39+
2840
# helper functions
2941

3042
def datafile(filename):

0 commit comments

Comments
 (0)