From 9847a0348ed6b26d75dce18206a25d8f7c89b269 Mon Sep 17 00:00:00 2001 From: Yugo Kato Date: Mon, 1 Dec 2025 07:32:16 -0800 Subject: [PATCH 1/3] Fix typo --- src/pytest_data_loader/loaders/loaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_data_loader/loaders/loaders.py b/src/pytest_data_loader/loaders/loaders.py index c5c8d4d..d98e7b2 100644 --- a/src/pytest_data_loader/loaders/loaders.py +++ b/src/pytest_data_loader/loaders/loaders.py @@ -153,7 +153,7 @@ def parametrize( - object: each key-value pair as a tuple - scalar: the whole value as a single parameter - Any other files with text data (.txt, .csv, .log, etc.): each line - - Binary files: Not supported without a cusom logic. An error will be raised. + - Binary files: Not supported without a custom logic. An error will be raised. :param filter_func: A function to filter the split data parts. Only matching parts are included as the test parameters. :param process_func: A function to adjust the shape of each split data before passing it to the test function. From e5ed8ee3925bd19dd5a95ee2f42bc9316c68b8a6 Mon Sep 17 00:00:00 2001 From: Yugo Kato Date: Mon, 1 Dec 2025 07:32:40 -0800 Subject: [PATCH 2/3] Update README --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1dbae23..afaecb6 100644 --- a/README.md +++ b/README.md @@ -69,11 +69,12 @@ Given you have the following project structure: │ ├── image.jpg │ └── image.png ├── tests1/ -│ ├── data/ -│ │ ├── data1.txt -│ │ └── data2.txt -│ └── test_something_else.py -└── test_something.py +│ └── test_something.py +└── tests2/ + ├── data/ + │ ├── data1.txt + │ └── data2.txt + └── test_something_else.py ``` ### 1. Load file data — `@load` @@ -103,22 +104,22 @@ def test_something2(file_path, data): ``` ```shell -$ pytest test_something.py -v +$ pytest tests1/test_something.py -v ================================ test session starts ================================= collected 2 items -tests/test_something.py::test_something1[data1.json] PASSED [ 50%] -tests/test_something.py::test_something2[data2.txt] PASSED [100%] +tests1/test_something.py::test_something1[data1.json] PASSED [ 50%] +tests1/test_something.py::test_something2[data2.txt] PASSED [100%] ================================= 2 passed in 0.01s ================================== ``` > [!NOTE] -> If both `./test_something.py` and `./tests1/test_something_else.py` happen to have the above same loader definitions, -> the first test function will load `./data/data1.json` for both test files, and the second test function will load -> `data2.txt` from each test file's **nearest** `data` directory. This ensures that each test file loads data from its -> nearest data directory. +> If both `./tests1/test_something.py` and `./tests2/test_something_else.py` happen to have the above same loader +> definitions, the first test function will load `./data/data1.json` for both test files, and the second test function +> will load `data2.txt` from each test file's **nearest** `data` directory. This ensures that each test file loads data +> from its nearest data directory. > This behavior applies to all loaders. @@ -150,16 +151,16 @@ def test_something2(file_path, data): ``` ```shell -$ pytest test_something.py -v +$ pytest tests1/test_something.py -v ================================ test session starts ================================= collected 5 items -tests/test_something.py::test_something1[data1.json:part1] PASSED [ 20%] -tests/test_something.py::test_something1[data1.json:part2] PASSED [ 40%] -tests/test_something.py::test_something2[data2.txt:part1] PASSED [ 60%] -tests/test_something.py::test_something2[data2.txt:part2] PASSED [ 80%] -tests/test_something.py::test_something2[data2.txt:part3] PASSED [100%] +tests1/test_something.py::test_something1[data1.json:part1] PASSED [ 20%] +tests1/test_something.py::test_something1[data1.json:part2] PASSED [ 40%] +tests1/test_something.py::test_something2[data2.txt:part1] PASSED [ 60%] +tests1/test_something.py::test_something2[data2.txt:part2] PASSED [ 80%] +tests1/test_something.py::test_something2[data2.txt:part3] PASSED [100%] ================================= 5 passed in 0.01s ================================== ``` @@ -196,14 +197,14 @@ def test_something(data): ``` ```shell -$ pytest test_something.py -v +$ pytest tests1/test_something.py -v ================================ test session starts ================================= collected 3 items -tests/test_something.py::test_something[image.gif] PASSED [ 33%] -tests/test_something.py::test_something[image.jpg] PASSED [ 66%] -tests/test_something.py::test_something[image.png] PASSED [100%] +tests1/test_something.py::test_something[image.gif] PASSED [ 33%] +tests1/test_something.py::test_something[image.jpg] PASSED [ 66%] +tests1/test_something.py::test_something[image.png] PASSED [100%] ================================= 3 passed in 0.01s ================================== ``` From def664533e4ee3d91ceed77ce100094adb967b1a Mon Sep 17 00:00:00 2001 From: Yugo Kato Date: Mon, 8 Dec 2025 10:33:20 -0800 Subject: [PATCH 3/3] Fix mypy error --- src/pytest_data_loader/loaders/impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_data_loader/loaders/impl.py b/src/pytest_data_loader/loaders/impl.py index c08d161..302528a 100644 --- a/src/pytest_data_loader/loaders/impl.py +++ b/src/pytest_data_loader/loaders/impl.py @@ -194,7 +194,7 @@ def parametrizer_func(self) -> Callable[..., Iterable[Any]]: @wraps(f) def _parametrizer_func(*args: Any, **kwargs: Any) -> Iterable[Any]: - parametrized_data = f(*args, **kwargs) + parametrized_data: Any = f(*args, **kwargs) if not isinstance(parametrized_data, Iterable) or isinstance(parametrized_data, str | bytes): t = parametrized_data if isinstance(parametrized_data, type) else type(parametrized_data) raise ValueError(f"Parametrized data must be an iterable container, not {t.__name__!r}")