Skip to content

Commit a5c7dad

Browse files
feat: add pytest schema. (#4566)
* feat: add pytest schema. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cd216b2 commit a5c7dad

File tree

4 files changed

+310
-0
lines changed

4 files changed

+310
-0
lines changed

src/api/json/catalog.json

+5
Original file line numberDiff line numberDiff line change
@@ -4482,6 +4482,11 @@
44824482
"fileMatch": ["pyrightconfig.json"],
44834483
"url": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json"
44844484
},
4485+
{
4486+
"name": "pytest",
4487+
"description": "pytest configuration",
4488+
"url": "https://json.schemastore.org/partial-pytest.json"
4489+
},
44854490
{
44864491
"name": "Qgoda",
44874492
"description": "Qgoda static site generator configuration file format",

src/schema-validation.jsonc

+4
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,9 @@
991991
"partial-pyright.json": {
992992
"unknownKeywords": ["markdownDescription", "x-intellij-html-description"]
993993
},
994+
"partial-pytest.json": {
995+
"unknownKeywords": ["x-tombi-array-values-order", "x-tombi-table-keys-order"]
996+
},
994997
"partial-setuptools.json": {
995998
"unknownFormat": [
996999
"python-module-name",
@@ -1099,6 +1102,7 @@
10991102
"partial-poe.json",
11001103
"partial-poetry.json",
11011104
"partial-pyright.json",
1105+
"partial-pytest.json",
11021106
"partial-repo-review.json",
11031107
"partial-scikit-build.json",
11041108
"partial-setuptools.json",

src/schemas/json/partial-pytest.json

+296
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://json.schemastore.org/partial-pytest.json",
4+
"description": "JSON schema for pytest configuration options under `[tool.pytest]` in `pyproject.toml`.",
5+
"type": "object",
6+
"properties": {
7+
"ini_options": {
8+
"$ref": "#/definitions/IniOptions",
9+
"title": "Bridge Configuration Options for `pytest.ini` File",
10+
"description": "The `ini_options` table is used as a bridge between the existing `pytest.ini` configuration system and future configuration formats. `pytest.ini` takes precedence over `[tool.pytest.ini_options]` in `pyproject.toml`."
11+
}
12+
},
13+
"additionalProperties": false,
14+
"x-tombi-table-keys-order": "schema",
15+
"definitions": {
16+
"IniOptions": {
17+
"type": "object",
18+
"properties": {
19+
"addopts": {
20+
"type": "array",
21+
"items": {
22+
"type": "string"
23+
},
24+
"description": "Extra command line options to be added by default.",
25+
"x-tombi-array-values-order": "ascending"
26+
},
27+
"cache_dir": {
28+
"type": "string",
29+
"description": "Sets directory for cache plugin. Can include environment variables.",
30+
"default": ".pytest_cache"
31+
},
32+
"consider_namespace_packages": {
33+
"type": "boolean",
34+
"description": "Controls whether pytest attempts to identify namespace packages.",
35+
"default": false
36+
},
37+
"console_output_style": {
38+
"type": "string",
39+
"enum": [
40+
"classic",
41+
"progress",
42+
"progress-even-when-capture-no",
43+
"count"
44+
],
45+
"description": "Sets console output style during test execution.",
46+
"default": "progress"
47+
},
48+
"doctest_encoding": {
49+
"type": "string",
50+
"description": "Sets default encoding for doctest files."
51+
},
52+
"doctest_optionflags": {
53+
"type": "array",
54+
"items": {
55+
"type": "string"
56+
},
57+
"description": "Specifies doctest flag names from the `doctest` module.",
58+
"x-tombi-array-values-order": "ascending"
59+
},
60+
"empty_parameter_set_mark": {
61+
"type": "string",
62+
"enum": ["skip", "xfail", "fail_at_collect"],
63+
"description": "Defines behavior for empty parameter sets in parameterization.",
64+
"default": "skip"
65+
},
66+
"faulthandler_timeout": {
67+
"type": "integer",
68+
"description": "Sets timeout in seconds for dumping the traceback of all threads if a test takes too long."
69+
},
70+
"filterwarnings": {
71+
"type": "array",
72+
"items": {
73+
"type": "string"
74+
},
75+
"description": "Sets action to take for matching warnings. Each item is a warning specification string.",
76+
"x-tombi-array-values-order": "ascending"
77+
},
78+
"junit_duration_report": {
79+
"type": "string",
80+
"enum": ["total", "call"],
81+
"description": "Sets how to record test durations in JUnit XML report.",
82+
"default": "total"
83+
},
84+
"junit_family": {
85+
"type": "string",
86+
"enum": ["xunit1", "xunit2"],
87+
"description": "Sets format of generated JUnit XML files.",
88+
"default": "xunit2"
89+
},
90+
"junit_logging": {
91+
"type": "string",
92+
"enum": ["no", "log", "system-out", "system-err", "out-err", "all"],
93+
"description": "Controls whether captured output is written to JUnit XML file.",
94+
"default": "no"
95+
},
96+
"junit_log_passing_tests": {
97+
"type": "boolean",
98+
"description": "If `junit_logging` is not 'no', controls whether to include output of passing tests.",
99+
"default": true
100+
},
101+
"junit_suite_name": {
102+
"type": "string",
103+
"description": "Sets name of root test suite in JUnit XML report."
104+
},
105+
"log_auto_indent": {
106+
"description": "Allows selective auto-indentation of multiline log messages. Can be true, false, positive integer, 'On', or 'Off'.",
107+
"oneOf": [
108+
{
109+
"type": "boolean",
110+
"default": false
111+
},
112+
{
113+
"type": "integer",
114+
"minimum": 0
115+
},
116+
{
117+
"type": "string",
118+
"enum": ["On", "Off"]
119+
}
120+
]
121+
},
122+
"log_cli": {
123+
"type": "boolean",
124+
"description": "Enables log display during test run (live logging).",
125+
"default": false
126+
},
127+
"log_cli_date_format": {
128+
"type": "string",
129+
"description": "Sets date format for live logging using `time.strftime()` format."
130+
},
131+
"log_cli_format": {
132+
"type": "string",
133+
"description": "Sets message format for live logging using `logging` format."
134+
},
135+
"log_cli_level": {
136+
"$ref": "#/definitions/LogLevel",
137+
"description": "Sets minimum log level for live logging. Can be level name or integer value."
138+
},
139+
"log_date_format": {
140+
"type": "string",
141+
"description": "Sets date format for captured logging using `time.strftime()` format."
142+
},
143+
"log_file": {
144+
"type": "string",
145+
"description": "Sets file path to write log messages to."
146+
},
147+
"log_file_date_format": {
148+
"type": "string",
149+
"description": "Sets date format for log file using `time.strftime()` format."
150+
},
151+
"log_file_format": {
152+
"type": "string",
153+
"description": "Sets message format for log file using `logging` format."
154+
},
155+
"log_file_level": {
156+
"$ref": "#/definitions/LogLevel",
157+
"description": "Sets minimum log level for log file. Can be level name or integer value."
158+
},
159+
"log_format": {
160+
"type": "string",
161+
"description": "Sets message format for captured logging using `logging` format."
162+
},
163+
"log_level": {
164+
"$ref": "#/definitions/LogLevel",
165+
"description": "Sets minimum log level for captured logging. Can be level name or integer value."
166+
},
167+
"markers": {
168+
"type": "array",
169+
"items": {
170+
"type": "string"
171+
},
172+
"description": "Allows registering additional markers for test functions.",
173+
"x-tombi-array-values-order": "ascending"
174+
},
175+
"minversion": {
176+
"type": "string",
177+
"description": "Specifies minimum required pytest version."
178+
},
179+
"norecursedirs": {
180+
"type": "array",
181+
"items": {
182+
"type": "string"
183+
},
184+
"description": "Sets base name patterns for directories to be skipped during test discovery. Uses fnmatch-style matching. Replaces default patterns.",
185+
"x-tombi-array-values-order": "ascending"
186+
},
187+
"python_classes": {
188+
"type": "array",
189+
"items": {
190+
"type": "string"
191+
},
192+
"description": "Specifies name prefixes or glob patterns for identifying test classes.",
193+
"x-tombi-array-values-order": "ascending"
194+
},
195+
"python_files": {
196+
"type": "array",
197+
"items": {
198+
"type": "string"
199+
},
200+
"description": "Specifies glob patterns for identifying Python test module files.",
201+
"default": ["test_*.py", "*_test.py"],
202+
"x-tombi-array-values-order": "ascending"
203+
},
204+
"python_functions": {
205+
"type": "array",
206+
"items": {
207+
"type": "string"
208+
},
209+
"description": "Specifies name prefixes or glob patterns for identifying test functions and methods.",
210+
"default": ["test_*"],
211+
"x-tombi-array-values-order": "ascending"
212+
},
213+
"pythonpath": {
214+
"type": "array",
215+
"items": {
216+
"type": "string"
217+
},
218+
"description": "Sets list of directories to be added to the Python search path. Paths are relative to root directory.",
219+
"x-tombi-array-values-order": "ascending"
220+
},
221+
"required_plugins": {
222+
"type": "array",
223+
"items": {
224+
"type": "string"
225+
},
226+
"description": "Space-separated list of plugins required to run pytest. Can include version specifiers.",
227+
"x-tombi-array-values-order": "ascending"
228+
},
229+
"testpaths": {
230+
"type": "array",
231+
"items": {
232+
"type": "string"
233+
},
234+
"description": "Sets directories to search for tests when no specific paths are given on the command line. Paths are relative to root directory. Shell-style wildcards can be used.",
235+
"x-tombi-array-values-order": "ascending"
236+
},
237+
"tmp_path_retention_count": {
238+
"type": "integer",
239+
"description": "Number of sessions to retain `tmp_path` directories for.",
240+
"default": 3
241+
},
242+
"tmp_path_retention_policy": {
243+
"type": "string",
244+
"enum": ["all", "failed", "none"],
245+
"description": "Controls which `tmp_path` directories to retain based on test outcome.",
246+
"default": "all"
247+
},
248+
"usefixtures": {
249+
"type": "array",
250+
"items": {
251+
"type": "string"
252+
},
253+
"description": "List of fixtures that will be applied to all test functions.",
254+
"x-tombi-array-values-order": "ascending"
255+
},
256+
"verbosity_assertions": {
257+
"oneOf": [
258+
{
259+
"type": "integer",
260+
"minimum": 0
261+
},
262+
{
263+
"type": "string",
264+
"enum": ["auto"]
265+
}
266+
],
267+
"description": "Sets verbosity specific to assertion-related output. Can be integer or 'auto'."
268+
},
269+
"verbosity_test_cases": {
270+
"oneOf": [
271+
{
272+
"type": "integer",
273+
"minimum": 0
274+
},
275+
{
276+
"type": "string",
277+
"enum": ["auto"]
278+
}
279+
],
280+
"description": "Sets verbosity specific to test case execution output. Can be integer or 'auto'."
281+
},
282+
"xfail_strict": {
283+
"type": "boolean",
284+
"description": "If true, test suite will fail if a test marked with `@pytest.mark.xfail` unexpectedly passes.",
285+
"default": false
286+
}
287+
},
288+
"additionalProperties": false,
289+
"x-tombi-table-keys-order": "schema"
290+
},
291+
"LogLevel": {
292+
"type": "string",
293+
"enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
294+
}
295+
}
296+
}

src/schemas/json/pyproject.json

+5
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,11 @@
934934
"title": "Static Type Checker",
935935
"description": "Static type checker for Python."
936936
},
937+
"pytest": {
938+
"$ref": "https://json.schemastore.org/partial-pytest.json",
939+
"title": "Testing Framework",
940+
"description": "Standardized automated testing of Python packages"
941+
},
937942
"repo-review": {
938943
"$ref": "https://json.schemastore.org/partial-repo-review.json",
939944
"title": "Repository Reviewer",

0 commit comments

Comments
 (0)