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() self.backend.close()
def break_cycles(self): def break_cycles(self):
delattr(self.backend, 'field_metadata')
self.data.cache.backend = None self.data.cache.backend = None
self.data.cache = 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 {{{ # Library wide properties {{{
@property @property

View File

@ -117,18 +117,24 @@ class LegacyTest(BaseTest):
'__init__', '__init__',
} }
for attr in dir(db): try:
if attr in SKIP_ATTRS: for attr in dir(db):
continue if attr in SKIP_ATTRS:
if not hasattr(ndb, attr): continue
raise AssertionError('The attribute %s is missing' % attr) if not hasattr(ndb, attr):
obj, nobj = getattr(db, attr), getattr(ndb, attr) raise AssertionError('The attribute %s is missing' % attr)
if attr not in SKIP_ARGSPEC: obj, nobj = getattr(db, attr), getattr(ndb, attr)
try: if attr not in SKIP_ARGSPEC:
argspec = inspect.getargspec(obj) try:
except TypeError: argspec = inspect.getargspec(obj)
pass except TypeError:
else: pass
self.assertEqual(argspec, inspect.getargspec(nobj), 'argspec for %s not the same' % attr) 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(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) 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)) self.assertTrue(old.has_cover(book_id))
old.close()
old.break_cycles()
del old
# }}} # }}}
def test_set_metadata(self): # {{{ def test_set_metadata(self): # {{{