diff --git a/parfive/downloader.py b/parfive/downloader.py index e3290bb..29c3bba 100644 --- a/parfive/downloader.py +++ b/parfive/downloader.py @@ -229,7 +229,7 @@ def _add_shutdown_signals(loop, task): if threading.current_thread() != threading.main_thread(): warnings.warn( "This download has been started in a thread which is not the main thread. You will not be able to interrupt the download.", - UserWarning + UserWarning, ) return diff --git a/parfive/tests/test_downloader.py b/parfive/tests/test_downloader.py index 5d79e82..6351d70 100644 --- a/parfive/tests/test_downloader.py +++ b/parfive/tests/test_downloader.py @@ -474,7 +474,10 @@ def __init__(self, *args, **kwargs): def run(self): self.result = self._target(*self._args, **self._kwargs) + import warnings + + def test_download_out_of_main_thread(httpserver, tmpdir): tmpdir = str(tmpdir) httpserver.serve_content( @@ -486,8 +489,11 @@ def test_download_out_of_main_thread(httpserver, tmpdir): thread = CustomThread(target=dl.download) thread.start() - - with pytest.warns(UserWarning, match="This download has been started in a thread which is not the main thread. You will not be able to interrupt the download."): + + with pytest.warns( + UserWarning, + match="This download has been started in a thread which is not the main thread. You will not be able to interrupt the download.", + ): thread.join() validate_test_file(thread.result)