Skip to content

Commit ed9bdb3

Browse files
committed
Using common unittest base for python 2 and 3.
1 parent 0042fa8 commit ed9bdb3

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

cluster/test/test_hierarchical.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,21 @@
3232
from cluster import HierarchicalClustering
3333

3434

35-
class HClusterSmallListTestCase(unittest.TestCase):
36-
"""
37-
Test for Bug #1516204
38-
"""
35+
class Py23TestCase(unittest.TestCase):
3936

4037
def __init__(self, *args, **kwargs):
41-
super(HClusterSmallListTestCase, self).__init__(*args, **kwargs)
38+
super(Py23TestCase, self).__init__(*args, **kwargs)
4239
if hexversion < 0x030000f0:
4340
self.assertCItemsEqual = self.assertItemsEqual
4441
else:
4542
self.assertCItemsEqual = self.assertCountEqual
4643

44+
45+
class HClusterSmallListTestCase(Py23TestCase):
46+
"""
47+
Test for Bug #1516204
48+
"""
49+
4750
def testClusterLen1(self):
4851
"""
4952
Testing if hierarchical clustering a set of length 1 returns a set of
@@ -60,7 +63,7 @@ def testClusterLen0(self):
6063
self.assertEqual([], cl.getlevel(40))
6164

6265

63-
class HClusterIntegerTestCase(unittest.TestCase):
66+
class HClusterIntegerTestCase(Py23TestCase):
6467

6568
def __init__(self, *args, **kwargs):
6669
super(HClusterIntegerTestCase, self).__init__(*args, **kwargs)
@@ -172,7 +175,7 @@ def testMultiprocessing(self):
172175
self.assertEqual(sorted(new_data), sorted(self.__data))
173176

174177

175-
class HClusterStringTestCase(unittest.TestCase):
178+
class HClusterStringTestCase(Py23TestCase):
176179

177180
def sim(self, x, y):
178181
sm = SequenceMatcher(lambda x: x in ". -", x, y)
@@ -212,3 +215,13 @@ def testUnmodifiedData(self):
212215
new_data = []
213216
[new_data.extend(_) for _ in cl.getlevel(0.5)]
214217
self.assertEqual(sorted(new_data), sorted(self.__data))
218+
219+
220+
if __name__ == '__main__':
221+
suite = unittest.TestSuite((
222+
unittest.makeSuite(HClusterIntegerTestCase),
223+
unittest.makeSuite(HClusterSmallListTestCase),
224+
unittest.makeSuite(HClusterStringTestCase),
225+
))
226+
227+
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)