[issue13387] add exact_type argument to assertIsInstance

Florent Xicluna report at bugs.python.org
Sat Nov 12 16:25:41 CET 2011

Florent Xicluna <florent.xicluna at gmail.com> added the comment:

I would say that this one is clear too:
  aelf.assertTrue(isinstance(obj, cls))

except that the failure message is not very friendly:
  AssertionError: False is not true

If we keep assertIsInstance, more people will continue to misuse it just because the method exist, when they really want to check (type(obj) is cls).

An option could be to add a snippet to the documentation of `assertIsInstance` stating that the right way to check exact type is `assertIs(type(obj), cls)`.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list