aboutsummaryrefslogtreecommitdiff
path: root/tests/testutils.py
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2026-01-10 17:15:40 +0100
committerDaniel Schadt <kingdread@gmx.de>2026-01-10 17:15:40 +0100
commite0cd553185383f3ccf94a04220c64f8cbe610a99 (patch)
tree35ac8632b1f61745d85ea5d0646459b5a9002747 /tests/testutils.py
parent3ba5031a74bc0dc7aab16dc8eb349b871c012a1c (diff)
downloadfietsboek-e0cd553185383f3ccf94a04220c64f8cbe610a99.tar.gz
fietsboek-e0cd553185383f3ccf94a04220c64f8cbe610a99.tar.bz2
fietsboek-e0cd553185383f3ccf94a04220c64f8cbe610a99.zip
upload pictures in playwright testcli-tests
We now have them as test assets, so why not use them.
Diffstat (limited to 'tests/testutils.py')
-rw-r--r--tests/testutils.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/testutils.py b/tests/testutils.py
index 9a62062..e49a0b5 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -21,6 +21,16 @@ class PopulationIds(NamedTuple):
riverrun: int
+def asset_path(filename: str) -> Path:
+ """Returns the path to the test asset given by the filename.
+
+ :param filename: The filename of the asset.
+ :return: The complete path.
+ """
+ asset_dir = Path(__file__).parent / "assets"
+ return asset_dir / filename
+
+
def load_test_asset(filename: str) -> bytes:
"""Load a test asset.
@@ -29,8 +39,7 @@ def load_test_asset(filename: str) -> bytes:
:param filkename: Name of the asset to load.
:return: The content of the file as bytes.
"""
- asset_dir = Path(__file__).parent / "assets"
- return (asset_dir / filename).read_bytes()
+ return asset_path(filename).read_bytes()
def load_gpx_asset(filename: str) -> bytes:
@@ -42,8 +51,7 @@ def load_gpx_asset(filename: str) -> bytes:
:param filename: Name of the asset to load.
:return: The content of the asset as bytes.
"""
- asset_dir = Path(__file__).parent / 'assets'
- test_file = asset_dir / filename
+ test_file = asset_path(filename)
with gzip.open(test_file, 'rb') as fobj:
return fobj.read()