attempt to fix tests isolation

This commit is contained in:
Victor Shyba 2018-07-23 21:59:57 -03:00 committed by Jack Robison
parent d35d340613
commit 99be38604a
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
4 changed files with 13 additions and 2 deletions

View file

@ -495,6 +495,7 @@ create_stream_sd_file = {
def mock_conf_settings(obj, settings={}):
conf.settings = None
settings.setdefault('download_mirrors', [])
conf.initialize_settings(False)
original_settings = conf.settings

View file

@ -106,7 +106,11 @@ class BlobManagerTest(unittest.TestCase):
# open the last blob
blob = yield self.bm.get_blob(blob_hashes[-1])
yield blob.open_for_writing(self.peer)
w, finished_d = yield blob.open_for_writing(self.peer)
# schedule a close, just to leave the reactor clean
finished_d.addBoth(lambda x:None)
self.addCleanup(w.close)
# delete the last blob and check if it still exists
yield self.bm.delete_blobs([blob_hash])

View file

@ -154,3 +154,8 @@ class BlobFileTest(unittest.TestCase):
# second write should fail to save
yield self.assertFailure(blob_file.save_verified_blob(writer_2), DownloadCanceledError)
# schedule a close, just to leave the reactor clean
finished_d_1.addBoth(lambda x:None)
finished_d_2.addBoth(lambda x:None)
self.addCleanup(writer_1.close)
self.addCleanup(writer_2.close)

View file

@ -4,6 +4,7 @@ from lbrynet import conf
from lbrynet.core import utils
from lbrynet.dht.hashannouncer import DHTHashAnnouncer
from tests.util import random_lbry_hash
from tests.mocks import mock_conf_settings
class MocDHTNode(object):
@ -38,7 +39,7 @@ class MocStorage(object):
class DHTHashAnnouncerTest(unittest.TestCase):
def setUp(self):
conf.initialize_settings(False)
mock_conf_settings(self)
self.num_blobs = 10
self.blobs_to_announce = []
for i in range(0, self.num_blobs):