mirror of
https://github.com/pretix/pretix.git
synced 2026-10-03 19:34:41 +00:00
Add pdf render tests (#6566)
* Add pdf tests * pdf tests: Save temporary pdfs for failed test debugging * Review comments
This commit is contained in:
+23
-1
@@ -21,6 +21,8 @@
|
||||
#
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from django.core.cache import cache
|
||||
@@ -28,7 +30,6 @@ from django.test import override_settings
|
||||
from django.utils import translation
|
||||
from django_scopes import scopes_disabled
|
||||
from fakeredis import FakeRedisConnection
|
||||
from hierarkey.proxy import dirty_cache_keys
|
||||
from xdist.dsession import DSession
|
||||
|
||||
from pretix.testutils.mock import get_redis_connection
|
||||
@@ -85,6 +86,7 @@ def reset_locale():
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_hierarkey_cache_state():
|
||||
from hierarkey.proxy import dirty_cache_keys
|
||||
dirty_cache_keys.set(set())
|
||||
|
||||
|
||||
@@ -143,3 +145,23 @@ def set_lock_namespaces(request):
|
||||
@pytest.fixture
|
||||
def class_monkeypatch(request, monkeypatch):
|
||||
request.cls.monkeypatch = monkeypatch
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
'--pdf-dir', action='store', help="output dir for files generated by pdf tests", type=Path
|
||||
)
|
||||
parser.addoption(
|
||||
'--pdf-tmp-keep', action='store_true', help="keep the temporary directory created for pdf tests"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pdf_dir(request, tmp_path_factory):
|
||||
dirname = re.sub('[^a-zA-Z0-9]+', '_', request.node.name).strip("_")
|
||||
if dir := request.config.getoption('--pdf-dir'):
|
||||
pdf_dir: Path = (dir / dirname).absolute()
|
||||
pdf_dir.mkdir(exist_ok=True, parents=True)
|
||||
yield pdf_dir
|
||||
else:
|
||||
yield tmp_path_factory.mktemp(dirname)
|
||||
|
||||
Reference in New Issue
Block a user