aboutsummaryrefslogtreecommitdiff
path: root/tests/test_dl.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-15 10:02:48 -0800
committerGitHub <noreply@github.com>2023-11-15 10:02:48 -0800
commit55a5311ee4da639a65bd60622315f3fff6936c9a (patch)
tree285f960d4a7afe9d27ecca51e86e7f00fb914d22 /tests/test_dl.py
parent96316c8be7bc21617ec5333f87864a0f002ebaa4 (diff)
parentba782d54aa70a1faf6bf6cdcaeb446f7b4c503db (diff)
downloadwikiget-55a5311ee4da639a65bd60622315f3fff6936c9a.tar.gz
wikiget-55a5311ee4da639a65bd60622315f3fff6936c9a.zip
Merge pull request #13 from clpo13/testing-tmp-folder
Change to temp directory when running tests
Diffstat (limited to 'tests/test_dl.py')
-rw-r--r--tests/test_dl.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/tests/test_dl.py b/tests/test_dl.py
index d7d5d77..cb5f0b6 100644
--- a/tests/test_dl.py
+++ b/tests/test_dl.py
@@ -54,15 +54,13 @@ class TestPrepDownload:
assert file == expected_file
- def test_prep_download_with_existing_file(self, tmp_path: Path) -> None:
+ def test_prep_download_with_existing_file(self, test_file: Path) -> None:
"""Test that an exception is raised when the download file already exists.
Attempting to download a file with the same destination name as an existing file
should raise a FileExistsError.
"""
- tmp_file = tmp_path / "File:Example.jpg"
- tmp_file.write_text("nothing")
- args = parse_args(["File:Example.jpg", "-o", str(tmp_file)])
+ args = parse_args(["File:Example.jpg", "-o", str(test_file)])
with pytest.raises(FileExistsError):
_ = prep_download(args.FILE, args)
@@ -301,15 +299,13 @@ class TestDownload:
"""Define tests related to wikiget.dl.download."""
@pytest.fixture()
- def mock_file(self, tmp_path: Path) -> File:
+ def mock_file(self) -> File:
"""Create a mock File object to test against.
- :param tmp_path: temporary path object
- :type tmp_path: Path
:return: mock File object
:rtype: File
"""
- file = File(name="Example.jpg", dest=str(tmp_path / "Example.jpg"))
+ file = File(name="Example.jpg")
file.image = Mock()
file.image.exists = True
file.image.imageinfo = {