| 982 | ScrollingMixin, EditingMixin, object)) |
| 983 | |
| 984 | def test_mro_disagreement(self): |
| 985 | # Testing error messages for MRO disagreement... |
| 986 | mro_err_msg = ("Cannot create a consistent method resolution " |
| 987 | "order (MRO) for bases ") |
| 988 | |
| 989 | def raises(exc, expected, callable, *args): |
| 990 | try: |
| 991 | callable(*args) |
| 992 | except exc as msg: |
| 993 | # the exact msg is generally considered an impl detail |
| 994 | if support.check_impl_detail(): |
| 995 | if not str(msg).startswith(expected): |
| 996 | self.fail("Message %r, expected %r" % |
| 997 | (str(msg), expected)) |
| 998 | else: |
| 999 | self.fail("Expected %s" % exc) |
| 1000 | |
| 1001 | class A(object): pass |
| 1002 | class B(A): pass |
| 1003 | class C(object): pass |
| 1004 | |
| 1005 | # Test some very simple errors |
| 1006 | raises(TypeError, "duplicate base class A", |
| 1007 | type, "X", (A, A), {}) |
| 1008 | raises(TypeError, mro_err_msg, |
| 1009 | type, "X", (A, B), {}) |
| 1010 | raises(TypeError, mro_err_msg, |
| 1011 | type, "X", (A, C, B), {}) |
| 1012 | # Test a slightly more complex error |
| 1013 | class GridLayout(object): pass |
| 1014 | class HorizontalGrid(GridLayout): pass |
| 1015 | class VerticalGrid(GridLayout): pass |
| 1016 | class HVGrid(HorizontalGrid, VerticalGrid): pass |
| 1017 | class VHGrid(VerticalGrid, HorizontalGrid): pass |
| 1018 | raises(TypeError, mro_err_msg, |
| 1019 | type, "ConfusedGrid", (HVGrid, VHGrid), {}) |
| 1020 | |
| 1021 | def test_object_class(self): |
| 1022 | # Testing object class... |