summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2023-11-22 15:51:49 +0100
committerFlorian Bruhin <me@the-compiler.org>2023-11-22 18:02:18 +0100
commit6147cae90178fb4ad4306d4a0866a6f09c6a1a9e (patch)
tree4431a543aa90df50f4f2b5463f267f7f3c147ea2
parent6b7eb77c4d6f03e75b1a878ddd0915deab409207 (diff)
downloadqutebrowser-6147cae90178fb4ad4306d4a0866a6f09c6a1a9e.tar.gz
qutebrowser-6147cae90178fb4ad4306d4a0866a6f09c6a1a9e.zip
pakjoy: Use existing tmp_cachedir
-rw-r--r--tests/unit/misc/test_pakjoy.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/unit/misc/test_pakjoy.py b/tests/unit/misc/test_pakjoy.py
index 326d8adfb..599127fef 100644
--- a/tests/unit/misc/test_pakjoy.py
+++ b/tests/unit/misc/test_pakjoy.py
@@ -18,6 +18,9 @@ from qutebrowser.utils import utils, version, standarddir
pytest.importorskip("qutebrowser.qt.webenginecore")
+pytestmark = pytest.mark.usefixtures("cache_tmpdir")
+
+
versions = version.qtwebengine_versions(avoid_init=True)
@@ -75,12 +78,6 @@ def test_version_gate(cache_tmpdir, unaffected_version, mocker, workdir_exists):
assert not workdir.exists()
-@pytest.fixture(autouse=True)
-def tmp_cache(tmp_path, monkeypatch):
- monkeypatch.setattr(pakjoy.standarddir, "cache", lambda: tmp_path)
- return str(tmp_path)
-
-
def json_without_comments(bytestring):
str_without_comments = "\n".join(
[
@@ -119,8 +116,9 @@ class TestWithRealResourcesFile:
# Test we managed to copy some files over
work_dir = pakjoy.copy_webengine_resources()
+ assert work_dir is not None
assert work_dir.exists()
- assert work_dir == standarddir.cache() / pakjoy.CACHE_DIR_NAME
+ assert work_dir == pathlib.Path(standarddir.cache()) / pakjoy.CACHE_DIR_NAME
assert (work_dir / pakjoy.PAK_FILENAME).exists()
assert len(list(work_dir.glob("*"))) > 1
@@ -150,9 +148,9 @@ class TestWithRealResourcesFile:
"Failed to copy webengine resources, not applying quirk"
]
- def test_expected_file_not_found(self, tmp_cache, monkeypatch, caplog):
+ def test_expected_file_not_found(self, cache_tmpdir, monkeypatch, caplog):
with caplog.at_level(logging.ERROR, "misc"):
- pakjoy._patch(pathlib.Path(tmp_cache) / "doesntexist")
+ pakjoy._patch(pathlib.Path(cache_tmpdir) / "doesntexist")
assert caplog.messages[-1].startswith(
"Resource pak doesn't exist at expected location! "
"Not applying quirks. Expected location: "
@@ -280,11 +278,11 @@ class TestWithConstructedResourcesFile:
):
parser.find_patch_offset()
- def test_url_not_found_high_level(self, tmp_cache, caplog, affected_version):
+ def test_url_not_found_high_level(self, cache_tmpdir, caplog, affected_version):
buffer = pak_factory(entries=[json_manifest_factory(url=b"example.com")])
# Write bytes to file so we can test pakjoy._patch()
- tmpfile = pathlib.Path(tmp_cache) / "bad.pak"
+ tmpfile = pathlib.Path(cache_tmpdir) / "bad.pak"
with open(tmpfile, "wb") as fd:
fd.write(buffer.read())