[TIP] new discovery.py - q&a???
dgou at mac.com
Mon May 4 11:01:31 PDT 2009
On or about Monday, May 04, 2009, at 01:43PM, Michael Foord indited:
>Perhaps this will make it simpler. load_tests, if present, always
>returns a test suite and is used to customize the loading of tests for
>the module or package it is defined in.
10,000' view - check.
>So they serve the same purpose but are called in different
>circumstances. A potential source of confusion is that in Python a
>package is just a module; so if you import the package as an object and
>pass it to loadTestsFromModule then load_tests will be called in the
>normal way for a module. This is why I think they need to have the same
You just convinced me that they should have separate names because they are really doing separate things; the issue of the same signature being a red-herring :)
I would suggest perhaps:
load_tests loads tests from a module
load_package_tests always loaded tests from a package.
Then if you want to load the package as a module and pass it to loadTestsFromModule, it's load_tests function (if any) will be called. Presumably, at this point, you know what you are doing. :) --- I'm projecting that I'd rather have two methods than to have two methods hidden inside of a test for the parameters on a single load_tests function (if I wanted to support his somewhat degenerate case; based on general experience since I haven't (and stuck on Python 2.4 wont' be) using this anytime soon.
Thanks for the discussion, I think it is an interesting extension mechanism, now that I understand it better. No further questions your honor.
More information about the testing-in-python