diff options
author | Raymond Hettinger <python@rcn.com> | 2010-04-04 21:45:01 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-04-04 21:45:01 (GMT) |
commit | bb006cf26cc41aefcddc8f06722c524826aacefa (patch) | |
tree | 5d0e82402052f188ea868cf94497eba52a7b38fd /Lib/unittest | |
parent | 4f185228b084ee45ef822198762154457dc343db (diff) | |
download | cpython-bb006cf26cc41aefcddc8f06722c524826aacefa.zip cpython-bb006cf26cc41aefcddc8f06722c524826aacefa.tar.gz cpython-bb006cf26cc41aefcddc8f06722c524826aacefa.tar.bz2 |
Add tests for cmp_to_key.
Adopt PEP 8 compliant function name.
Factor-out existing uses cmp_to_key.
Update documentation to use internal pointers instead of external resource.
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/loader.py | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index e0b8585..f0cc157 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -6,23 +6,13 @@ import sys import traceback import types +from functools import cmp_to_key as _CmpToKey from fnmatch import fnmatch from . import case, suite __unittest = True - -def _CmpToKey(mycmp): - 'Convert a cmp= function into a key= function' - class K(object): - def __init__(self, obj): - self.obj = obj - def __lt__(self, other): - return mycmp(self.obj, other.obj) == -1 - return K - - # what about .pyc or .pyo (etc) # we would need to avoid loading the same tests multiple times # from '.py', '.pyc' *and* '.pyo' |