diff options
author | Barry Warsaw <barry@python.org> | 2014-09-08 21:29:02 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2014-09-08 21:29:02 (GMT) |
commit | bb1e3f1ebe99e1cb5a7c136991b8e8f41e4fa4bb (patch) | |
tree | 1fcf82cb99e15e4505cf4e8df3cbafae285d9cb1 /Lib/unittest/loader.py | |
parent | d78742a260ba09e53c844de7b1fd11a11c674945 (diff) | |
download | cpython-bb1e3f1ebe99e1cb5a7c136991b8e8f41e4fa4bb.zip cpython-bb1e3f1ebe99e1cb5a7c136991b8e8f41e4fa4bb.tar.gz cpython-bb1e3f1ebe99e1cb5a7c136991b8e8f41e4fa4bb.tar.bz2 |
A few tweaks for issue16662 based on feedback from Robert Collins.
Diffstat (limited to 'Lib/unittest/loader.py')
-rw-r--r-- | Lib/unittest/loader.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index 590e227..a8c6492 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -79,12 +79,15 @@ class TestLoader(object): # use_load_tests argument. For backward compatibility, we still # accept the argument (which can also be the first position) but we # ignore it and issue a deprecation warning if it's present. - if len(args) == 1 or 'use_load_tests' in kws: + if len(args) > 0 or 'use_load_tests' in kws: warnings.warn('use_load_tests is deprecated and ignored', DeprecationWarning) kws.pop('use_load_tests', None) if len(args) > 1: - raise TypeError('loadTestsFromModule() takes 1 positional argument but {} were given'.format(len(args))) + # Complain about the number of arguments, but don't forget the + # required `module` argument. + complaint = len(args) + 1 + raise TypeError('loadTestsFromModule() takes 1 positional argument but {} were given'.format(complaint)) if len(kws) != 0: # Since the keyword arguments are unsorted (see PEP 468), just # pick the alphabetically sorted first argument to complain about, |