(self)
| 5122 | self.fail("result does not equal expected, see print above") |
| 5123 | |
| 5124 | def test_inspect_classify_class_attrs(self): |
| 5125 | # indirectly test __objclass__ |
| 5126 | from inspect import Attribute |
| 5127 | values = [ |
| 5128 | Attribute(name='__class__', kind='data', |
| 5129 | defining_class=object, object=EnumType), |
| 5130 | Attribute(name='__contains__', kind='method', |
| 5131 | defining_class=EnumType, object=self.Color.__contains__), |
| 5132 | Attribute(name='__doc__', kind='data', |
| 5133 | defining_class=self.Color, object='...'), |
| 5134 | Attribute(name='__getitem__', kind='method', |
| 5135 | defining_class=EnumType, object=self.Color.__getitem__), |
| 5136 | Attribute(name='__iter__', kind='method', |
| 5137 | defining_class=EnumType, object=self.Color.__iter__), |
| 5138 | Attribute(name='__init_subclass__', kind='class method', |
| 5139 | defining_class=object, object=getattr(self.Color, '__init_subclass__')), |
| 5140 | Attribute(name='__len__', kind='method', |
| 5141 | defining_class=EnumType, object=self.Color.__len__), |
| 5142 | Attribute(name='__members__', kind='property', |
| 5143 | defining_class=EnumType, object=EnumType.__members__), |
| 5144 | Attribute(name='__module__', kind='data', |
| 5145 | defining_class=self.Color, object=__name__), |
| 5146 | Attribute(name='__name__', kind='data', |
| 5147 | defining_class=self.Color, object='Color'), |
| 5148 | Attribute(name='__qualname__', kind='data', |
| 5149 | defining_class=self.Color, object='TestStdLib.Color'), |
| 5150 | Attribute(name='YELLOW', kind='data', |
| 5151 | defining_class=self.Color, object=self.Color.YELLOW), |
| 5152 | Attribute(name='MAGENTA', kind='data', |
| 5153 | defining_class=self.Color, object=self.Color.MAGENTA), |
| 5154 | Attribute(name='CYAN', kind='data', |
| 5155 | defining_class=self.Color, object=self.Color.CYAN), |
| 5156 | Attribute(name='name', kind='data', |
| 5157 | defining_class=Enum, object=Enum.__dict__['name']), |
| 5158 | Attribute(name='value', kind='data', |
| 5159 | defining_class=Enum, object=Enum.__dict__['value']), |
| 5160 | ] |
| 5161 | for v in values: |
| 5162 | try: |
| 5163 | v.name |
| 5164 | except AttributeError: |
| 5165 | print(v) |
| 5166 | values.sort(key=lambda item: item.name) |
| 5167 | result = list(inspect.classify_class_attrs(self.Color)) |
| 5168 | result.sort(key=lambda item: item.name) |
| 5169 | self.assertEqual( |
| 5170 | len(values), len(result), |
| 5171 | "%s != %s" % ([a.name for a in values], [a.name for a in result]) |
| 5172 | ) |
| 5173 | failed = False |
| 5174 | for v, r in zip(values, result): |
| 5175 | if r.name in ('__init_subclass__', '__doc__'): |
| 5176 | # not sure how to make the __init_subclass_ Attributes match |
| 5177 | # so as long as there is one, call it good |
| 5178 | # __doc__ is too big to check exactly, so treat the same as __init_subclass__ |
| 5179 | for name in ('name','kind','defining_class'): |
| 5180 | if getattr(v, name) != getattr(r, name): |
| 5181 | print('\n%s\n%s\n%s\n%s\n' % ('=' * 75, r, v, '=' * 75), sep='') |
nothing calls this directly
no test coverage detected