This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients docs@python, ezio.melotti, michael.foord, pitrou
Date 2012-10-09.08:23:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349771035.38.0.947966701241.issue16171@psf.upfronthosting.co.za>
In-reply-to
Content
unittest docs suggest the following "load_tests" for a __main__.py:

def load_tests(loader, standard_tests, pattern):
    # top level directory cached on loader instance
    this_dir = os.path.dirname(__file__)
    package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
    standard_tests.addTests(package_tests)
    return standard_tests

This function fails with a weird error message when no pattern is given on the command line. A better alternative would be:

def load_tests(loader, standard_tests, pattern):
    # top level directory cached on loader instance
    this_dir = os.path.dirname(__file__)
    pattern = pattern or "test_*.py"
    package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
    standard_tests.addTests(package_tests)
    return standard_tests
History
Date User Action Args
2012-10-09 08:23:55pitrousetrecipients: + pitrou, ezio.melotti, michael.foord, docs@python
2012-10-09 08:23:55pitrousetmessageid: <1349771035.38.0.947966701241.issue16171@psf.upfronthosting.co.za>
2012-10-09 08:23:55pitroulinkissue16171 messages
2012-10-09 08:23:54pitroucreate