[issue11218] pattern=None when following documentation for load_tests and unittest.main()

Martin von Gagern report at bugs.python.org
Fri Apr 13 23:23:39 CEST 2012


Martin von Gagern <Martin.vGagern at gmx.net> added the comment:

Michael wrote: "[…] the real pattern being passed in".
I wonder, what would be "the real pattern"? In the code I originally pasted, the load_tests function would be invoked by loadTestsFromModule (for module __main__). There is nothing file-based about this, so although you could pass a default pattern, it wouldn't be any more or less "real" than passing None. It might be more useful, though.

"most patterns will actually *prevent* __init__.py from being loaded by test discovery - this turns out to not be very useful and in all practical cases this argument will be None."

Not sure I follow there. For the root of the test suite, yes, it will always be None. But for child packages it will be the pattern that led to the discovery of the __init__.py of that package. In all practical cases this will be a string different from both None and the default of 'test*.py', as it has to match the directory name. Most likely it will be what the load_tests function of the parent package passed to its invocation of discover.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11218>
_______________________________________


More information about the Python-bugs-list mailing list