aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-08 17:06:33 -0800
committerCody Logan <cody@lokken.dev>2023-11-08 17:06:33 -0800
commit733eeb27581ee6fc2a9c2d79d7b002127bde85f1 (patch)
treeba9b98737adc89a3faf380d53abd6a34ddca5a31
parent96316c8be7bc21617ec5333f87864a0f002ebaa4 (diff)
downloadwikiget-733eeb27581ee6fc2a9c2d79d7b002127bde85f1.tar.gz
wikiget-733eeb27581ee6fc2a9c2d79d7b002127bde85f1.zip
Change to a temporary directory before running tests
Some tests will throw errors if files or directories with certain names exist in the current working directory when pytest is run, such as Example.jpg.
-rw-r--r--tests/conftest.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 5fccfc0..8b1fea9 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -17,12 +17,25 @@
"""Define fixtures used across all tests in this folder."""
+from os import chdir
+from pathlib import Path
+
import pytest
import requests_mock as rm
from wikiget.file import File
+@pytest.fixture(autouse=True)
+def _chdir_to_tmp_dir(tmp_path: Path) -> None:
+ """Change to a temporary directory before running tests.
+
+ :param tmp_path: temporary path object
+ :type tmp_path: Path
+ """
+ chdir(tmp_path)
+
+
@pytest.fixture()
def file_with_name() -> File:
"""Create a test File with only a filename.