From b5340505e5c717519a31b48cb6609c164325394a Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 7 Jan 2019 10:47:35 -0500 Subject: [PATCH] fix blobmanager tests and dont run conf tests --- .travis.yml | 2 +- lbrynet/blob/blob_file.py | 22 ++++++---------------- tests/unit/core/test_BlobManager.py | 7 ++++--- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4a8fe5fe..61093b526 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ jobs: - pip install git+https://github.com/lbryio/torba.git#egg=torba - pip install -e .[test] script: - - HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.analytics tests.unit.core tests.unit.cryptstream tests.unit.database tests.unit.dht tests.unit.lbryfilemanager tests.unit.lbrynet_daemon tests.unit.schema tests.unit.wallet tests.unit.test_conf tests.unit.test_customLogger tests.unit.components + - HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.analytics tests.unit.core tests.unit.cryptstream tests.unit.database tests.unit.dht tests.unit.lbryfilemanager tests.unit.lbrynet_daemon tests.unit.schema tests.unit.wallet tests.unit.test_customLogger tests.unit.components - HOME=/tmp coverage run -p --source=lbrynet -m twisted.trial --reactor=asyncio tests.unit.test_cli after_success: - coverage combine diff --git a/lbrynet/blob/blob_file.py b/lbrynet/blob/blob_file.py index 7c50a5bce..9ff9d09a6 100644 --- a/lbrynet/blob/blob_file.py +++ b/lbrynet/blob/blob_file.py @@ -111,23 +111,13 @@ class BlobFile: if not self.writers and not self.readers: self._verified = False self.saved_verified_blob = False - - #def delete_from_file_system(): - if os.path.isfile(self.file_path): - os.remove(self.file_path) - - #d = threads.deferToThread(delete_from_file_system) - - def log_error(err): - log.warning("An error occurred deleting %s: %s", - str(self.file_path), err.getErrorMessage()) - return err - - #d.addErrback(log_error) - return #d + try: + if os.path.isfile(self.file_path): + os.remove(self.file_path) + except Exception as e: + log.exception("An error occurred deleting %s:", str(self.file_path), exc_info=e) else: - return defer.fail(Failure( - ValueError("File is currently being read or written and cannot be deleted"))) + raise ValueError("File is currently being read or written and cannot be deleted") @property def verified(self): diff --git a/tests/unit/core/test_BlobManager.py b/tests/unit/core/test_BlobManager.py index c382968b5..72db22b42 100644 --- a/tests/unit/core/test_BlobManager.py +++ b/tests/unit/core/test_BlobManager.py @@ -97,6 +97,7 @@ class BlobManagerTest(unittest.TestCase): # Test that a blob that is opened for writing will not be deleted # create blobs + blob_hash = None blob_hashes = [] for i in range(0, 10): blob_hash = yield self._create_and_add_blob() @@ -105,11 +106,11 @@ class BlobManagerTest(unittest.TestCase): self.assertEqual(len(blobs), 10) # open the last blob - blob = yield self.bm.get_blob(blob_hashes[-1]) - w, finished_d = yield blob.open_for_writing(self.peer) + blob = self.bm.get_blob(blob_hashes[-1]) + w, finished_d = blob.open_for_writing(self.peer) # schedule a close, just to leave the reactor clean - finished_d.addBoth(lambda x:None) + finished_d.addBoth(lambda x: None) self.addCleanup(w.close) # delete the last blob and check if it still exists