Code Duplication    Length = 25-27 lines in 2 locations

yorm/test/test_types_standard.py 2 locations

@@ 68-94 (lines=27) @@
65
            expect(String.to_data(first)) == second
66
67
68
def describe_integer():
69
70
    obj = 42
71
    pairs = [
72
        (obj, obj),
73
        (None, 0),
74
        ("1", 1),
75
        ("1.1", 1),
76
        (True, 1),
77
        (False, 0),
78
    ]
79
80
    def describe_to_value():
81
82
        @pytest.mark.parametrize("first,second", pairs)
83
        def it_converts_correctly(first, second):
84
            expect(Integer.to_value(first)) == second
85
86
        def it_raises_an_exception_when_unable_to_convert():
87
            with expect.raises(ValueError):
88
                Integer.to_value("abc")
89
90
    def describe_to_data():
91
92
        @pytest.mark.parametrize("first,second", pairs)
93
        def it_converts_correctly(first, second):
94
            expect(Integer.to_data(first)) == second
95
96
97
def describe_float():
@@ 97-121 (lines=25) @@
94
            expect(Integer.to_data(first)) == second
95
96
97
def describe_float():
98
99
    obj = 4.2
100
    pairs = [
101
        (obj, obj),
102
        (None, 0.0),
103
        ("1.0", 1.0),
104
        ("1.1", 1.1),
105
    ]
106
107
    def describe_to_value():
108
109
        @pytest.mark.parametrize("first,second", pairs)
110
        def it_converts_correctly(first, second):
111
            expect(Float.to_value(first)) == second
112
113
        def it_raises_an_exception_when_unable_to_convert():
114
            with expect.raises(ValueError):
115
                Float.to_value("abc")
116
117
    def describe_to_data():
118
119
        @pytest.mark.parametrize("first,second", pairs)
120
        def it_converts_correctly(first, second):
121
            expect(Float.to_data(first)) == second
122
123
124
def describe_boolean():