mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: Fix legacy_coverage test
This commit is contained in:
parent
1529fb2f8b
commit
ed42a7c1b6
@ -70,9 +70,11 @@ class LibraryDatabase(object):
|
|||||||
|
|
||||||
def __init__(self, library_path,
|
def __init__(self, library_path,
|
||||||
default_prefs=None, read_only=False, is_second_db=False,
|
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
|
self.is_second_db = is_second_db
|
||||||
|
if progress_callback is None:
|
||||||
|
progress_callback = lambda x, y:True
|
||||||
self.listeners = set()
|
self.listeners = set()
|
||||||
|
|
||||||
backend = self.backend = create_backend(library_path, default_prefs=default_prefs,
|
backend = self.backend = create_backend(library_path, default_prefs=default_prefs,
|
||||||
|
@ -37,12 +37,18 @@ class ET(object):
|
|||||||
return newres
|
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):
|
def compare_argspecs(old, new, attr):
|
||||||
# We dont compare the names of the non-keyword arguments as they are often
|
# We dont compare the names of the non-keyword arguments as they are often
|
||||||
# different and they dont affect the usage of the API.
|
# 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:
|
if not ok:
|
||||||
raise AssertionError('The argspec for %s does not match. %r != %r' % (attr, old, new))
|
raise AssertionError('The argspec for %s does not match. %r != %r' % (attr, old, new))
|
||||||
|
|
||||||
@ -459,7 +465,7 @@ class LegacyTest(BaseTest):
|
|||||||
try:
|
try:
|
||||||
argspec = inspect.getargspec(obj)
|
argspec = inspect.getargspec(obj)
|
||||||
nargspec = inspect.getargspec(nobj)
|
nargspec = inspect.getargspec(nobj)
|
||||||
except TypeError:
|
except (TypeError, ValueError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
compare_argspecs(argspec, nargspec, attr)
|
compare_argspecs(argspec, nargspec, attr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user