Skip to content

Commit

Permalink
Fix test issue where warning was being raised but not captured
Browse files Browse the repository at this point in the history
  • Loading branch information
samaloney committed Apr 4, 2024
1 parent 4dbc2da commit 0468bc0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions parfive/tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import threading
from pathlib import Path
from tempfile import gettempdir
from time import sleep
from unittest import mock
from unittest.mock import patch

Expand Down Expand Up @@ -523,9 +524,8 @@ def __init__(self, *args, **kwargs):
def run(self):
self.result = self._target(*self._args, **self._kwargs)


@skip_windows
def test_download_out_of_main_thread(httpserver, tmpdir):
def test_download_out_of_main_thread(httpserver, tmpdir, recwarn):
tmpdir = str(tmpdir)
httpserver.serve_content(
"SIMPLE = T", headers={"Content-Disposition": "attachment; filename=testfile.fits"}
Expand All @@ -537,10 +537,10 @@ 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.",
):
thread.join()
thread.join()

validate_test_file(thread.result)

assert len(recwarn) > 0
assert any(['This download has been started in a thread which is not the main thread. You will not be able to interrupt the download.' ==
w.message.args[0] for w in recwarn])

0 comments on commit 0468bc0

Please sign in to comment.