@@ 173-204 (lines=32) @@ | ||
170 | assert D().ns.footer() == 'D' |
|
171 | ||
172 | ||
173 | def test_abstractstaticmethod_basics(abc): |
|
174 | """Test abstract staticmethod works as expected. |
|
175 | ||
176 | Adapted from Python's test suite. |
|
177 | """ |
|
178 | @staticmethod |
|
179 | @abstractmethod |
|
180 | def footer(): |
|
181 | pass |
|
182 | assert footer.__isabstractmethod__ |
|
183 | ||
184 | @staticmethod |
|
185 | def barter(): |
|
186 | pass |
|
187 | assert not (getattr(barter, "__isabstractmethod__", False)) |
|
188 | ||
189 | class C(metaclass=abc.NamespaceableABCMeta): |
|
190 | """A throwaway test class.""" |
|
191 | @staticmethod |
|
192 | @abstractmethod |
|
193 | def footer(): |
|
194 | return 3 |
|
195 | with pytest.raises(TypeError): |
|
196 | print(C()) |
|
197 | ||
198 | class D(C): |
|
199 | """A throwaway test class.""" |
|
200 | @staticmethod |
|
201 | def footer(): |
|
202 | return 4 |
|
203 | assert D.footer() == 4 |
|
204 | assert D().footer() == 4 |
|
205 | ||
206 | ||
207 | def test_abstractstaticmethod_namespaced(abc, namespace): |
|
@@ 117-148 (lines=32) @@ | ||
114 | assert D().ns.footer == 3 |
|
115 | ||
116 | ||
117 | def test_abstractclassmethod_basics(abc): |
|
118 | """Test abstract classmethod works as expected. |
|
119 | ||
120 | Adapted from Python's test suite. |
|
121 | """ |
|
122 | @classmethod |
|
123 | @abstractmethod |
|
124 | def footer(cls): |
|
125 | pass |
|
126 | assert footer.__isabstractmethod__ |
|
127 | ||
128 | @classmethod |
|
129 | def barter(cls): |
|
130 | pass |
|
131 | assert not getattr(barter, "__isabstractmethod__", False) |
|
132 | ||
133 | class C(metaclass=abc.NamespaceableABCMeta): |
|
134 | """A throwaway test class.""" |
|
135 | @classmethod |
|
136 | @abstractmethod |
|
137 | def footer(cls): |
|
138 | return cls.__name__ |
|
139 | with pytest.raises(TypeError): |
|
140 | print(C()) |
|
141 | ||
142 | class D(C): |
|
143 | """A throwaway test class.""" |
|
144 | @classmethod |
|
145 | def footer(cls): |
|
146 | return super().footer() |
|
147 | assert D.footer() == 'D' |
|
148 | assert D().footer() == 'D' |
|
149 | ||
150 | ||
151 | def test_abstractclassmethod_namespaced(abc, namespace): |