Code Duplication    Length = 34-36 lines in 2 locations

tests/test_compat.py 2 locations

@@ 124-159 (lines=36) @@
121
    assert DClass().ns.footer == 3
122
123
124
def test_abstractclassmethod_basics(abc):
125
    """Test abstract classmethod works as expected.
126
127
    Adapted from Python's test suite.
128
    """
129
    @classmethod
130
    @abstractmethod
131
    def footer(cls):
132
        """Return cls. Abstract."""
133
        return cls
134
    assert footer.__isabstractmethod__
135
136
    @classmethod
137
    def barter(cls):
138
        """Return cls. Concrete."""
139
        return cls
140
    assert not getattr(barter, "__isabstractmethod__", False)
141
142
    class CClass(metaclass=abc.NamespaceableABCMeta):
143
        """A throwaway test class."""
144
        @classmethod
145
        @abstractmethod
146
        def footer(cls):
147
            """Return class name. Abstract."""
148
            return cls.__name__
149
    with pytest.raises(TypeError):
150
        print(CClass())
151
152
    class DClass(CClass):
153
        """A throwaway test class."""
154
        @classmethod
155
        def footer(cls):
156
            """Return class name. Concrete."""
157
            return super().footer()
158
    assert DClass.footer() == 'DClass'
159
    assert DClass().footer() == 'DClass'
160
161
162
def test_abstractclassmethod_namespaced(abc, namespace):
@@ 184-217 (lines=34) @@
181
    assert DClass().ns.footer() == 'DClass'
182
183
184
def test_abstractstaticmethod_basics(abc):
185
    """Test abstract staticmethod works as expected.
186
187
    Adapted from Python's test suite.
188
    """
189
    @staticmethod
190
    @abstractmethod
191
    def footer():
192
        """Do nothing. Abstract."""
193
    assert footer.__isabstractmethod__
194
195
    @staticmethod
196
    def barter():
197
        """Do nothing. Concrete."""
198
    assert not getattr(barter, "__isabstractmethod__", False)
199
200
    class CClass(metaclass=abc.NamespaceableABCMeta):
201
        """A throwaway test class."""
202
        @staticmethod
203
        @abstractmethod
204
        def footer():
205
            """Return 3. Abstract."""
206
            return 3
207
    with pytest.raises(TypeError):
208
        print(CClass())
209
210
    class DClass(CClass):
211
        """A throwaway test class."""
212
        @staticmethod
213
        def footer():
214
            """Return 4. Concrete."""
215
            return 4
216
    assert DClass.footer() == 4
217
    assert DClass().footer() == 4
218
219
220
def test_abstractstaticmethod_namespaced(abc, namespace):