pytest-jsonschema 1.0.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_jsonschema-1.0.0/.editorconfig +35 -0
- pytest_jsonschema-1.0.0/.flake8 +11 -0
- pytest_jsonschema-1.0.0/.gitignore +45 -0
- pytest_jsonschema-1.0.0/.vscode/extensions.json +6 -0
- pytest_jsonschema-1.0.0/.vscode/settings.json +13 -0
- pytest_jsonschema-1.0.0/CHANGELOG.md +49 -0
- pytest_jsonschema-1.0.0/LICENSE +22 -0
- pytest_jsonschema-1.0.0/Makefile +125 -0
- pytest_jsonschema-1.0.0/PKG-INFO +160 -0
- pytest_jsonschema-1.0.0/README.md +107 -0
- pytest_jsonschema-1.0.0/dependabot.yml +8 -0
- pytest_jsonschema-1.0.0/news/.changelog_template.jinja +15 -0
- pytest_jsonschema-1.0.0/news/.gitkeep +0 -0
- pytest_jsonschema-1.0.0/pyproject.toml +196 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/__init__.py +1 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/fixtures.py +44 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/loaders.py +50 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/__init__.py +9 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/ansible-vars.json +30 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/ansible.json +1388 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/docker-compose.json +2474 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/github-action.json +725 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/github-funding.json +113 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/github-issue-config.json +55 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/github-issue-forms.json +2302 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/github-workflow.json +2045 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/gitlab-ci.json +3107 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/package.json +1309 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/pre-commit-config.json +278 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/pre-commit-hooks.json +450 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/prettierrc.json +533 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/pyproject.json +1157 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/schemas/tsconfig.json +1894 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/types.py +20 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/utils/__init__.py +0 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/utils/update_schema.py +58 -0
- pytest_jsonschema-1.0.0/src/pytest_jsonschema/validator.py +19 -0
- pytest_jsonschema-1.0.0/tests/conftest.py +32 -0
- pytest_jsonschema-1.0.0/tests/resources/invalid/github-workflow-changelog.yml +26 -0
- pytest_jsonschema-1.0.0/tests/resources/invalid/github-workflow-code.yml +31 -0
- pytest_jsonschema-1.0.0/tests/resources/invalid/github-workflow-lint.yml +7 -0
- pytest_jsonschema-1.0.0/tests/resources/invalid/package.json +390 -0
- pytest_jsonschema-1.0.0/tests/resources/invalid/pyproject.toml +193 -0
- pytest_jsonschema-1.0.0/tests/resources/invalid/tsconfig.json +3 -0
- pytest_jsonschema-1.0.0/tests/resources/valid/github-workflow-changelog.yml +29 -0
- pytest_jsonschema-1.0.0/tests/resources/valid/github-workflow-code.yml +35 -0
- pytest_jsonschema-1.0.0/tests/resources/valid/github-workflow-lint.yml +30 -0
- pytest_jsonschema-1.0.0/tests/resources/valid/package.json +390 -0
- pytest_jsonschema-1.0.0/tests/resources/valid/pyproject.toml +194 -0
- pytest_jsonschema-1.0.0/tests/resources/valid/tsconfig.json +34 -0
- pytest_jsonschema-1.0.0/tests/test_fixtures.py +98 -0
- pytest_jsonschema-1.0.0/tests/test_jsonschema.py +26 -0
- pytest_jsonschema-1.0.0/tests/test_validator.py +27 -0
- pytest_jsonschema-1.0.0/uv.lock +1392 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
# EditorConfig Configuration file, for more details see:
|
|
3
|
+
# https://EditorConfig.org
|
|
4
|
+
# EditorConfig is a convention description, that could be interpreted
|
|
5
|
+
# by multiple editors to enforce common coding conventions for specific
|
|
6
|
+
# file types
|
|
7
|
+
|
|
8
|
+
# top-most EditorConfig file:
|
|
9
|
+
# Will ignore other EditorConfig files in Home directory or upper tree level.
|
|
10
|
+
root = true
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
[*] # For All Files
|
|
14
|
+
# Unix-style newlines with a newline ending every file
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
insert_final_newline = true
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
# Set default charset
|
|
19
|
+
charset = utf-8
|
|
20
|
+
# Indent style default
|
|
21
|
+
indent_style = space
|
|
22
|
+
|
|
23
|
+
[*.{py,cfg,ini}]
|
|
24
|
+
# 4 space indentation
|
|
25
|
+
indent_size = 4
|
|
26
|
+
|
|
27
|
+
[*.{html,dtml,pt,zpt,xml,zcml,js,json,ts,less,scss,css,sass,yml,yaml}]
|
|
28
|
+
# 2 space indentation
|
|
29
|
+
indent_size = 2
|
|
30
|
+
|
|
31
|
+
[{Makefile,.gitmodules}]
|
|
32
|
+
# Tab indentation (no size specified, but view as 4 spaces)
|
|
33
|
+
indent_style = tab
|
|
34
|
+
indent_size = unset
|
|
35
|
+
tab_width = unset
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# python related
|
|
2
|
+
*.egg-info
|
|
3
|
+
*.pyc
|
|
4
|
+
*.pyo
|
|
5
|
+
|
|
6
|
+
# tools related
|
|
7
|
+
__pycache__/
|
|
8
|
+
.coverage
|
|
9
|
+
.mypy_cache
|
|
10
|
+
.pytest_cache
|
|
11
|
+
.ruff_cache
|
|
12
|
+
/build/
|
|
13
|
+
coverage.xml
|
|
14
|
+
dist/
|
|
15
|
+
docs/_build
|
|
16
|
+
node_modules/
|
|
17
|
+
|
|
18
|
+
# venv / buildout related
|
|
19
|
+
.eggs/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
.mr.developer.cfg
|
|
22
|
+
.venv/
|
|
23
|
+
bin/
|
|
24
|
+
develop-eggs/
|
|
25
|
+
eggs/
|
|
26
|
+
etc/
|
|
27
|
+
include/
|
|
28
|
+
lib/
|
|
29
|
+
lib64
|
|
30
|
+
parts/
|
|
31
|
+
pyvenv.cfg
|
|
32
|
+
var/
|
|
33
|
+
|
|
34
|
+
# mxdev
|
|
35
|
+
.installed.txt
|
|
36
|
+
.lock
|
|
37
|
+
/.make-sentinels/
|
|
38
|
+
/*-mxdev.txt
|
|
39
|
+
/instance/
|
|
40
|
+
/reports/
|
|
41
|
+
/sources/
|
|
42
|
+
/venv/
|
|
43
|
+
constraints*.txt
|
|
44
|
+
requirements*.txt
|
|
45
|
+
.coverage*
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"flake8.args": ["--config=pyproject.toml"],
|
|
3
|
+
"ruff.organizeImports": true,
|
|
4
|
+
"python.terminal.activateEnvironment": true,
|
|
5
|
+
"python.testing.pytestArgs": [
|
|
6
|
+
"tests"
|
|
7
|
+
],
|
|
8
|
+
"python.testing.unittestEnabled": false,
|
|
9
|
+
"python.testing.pytestEnabled": true,
|
|
10
|
+
"[markdown]": {
|
|
11
|
+
"editor.formatOnSave": false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!-- You should *NOT* be adding new change log entries to this file.
|
|
4
|
+
You should create a file in the news directory instead.
|
|
5
|
+
For helpful instructions, please see:
|
|
6
|
+
https://6.docs.plone.org/volto/developer-guidelines/contributing.html#create-a-pull-request
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<!-- towncrier release notes start -->
|
|
10
|
+
|
|
11
|
+
## 1.0.0 (2025-11-07)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### New features:
|
|
15
|
+
|
|
16
|
+
- Update schemas. @ericof
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug fixes:
|
|
20
|
+
|
|
21
|
+
- The host json.schemastore.org has been changed to www.schemastore.org. @ericof [#8](https://github.com/collective/pytest-jsonschema/issues/8)
|
|
22
|
+
|
|
23
|
+
## 1.0.0b1 (2025-04-20)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Internal:
|
|
27
|
+
|
|
28
|
+
- Modernize package, improve mypy support @ericof
|
|
29
|
+
|
|
30
|
+
## 1.0.0a2 (2024-03-27)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bugfix
|
|
34
|
+
|
|
35
|
+
- Add MANIFEST.in file [@ericof] [#5](https://github.com/collective/pytest-jsonschema/issue/5)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Documentation
|
|
39
|
+
|
|
40
|
+
- Improve README.md with usage information [@ericof] [#4](https://github.com/collective/pytest-jsonschema/issue/4)
|
|
41
|
+
|
|
42
|
+
## 1.0.0a1 (2024-03-27)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Feature
|
|
46
|
+
|
|
47
|
+
- Implement fixture to validate a file against a json schema [@ericof] [#1](https://github.com/collective/pytest-jsonschema/issue/1)
|
|
48
|
+
- Implement fixture to validate a string against a json schema [@ericof] [#2](https://github.com/collective/pytest-jsonschema/issue/2)
|
|
49
|
+
- Implement fixture to validate a data structure against a json schema [@ericof] [#3](https://github.com/collective/pytest-jsonschema/issue/3)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
The MIT License (MIT)
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Érico Andrei
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
### Defensive settings for make:
|
|
2
|
+
# https://tech.davis-hansson.com/p/make/
|
|
3
|
+
SHELL:=bash
|
|
4
|
+
.ONESHELL:
|
|
5
|
+
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
|
|
6
|
+
.SILENT:
|
|
7
|
+
.DELETE_ON_ERROR:
|
|
8
|
+
MAKEFLAGS+=--warn-undefined-variables
|
|
9
|
+
MAKEFLAGS+=--no-builtin-rules
|
|
10
|
+
|
|
11
|
+
# We like colors
|
|
12
|
+
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
|
|
13
|
+
RED=`tput setaf 1`
|
|
14
|
+
GREEN=`tput setaf 2`
|
|
15
|
+
RESET=`tput sgr0`
|
|
16
|
+
YELLOW=`tput setaf 3`
|
|
17
|
+
|
|
18
|
+
# Python checks
|
|
19
|
+
UV?=uv
|
|
20
|
+
|
|
21
|
+
# installed?
|
|
22
|
+
ifeq (, $(shell which $(UV) ))
|
|
23
|
+
$(error "UV=$(UV) not found in $(PATH)")
|
|
24
|
+
endif
|
|
25
|
+
|
|
26
|
+
BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
27
|
+
|
|
28
|
+
VENV_FOLDER=$(BACKEND_FOLDER)/.venv
|
|
29
|
+
BIN_FOLDER=$(VENV_FOLDER)/bin
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
all: build
|
|
33
|
+
|
|
34
|
+
# Add the following 'help' target to your Makefile
|
|
35
|
+
# And add help text after each target name starting with '\#\#'
|
|
36
|
+
.PHONY: help
|
|
37
|
+
help: ## This help message
|
|
38
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
############################################
|
|
42
|
+
# Install
|
|
43
|
+
############################################
|
|
44
|
+
|
|
45
|
+
$(VENV_FOLDER): ## Install dependencies
|
|
46
|
+
@echo "$(GREEN)==> Install environment$(RESET)"
|
|
47
|
+
@uv sync
|
|
48
|
+
|
|
49
|
+
.PHONY: sync
|
|
50
|
+
sync: $(VENV_FOLDER) ## Sync project dependencies
|
|
51
|
+
@echo "$(GREEN)==> Sync project dependencies$(RESET)"
|
|
52
|
+
@uv sync
|
|
53
|
+
|
|
54
|
+
.PHONY: install
|
|
55
|
+
install: $(VENV_FOLDER) ## Install Plone and dependencies
|
|
56
|
+
|
|
57
|
+
.PHONY: clean
|
|
58
|
+
clean: ## Clean installation
|
|
59
|
+
@echo "$(RED)==> Cleaning environment and build$(RESET)"
|
|
60
|
+
@rm -rf $(VENV_FOLDER) pyvenv.cfg .installed.cfg .venv .pytest_cache .ruff_cache constraints* requirements*
|
|
61
|
+
|
|
62
|
+
############################################
|
|
63
|
+
# QA
|
|
64
|
+
############################################
|
|
65
|
+
.PHONY: mypy
|
|
66
|
+
mypy: ## Type checking
|
|
67
|
+
@echo "$(GREEN)==> Run mypy$(RESET)"
|
|
68
|
+
@uv run mypy src
|
|
69
|
+
|
|
70
|
+
.PHONY: lint
|
|
71
|
+
lint: ## Check and fix code base according to Plone standards
|
|
72
|
+
@echo "$(GREEN)==> Lint codebase$(RESET)"
|
|
73
|
+
@uvx ruff@latest check --fix --config $(BACKEND_FOLDER)/pyproject.toml
|
|
74
|
+
@uvx pyroma@latest -d .
|
|
75
|
+
@uvx check-python-versions@latest .
|
|
76
|
+
@uvx zpretty@latest --check src
|
|
77
|
+
@uv run mypy src
|
|
78
|
+
|
|
79
|
+
.PHONY: format
|
|
80
|
+
format: ## Check and fix code base according to Plone standards
|
|
81
|
+
@echo "$(GREEN)==> Format codebase$(RESET)"
|
|
82
|
+
@uvx ruff@latest check --select I --fix --config $(BACKEND_FOLDER)/pyproject.toml
|
|
83
|
+
@uvx ruff@latest format --config $(BACKEND_FOLDER)/pyproject.toml
|
|
84
|
+
@uvx zpretty@latest -i src
|
|
85
|
+
|
|
86
|
+
.PHONY: check
|
|
87
|
+
check: format lint ## Check and fix code base according to Plone standards
|
|
88
|
+
|
|
89
|
+
############################################
|
|
90
|
+
# Update schemas
|
|
91
|
+
############################################
|
|
92
|
+
.PHONY: update-schemas
|
|
93
|
+
update-schemas: ## Update existing schemas
|
|
94
|
+
@echo "$(GREEN)==> Update existing schemas$(RESET)"
|
|
95
|
+
@uv run python src/pytest_jsonschema/utils/update_schema.py
|
|
96
|
+
|
|
97
|
+
############################################
|
|
98
|
+
# Tests
|
|
99
|
+
############################################
|
|
100
|
+
.PHONY: test
|
|
101
|
+
test: $(VENV_FOLDER) ## run tests
|
|
102
|
+
@uv run pytest
|
|
103
|
+
|
|
104
|
+
.PHONY: test-coverage
|
|
105
|
+
test-coverage: $(VENV_FOLDER) ## run tests with coverage
|
|
106
|
+
@uv run coverage run --source=pytest_jsonschema --module pytest --cov-report term-missing
|
|
107
|
+
@uv run coverage report --format markdown
|
|
108
|
+
|
|
109
|
+
############################################
|
|
110
|
+
# Release
|
|
111
|
+
############################################
|
|
112
|
+
.PHONY: changelog
|
|
113
|
+
changelog: ## Release the package to pypi.org
|
|
114
|
+
@echo "🚀 Display the draft for the changelog"
|
|
115
|
+
@uv run towncrier --draft
|
|
116
|
+
|
|
117
|
+
.PHONY: release
|
|
118
|
+
release: ## Release the package to pypi.org
|
|
119
|
+
@echo "🚀 Release package"
|
|
120
|
+
@uv run prerelease
|
|
121
|
+
@uv run release
|
|
122
|
+
@rm -Rf dist
|
|
123
|
+
@uv build
|
|
124
|
+
@uv publish
|
|
125
|
+
@uv run postrelease
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytest-jsonschema
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A pytest plugin to perform JSONSchema validations
|
|
5
|
+
Project-URL: Homepage, https://github.com/collective/pytest-jsonschema
|
|
6
|
+
Project-URL: PyPI, https://pypi.org/project/pytest-jsonschema
|
|
7
|
+
Project-URL: Source, https://github.com/collective/pytest-jsonschema
|
|
8
|
+
Project-URL: Tracker, https://github.com/collective/pytest-jsonschema/issues
|
|
9
|
+
Author-email: Érico Andrei <ericof@plone.org>
|
|
10
|
+
Maintainer-email: Érico Andrei <ericof@plone.org>
|
|
11
|
+
License:
|
|
12
|
+
The MIT License (MIT)
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2024 Érico Andrei
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in
|
|
24
|
+
all copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
32
|
+
THE SOFTWARE.
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Keywords: pytest,testing
|
|
35
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
36
|
+
Classifier: Framework :: Pytest
|
|
37
|
+
Classifier: Intended Audience :: Developers
|
|
38
|
+
Classifier: Operating System :: OS Independent
|
|
39
|
+
Classifier: Programming Language :: Python
|
|
40
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
45
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
46
|
+
Classifier: Topic :: Software Development :: Testing
|
|
47
|
+
Requires-Python: >=3.10
|
|
48
|
+
Requires-Dist: jsonschema
|
|
49
|
+
Requires-Dist: pytest>=6.2.0
|
|
50
|
+
Requires-Dist: ruamel-yaml
|
|
51
|
+
Requires-Dist: tomli==2.0.1; python_version <= '3.11'
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
<h1 align="center">pytest-jsonschema</h1>
|
|
55
|
+
|
|
56
|
+
<div align="center">
|
|
57
|
+
|
|
58
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
59
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
60
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
61
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
62
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
63
|
+
[](https://github.com/collective/pytest-jsonschema/actions/workflows/ci.yml)
|
|
64
|
+
[](https://github.com/collective/pytest-jsonschema/graphs/contributors)
|
|
65
|
+
[](https://github.com/collective/pytest-jsonschema/stargazers)
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
**pytest-jsonschema** is a plugin for [pytest](https://docs.pytest.org) designed to facilitate JSON Schema validations within your test suites. This tool enables you to validate JSON files, strings, and Python objects against predefined JSON Schemas, ensuring your data adheres to expected formats.
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
Install **pytest-jsonschema** using pip / uv from PyPI:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install pytest-jsonschema
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Features & Usage
|
|
80
|
+
|
|
81
|
+
The package introduces three pytest fixtures for validating JSON data:
|
|
82
|
+
|
|
83
|
+
### `schema_validate_file`
|
|
84
|
+
|
|
85
|
+
Validates a JSON file located in your test suite directory:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from pathlib import Path
|
|
89
|
+
|
|
90
|
+
def test_package_json_is_valid(schema_validate_file):
|
|
91
|
+
path = Path("package.json")
|
|
92
|
+
assert schema_validate_file(path=path, schema_name="package")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `schema_validate_string`
|
|
96
|
+
|
|
97
|
+
Validates a JSON string:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from pathlib import Path
|
|
101
|
+
|
|
102
|
+
def test_package_json_is_valid(schema_validate_string):
|
|
103
|
+
data = Path("package.json").read_text()
|
|
104
|
+
assert schema_validate_string(data=data, schema_name="package", file_type="json")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `schema_validate`
|
|
108
|
+
|
|
109
|
+
Validates a Python dictionary representing JSON data:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import json
|
|
113
|
+
from pathlib import Path
|
|
114
|
+
|
|
115
|
+
def test_package_json_is_valid(schema_validate):
|
|
116
|
+
data = json.loads(Path("package.json").read_text())
|
|
117
|
+
assert schema_validate(data=data, schema_name="package")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Requirements
|
|
121
|
+
|
|
122
|
+
- pytest >= 6.2.0
|
|
123
|
+
|
|
124
|
+
## Contributing
|
|
125
|
+
|
|
126
|
+
To contribute to **pytest-jsonschema**, please follow these steps:
|
|
127
|
+
|
|
128
|
+
1. Clone the repository:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
git clone git@github.com:collective/pytest-jsonschema.git
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. Install the package for development:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
make install
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
3. Format the codebase:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
make format
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
4. Run tests:
|
|
147
|
+
- To run all tests:
|
|
148
|
+
```bash
|
|
149
|
+
uv run pytest
|
|
150
|
+
```
|
|
151
|
+
- To stop on the first error and open a pdb session:
|
|
152
|
+
```
|
|
153
|
+
uv run pytest -x --pdb
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Testing is conducted using [`pytest`](https://docs.pytest.org/en/stable/).
|
|
157
|
+
|
|
158
|
+
## License 📜
|
|
159
|
+
|
|
160
|
+
**pytest-jsonschema** is licensed under the [MIT License](./LICENSE).
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<h1 align="center">pytest-jsonschema</h1>
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
6
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
7
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
8
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
9
|
+
[](https://pypi.org/project/pytest-jsonschema/)
|
|
10
|
+
[](https://github.com/collective/pytest-jsonschema/actions/workflows/ci.yml)
|
|
11
|
+
[](https://github.com/collective/pytest-jsonschema/graphs/contributors)
|
|
12
|
+
[](https://github.com/collective/pytest-jsonschema/stargazers)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
**pytest-jsonschema** is a plugin for [pytest](https://docs.pytest.org) designed to facilitate JSON Schema validations within your test suites. This tool enables you to validate JSON files, strings, and Python objects against predefined JSON Schemas, ensuring your data adheres to expected formats.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Install **pytest-jsonschema** using pip / uv from PyPI:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install pytest-jsonschema
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features & Usage
|
|
27
|
+
|
|
28
|
+
The package introduces three pytest fixtures for validating JSON data:
|
|
29
|
+
|
|
30
|
+
### `schema_validate_file`
|
|
31
|
+
|
|
32
|
+
Validates a JSON file located in your test suite directory:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from pathlib import Path
|
|
36
|
+
|
|
37
|
+
def test_package_json_is_valid(schema_validate_file):
|
|
38
|
+
path = Path("package.json")
|
|
39
|
+
assert schema_validate_file(path=path, schema_name="package")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### `schema_validate_string`
|
|
43
|
+
|
|
44
|
+
Validates a JSON string:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from pathlib import Path
|
|
48
|
+
|
|
49
|
+
def test_package_json_is_valid(schema_validate_string):
|
|
50
|
+
data = Path("package.json").read_text()
|
|
51
|
+
assert schema_validate_string(data=data, schema_name="package", file_type="json")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### `schema_validate`
|
|
55
|
+
|
|
56
|
+
Validates a Python dictionary representing JSON data:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import json
|
|
60
|
+
from pathlib import Path
|
|
61
|
+
|
|
62
|
+
def test_package_json_is_valid(schema_validate):
|
|
63
|
+
data = json.loads(Path("package.json").read_text())
|
|
64
|
+
assert schema_validate(data=data, schema_name="package")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Requirements
|
|
68
|
+
|
|
69
|
+
- pytest >= 6.2.0
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
To contribute to **pytest-jsonschema**, please follow these steps:
|
|
74
|
+
|
|
75
|
+
1. Clone the repository:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone git@github.com:collective/pytest-jsonschema.git
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
2. Install the package for development:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
make install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
3. Format the codebase:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
make format
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
4. Run tests:
|
|
94
|
+
- To run all tests:
|
|
95
|
+
```bash
|
|
96
|
+
uv run pytest
|
|
97
|
+
```
|
|
98
|
+
- To stop on the first error and open a pdb session:
|
|
99
|
+
```
|
|
100
|
+
uv run pytest -x --pdb
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Testing is conducted using [`pytest`](https://docs.pytest.org/en/stable/).
|
|
104
|
+
|
|
105
|
+
## License 📜
|
|
106
|
+
|
|
107
|
+
**pytest-jsonschema** is licensed under the [MIT License](./LICENSE).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{% if sections[""] %}
|
|
2
|
+
{% for category, val in definitions.items() if category in sections[""] %}
|
|
3
|
+
|
|
4
|
+
### {{ definitions[category]['name'] }}
|
|
5
|
+
|
|
6
|
+
{% for text, values in sections[""][category].items() %}
|
|
7
|
+
- {{ text }} {{ values|join(', ') }}
|
|
8
|
+
{% endfor %}
|
|
9
|
+
|
|
10
|
+
{% endfor %}
|
|
11
|
+
{% else %}
|
|
12
|
+
No significant changes.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
{% endif %}
|
|
File without changes
|