pytest-csv-params 2.0.0__tar.gz → 2.1.1__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.
Files changed (115) hide show
  1. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/PKG-INFO +18 -14
  2. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/README.md +16 -12
  3. pytest_csv_params-2.1.1/_ptcsvp/cmdline.py +56 -0
  4. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/parametrize.py +22 -2
  5. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/plugin.py +10 -0
  6. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pyproject.toml +9 -3
  7. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/types.py +6 -0
  8. pytest_csv_params-2.0.0/.ci/Jenkinsfile +0 -71
  9. pytest_csv_params-2.0.0/.devcontainer/Dockerfile +0 -31
  10. pytest_csv_params-2.0.0/.devcontainer/devcontainer.json +0 -18
  11. pytest_csv_params-2.0.0/.idea/.gitignore +0 -8
  12. pytest_csv_params-2.0.0/.idea/inspectionProfiles/profiles_settings.xml +0 -6
  13. pytest_csv_params-2.0.0/.idea/misc.xml +0 -4
  14. pytest_csv_params-2.0.0/.idea/modules.xml +0 -8
  15. pytest_csv_params-2.0.0/.idea/pytest-csv-params.iml +0 -14
  16. pytest_csv_params-2.0.0/.idea/vcs.xml +0 -6
  17. pytest_csv_params-2.0.0/.pylintrc +0 -611
  18. pytest_csv_params-2.0.0/CONTRIBUTING.md +0 -11
  19. pytest_csv_params-2.0.0/_ptcsvp/cmdline.py +0 -30
  20. pytest_csv_params-2.0.0/docs/Makefile +0 -20
  21. pytest_csv_params-2.0.0/docs/_static/.gitkeep +0 -0
  22. pytest_csv_params-2.0.0/docs/_static/font/fira/style.css +0 -48
  23. pytest_csv_params-2.0.0/docs/_static/font/fira/woff/FiraCode-Bold.woff +0 -0
  24. pytest_csv_params-2.0.0/docs/_static/font/fira/woff/FiraCode-Light.woff +0 -0
  25. pytest_csv_params-2.0.0/docs/_static/font/fira/woff/FiraCode-Medium.woff +0 -0
  26. pytest_csv_params-2.0.0/docs/_static/font/fira/woff/FiraCode-Regular.woff +0 -0
  27. pytest_csv_params-2.0.0/docs/_static/font/fira/woff/FiraCode-SemiBold.woff +0 -0
  28. pytest_csv_params-2.0.0/docs/_static/font/fira/woff/FiraCode-VF.woff +0 -0
  29. pytest_csv_params-2.0.0/docs/_static/font/fira/woff2/FiraCode-Bold.woff2 +0 -0
  30. pytest_csv_params-2.0.0/docs/_static/font/fira/woff2/FiraCode-Light.woff2 +0 -0
  31. pytest_csv_params-2.0.0/docs/_static/font/fira/woff2/FiraCode-Medium.woff2 +0 -0
  32. pytest_csv_params-2.0.0/docs/_static/font/fira/woff2/FiraCode-Regular.woff2 +0 -0
  33. pytest_csv_params-2.0.0/docs/_static/font/fira/woff2/FiraCode-SemiBold.woff2 +0 -0
  34. pytest_csv_params-2.0.0/docs/_static/font/fira/woff2/FiraCode-VF.woff2 +0 -0
  35. pytest_csv_params-2.0.0/docs/_static/font/vollkorn/Vollkorn-Bold.woff +0 -0
  36. pytest_csv_params-2.0.0/docs/_static/font/vollkorn/Vollkorn-Regular.woff +0 -0
  37. pytest_csv_params-2.0.0/docs/_static/font/vollkorn/style.css +0 -16
  38. pytest_csv_params-2.0.0/docs/_templates/layout.html +0 -21
  39. pytest_csv_params-2.0.0/docs/_toc.rst +0 -41
  40. pytest_csv_params-2.0.0/docs/conf.py +0 -112
  41. pytest_csv_params-2.0.0/docs/genindex.rst +0 -2
  42. pytest_csv_params-2.0.0/docs/icon/pytest-csv-params.png +0 -0
  43. pytest_csv_params-2.0.0/docs/index.md +0 -38
  44. pytest_csv_params-2.0.0/docs/make.bat +0 -35
  45. pytest_csv_params-2.0.0/docs/pages/api-ref/private.md +0 -67
  46. pytest_csv_params-2.0.0/docs/pages/api-ref/public.md +0 -67
  47. pytest_csv_params-2.0.0/docs/pages/api-ref/tests.md +0 -127
  48. pytest_csv_params-2.0.0/docs/pages/api.md +0 -11
  49. pytest_csv_params-2.0.0/docs/pages/changelog.md +0 -204
  50. pytest_csv_params-2.0.0/docs/pages/config.md +0 -298
  51. pytest_csv_params-2.0.0/docs/pages/contributing.md +0 -6
  52. pytest_csv_params-2.0.0/docs/pages/developer.md +0 -178
  53. pytest_csv_params-2.0.0/docs/pages/examples.md +0 -25
  54. pytest_csv_params-2.0.0/docs/pages/guide.md +0 -128
  55. pytest_csv_params-2.0.0/docs/pages/install.md +0 -47
  56. pytest_csv_params-2.0.0/docs/pages/issues.md +0 -4
  57. pytest_csv_params-2.0.0/docs/pages/license.md +0 -9
  58. pytest_csv_params-2.0.0/docs/py-modindex.rst +0 -2
  59. pytest_csv_params-2.0.0/docs/serve.py +0 -28
  60. pytest_csv_params-2.0.0/tests/__init__.py +0 -0
  61. pytest_csv_params-2.0.0/tests/assets/blog-example.csv +0 -4
  62. pytest_csv_params-2.0.0/tests/assets/doc-example.csv +0 -9
  63. pytest_csv_params-2.0.0/tests/assets/example.csv +0 -3
  64. pytest_csv_params-2.0.0/tests/assets/reuse_test1.csv +0 -4
  65. pytest_csv_params-2.0.0/tests/assets/reuse_test2.csv +0 -4
  66. pytest_csv_params-2.0.0/tests/assets/test1.csv +0 -6
  67. pytest_csv_params-2.0.0/tests/assets/test10.csv +0 -10
  68. pytest_csv_params-2.0.0/tests/assets/test11.csv +0 -6
  69. pytest_csv_params-2.0.0/tests/assets/test2.csv +0 -6
  70. pytest_csv_params-2.0.0/tests/assets/test3.csv +0 -6
  71. pytest_csv_params-2.0.0/tests/assets/test4.csv +0 -6
  72. pytest_csv_params-2.0.0/tests/assets/test5.csv +0 -6
  73. pytest_csv_params-2.0.0/tests/assets/test6.csv +0 -6
  74. pytest_csv_params-2.0.0/tests/assets/test7.csv +0 -1
  75. pytest_csv_params-2.0.0/tests/assets/test8.csv +0 -0
  76. pytest_csv_params-2.0.0/tests/assets/test9.csv +0 -4
  77. pytest_csv_params-2.0.0/tests/conftest.py +0 -9
  78. pytest_csv_params-2.0.0/tests/plugin/__init__.py +0 -0
  79. pytest_csv_params-2.0.0/tests/plugin/assets/.gitattributes +0 -1
  80. pytest_csv_params-2.0.0/tests/plugin/assets/bad-test.csv +0 -4
  81. pytest_csv_params-2.0.0/tests/plugin/assets/fruit_test.tpl +0 -13
  82. pytest_csv_params-2.0.0/tests/plugin/assets/simple-test.csv +0 -5
  83. pytest_csv_params-2.0.0/tests/plugin/assets/text-only.csv +0 -4
  84. pytest_csv_params-2.0.0/tests/plugin/assets/text_test.tpl +0 -7
  85. pytest_csv_params-2.0.0/tests/plugin/conftest.py +0 -111
  86. pytest_csv_params-2.0.0/tests/plugin/test_cmd_line.py +0 -75
  87. pytest_csv_params-2.0.0/tests/plugin/test_plugin.py +0 -110
  88. pytest_csv_params-2.0.0/tests/poc/__init__.py +0 -0
  89. pytest_csv_params-2.0.0/tests/poc/conftest.py +0 -51
  90. pytest_csv_params-2.0.0/tests/poc/test_parametrize_with_generator.py +0 -88
  91. pytest_csv_params-2.0.0/tests/test_blog_example.py +0 -106
  92. pytest_csv_params-2.0.0/tests/test_clean_headers.py +0 -94
  93. pytest_csv_params-2.0.0/tests/test_complex_example.py +0 -62
  94. pytest_csv_params-2.0.0/tests/test_docs_example.py +0 -100
  95. pytest_csv_params-2.0.0/tests/test_id_col_is_data_col.py +0 -43
  96. pytest_csv_params-2.0.0/tests/test_id_col_is_data_col_shortcut.py +0 -43
  97. pytest_csv_params-2.0.0/tests/test_parametrize.py +0 -173
  98. pytest_csv_params-2.0.0/tests/test_read_csv.py +0 -117
  99. pytest_csv_params-2.0.0/tests/test_varname.py +0 -125
  100. pytest_csv_params-2.0.0/tests/test_version_check.py +0 -212
  101. pytest_csv_params-2.0.0/uv.lock +0 -1266
  102. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/.gitignore +0 -0
  103. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/LICENSE.txt +0 -0
  104. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/__init__.py +0 -0
  105. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/configure.py +0 -0
  106. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/exception.py +0 -0
  107. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/varname.py +0 -0
  108. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/_ptcsvp/version.py +0 -0
  109. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/__init__.py +0 -0
  110. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/decorator.py +0 -0
  111. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/dialect.py +0 -0
  112. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/exception.py +0 -0
  113. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/plugin.py +0 -0
  114. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/shortcut.py +0 -0
  115. {pytest_csv_params-2.0.0 → pytest_csv_params-2.1.1}/pytest_csv_params/warning.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pytest-csv-params
