[Python-checkins] r54208 - python/branches/release25-maint/Lib/unittest.py
Neal Norwitz
nnorwitz at gmail.com
Thu Mar 8 05:54:23 CET 2007
I'm not sure it's the best thing to backport this. I agree with the
change, but worry that people writing bad unit tests will suddenly
have it break. They might have the proper signature, even if they
don't inherit from the right classes.
I guess the only part I'm worried about is the second if in addTest.
The callable and basestring checks will just error out earlier which
definitely seems reasonable.
If you really feel strongly that this should go in, it should have a NEWS entry.
n
--
On 3/7/07, georg.brandl <python-checkins at python.org> wrote:
> Author: georg.brandl
> Date: Wed Mar 7 12:55:25 2007
> New Revision: 54208
>> Modified:
> python/branches/release25-maint/Lib/unittest.py
> Log:
> backport rev. 54207: add a few sanity checks in unittest.TestSuite.addTest(s).
>>> Modified: python/branches/release25-maint/Lib/unittest.py
> ==============================================================================
> --- python/branches/release25-maint/Lib/unittest.py (original)
> +++ python/branches/release25-maint/Lib/unittest.py Wed Mar 7 12:55:25 2007
> @@ -411,9 +411,18 @@
> return cases
>> def addTest(self, test):
> + # sanity checks
> + if not callable(test):
> + raise TypeError("the test to add must be callable")
> + if (isinstance(test, (type, types.ClassType)) and
> + issubclass(test, (TestCase, TestSuite))):
> + raise TypeError("TestCases and TestSuites must be instantiated "
> + "before passing them to addTest()")
> self._tests.append(test)
>> def addTests(self, tests):
> + if isinstance(tests, basestring):
> + raise TypeError("tests must be an iterable of tests, not a string")
> for test in tests:
> self.addTest(test)
>> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
More information about the Python-checkins
mailing list