self.assertEqual(x2, SubSpam)
self.assertEqual(a2, a1)
self.assertEqual(d2, d1)
- with self.assertRaises(TypeError):
+
+ with self.assertRaises(TypeError) as cm:
spam_cm()
- with self.assertRaises(TypeError):
+ self.assertEqual(
+ str(cm.exception),
+ "descriptor 'classmeth' of 'xxsubtype.spamlist' "
+ "object needs an argument")
+
+ with self.assertRaises(TypeError) as cm:
spam_cm(spam.spamlist())
- with self.assertRaises(TypeError):
+ self.assertEqual(
+ str(cm.exception),
+ "descriptor 'classmeth' requires a type "
+ "but received a 'xxsubtype.spamlist' instance")
+
+ with self.assertRaises(TypeError) as cm:
spam_cm(list)
+ self.assertEqual(
+ str(cm.exception),
+ "descriptor 'classmeth' requires a subtype of 'xxsubtype.spamlist' "
+ "but received 'list'")
def test_staticmethods(self):
# Testing static methods...
if (!PyType_Check(self)) {
PyErr_Format(PyExc_TypeError,
"descriptor '%V' requires a type "
- "but received a '%.100s'",
+ "but received a '%.100s' instance",
descr_name((PyDescrObject *)descr), "?",
- PyDescr_TYPE(descr)->tp_name,
self->ob_type->tp_name);
return NULL;
}
if (!PyType_IsSubtype((PyTypeObject *)self, PyDescr_TYPE(descr))) {
PyErr_Format(PyExc_TypeError,
- "descriptor '%V' "
- "requires a subtype of '%.100s' "
- "but received '%.100s",
+ "descriptor '%V' requires a subtype of '%.100s' "
+ "but received '%.100s'",
descr_name((PyDescrObject *)descr), "?",
PyDescr_TYPE(descr)->tp_name,
- self->ob_type->tp_name);
+ ((PyTypeObject*)self)->tp_name);
return NULL;
}