From 2737b3635f2cbd6f00fa07c9d02dd9413ec8738a Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 16 Oct 2019 21:48:30 +0200 Subject: [PATCH] Revert last change --- lbry/lbry/testcase.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lbry/lbry/testcase.py b/lbry/lbry/testcase.py index 506631f93..6f92f90af 100644 --- a/lbry/lbry/testcase.py +++ b/lbry/lbry/testcase.py @@ -199,10 +199,18 @@ class CommandTestCase(IntegrationTestCase): def create_tempfile(self, data=None, prefix=None, suffix=None, dir_path=None): dir_path = dir_path or self.daemon.conf.download_dir - self.file = tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, dir=dir_path) - self.file.write(data) - self.file.flush() - return self.file.name + file = tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, dir=dir_path) + file.write(data) + file.flush() + + def cleanup(): + try: + file.close() + except FileNotFoundError: + pass + + self.addCleanup(cleanup) + return file.name async def stream_create(self, name='hovercraft', bid='1.0', data=b'hi!', confirm=True, prefix=None, suffix=None, **kwargs):