From 0fff16efe644f0de909ee4494ee3375173385ce5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 16 Feb 2024 09:48:20 +1100 Subject: [PATCH] improve readability of test parameters --- tests/filesystem/settings.py | 8 +++++++- tests/filesystem/test_filesystem.py | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/filesystem/settings.py b/tests/filesystem/settings.py index ffb8ce753..a7c3db1dd 100644 --- a/tests/filesystem/settings.py +++ b/tests/filesystem/settings.py @@ -25,7 +25,11 @@ }, ] -GLOB_RESULTS = [ +FACTORY_TEST_IDS = [ + f"url={factory_args['bucket_url'][:15]}..." for factory_args in FACTORY_ARGS +] + +GLOBS = [ { "glob": None, "file_names": ["sample.txt"], @@ -84,3 +88,5 @@ "file_names": ["sample.txt"], }, ] + +GLOB_TEST_IDS = [f"glob={glob_result['glob']}" for glob_result in GLOBS] diff --git a/tests/filesystem/test_filesystem.py b/tests/filesystem/test_filesystem.py index 20240e458..0de9057a3 100644 --- a/tests/filesystem/test_filesystem.py +++ b/tests/filesystem/test_filesystem.py @@ -20,12 +20,12 @@ ) from tests.filesystem.utils import unpack_factory_args -from .settings import GLOB_RESULTS, FACTORY_ARGS +from .settings import GLOBS, GLOB_TEST_IDS, FACTORY_ARGS, FACTORY_TEST_IDS -@pytest.mark.parametrize("factory_args", FACTORY_ARGS) -@pytest.mark.parametrize("glob_params", GLOB_RESULTS) -def test_file_list(factory_args: Dict[str, Any], glob_params: Dict[str, Any]) -> None: +@pytest.mark.parametrize("factory_args", FACTORY_ARGS, ids=FACTORY_TEST_IDS) +@pytest.mark.parametrize("globs", GLOBS, ids=GLOB_TEST_IDS) +def test_file_list(factory_args: Dict[str, Any], globs: Dict[str, Any]) -> None: bucket_url, kwargs = unpack_factory_args(factory_args) @dlt.transformer @@ -33,7 +33,7 @@ def bypass(items) -> str: return items # we only pass the glob parameter to the resource if it is not None - if file_glob := glob_params["glob"]: + if file_glob := globs["glob"]: filesystem_res = ( filesystem( bucket_url=bucket_url, @@ -48,8 +48,8 @@ def bypass(items) -> str: all_files = list(filesystem_res) file_count = len(all_files) file_names = [item["file_name"] for item in all_files] - assert file_count == len(glob_params["file_names"]) - assert file_names == glob_params["file_names"] + assert file_count == len(globs["file_names"]) + assert file_names == globs["file_names"] @pytest.mark.parametrize("extract_content", [True, False])