[TIP] Test discovery for unittest
John Arbash Meinel
john at arbash-meinel.com
Mon Apr 6 15:26:09 PDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
>>> - errors are reported poorly and typically result in the entire
>>> suite not running.
>> How does load_tests alleviate this problem?
> We can fix the loader - we have code in bzr to handle import errors
> during test loading in such a way that the whole suite isn't aborted. I
> would do it differently the second time around, but the code would still
> go in the loader. (Also see Olemis' point about test discovery arguably
> being a loader responsibility - I agree with him about that. I don't
> agree about DiscoveringTestSuite, it is just an adapter from loader to a
> memoised test suite, and that's useful)
Actually, I think all we do is give a proper 'ImportError' under these
circumstances. The problem with the standard loader, is that it just
gives unhelpful errors.
For example, if you try to do:
But 'submodule' has a typo in it, so it fails to import. Then instead of
getting SyntaxError with a nice traceback so you can fix the typo, you
get some sort of "module mymod has no attribute 'submodule'".
Auto-discovery will have similar problems. If you fail to import, do you
raise an error, or do you just skip that file? (Skipping things silently
can easily lead to tests that don't run when you expected them to.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the testing-in-python