[issue13387] add exact_type argument to assertIsInstance
Florent Xicluna
report at bugs.python.org
Sat Nov 12 15:52:19 CET 2011
Florent Xicluna <florent.xicluna at gmail.com> added the comment:
At least in the standard library test suite, it should be useful.
When the test is stricter, it catches errors earlier.
I remember when assertIsInstance was made available (issue #7031), we started to rewrite some expressions
self.assertEqual(type(result), str)
with
self.assertIsInstance(result, str)
Actually, it means we relaxed the test.
Today, I don't want to use assertIsInstance anymore because I want to check the exact type() of the result.
The attached files list the usage of both in Lib/test/*py:
- 325 assertIsInstance
- 234 assert. . .type(. . .)
IMHO, some assertIsInstance can be stricter.
Most of the other type() tests can be replaced with this method.
----------
keywords: +patch
Added file: http://bugs.python.org/file23663/issue13387_exact_type.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13387>
_______________________________________
More information about the Python-bugs-list
mailing list