3
- Version: 2.0.0
3
+ Version: 2.1.1
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<9.2,>=8.3
34
+ Requires-Dist: pytest<10,>=8.3
35
35
  Description-Content-Type: text/markdown
36
36
 
37
37
  ![pytest-csv-params](https://docs.codebau.dev/pytest-plugins/pytest-csv-params/_images/pytest-csv-params.png)
@@ -79,23 +79,27 @@ uv add --group dev pytest-csv-params
79
79
 
80
80
  ## Usage: Command Line Argument
81
81
 
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` |
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 | Type | Description | Example |
91
- |------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
92
- | `data_file` | `str` | The CSV file to use, relative or absolute path | `"/var/testdata/test1.csv"` |
93
- | `base_dir` | `str` (optional) | Directory to look up relative CSV files (see `data_file`); overrides the command line argument | `join(dirname(__file__), "assets")` |
94
- | `id_col` | `str` (optional) | Column name of the CSV that contains test case IDs | `"ID#"` |
95
- | `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` |
96
- | `data_casts` | `dict` (optional) | Cast Methods for the CSV Data (see "Data Casting" below) | `{ "a": int, "b": float }` |
97
- | `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" }` |
98
- | `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` |
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 | 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` |
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 | Type | Description | Example |
55
- |------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
56
- | `data_file` | `str` | The CSV file to use, relative or absolute path | `"/var/testdata/test1.csv"` |
57
- | `base_dir` | `str` (optional) | Directory to look up relative CSV files (see `data_file`); overrides the command line argument | `join(dirname(__file__), "assets")` |
58
- | `id_col` | `str` (optional) | Column name of the CSV that contains test case IDs | `"ID#"` |
59
- | `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` |
60
- | `data_casts` | `dict` (optional) | Cast Methods for the CSV Data (see "Data Casting" below) | `{ "a": int, "b": float }` |
61
- | `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" }` |
62
- | `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` |
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
- csv_lines = read_csv(base_dir, data_file, dialect)
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-csv-params"
3
- version = "2.0.0"
3
+ version = "2.1.1"
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,<9.2",
37
+ "pytest>=8.3,<10",
38
38
  ]
