-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_lcom.py
46 lines (31 loc) · 1.24 KB
/
test_lcom.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
from src.lcom import LCOM4
from src.reflection import ModuleReflection
class LCOMTestCase(object):
@classmethod
def setup_class(cls):
cls.fixtures = ModuleReflection.from_file('./tests/fixtures.py')
class TestLCOM4(LCOMTestCase):
def test_calculate_for_zero(self):
ref = self.fixtures.class_by_name('tests.fixtures.Zero')
lcom = LCOM4().calculate(ref)
assert lcom == 0
def test_calculate_for_one(self):
ref = self.fixtures.class_by_name('tests.fixtures.One')
lcom = LCOM4().calculate(ref)
assert lcom == 1
def test_calculate_for_two(self):
ref = self.fixtures.class_by_name('tests.fixtures.Two')
lcom = LCOM4().calculate(ref)
assert lcom == 2
def test_calculate_for_three(self):
ref = self.fixtures.class_by_name('tests.fixtures.Three')
lcom = LCOM4().calculate(ref)
assert lcom == 3
def test_calculate_for_deep(self):
ref = self.fixtures.class_by_name('tests.fixtures.DeepOne')
lcom = LCOM4().calculate(ref)
assert lcom == 1
def test_calculate_for_loose(self):
ref = self.fixtures.class_by_name('tests.fixtures.Loose')
lcom = LCOM4().calculate(ref)
assert lcom == 0