Make ThreadSafePrefs an instance of MutableMapping

So dict(prefs) works and th etest does not need to be changed
This commit is contained in:
Kovid Goyal 2020-09-19 06:43:00 +05:30
parent 4e766ab401
commit 06a665012b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View File

@ -7,6 +7,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import os, traceback, weakref
from polyglot.builtins import iteritems, zip
from collections.abc import MutableMapping
from calibre import force_unicode, isbytestring
from calibre.constants import preferred_encoding
@ -52,7 +53,7 @@ def set_global_state(db):
set_saved_searches(db, 'saved_searches')
class ThreadSafePrefs:
class ThreadSafePrefs(MutableMapping):
def __init__(self, db):
self.db = weakref.ref(db)

View File

@ -189,7 +189,7 @@ class LegacyTest(BaseTest):
db = self.init_old()
newstag = ndb.new_api.get_item_id('tags', 'news')
self.assertEqual(dict(db.prefs), ndb.prefs.copy())
self.assertEqual(dict(db.prefs), dict(ndb.prefs))
for meth, args in iteritems({
'find_identical_books': [(Metadata('title one', ['author one']),), (Metadata('unknown'),), (Metadata('xxxx'),)],