Skip to content

Commit 0fff16e

Browse files
author
Your Name
committed
improve readability of test parameters
1 parent ff9228a commit 0fff16e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

tests/filesystem/settings.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
},
2626
]
2727

28-
GLOB_RESULTS = [
28+
FACTORY_TEST_IDS = [
29+
f"url={factory_args['bucket_url'][:15]}..." for factory_args in FACTORY_ARGS
30+
]
31+
32+
GLOBS = [
2933
{
3034
"glob": None,
3135
"file_names": ["sample.txt"],
@@ -84,3 +88,5 @@
8488
"file_names": ["sample.txt"],
8589
},
8690
]
91+
92+
GLOB_TEST_IDS = [f"glob={glob_result['glob']}" for glob_result in GLOBS]

tests/filesystem/test_filesystem.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
)
2121
from tests.filesystem.utils import unpack_factory_args
2222

23-
from .settings import GLOB_RESULTS, FACTORY_ARGS
23+
from .settings import GLOBS, GLOB_TEST_IDS, FACTORY_ARGS, FACTORY_TEST_IDS
2424

2525

26-
@pytest.mark.parametrize("factory_args", FACTORY_ARGS)
27-
@pytest.mark.parametrize("glob_params", GLOB_RESULTS)
28-
def test_file_list(factory_args: Dict[str, Any], glob_params: Dict[str, Any]) -> None:
26+
@pytest.mark.parametrize("factory_args", FACTORY_ARGS, ids=FACTORY_TEST_IDS)
27+
@pytest.mark.parametrize("globs", GLOBS, ids=GLOB_TEST_IDS)
28+
def test_file_list(factory_args: Dict[str, Any], globs: Dict[str, Any]) -> None:
2929
bucket_url, kwargs = unpack_factory_args(factory_args)
3030

3131
@dlt.transformer
3232
def bypass(items) -> str:
3333
return items
3434

3535
# we only pass the glob parameter to the resource if it is not None
36-
if file_glob := glob_params["glob"]:
36+
if file_glob := globs["glob"]:
3737
filesystem_res = (
3838
filesystem(
3939
bucket_url=bucket_url,
@@ -48,8 +48,8 @@ def bypass(items) -> str:
4848
all_files = list(filesystem_res)
4949
file_count = len(all_files)
5050
file_names = [item["file_name"] for item in all_files]
51-
assert file_count == len(glob_params["file_names"])
52-
assert file_names == glob_params["file_names"]
51+
assert file_count == len(globs["file_names"])
52+
assert file_names == globs["file_names"]
5353

5454

5555
@pytest.mark.parametrize("extract_content", [True, False])

0 commit comments

Comments
 (0)