MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_descriptors_with_abstractmethod

Method test_descriptors_with_abstractmethod

Lib/test/test_abc.py:200–228  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

198 self.assertTrue(isabstract(F))
199
200 def test_descriptors_with_abstractmethod(self):
201 class C(metaclass=abc_ABCMeta):
202 @property
203 @abc.abstractmethod
204 def foo(self): return 3
205 @foo.setter
206 @abc.abstractmethod
207 def foo(self, val): pass
208 self.assertRaises(TypeError, C)
209 class D(C):
210 @C.foo.getter
211 def foo(self): return super().foo
212 self.assertRaises(TypeError, D)
213 class E(D):
214 @D.foo.setter
215 def foo(self, val): pass
216 self.assertEqual(E().foo, 3)
217 # check that the property's __isabstractmethod__ descriptor does the
218 # right thing when presented with a value that fails truth testing:
219 class NotBool(object):
220 def __bool__(self):
221 raise ValueError()
222 __len__ = __bool__
223 with self.assertRaises(ValueError):
224 class F(C):
225 def bar(self):
226 pass
227 bar.__isabstractmethod__ = NotBool()
228 foo = property(bar)
229
230
231 def test_customdescriptors_with_abstractmethod(self):

Callers

nothing calls this directly

Calls 3

EClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected