pytest-csv-params 2.0.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/PKG-INFO +18 -14
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/README.md +16 -12
- pytest_csv_params-2.1.0/_ptcsvp/cmdline.py +56 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/parametrize.py +22 -2
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/plugin.py +10 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/changelog.md +19 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/config.md +52 -12
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/install.md +8 -2
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pyproject.toml +3 -3
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/types.py +6 -0
- pytest_csv_params-2.1.0/tests/assets/empty1.csv +1 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/test_cmd_line.py +39 -14
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/test_plugin.py +3 -5
- pytest_csv_params-2.1.0/tests/poc/__init__.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_docs_example.py +1 -1
- pytest_csv_params-2.1.0/tests/test_empty_csv_files.py +70 -0
- pytest_csv_params-2.1.0/tests/test_non_existing_csv_files.py +38 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/uv.lock +2 -2
- pytest_csv_params-2.0.0/.devcontainer/Dockerfile +0 -31
- pytest_csv_params-2.0.0/.devcontainer/devcontainer.json +0 -18
- pytest_csv_params-2.0.0/_ptcsvp/cmdline.py +0 -30
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.ci/Jenkinsfile +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.gitignore +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/.gitignore +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/misc.xml +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/modules.xml +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/pytest-csv-params.iml +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/vcs.xml +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.pylintrc +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/CONTRIBUTING.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/LICENSE.txt +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/__init__.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/configure.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/exception.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/varname.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/_ptcsvp/version.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/Makefile +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/.gitkeep +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/style.css +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Bold.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Light.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Medium.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Regular.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-SemiBold.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-VF.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-Bold.woff2 +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-Light.woff2 +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-Medium.woff2 +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-Regular.woff2 +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-SemiBold.woff2 +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-VF.woff2 +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/vollkorn/Vollkorn-Bold.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/vollkorn/Vollkorn-Regular.woff +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/vollkorn/style.css +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_templates/layout.html +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_toc.rst +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/conf.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/genindex.rst +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/icon/pytest-csv-params.png +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/index.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/make.bat +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/api-ref/private.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/api-ref/public.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/api-ref/tests.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/api.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/contributing.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/developer.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/examples.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/guide.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/issues.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/pages/license.md +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/py-modindex.rst +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/serve.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/__init__.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/decorator.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/dialect.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/exception.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/plugin.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/shortcut.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/pytest_csv_params/warning.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/__init__.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/blog-example.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/doc-example.csv +0 -0
- /pytest_csv_params-2.0.0/tests/assets/test8.csv → /pytest_csv_params-2.1.0/tests/assets/empty2.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/example.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/reuse_test1.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/reuse_test2.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test1.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test10.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test11.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test2.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test3.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test4.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test5.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test6.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test7.csv +0 -0
- /pytest_csv_params-2.0.0/tests/plugin/__init__.py → /pytest_csv_params-2.1.0/tests/assets/test8.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/assets/test9.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/conftest.py +0 -0
- {pytest_csv_params-2.0.0/tests/poc → pytest_csv_params-2.1.0/tests/plugin}/__init__.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/assets/.gitattributes +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/assets/bad-test.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/assets/fruit_test.tpl +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/assets/simple-test.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/assets/text-only.csv +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/assets/text_test.tpl +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/plugin/conftest.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/poc/conftest.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/poc/test_parametrize_with_generator.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_blog_example.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_clean_headers.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_complex_example.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_id_col_is_data_col.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_id_col_is_data_col_shortcut.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_parametrize.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_read_csv.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_varname.py +0 -0
- {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_version_check.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pytest-csv-params
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Pytest plugin for Test Case Parametrization with CSV files
|
|
5
5
|
Project-URL: repository, https://git.codebau.dev/pytest-plugins/pytest-csv-params
|
|
6
6
|
Project-URL: homepage, https://git.codebau.dev/pytest-plugins/pytest-csv-params
|
|
@@ -31,7 +31,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
31
31
|
Classifier: Topic :: Software Development :: Testing
|
|
32
32
|
Classifier: Topic :: Utilities
|
|
33
33
|
Requires-Python: <3.16,>=3.10
|
|
34
|
-
Requires-Dist: pytest<
|
|
34
|
+
Requires-Dist: pytest<10,>=8.3
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
|
|
37
37
|

|
|
@@ -79,23 +79,27 @@ uv add --group dev pytest-csv-params
|
|
|
79
79
|
|
|
80
80
|
## Usage: Command Line Argument
|
|
81
81
|
|
|
82
|
-
| Argument
|
|
83
|
-
|
|
84
|
-
| `--csv-params-base-dir`
|
|
82
|
+
| Argument | Required | Description | Example |
|
|
83
|
+
|-----------------------------|---------------|-------------------------------------------------------------------------------------------|----------------------------------------------|
|
|
84
|
+
| `--csv-params-base-dir` | no (optional) | Define a base dir for all relative-path CSV data files (since 0.1.0) | `pytest --csv-params-base-dir /var/testdata` |
|
|
85
|
+
| `--csv-params-skip-missing` | no (optional) | Let tests automatically skip when CSV source is missing (since 2.1.0) | `pytest --csv-params-skip-missing` |
|
|
86
|
+
| `--csv-params-skip-empty` | no (optional) | Let tests automatically skip when CSV source does not contain any test data (since 2.1.0) | `pytest --csv-params-skip-empty` |
|
|
85
87
|
|
|
86
88
|
## Usage: Decorator
|
|
87
89
|
|
|
88
90
|
Simply decorate your test method with `@csv_params` (`pytest_csv_params.decorator.csv_params`) and the following parameters:
|
|
89
91
|
|
|
90
|
-
| Parameter
|
|
91
|
-
|
|
92
|
-
| `data_file`
|
|
93
|
-
| `base_dir`
|
|
94
|
-
| `id_col`
|
|
95
|
-
| `dialect`
|
|
96
|
-
| `data_casts`
|
|
97
|
-
| `header_renames`
|
|
98
|
-
| `reuse_id_col`
|
|
92
|
+
| Parameter | Type | Description | Example |
|
|
93
|
+
|-------------------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
|
|
94
|
+
| `data_file` | `str` | The CSV file to use, relative or absolute path | `"/var/testdata/test1.csv"` |
|
|
95
|
+
| `base_dir` | `str` (optional) | Directory to look up relative CSV files (see `data_file`); overrides the command line argument | `join(dirname(__file__), "assets")` |
|
|
96
|
+
| `id_col` | `str` (optional) | Column name of the CSV that contains test case IDs | `"ID#"` |
|
|
97
|
+
| `dialect` | `csv.Dialect` (optional) | CSV Dialect definition (see [Python CSV Documentation](https://docs.python.org/3/library/csv.html#dialects-and-formatting-parameters)) | `csv.excel_tab` |
|
|
98
|
+
| `data_casts` | `dict` (optional) | Cast Methods for the CSV Data (see "Data Casting" below) | `{ "a": int, "b": float }` |
|
|
99
|
+
| `header_renames` | `dict` (optional) | Replace headers from the CSV file, so that they can be used as parameters for the test function (since 0.3.0) | `{ "Annual Amount of Bananas": "banana_count", "Cherry export price": "cherry_export_price" }` |
|
|
100
|
+
| `reuse_id_col` | `bool` (optional) | Allows to re-use the ID column as test data column (since 1.3.0), defaults to `False` for backwards compatibility | `True` |
|
|
101
|
+
| `skip_when_missing_csv_file` | `bool` (optional) | When the CSV data cannot be loaded, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
|
|
102
|
+
| `skip_when_empty_csv_file` | `bool` (optional) | When the CSV data file is empty, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
|
|
99
103
|
|
|
100
104
|
## CSV Format
|
|
101
105
|
|
|
@@ -43,23 +43,27 @@ uv add --group dev pytest-csv-params
|
|
|
43
43
|
|
|
44
44
|
## Usage: Command Line Argument
|
|
45
45
|
|
|
46
|
-
| Argument
|
|
47
|
-
|
|
48
|
-
| `--csv-params-base-dir`
|
|
46
|
+
| Argument | Required | Description | Example |
|
|
47
|
+
|-----------------------------|---------------|-------------------------------------------------------------------------------------------|----------------------------------------------|
|
|
48
|
+
| `--csv-params-base-dir` | no (optional) | Define a base dir for all relative-path CSV data files (since 0.1.0) | `pytest --csv-params-base-dir /var/testdata` |
|
|
49
|
+
| `--csv-params-skip-missing` | no (optional) | Let tests automatically skip when CSV source is missing (since 2.1.0) | `pytest --csv-params-skip-missing` |
|
|
50
|
+
| `--csv-params-skip-empty` | no (optional) | Let tests automatically skip when CSV source does not contain any test data (since 2.1.0) | `pytest --csv-params-skip-empty` |
|
|
49
51
|
|
|
50
52
|
## Usage: Decorator
|
|
51
53
|
|
|
52
54
|
Simply decorate your test method with `@csv_params` (`pytest_csv_params.decorator.csv_params`) and the following parameters:
|
|
53
55
|
|
|
54
|
-
| Parameter
|
|
55
|
-
|
|
56
|
-
| `data_file`
|
|
57
|
-
| `base_dir`
|
|
58
|
-
| `id_col`
|
|
59
|
-
| `dialect`
|
|
60
|
-
| `data_casts`
|
|
61
|
-
| `header_renames`
|
|
62
|
-
| `reuse_id_col`
|
|
56
|
+
| Parameter | Type | Description | Example |
|
|
57
|
+
|-------------------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
|
|
58
|
+
| `data_file` | `str` | The CSV file to use, relative or absolute path | `"/var/testdata/test1.csv"` |
|
|
59
|
+
| `base_dir` | `str` (optional) | Directory to look up relative CSV files (see `data_file`); overrides the command line argument | `join(dirname(__file__), "assets")` |
|
|
60
|
+
| `id_col` | `str` (optional) | Column name of the CSV that contains test case IDs | `"ID#"` |
|
|
61
|
+
| `dialect` | `csv.Dialect` (optional) | CSV Dialect definition (see [Python CSV Documentation](https://docs.python.org/3/library/csv.html#dialects-and-formatting-parameters)) | `csv.excel_tab` |
|
|
62
|
+
| `data_casts` | `dict` (optional) | Cast Methods for the CSV Data (see "Data Casting" below) | `{ "a": int, "b": float }` |
|
|
63
|
+
| `header_renames` | `dict` (optional) | Replace headers from the CSV file, so that they can be used as parameters for the test function (since 0.3.0) | `{ "Annual Amount of Bananas": "banana_count", "Cherry export price": "cherry_export_price" }` |
|
|
64
|
+
| `reuse_id_col` | `bool` (optional) | Allows to re-use the ID column as test data column (since 1.3.0), defaults to `False` for backwards compatibility | `True` |
|
|
65
|
+
| `skip_when_missing_csv_file` | `bool` (optional) | When the CSV data cannot be loaded, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
|
|
66
|
+
| `skip_when_empty_csv_file` | `bool` (optional) | When the CSV data file is empty, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
|
|
63
67
|
|
|
64
68
|
## CSV Format
|
|
65
69
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This pytest plugin requires command line arguments that are parsed from the pytest framework. This module contains code
|
|
3
|
+
to instruct pytest to deliver the required values.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from _pytest.config.argparsing import Parser
|
|
7
|
+
|
|
8
|
+
HELP_TEXT_BASE_DIR = "set base dir for getting CSV data files from"
|
|
9
|
+
"""
|
|
10
|
+
This is the help text for the base dir command line argument that is added by :meth:`pytest_addoption`.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
HELP_TEXT_SKIP_MISSING = "skip tests when csv source is missing"
|
|
14
|
+
"""
|
|
15
|
+
This is the help text for the skip missing command line argument that is added by :meth:`pytest_addoption`.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
HELP_TEXT_SKIP_EMPTY = "skip tests when csv source is empty"
|
|
19
|
+
"""
|
|
20
|
+
This is the help text for the skip empty command line argument that is added by :meth:`pytest_addoption`.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def pytest_addoption(parser: Parser, plugin_name: str = "csv-params") -> None:
|
|
25
|
+
"""
|
|
26
|
+
Entrypoint for pytest to extend the own :class:`Parser` with the things we need extra.
|
|
27
|
+
|
|
28
|
+
:param parser: The pytest command line argument parser
|
|
29
|
+
:param plugin_name: The name of our plugin, with default value
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
group = parser.getgroup(plugin_name)
|
|
33
|
+
group.addoption(
|
|
34
|
+
f"--{plugin_name}-base-dir",
|
|
35
|
+
action="store",
|
|
36
|
+
type=str,
|
|
37
|
+
default=None,
|
|
38
|
+
required=False,
|
|
39
|
+
help=HELP_TEXT_BASE_DIR,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
group.addoption(
|
|
43
|
+
f"--{plugin_name}-skip-missing",
|
|
44
|
+
action="store_true",
|
|
45
|
+
default=False,
|
|
46
|
+
required=False,
|
|
47
|
+
help=HELP_TEXT_SKIP_MISSING,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
group.addoption(
|
|
51
|
+
f"--{plugin_name}-skip-empty",
|
|
52
|
+
action="store_true",
|
|
53
|
+
default=False,
|
|
54
|
+
required=False,
|
|
55
|
+
help=HELP_TEXT_SKIP_EMPTY,
|
|
56
|
+
)
|
|
@@ -10,7 +10,7 @@ from warnings import warn
|
|
|
10
10
|
import pytest
|
|
11
11
|
from _pytest.mark import MarkDecorator
|
|
12
12
|
|
|
13
|
-
from _ptcsvp.plugin import BASE_DIR_KEY, Plugin
|
|
13
|
+
from _ptcsvp.plugin import BASE_DIR_KEY, Plugin, SKIP_MISSING_KEY, SKIP_EMPTY_KEY
|
|
14
14
|
from _ptcsvp.varname import make_name_valid
|
|
15
15
|
from pytest_csv_params.dialect import CsvParamsDefaultDialect
|
|
16
16
|
from pytest_csv_params.exception import (
|
|
@@ -26,6 +26,7 @@ from pytest_csv_params.types import (
|
|
|
26
26
|
DataFile,
|
|
27
27
|
HeaderRenames,
|
|
28
28
|
IdColName,
|
|
29
|
+
SkipConfig,
|
|
29
30
|
)
|
|
30
31
|
from pytest_csv_params.warning import CsvParamsOnlyOneColumnIsUsedAsIdAndDataWarning
|
|
31
32
|
|
|
@@ -107,6 +108,8 @@ def add_parametrization( # pylint: disable=too-many-arguments
|
|
|
107
108
|
dialect: CsvDialect = CsvParamsDefaultDialect,
|
|
108
109
|
header_renames: HeaderRenames = None,
|
|
109
110
|
reuse_id_col: bool = False,
|
|
111
|
+
skip_when_missing_csv_file: SkipConfig = None,
|
|
112
|
+
skip_when_empty_csv_file: SkipConfig = None,
|
|
110
113
|
) -> MarkDecorator:
|
|
111
114
|
"""
|
|
112
115
|
Parametrize a test function with data from a CSV file.
|
|
@@ -120,13 +123,30 @@ def add_parametrization( # pylint: disable=too-many-arguments
|
|
|
120
123
|
:param dialect: The CSV file dialect (CSV file format) to use
|
|
121
124
|
:param header_renames: A dictonary mapping the header names from the CSV file to usable names for the tests
|
|
122
125
|
:param reuse_id_col: Allows re-using the ID col as test data column; defaults to `False` for backwards compatibility
|
|
126
|
+
:param skip_when_missing_csv_file: Let tests automatically skip when CSV source is missing (since 2.1.0)
|
|
127
|
+
:param skip_when_empty_csv_file: Let tests automatically skip when CSV source does not contain any test data (since 2.1.0)
|
|
123
128
|
|
|
124
129
|
:returns: :meth:`pytest.mark.parametrize` mark decorator, filled with all the data from the CSV.
|
|
125
130
|
"""
|
|
126
131
|
if base_dir is None:
|
|
127
132
|
base_dir = getattr(Plugin, BASE_DIR_KEY, None)
|
|
128
|
-
|
|
133
|
+
if skip_when_missing_csv_file is None:
|
|
134
|
+
skip_when_missing_csv_file = getattr(Plugin, SKIP_MISSING_KEY, False)
|
|
135
|
+
if skip_when_empty_csv_file is None:
|
|
136
|
+
skip_when_empty_csv_file = getattr(Plugin, SKIP_EMPTY_KEY, False)
|
|
137
|
+
try:
|
|
138
|
+
csv_lines = read_csv(base_dir, data_file, dialect)
|
|
139
|
+
except (CsvParamsDataFileNotFound, CsvParamsDataFileInaccessible):
|
|
140
|
+
if skip_when_missing_csv_file:
|
|
141
|
+
return pytest.mark.skip(
|
|
142
|
+
reason=f"CSV file '{data_file}' not found, test needs to be skipped"
|
|
143
|
+
)
|
|
144
|
+
raise
|
|
129
145
|
if len(csv_lines) < 2:
|
|
146
|
+
if skip_when_empty_csv_file:
|
|
147
|
+
return pytest.mark.skip(
|
|
148
|
+
reason=f"CSV file '{data_file}' has no test data in it, test needs to be skipped"
|
|
149
|
+
)
|
|
130
150
|
raise CsvParamsDataFileInvalid(
|
|
131
151
|
"File does not contain a single data row"
|
|
132
152
|
) from None
|
|
@@ -8,6 +8,14 @@ BASE_DIR_KEY = "__pytest_csv_params__config__base_dir"
|
|
|
8
8
|
"""
|
|
9
9
|
The class attribute key for :class:`Plugin` to store the base dir command line argument value.
|
|
10
10
|
"""
|
|
11
|
+
SKIP_MISSING_KEY = "__pytest_csv_params__config__skip_missing"
|
|
12
|
+
"""
|
|
13
|
+
The class attribute key for :class:`Plugin` to store the skip missing command line argument value.
|
|
14
|
+
"""
|
|
15
|
+
SKIP_EMPTY_KEY = "__pytest_csv_params__config__skip_empty"
|
|
16
|
+
"""
|
|
17
|
+
The class attribute key for :class:`Plugin` to store the skip empty command line argument value.
|
|
18
|
+
"""
|
|
11
19
|
|
|
12
20
|
|
|
13
21
|
class Plugin: # pylint: disable=too-few-public-methods
|
|
@@ -25,3 +33,5 @@ class Plugin: # pylint: disable=too-few-public-methods
|
|
|
25
33
|
:param config: Pytest configuration
|
|
26
34
|
"""
|
|
27
35
|
setattr(Plugin, BASE_DIR_KEY, config.option.csv_params_base_dir)
|
|
36
|
+
setattr(Plugin, SKIP_MISSING_KEY, config.option.csv_params_skip_missing)
|
|
37
|
+
setattr(Plugin, SKIP_EMPTY_KEY, config.option.csv_params_skip_empty)
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 2.1.0
|
|
4
|
+
|
|
5
|
+
<u>Breaking Changes:</u> ✓ None
|
|
6
|
+
|
|
7
|
+
<u>New Feature:</u>
|
|
8
|
+
|
|
9
|
+
This version adds two new features, both are disabled by default to avoid breaking changes and keeping up backward compatibility:
|
|
10
|
+
|
|
11
|
+
- Skip test if the CSV data source file is missing
|
|
12
|
+
- Skip test if the CSV data file exists, but does not contain test data
|
|
13
|
+
|
|
14
|
+
Both features are activated globally by a command line flag, or for specific tests by setting an parameter in the decorator.
|
|
15
|
+
Refer to the documentation for details.
|
|
16
|
+
|
|
17
|
+
<u>Deprecation Notice:</u>
|
|
18
|
+
|
|
19
|
+
- One of the next versions will **drop Pytest 8.x support**
|
|
20
|
+
- One of the next versions will **drop Python 3.10 support**
|
|
21
|
+
|
|
3
22
|
## Version 2.0.0
|
|
4
23
|
|
|
5
24
|
This release does not contain any new features, but it increases the major version number, as it includes breaking changes
|
|
@@ -6,15 +6,17 @@ These are the parameters for the decorator {meth}`pytest_csv_params.decorator.cs
|
|
|
6
6
|
|
|
7
7
|
### Overview
|
|
8
8
|
|
|
9
|
-
| Parameter
|
|
10
|
-
|
|
11
|
-
| `data_file`
|
|
12
|
-
| `base_dir`
|
|
13
|
-
| `id_col`
|
|
14
|
-
| `dialect`
|
|
15
|
-
| `data_casts`
|
|
16
|
-
| `header_renames`
|
|
17
|
-
| `reuse_id_col`
|
|
9
|
+
| Parameter | Type | Description | Example |
|
|
10
|
+
|-------------------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
|
|
11
|
+
| `data_file` | `str` | The CSV file to use, relative or absolute path | `"/var/testdata/test1.csv"` |
|
|
12
|
+
| `base_dir` | `str` (optional) | Directory to look up relative CSV files (see `data_file`); overrides the command line argument | `join(dirname(__file__), "assets")` |
|
|
13
|
+
| `id_col` | `str` (optional) | Column name of the CSV that contains test case IDs | `"ID#"` |
|
|
14
|
+
| `dialect` | `csv.Dialect` (optional) | CSV Dialect definition (see [Python CSV Documentation](https://docs.python.org/3/library/csv.html#dialects-and-formatting-parameters)) | `csv.excel_tab` |
|
|
15
|
+
| `data_casts` | `dict` (optional) | Cast Methods for the CSV Data (see "Data Casting" below) | `{ "a": int, "b": float }` |
|
|
16
|
+
| `header_renames` | `dict` (optional) | Replace headers from the CSV file, so that they can be used as parameters for the test function (since 0.3.0) | `{ "Annual Amount of Bananas": "banana_count", "Cherry export price": "cherry_export_price" }` |
|
|
17
|
+
| `reuse_id_col` | `bool` (optional) | Allows to re-use the ID column as test data column (since 1.3.0), defaults to `False` for backwards compatibility | `True` |
|
|
18
|
+
| `skip_when_missing_csv_file` | `bool` (optional) | When the CSV data cannot be loaded, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
|
|
19
|
+
| `skip_when_empty_csv_file` | `bool` (optional) | When the CSV data file is empty, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
|
|
18
20
|
|
|
19
21
|
### Detailed Description
|
|
20
22
|
|
|
@@ -253,15 +255,35 @@ def test_something_with_reusing_id_col(flux_setting: str, power_level: str, test
|
|
|
253
255
|
...
|
|
254
256
|
```
|
|
255
257
|
|
|
258
|
+
#### `skip_when_missing_csv_file`
|
|
259
|
+
|
|
260
|
+
Under normal circumstances, your whole test run would break, if a CSV file is missing. Setting this parameter to `True`
|
|
261
|
+
marks the test to be skipped in that case instead of breaking the run. Also adds a message to the test report.
|
|
262
|
+
|
|
263
|
+
There's also a command line argument `--skip-missing-csv-file` to turn on this behaviour globally.
|
|
264
|
+
|
|
265
|
+
**Available since 2.1.0.** For backwards compatibility, this parameter is `False` by default.
|
|
266
|
+
|
|
267
|
+
#### `skip_when_empty_csv_file`
|
|
268
|
+
|
|
269
|
+
Under normal circumstances, your whole test run would break, if a CSV file is empty. Setting this parameter to `True`
|
|
270
|
+
marks the test to be skipped in that case instead of breaking the run. Also adds a message to the test report.
|
|
271
|
+
|
|
272
|
+
There's also a command line argument `--skip-empty-csv-file` to turn on this behaviour globally.
|
|
273
|
+
|
|
274
|
+
**Available since 2.1.0.** For backwards compatibility, this parameter is `False` by default.
|
|
275
|
+
|
|
256
276
|
## Command Line Arguments
|
|
257
277
|
|
|
258
278
|
These are the command line arguments for the pytest run.
|
|
259
279
|
|
|
260
280
|
### Overview
|
|
261
281
|
|
|
262
|
-
| Argument
|
|
263
|
-
|
|
264
|
-
| `--csv-params-base-dir`
|
|
282
|
+
| Argument | Required | Description | Example |
|
|
283
|
+
|-----------------------------|---------------|-------------------------------------------------------------------------------------------|----------------------------------------------|
|
|
284
|
+
| `--csv-params-base-dir` | no (optional) | Define a base dir for all relative-path CSV data files (since 0.1.0) | `pytest --csv-params-base-dir /var/testdata` |
|
|
285
|
+
| `--csv-params-skip-missing` | no (optional) | Let tests automatically skip when CSV source is missing (since 2.1.0) | `pytest --csv-params-skip-missing` |
|
|
286
|
+
| `--csv-params-skip-empty` | no (optional) | Let tests automatically skip when CSV source does not contain any test data (since 2.1.0) | `pytest --csv-params-skip-empty` |
|
|
265
287
|
|
|
266
288
|
### Detailed Description
|
|
267
289
|
|
|
@@ -271,6 +293,24 @@ This is a convenience command line argument. It allows you to set a base directo
|
|
|
271
293
|
cases. If you use relative `data_file`s, this can be automatically prepended. You can still override this setting per
|
|
272
294
|
test by using the `base_dir` configuration.
|
|
273
295
|
|
|
296
|
+
#### `--csv-params-skip-missing`
|
|
297
|
+
|
|
298
|
+
This changes the behaviour during test case collection. If set, a test case that is decorated with a non-existing
|
|
299
|
+
CSV file, will be automatically marked as "skipped", instead of breaking the collection phase completely.
|
|
300
|
+
|
|
301
|
+
Since this can easily cover an error in your test setup, the default behaviour is breaking.
|
|
302
|
+
|
|
303
|
+
Available since 2.1.0.
|
|
304
|
+
|
|
305
|
+
#### `--csv-params-skip-empty`
|
|
306
|
+
|
|
307
|
+
Like `--csv-params-skip-missing`, this also changes the behaviour during test case collection. If set, a test that is
|
|
308
|
+
decorated with an empty CSV file, will be automatically marked as "skipped", instead of breaking the collection phase completely.
|
|
309
|
+
|
|
310
|
+
Since this can easily cover an error in your test setup, the default behaviour is breaking.
|
|
311
|
+
|
|
312
|
+
Available since 2.1.0.
|
|
313
|
+
|
|
274
314
|
## How a CSV file is found
|
|
275
315
|
|
|
276
316
|
```text
|
|
@@ -5,8 +5,8 @@ recommended.
|
|
|
5
5
|
|
|
6
6
|
The minimum requirements are:
|
|
7
7
|
|
|
8
|
-
- Python >= 3.
|
|
9
|
-
- Pytest >= 8.3
|
|
8
|
+
- Python >= 3.10, < 3.16
|
|
9
|
+
- Pytest >= 8.3, <10
|
|
10
10
|
|
|
11
11
|
The plugin should run anywhere where these two things can be used.
|
|
12
12
|
|
|
@@ -42,6 +42,12 @@ Alternatively, you can use the codebau.dev package repository with `poetry` also
|
|
|
42
42
|
|
|
43
43
|
For more information about `poetry`, visit [python-poetry.org](https://python-poetry.org/)
|
|
44
44
|
|
|
45
|
+
## Install via `uv`
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv add --group dev pytest-csv-params
|
|
49
|
+
```
|
|
50
|
+
|
|
45
51
|
## For development
|
|
46
52
|
|
|
47
53
|
Please checkout the repository from [git.codebau.dev](https://git.codebau.dev/pytest-plugins/pytest-csv-params).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pytest-csv-params"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.1.0"
|
|
4
4
|
description = "Pytest plugin for Test Case Parametrization with CSV files"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Juergen Edelbluth", email = "csv_params@jued.de" },
|
|
@@ -34,7 +34,7 @@ keywords = [
|
|
|
34
34
|
requires-python = ">=3.10,<3.16"
|
|
35
35
|
|
|
36
36
|
dependencies = [
|
|
37
|
-
"pytest>=8.3,<
|
|
37
|
+
"pytest>=8.3,<10",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
[dependency-groups]
|
|
@@ -149,4 +149,4 @@ build-backend = "hatchling.build"
|
|
|
149
149
|
packages = [
|
|
150
150
|
"_ptcsvp",
|
|
151
151
|
"pytest_csv_params",
|
|
152
|
-
]
|
|
152
|
+
]
|
|
@@ -64,3 +64,9 @@ HeaderRenames = Optional[HeaderRenamesDict]
|
|
|
64
64
|
The :class:`HeaderRenames` describes the type of the `header_renames` parameter of the
|
|
65
65
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator. It is just an optional :class:`HeaderRenamesDict`.
|
|
66
66
|
"""
|
|
67
|
+
|
|
68
|
+
SkipConfig = Optional[bool]
|
|
69
|
+
"""
|
|
70
|
+
The :class:`SkipWhenMissingCSVFile` describes the type of the `skip_when_missing_csv_files` parameter of the
|
|
71
|
+
:meth:`~pytest_csv_params.decorator.csv_params` decorator. It is just an optional :class:`bool`.
|
|
72
|
+
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"#ID", "Animal", "Color"
|
|
@@ -11,7 +11,11 @@ from typing import Callable
|
|
|
11
11
|
import pytest
|
|
12
12
|
from _pytest.pytester import Pytester
|
|
13
13
|
|
|
14
|
-
from _ptcsvp.cmdline import
|
|
14
|
+
from _ptcsvp.cmdline import (
|
|
15
|
+
HELP_TEXT_BASE_DIR,
|
|
16
|
+
HELP_TEXT_SKIP_MISSING,
|
|
17
|
+
HELP_TEXT_SKIP_EMPTY,
|
|
18
|
+
)
|
|
15
19
|
|
|
16
20
|
|
|
17
21
|
@pytest.mark.parametrize(
|
|
@@ -38,7 +42,7 @@ def test_base_dir_param(
|
|
|
38
42
|
|
|
39
43
|
csv_file = str(pytester.makefile(".csv", simple_test_csv).absolute())
|
|
40
44
|
|
|
41
|
-
parameters = [
|
|
45
|
+
parameters = []
|
|
42
46
|
if base_dir:
|
|
43
47
|
path = Path(csv_file)
|
|
44
48
|
parameters.extend(["--csv-params-base-dir", str(path.parent.absolute())])
|
|
@@ -58,18 +62,39 @@ def test_help(pytester: Pytester) -> None:
|
|
|
58
62
|
"""
|
|
59
63
|
|
|
60
64
|
result = pytester.runpytest("--help")
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
start_of_relevant_help = -1
|
|
66
|
+
|
|
67
|
+
base_dir_param_index = -1
|
|
68
|
+
skip_missing_param_index = -1
|
|
69
|
+
skip_empty_param_index = -1
|
|
70
|
+
|
|
71
|
+
index_help_base_dir = -1
|
|
72
|
+
index_help_skip_missing = -1
|
|
73
|
+
index_help_skip_empty = -1
|
|
64
74
|
|
|
65
75
|
for index, line in enumerate(result.stdout.lines):
|
|
66
|
-
if "csv-params:" in line and
|
|
67
|
-
|
|
76
|
+
if "csv-params:" in line and start_of_relevant_help < 0:
|
|
77
|
+
start_of_relevant_help = index
|
|
68
78
|
continue
|
|
69
|
-
if
|
|
70
|
-
|
|
71
|
-
if
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if start_of_relevant_help < 0:
|
|
80
|
+
continue
|
|
81
|
+
if "--csv-params-base-dir" in line:
|
|
82
|
+
base_dir_param_index = index
|
|
83
|
+
if "--csv-params-skip-missing" in line:
|
|
84
|
+
skip_missing_param_index = index
|
|
85
|
+
if "--csv-params-skip-empty" in line:
|
|
86
|
+
skip_empty_param_index = index
|
|
87
|
+
if HELP_TEXT_BASE_DIR in line and base_dir_param_index > 0:
|
|
88
|
+
index_help_base_dir = index
|
|
89
|
+
if HELP_TEXT_SKIP_MISSING in line and skip_missing_param_index > 0:
|
|
90
|
+
index_help_skip_missing = index
|
|
91
|
+
if HELP_TEXT_SKIP_EMPTY in line and skip_empty_param_index > 0:
|
|
92
|
+
index_help_skip_empty = index
|
|
93
|
+
|
|
94
|
+
assert start_of_relevant_help >= 0
|
|
95
|
+
assert base_dir_param_index > start_of_relevant_help
|
|
96
|
+
assert index_help_base_dir > base_dir_param_index
|
|
97
|
+
assert skip_missing_param_index > start_of_relevant_help
|
|
98
|
+
assert index_help_skip_missing > skip_missing_param_index
|
|
99
|
+
assert skip_empty_param_index > start_of_relevant_help
|
|
100
|
+
assert index_help_skip_empty > skip_empty_param_index
|
|
@@ -26,7 +26,7 @@ def test_plugin_test_multiplication(
|
|
|
26
26
|
|
|
27
27
|
pytester.makepyfile(simple_fruit_test(csv_file))
|
|
28
28
|
|
|
29
|
-
result = pytester.runpytest(
|
|
29
|
+
result = pytester.runpytest()
|
|
30
30
|
result.assert_outcomes(passed=3, failed=1)
|
|
31
31
|
|
|
32
32
|
|
|
@@ -45,7 +45,7 @@ def test_plugin_test_error(
|
|
|
45
45
|
|
|
46
46
|
pytester.makepyfile(simple_fruit_test(csv_file))
|
|
47
47
|
|
|
48
|
-
result = pytester.runpytest(
|
|
48
|
+
result = pytester.runpytest()
|
|
49
49
|
result.assert_outcomes(errors=1)
|
|
50
50
|
|
|
51
51
|
|
|
@@ -64,7 +64,7 @@ def test_plugin_test_text_shorthand(
|
|
|
64
64
|
|
|
65
65
|
pytester.makepyfile(simple_text_test(csv_file))
|
|
66
66
|
|
|
67
|
-
result = pytester.runpytest(
|
|
67
|
+
result = pytester.runpytest()
|
|
68
68
|
result.assert_outcomes(passed=2, failed=1)
|
|
69
69
|
|
|
70
70
|
|
|
@@ -102,8 +102,6 @@ def test_plugin_all_tests_at_once( # pylint: disable=too-many-arguments
|
|
|
102
102
|
)
|
|
103
103
|
|
|
104
104
|
result = pytester.runpytest(
|
|
105
|
-
"-p",
|
|
106
|
-
"no:bandit",
|
|
107
105
|
Path("test_plugin_test_all_one.py"),
|
|
108
106
|
Path("test_plugin_test_all_three.py"),
|
|
109
107
|
)
|
|
File without changes
|
|
@@ -53,7 +53,7 @@ def get_dimensions(dimensions_str: str) -> Tuple[int, int, int]:
|
|
|
53
53
|
dimensions_tuple = tuple(map(lambda x: int(x.strip()), dimensions_str.split("x")))
|
|
54
54
|
if len(dimensions_tuple) != 3:
|
|
55
55
|
raise ValueError("Dimensions invalid") from None
|
|
56
|
-
return dimensions_tuple
|
|
56
|
+
return dimensions_tuple
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
@csv_params(
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from os.path import join, dirname
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from pytest_csv_params.decorator import csv_params
|
|
6
|
+
from pytest_csv_params.exception import CsvParamsDataFileInvalid
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@csv_params(
|
|
10
|
+
data_file=join(dirname(__file__), "assets", "empty1.csv"),
|
|
11
|
+
id_col="ID#",
|
|
12
|
+
skip_when_empty_csv_file=True,
|
|
13
|
+
)
|
|
14
|
+
def test_no_element() -> None:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@csv_params(
|
|
19
|
+
data_file=join(dirname(__file__), "assets", "empty2.csv"),
|
|
20
|
+
id_col="ID#",
|
|
21
|
+
skip_when_empty_csv_file=True,
|
|
22
|
+
)
|
|
23
|
+
def test_no_data() -> None:
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_throws_exception_with_param_no_element() -> None:
|
|
28
|
+
with pytest.raises(CsvParamsDataFileInvalid):
|
|
29
|
+
|
|
30
|
+
@csv_params(
|
|
31
|
+
data_file=join(dirname(__file__), "assets", "empty1.csv"),
|
|
32
|
+
id_col="ID#",
|
|
33
|
+
skip_when_empty_csv_file=False,
|
|
34
|
+
)
|
|
35
|
+
def _test() -> None:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_throws_exception_with_param_no_data() -> None:
|
|
40
|
+
with pytest.raises(CsvParamsDataFileInvalid):
|
|
41
|
+
|
|
42
|
+
@csv_params(
|
|
43
|
+
data_file=join(dirname(__file__), "assets", "empty2.csv"),
|
|
44
|
+
id_col="ID#",
|
|
45
|
+
skip_when_empty_csv_file=False,
|
|
46
|
+
)
|
|
47
|
+
def _test() -> None:
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_throws_exception_without_param_no_element() -> None:
|
|
52
|
+
with pytest.raises(CsvParamsDataFileInvalid):
|
|
53
|
+
|
|
54
|
+
@csv_params(
|
|
55
|
+
data_file=join(dirname(__file__), "assets", "empty1.csv"),
|
|
56
|
+
id_col="ID#",
|
|
57
|
+
)
|
|
58
|
+
def _test() -> None:
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_throws_exception_without_param_no_data() -> None:
|
|
63
|
+
with pytest.raises(CsvParamsDataFileInvalid):
|
|
64
|
+
|
|
65
|
+
@csv_params(
|
|
66
|
+
data_file=join(dirname(__file__), "assets", "empty2.csv"),
|
|
67
|
+
id_col="ID#",
|
|
68
|
+
)
|
|
69
|
+
def _test() -> None:
|
|
70
|
+
pass
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from os.path import join, dirname
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from pytest_csv_params.decorator import csv_params
|
|
6
|
+
from pytest_csv_params.exception import CsvParamsDataFileNotFound
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@csv_params(
|
|
10
|
+
data_file=join(dirname(__file__), "assets", "does-not-exist.csv"),
|
|
11
|
+
id_col="ID#",
|
|
12
|
+
skip_when_missing_csv_file=True,
|
|
13
|
+
)
|
|
14
|
+
def test_simple_skip() -> None:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_throws_exception_with_param() -> None:
|
|
19
|
+
with pytest.raises(CsvParamsDataFileNotFound):
|
|
20
|
+
|
|
21
|
+
@csv_params(
|
|
22
|
+
data_file=join(dirname(__file__), "assets", "does-not-exist.csv"),
|
|
23
|
+
id_col="ID#",
|
|
24
|
+
skip_when_missing_csv_file=False,
|
|
25
|
+
)
|
|
26
|
+
def _test() -> None:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_throws_exception_without_param() -> None:
|
|
31
|
+
with pytest.raises(CsvParamsDataFileNotFound):
|
|
32
|
+
|
|
33
|
+
@csv_params(
|
|
34
|
+
data_file=join(dirname(__file__), "assets", "does-not-exist.csv"),
|
|
35
|
+
id_col="ID#",
|
|
36
|
+
)
|
|
37
|
+
def _test() -> None:
|
|
38
|
+
pass
|
|
@@ -805,7 +805,7 @@ wheels = [
|
|
|
805
805
|
|
|
806
806
|
[[package]]
|
|
807
807
|
name = "pytest-csv-params"
|
|
808
|
-
version = "2.
|
|
808
|
+
version = "2.1.0"
|
|
809
809
|
source = { editable = "." }
|
|
810
810
|
dependencies = [
|
|
811
811
|
{ name = "pytest" },
|
|
@@ -833,7 +833,7 @@ dev = ">=3.11"
|
|
|
833
833
|
docs = ">=3.11,<3.15"
|
|
834
834
|
|
|
835
835
|
[package.metadata]
|
|
836
|
-
requires-dist = [{ name = "pytest", specifier = ">=8.3,<
|
|
836
|
+
requires-dist = [{ name = "pytest", specifier = ">=8.3,<10" }]
|
|
837
837
|
|
|
838
838
|
[package.metadata.requires-dev]
|
|
839
839
|
dev = [
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
FROM alpine:latest
|
|
2
|
-
|
|
3
|
-
LABEL org.opencontainers.image.authors="Juergen Edelbluth <dev@juergen.rocks>"
|
|
4
|
-
|
|
5
|
-
USER root
|
|
6
|
-
|
|
7
|
-
RUN apk update && apk upgrade
|
|
8
|
-
RUN apk add patch build-base gcc zip xz-dev bzip2-dev zlib-dev libffi-dev linux-headers readline-dev openssl-dev openssl sqlite sqlite-dev
|
|
9
|
-
|
|
10
|
-
RUN apk add git gpg wget curl bash bash-completion shadow nano starship openssh-client openssh-sftp-server just
|
|
11
|
-
RUN chsh -s /bin/bash
|
|
12
|
-
|
|
13
|
-
RUN echo 'eval "$(starship init bash)"' >> ~/.bashrc
|
|
14
|
-
|
|
15
|
-
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | /bin/bash
|
|
16
|
-
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
|
17
|
-
RUN echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
|
18
|
-
RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc
|
|
19
|
-
|
|
20
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv update"
|
|
21
|
-
|
|
22
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv install 3.9"
|
|
23
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv install 3.10"
|
|
24
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv install 3.11"
|
|
25
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv install 3.12"
|
|
26
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv install 3.13"
|
|
27
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv install 3.14"
|
|
28
|
-
|
|
29
|
-
RUN /bin/bash -c ". ~/.bashrc && pyenv global 3.14"
|
|
30
|
-
|
|
31
|
-
RUN /bin/bash -c ". ~/.bashrc && python3 -m pip install pipx && python3 -m pipx ensurepath && pipx install poetry"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pytest-csv-params",
|
|
3
|
-
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
|
4
|
-
"customizations": {
|
|
5
|
-
"vscode": {
|
|
6
|
-
"extensions": [
|
|
7
|
-
"ms-python.python",
|
|
8
|
-
"ms-python.debugpy",
|
|
9
|
-
"zeshuaro.vscode-python-poetry",
|
|
10
|
-
"ms-azuretools.vscode-docker"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"build": {
|
|
15
|
-
"dockerfile": "Dockerfile"
|
|
16
|
-
},
|
|
17
|
-
"remoteUser": "root"
|
|
18
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This pytest plugin requires command line arguments that are parsed from the pytest framework. This module contains code
|
|
3
|
-
to instruct pytest to deliver the required values.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from _pytest.config.argparsing import Parser
|
|
7
|
-
|
|
8
|
-
HELP_TEXT = "set base dir for getting CSV data files from"
|
|
9
|
-
"""
|
|
10
|
-
This is the help text for the command line arguments that is added by :meth:`pytest_addoption`.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def pytest_addoption(parser: Parser, plugin_name: str = "csv-params") -> None:
|
|
15
|
-
"""
|
|
16
|
-
Entrypoint for pytest to extend the own :class:`Parser` with the things we need extra.
|
|
17
|
-
|
|
18
|
-
:param parser: The pytest command line argument parser
|
|
19
|
-
:param plugin_name: The name of our plugin, with default value
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
group = parser.getgroup(plugin_name)
|
|
23
|
-
group.addoption(
|
|
24
|
-
f"--{plugin_name}-base-dir",
|
|
25
|
-
action="store",
|
|
26
|
-
type=str,
|
|
27
|
-
default=None,
|
|
28
|
-
required=False,
|
|
29
|
-
help=HELP_TEXT,
|
|
30
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/.idea/inspectionProfiles/profiles_settings.xml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Bold.woff
RENAMED
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Light.woff
RENAMED
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-Medium.woff
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff/FiraCode-VF.woff
RENAMED
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-Bold.woff2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/fira/woff2/FiraCode-VF.woff2
RENAMED
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/vollkorn/Vollkorn-Bold.woff
RENAMED
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/docs/_static/font/vollkorn/Vollkorn-Regular.woff
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/pytest_csv_params-2.0.0/tests/assets/test8.csv → /pytest_csv_params-2.1.0/tests/assets/empty2.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/pytest_csv_params-2.0.0/tests/plugin/__init__.py → /pytest_csv_params-2.1.0/tests/assets/test8.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/poc/test_parametrize_with_generator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_csv_params-2.0.0 → pytest_csv_params-2.1.0}/tests/test_id_col_is_data_col_shortcut.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|