x has to be an instance of a class inheriting from Base.
(x)
| 3524 | class Base(object): |
| 3525 | pass |
| 3526 | def verify_dict_readonly(x): |
| 3527 | """ |
| 3528 | x has to be an instance of a class inheriting from Base. |
| 3529 | """ |
| 3530 | cant(x, {}) |
| 3531 | try: |
| 3532 | del x.__dict__ |
| 3533 | except (AttributeError, TypeError): |
| 3534 | pass |
| 3535 | else: |
| 3536 | self.fail("shouldn't allow del %r.__dict__" % x) |
| 3537 | dict_descr = Base.__dict__["__dict__"] |
| 3538 | try: |
| 3539 | dict_descr.__set__(x, {}) |
| 3540 | except (AttributeError, TypeError): |
| 3541 | pass |
| 3542 | else: |
| 3543 | self.fail("dict_descr allowed access to %r's dict" % x) |
| 3544 | |
| 3545 | # Classes don't allow __dict__ assignment and have readonly dicts |
| 3546 | class Meta1(type, Base): |