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

Method cant

Lib/test/test_descr.py:3340–3352  ·  view source on GitHub ↗
(x, C)

Source from the content-addressed store, hash-verified

3338 x.__class__ = cls
3339 self.assertIs(x.__class__, cls)
3340 def cant(x, C):
3341 try:
3342 x.__class__ = C
3343 except TypeError:
3344 pass
3345 else:
3346 self.fail("shouldn't allow %r.__class__ = %r" % (x, C))
3347 try:
3348 delattr(x, "__class__")
3349 except (TypeError, AttributeError):
3350 pass
3351 else:
3352 self.fail("shouldn't allow del %r.__class__" % x)
3353 cant(C(), list)
3354 cant(list(), C)
3355 cant(C(), 1)

Callers

nothing calls this directly

Calls 2

delattrFunction · 0.85
failMethod · 0.45

Tested by

no test coverage detected