From f5fd286663fa502eaf76e7ed9f3afa77264dc337 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 30 Apr 2026 17:43:33 +0200 Subject: [PATCH] fix: make www tests work with editable instead of just plain installs --- cmdeploy/src/cmdeploy/tests/test_helpers.py | 5 ++--- cmdeploy/src/cmdeploy/www.py | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmdeploy/src/cmdeploy/tests/test_helpers.py b/cmdeploy/src/cmdeploy/tests/test_helpers.py index 58b3886b..715477b2 100644 --- a/cmdeploy/src/cmdeploy/tests/test_helpers.py +++ b/cmdeploy/src/cmdeploy/tests/test_helpers.py @@ -1,11 +1,10 @@ -import importlib.resources +from pathlib import Path from cmdeploy.www import build_webpages def test_build_webpages(tmp_path, make_config): - pkgroot = importlib.resources.files("cmdeploy") - src_dir = pkgroot.joinpath("../../../www/src").resolve() + src_dir = (Path(__file__).resolve() / "../../../../../www/src").resolve() assert src_dir.exists(), src_dir config = make_config("chat.example.org") build_dir = tmp_path.joinpath("build") diff --git a/cmdeploy/src/cmdeploy/www.py b/cmdeploy/src/cmdeploy/www.py index e0b3a3c8..9b543c6e 100644 --- a/cmdeploy/src/cmdeploy/www.py +++ b/cmdeploy/src/cmdeploy/www.py @@ -1,5 +1,4 @@ import hashlib -import importlib.resources import re import time import traceback @@ -37,7 +36,7 @@ def prepare_template(source): def get_paths(config) -> (Path, Path, Path): - reporoot = importlib.resources.files(__package__).joinpath("../../../").resolve() + reporoot = (Path(__file__).resolve() / "../../../../").resolve() www_path = Path(config.www_folder) # if www_folder was not set, use default directory if config.www_folder == "": @@ -133,8 +132,7 @@ def find_merge_conflict(src_dir) -> Path: def main(): - path = importlib.resources.files(__package__) - reporoot = path.joinpath("../../../").resolve() + reporoot = (Path(__file__).resolve() / "../../../../").resolve() inipath = reporoot.joinpath("chatmail.ini") config = read_config(inipath) config.webdev = True