tests.test_attributes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 69
dl 0
loc 86
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestAttribute.test_is_private_or_public() 0 31 1
A TestAttribute.test_eq() 0 29 1
A TestAttribute.test_is_constant() 0 16 1
1
from unittest import TestCase
2
3
from barentsz._attribute import Attribute
4
5
6
class TestAttribute(TestCase):
7
8
    def test_is_private_or_public(self):
9
        # SETUP
10
        attribute1 = Attribute(
11
            name='attr',
12
            type_=int,
13
            value=42,
14
            doc='some doc',
15
            comment='some comment',
16
            hint='int',
17
            module=None,
18
            assigned_value='42',
19
            line='attr: int = 42',
20
            line_nr=-1)
21
22
        attribute2 = Attribute(
23
            name='_attr',
24
            type_=int,
25
            value=42,
26
            doc='some doc',
27
            comment='some comment',
28
            hint='int',
29
            module=None,
30
            assigned_value='42',
31
            line='attr: int = 42',
32
            line_nr=-1)
33
34
        # EXECUTE & VERIFY
35
        self.assertTrue(not attribute1.is_private)
36
        self.assertTrue(attribute1.is_public)
37
        self.assertTrue(attribute2.is_private)
38
        self.assertTrue(not attribute2.is_public)
39
40
    def test_is_constant(self):
41
        # SETUP
42
        attribute1 = Attribute(
43
            name='ATTR',
44
            type_=int,
45
            value=42,
46
            doc='some doc',
47
            comment='some comment',
48
            hint='int',
49
            module=None,
50
            assigned_value='42',
51
            line='attr: int = 42',
52
            line_nr=-1)
53
54
        # EXECUTE & VERIFY
55
        self.assertTrue(attribute1.is_constant)
56
57
    def test_eq(self):
58
        # SETUP
59
        attribute1 = Attribute(
60
            name='attr',
61
            type_=int,
62
            value=42,
63
            doc='some doc',
64
            comment='some comment',
65
            hint='int',
66
            module=None,
67
            assigned_value='42',
68
            line='attr: int = 42',
69
            line_nr=-1)
70
71
        attribute2 = Attribute(
72
            name='attr',
73
            type_=int,
74
            value=42,
75
            doc='some doc',
76
            comment='some comment',
77
            hint='int',
78
            module=None,
79
            assigned_value='42',
80
            line='attr: int = 42',
81
            line_nr=-1)
82
83
        # EXECUTE & VERIFY
84
        self.assertTrue(attribute1 is not attribute2)
85
        self.assertTrue(attribute1 == attribute2)
86