[TIP] Why do we need loadTestsFromPackage ?

Olemis Lang olemis at gmail.com
Tue Apr 14 07:59:13 PDT 2009

On Tue, Apr 14, 2009 at 8:44 AM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
> Olemis Lang wrote:
>> On Tue, Apr 14, 2009 at 5:39 AM, Michael Foord
>> <fuzzyman at voidspace.org.uk> wrote:
>>> Robert Collins wrote:
>>>> On Tue, 2009-04-14 at 11:13 +0100, Michael Foord wrote:
>>> I think I'm now marginally in favour of providing the implementation of
>>> this in loadTestsFromPackage - with the load_tests protocol being in
>>> loadTestsFromModule as you showed previously.
>> Please could anybody tell me why is it necessary to add
>> loadTestsFromPackage ? I dont really think its necessary.
>> Its another method and I dont think that complicating the loaders
>> interface be a good decision.
>> What is the difference between loadTestsFromPackage and
>> loadTestsFromModule ? The only difference I see so far is the
>> discovery strategy, so IMHO a separate loader should handle this ...
>> Pls I'd really want to understand
> For discovery. If we do it in a new loader (and I don't see the difference
> beyond your notional ideas of OO purity)
> what would the interface to the
> discovery mechanism look like?

simpleloader = Loader1()
s1 = simpleloader.loadTestsFromModule(pkg) # Just top-level module

    # as usual
discoloader = DiscoLoader(simpleloader)        # The concrete loader is

    # an arg. It is used to actually

    # load tests out of single

    # modules whereas

    # DiscoLoader handles

    # listing files | modules

    # and so on

s2 = discoloader.loadTestsFromModule(pkg)   # All tests in pkg

> You say you don't understand why, I don't understand why not.

I understand that loadTestsFromPackage is a candidate. I'm not sure
about its benefits, especially because AFAICS and IMHO there is no
need to include loadTestsFromPackage in order to allow discovery. I
think that the option I mentioned above is more dynamic and is
suitable for diverse discovery strategies, varying apart of the code
for the real | concrete loader.

Could we pls keep focused on the pros & cons of both approaches with
concrete arguments ?



Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

More information about the testing-in-python mailing list