39
39
 
40
40
  [dependency-groups]
@@ -149,4 +149,10 @@ build-backend = "hatchling.build"
149
149
  packages = [
150
150
  "_ptcsvp",
151
151
  "pytest_csv_params",
152
- ]
152
+ ]
153
+
154
+ [tool.hatch.build.targets.sdist]
155
+ only-include = [
156
+ "_ptcsvp",
157
+ "pytest_csv_params",
158
+ ]
@@ -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
+ """
@@ -1,71 +0,0 @@
1
- pipeline {
2
-
3
- environment {
4
- PY_COLORS = "0"
5
- }
6
-
7
- agent any
8
-
9
- stages {
10
- stage('CI') {
11
- matrix {
12
- axes {
13
- axis {
14
- name 'PYTHON_VERSION'
15
- values '3.11', '3.12', '3.13', '3.14', '3.15'
16
- }
17
- }
18
- stages {
19
- stage('Python Build') {
20
- options {
21
- lock('single-pytest-csv-params-build')
22
- }
23
- stages {
24
- stage('Prepare') {
25
- steps {
26
- sh 'uv sync --python ${PYTHON_VERSION} --group dev'
27
- sh 'uv run --python ${PYTHON_VERSION} coverage erase'
28
- }
29
- }
30
- stage('Test') {
31
- steps {
32
- sh 'uv run --python ${PYTHON_VERSION} pytest --cache-clear --cov-append'
33
- xunit checksName: "Tests ${PYTHON_VERSION}", tools: [JUnit(excludesPattern: '', pattern: 'test-reports/*.xml', stopProcessingIfError: true)]
34
- recordCoverage(
35
- tools: [[parser: 'COBERTURA', pattern: 'coverage.xml']],
36
- id: "python-${PYTHON_VERSION}-coverage",
37
- name: "Python ${PYTHON_VERSION} Coverage",
38
- sourceCodeRetention: 'EVERY_BUILD',
39
- qualityGates: [
40
- [threshold: 80.0, metric: 'LINE', baseline: 'PROJECT', unstable: true],
41
- [threshold: 70.0, metric: 'BRANCH', baseline: 'PROJECT', unstable: true]
42
- ]
43
- )
44
- }
45
- }
46
- stage('Build') {
47
- steps {
48
- sh 'uv build'
49
- }
50
- }
51
- }
52
- }
53
- }
54
- }
55
- }
56
- }
57
-
58
- post {
59
- success {
60
- deleteDir()
61
- }
62
- always {
63
- withCredentials([string(credentialsId: 'jed-notification-email', variable: 'EMAIL')]) {
64
- mail to: '$EMAIL',
65
- subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
66
- body: "Duration: ${currentBuild.durationString} / Jenkins URL: ${env.BUILD_URL}"
67
- }
68
- }
69
- }
70
-
71
- }
@@ -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,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Editor-based HTTP Client requests
5
- /httpRequests/
6
- # Datasource local storage ignored files
7
- /dataSources/
8
- /dataSources.local.xml
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <settings>
3
- <option name="USE_PROJECT_PROFILE" value="false" />
4
- <version value="1.0" />
5
- </settings>
6
- </component>
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="Poetry (pytest-csv-params)" project-jdk-type="Python SDK" />
4
- </project>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/pytest-csv-params.iml" filepath="$PROJECT_DIR$/.idea/pytest-csv-params.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module external.system.id="pyproject.toml" type="PYTHON_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.venv" />
6
- </content>
7
- <orderEntry type="jdk" jdkName="~/projekte/pytest-csv-params/.venv" jdkType="Python SDK" />
8
- <orderEntry type="sourceFolder" forTests="false" />
9
- </component>
10
- <component name="PyDocumentationSettings">
11
- <option name="format" value="PLAIN" />
12
- <option name="myDocStringFormat" value="Plain" />
13
- </component>
14
- </module>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>