From e95aff7ca9c4bc76a1b552d82acddb840b10d861 Mon Sep 17 00:00:00 2001 From: Marek Fiala Date: Fri, 16 Aug 2024 15:31:30 +0200 Subject: [PATCH] feat(tools): sanitize all fixtures using test names The parametrization include `[` and `]` in names. This is not possible to use within path. Expand the sanitization into all fixtures using request.node.name. --- tools/test_build_system/conftest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/test_build_system/conftest.py b/tools/test_build_system/conftest.py index 0b8472fccc..74b96ae7a1 100644 --- a/tools/test_build_system/conftest.py +++ b/tools/test_build_system/conftest.py @@ -133,7 +133,9 @@ def test_app_copy(func_work_dir: Path, request: FixtureRequest) -> typing.Genera @pytest.fixture def test_git_template_app(func_work_dir: Path, request: FixtureRequest) -> typing.Generator[Path, None, None]: - copy_to = request.node.name + '_app' + # sanitize test name in case pytest.mark.parametrize was used + test_name_sanitized = request.node.name.replace('[', '_').replace(']', '') + copy_to = test_name_sanitized + '_app' path_to = func_work_dir / copy_to logging.debug(f'cloning git-template app to {path_to}') @@ -156,11 +158,13 @@ def test_git_template_app(func_work_dir: Path, request: FixtureRequest) -> typin @pytest.fixture def idf_copy(func_work_dir: Path, request: FixtureRequest) -> typing.Generator[Path, None, None]: - copy_to = request.node.name + '_idf' + # sanitize test name in case pytest.mark.parametrize was used + test_name_sanitized = request.node.name.replace('[', '_').replace(']', '') + copy_to = test_name_sanitized + '_idf' # allow overriding the destination via pytest.mark.idf_copy_with_space so the destination contain space mark_with_space = request.node.get_closest_marker('idf_copy_with_space') if mark_with_space: - copy_to = request.node.name + ' idf' + copy_to = test_name_sanitized + ' idf' # allow overriding the destination via pytest.mark.idf_copy() mark = request.node.get_closest_marker('idf_copy')