|
25 | 25 | assert_not_in, |
26 | 26 | assert_regex, |
27 | 27 | assert_is_instance, |
| 28 | + assert_not_is_instance, |
28 | 29 | assert_has_attr, |
29 | 30 | assert_datetime_about_now, |
30 | 31 | assert_datetime_about_now_utc, |
@@ -341,26 +342,36 @@ def test_assert_between__too_high__custom_message(self): |
341 | 342 | with _assert_raises_assertion("my message"): |
342 | 343 | assert_between(0, 10, 11, msg="my message") |
343 | 344 |
|
344 | | - def test_assert_is_instance__is_instance(self): |
| 345 | + def test_assert_is_instance(self): |
345 | 346 | assert_is_instance(4, int) |
346 | | - |
347 | | - def test_assert_is_instance__is_instance__multiple_classes(self): |
348 | 347 | assert_is_instance(4, (str, int)) |
349 | | - |
350 | | - def test_assert_is_instance__is_sub_class(self): |
351 | 348 | assert_is_instance(OSError(), Exception) |
| 349 | + with _assert_raises_assertion("my message"): |
| 350 | + assert_is_instance("my string", int, msg="my message") |
352 | 351 |
|
353 | | - def test_assert_is_instance__not_instance__default_message(self): |
354 | | - expected_message = ("'my string' is of <class 'str'>, " |
355 | | - "expected <class 'int'>") |
| 352 | + def test_assert_is_instance__default_message(self): |
| 353 | + expected_message = ( |
| 354 | + "'my string' is an instance of <class 'str'>, " |
| 355 | + "expected <class 'int'>") |
356 | 356 | if sys.version_info[0] < 3: |
357 | 357 | expected_message = expected_message.replace("class", "type") |
358 | 358 | with _assert_raises_assertion(expected_message): |
359 | 359 | assert_is_instance("my string", int) |
360 | 360 |
|
361 | | - def test_assert_is_instance__custom_message(self): |
| 361 | + def test_assert_not_is_instance(self): |
| 362 | + assert_not_is_instance(4, str) |
| 363 | + assert_not_is_instance(4, (str, bytes)) |
362 | 364 | with _assert_raises_assertion("my message"): |
363 | | - assert_is_instance("my string", int, msg="my message") |
| 365 | + assert_not_is_instance(OSError(), Exception, msg="my message") |
| 366 | + |
| 367 | + def test_assert_not_is_instance__default_message(self): |
| 368 | + expected_message = "OSError() is an instance of <class 'OSError'>" |
| 369 | + if sys.version_info[0] < 3: |
| 370 | + expected_message = expected_message.replace("class", "type") |
| 371 | + expected_message = expected_message.replace( |
| 372 | + "type 'OSError'", "type 'exceptions.OSError'") |
| 373 | + with _assert_raises_assertion(expected_message): |
| 374 | + assert_not_is_instance(OSError(), Exception) |
364 | 375 |
|
365 | 376 | def test_assert_has_attr__has_attribute(self): |
366 | 377 | d = _DummyObject() |
|
0 commit comments