-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathunit_tests.py
executable file
·51 lines (41 loc) · 1.66 KB
/
unit_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python2.6
######################################################################
# unit_tests.py
######################################################################
# In which we define unit tests for the project.
######################################################################
# For license information, see LICENSE file
# For copyright information, see COPYRIGHT file
######################################################################
import itertools
import unittest
import fp_mining
import dataset
class TestFrequentPatternFunctions(unittest.TestCase):
""" Unit tests for fp_mining """
class TestDatasetFunctions(unittest.TestCase):
def test_dataset_conversion(self):
ds = dataset.Dataset()
ds.readFromFile('../data/tiny.dat')
vds = dataset.VerticalDataset()
vds.readFromDataset(ds)
ds2 = dataset.Dataset()
ds2.readFromDataset(vds)
self.assertEqual(ds.rows,ds2.rows)
ds.readFromFile('../data/chess_tiny.dat')
vds = dataset.VerticalDataset()
vds.readFromDataset(ds)
ds2 = dataset.Dataset()
ds2.readFromDataset(vds)
self.assertEqual(ds.rows,ds2.rows)
ds.readFromFile('../data/chess.dat')
vds = dataset.VerticalDataset()
vds.readFromDataset(ds)
ds2 = dataset.Dataset()
ds2.readFromDataset(vds)
self.assertEqual(ds.rows,ds2.rows)
if __name__ == '__main__':
tl = unittest.TestLoader()
suite = tl.loadTestsFromTestCase(TestFrequentPatternFunctions)
suite.addTest(tl.loadTestsFromTestCase(TestDatasetFunctions))
unittest.TextTestRunner(verbosity=2).run(suite)