py3: Fix legacy_coverage test

This commit is contained in:
Kovid Goyal 2019-04-14 12:20:43 +05:30
parent 1529fb2f8b
commit ed42a7c1b6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 4 deletions

View File

@ -70,9 +70,11 @@ class LibraryDatabase(object):
def __init__(self, library_path,
default_prefs=None, read_only=False, is_second_db=False,
progress_callback=lambda x, y:True, restore_all_prefs=False):
progress_callback=None, restore_all_prefs=False, row_factory=False):
self.is_second_db = is_second_db
if progress_callback is None:
progress_callback = lambda x, y:True
self.listeners = set()
backend = self.backend = create_backend(library_path, default_prefs=default_prefs,

View File

@ -37,12 +37,18 @@ class ET(object):
return newres
def get_defaults(spec):
num = len(spec.defaults or ())
if not num:
return {}
return dict(zip(spec.args[-num:], spec.defaults))
def compare_argspecs(old, new, attr):
# We dont compare the names of the non-keyword arguments as they are often
# different and they dont affect the usage of the API.
num = len(old.defaults or ())
ok = len(old.args) == len(new.args) and old.defaults == new.defaults and (num == 0 or old.args[-num:] == new.args[-num:])
ok = len(old.args) == len(new.args) and get_defaults(old) == get_defaults(new)
if not ok:
raise AssertionError('The argspec for %s does not match. %r != %r' % (attr, old, new))
@ -459,7 +465,7 @@ class LegacyTest(BaseTest):
try:
argspec = inspect.getargspec(obj)
nargspec = inspect.getargspec(nobj)
except TypeError:
except (TypeError, ValueError):
pass
else:
compare_argspecs(argspec, nargspec, attr)