@@ -883,6 +883,12 @@ Test cases
883
883
| :meth: `assertNotIsInstance(a, b) | ``not isinstance(a, b) `` | 3.2 |
884
884
| <TestCase.assertNotIsInstance>` | | |
885
885
+-----------------------------------------+-----------------------------+---------------+
886
+ | :meth: `assertIsSubclass(a, b) | ``issubclass(a, b) `` | 3.14 |
887
+ | <TestCase.assertIsSubclass>` | | |
888
+ +-----------------------------------------+-----------------------------+---------------+
889
+ | :meth: `assertNotIsSubclass(a, b) | ``not issubclass(a, b) `` | 3.14 |
890
+ | <TestCase.assertNotIsSubclass>` | | |
891
+ +-----------------------------------------+-----------------------------+---------------+
886
892
887
893
All the assert methods accept a *msg * argument that, if specified, is used
888
894
as the error message on failure (see also :data: `longMessage `).
@@ -961,6 +967,15 @@ Test cases
961
967
.. versionadded :: 3.2
962
968
963
969
970
+ .. method :: assertIsSubclass(cls, superclass, msg=None)
971
+ assertNotIsSubclass(cls, superclass, msg=None)
972
+
973
+ Test that *cls * is (or is not) a subclass of *superclass * (which can be a
974
+ class or a tuple of classes, as supported by :func: `issubclass `).
975
+ To check for the exact type, use :func: `assertIs(cls, superclass) <assertIs> `.
976
+
977
+ .. versionadded :: next
978
+
964
979
965
980
It is also possible to check the production of exceptions, warnings, and
966
981
log messages using the following methods:
@@ -1210,6 +1225,24 @@ Test cases
1210
1225
| <TestCase.assertCountEqual>` | elements in the same number, | |
1211
1226
| | regardless of their order. | |
1212
1227
+---------------------------------------+--------------------------------+--------------+
1228
+ | :meth: `assertStartsWith(a, b) | ``a.startswith(b) `` | 3.14 |
1229
+ | <TestCase.assertStartsWith>` | | |
1230
+ +---------------------------------------+--------------------------------+--------------+
1231
+ | :meth: `assertNotStartsWith(a, b) | ``not a.startswith(b) `` | 3.14 |
1232
+ | <TestCase.assertNotStartsWith>` | | |
1233
+ +---------------------------------------+--------------------------------+--------------+
1234
+ | :meth: `assertEndsWith(a, b) | ``a.endswith(b) `` | 3.14 |
1235
+ | <TestCase.assertEndsWith>` | | |
1236
+ +---------------------------------------+--------------------------------+--------------+
1237
+ | :meth: `assertNotEndsWith(a, b) | ``not a.endswith(b) `` | 3.14 |
1238
+ | <TestCase.assertNotEndsWith>` | | |
1239
+ +---------------------------------------+--------------------------------+--------------+
1240
+ | :meth: `assertHasAttr(a, b) | ``hastattr(a, b) `` | 3.14 |
1241
+ | <TestCase.assertHasAttr>` | | |
1242
+ +---------------------------------------+--------------------------------+--------------+
1243
+ | :meth: `assertNotHasAttr(a, b) | ``not hastattr(a, b) `` | 3.14 |
1244
+ | <TestCase.assertNotHasAttr>` | | |
1245
+ +---------------------------------------+--------------------------------+--------------+
1213
1246
1214
1247
1215
1248
.. method :: assertAlmostEqual(first, second, places=7, msg=None, delta=None)
@@ -1279,6 +1312,34 @@ Test cases
1279
1312
.. versionadded :: 3.2
1280
1313
1281
1314
1315
+ .. method :: assertStartsWith(s, prefix, msg=None)
1316
+ .. method :: assertNotStartsWith(s, prefix, msg=None)
1317
+
1318
+ Test that the Unicode or byte string *s * starts (or does not start)
1319
+ with a *prefix *.
1320
+ *prefix * can also be a tuple of strings to try.
1321
+
1322
+ .. versionadded :: next
1323
+
1324
+
1325
+ .. method :: assertEndsWith(s, suffix, msg=None)
1326
+ .. method :: assertNotEndsWith(s, suffix, msg=None)
1327
+
1328
+ Test that the Unicode or byte string *s * ends (or does not end)
1329
+ with a *suffix *.
1330
+ *suffix * can also be a tuple of strings to try.
1331
+
1332
+ .. versionadded :: next
1333
+
1334
+
1335
+ .. method :: assertHasAttr(obj, name, msg=None)
1336
+ .. method :: assertNotHasAttr(obj, name, msg=None)
1337
+
1338
+ Test that the object *obj * has (or has not) an attribute *name *.
1339
+
1340
+ .. versionadded :: next
1341
+
1342
+
1282
1343
.. _type-specific-methods :
1283
1344
1284
1345
The :meth: `assertEqual ` method dispatches the equality check for objects of
0 commit comments