Fix test failures due to file locking on windows

This commit is contained in:
Kovid Goyal 2013-07-04 13:16:09 +05:30
parent 7e4a124d52
commit f1ce0eb75c
3 changed files with 25 additions and 14 deletions

View File

@ -64,9 +64,11 @@ class LibraryDatabase(object):
self.backend.close()
def break_cycles(self):
delattr(self.backend, 'field_metadata')
self.data.cache.backend = None
self.data.cache = None
self.data = self.backend = self.new_api = self.field_metadata = self.prefs = self.listeners = self.refresh_ondevice = None
for x in ('data', 'backend', 'new_api', 'listeners',):
delattr(self, x)
# Library wide properties {{{
@property

View File

@ -117,18 +117,24 @@ class LegacyTest(BaseTest):
'__init__',
}
for attr in dir(db):
if attr in SKIP_ATTRS:
continue
if not hasattr(ndb, attr):
raise AssertionError('The attribute %s is missing' % attr)
obj, nobj = getattr(db, attr), getattr(ndb, attr)
if attr not in SKIP_ARGSPEC:
try:
argspec = inspect.getargspec(obj)
except TypeError:
pass
else:
self.assertEqual(argspec, inspect.getargspec(nobj), 'argspec for %s not the same' % attr)
try:
for attr in dir(db):
if attr in SKIP_ATTRS:
continue
if not hasattr(ndb, attr):
raise AssertionError('The attribute %s is missing' % attr)
obj, nobj = getattr(db, attr), getattr(ndb, attr)
if attr not in SKIP_ARGSPEC:
try:
argspec = inspect.getargspec(obj)
except TypeError:
pass
else:
self.assertEqual(argspec, inspect.getargspec(nobj), 'argspec for %s not the same' % attr)
finally:
for db in (ndb, db):
db.close()
db.break_cycles()
# }}}

View File

@ -374,6 +374,9 @@ class WritingTest(BaseTest):
ae(cache.field_for('cover', book_id), 1)
ae(old.cover(book_id, index_is_id=True), img, 'Cover was not set correctly for book %d' % book_id)
self.assertTrue(old.has_cover(book_id))
old.close()
old.break_cycles()
del old
# }}}
def test_set_metadata(self): # {{{