[TIP] Test discovery for unittest
Olemis Lang
olemis at gmail.com
Tue Apr 7 06:59:14 PDT 2009
On Tue, Apr 7, 2009 at 8:48 AM, Marius Gedminas <marius at gedmin.as> wrote:
> On Tue, Apr 07, 2009 at 08:31:42AM +1000, Robert Collins wrote:
>> On Mon, 2009-04-06 at 23:17 +0100, Michael Foord wrote:
>
>> The following is the guts of the patch: everything else is tests and
>> documentation.
>>
>> * Alter TestLoader.loadTestsFromModule:
>> tests = []
>> for name in dir(module):
>> obj = getattr(module, name)
>> if (isinstance(obj, (type, types.ClassType)) and
>> issubclass(obj, TestCase)):
>> tests.append(self.loadTestsFromTestCase(obj))
>> + result = self.suiteClass(tests)
>> + load_hook = getattr(module, 'load_tests', None)
>> + if load_hook is not None:
>> + result = load_hook(self, result)
>> + if not result:
>> + return self.suiteClass()
>> + else:
>> + return result
>> - return self.suiteClass(tests)
>>
>
> Zope 3 doesn't use loadTestsFromModule, so this change won't break
> anything.
>
-1 from me. Explicit is better than implicit. If I want to load tests
from a package, I want that decision to be obvious, and not full of
hidden details and hooks (I've not seen that before in XUnit framews
-I mean as the official way to do it -, and I'm almost sure that they
wanted to do similar things ...). I'm writing a separate message with
further comments.
--
Regards,
Olemis.
Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/
Featured article:
Se retira el BDFL ... ¿El fin de Python 3k?
More information about the testing-in-python
mailing list