Name | pytest-jsonschema JSON |
Version |
1.0.0a2
JSON |
| download |
home_page | None |
Summary | A pytest plugin to perform JSONSchema validations |
upload_time | 2024-03-27 23:05:22 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | The MIT License (MIT) Copyright (c) 2024 Érico Andrei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
pytest
testing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<h1 align="center">pytest-jsonschema</h1>
<div align="center">
[![PyPI](https://img.shields.io/pypi/v/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)
[![Python Version](https://img.shields.io/pypi/pyversions/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)
[![Wheel](https://img.shields.io/pypi/wheel/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)
[![License](https://img.shields.io/pypi/l/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)
[![Status](https://img.shields.io/pypi/status/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)
[![Tests](https://github.com/collective/pytest-jsonschema/actions/workflows/code.yml/badge.svg)](https://github.com/collective/pytest-jsonschema/actions/workflows/code.yml)
[![Linters](https://github.com/collective/pytest-jsonschema/actions/workflows/lint.yml/badge.svg)](https://github.com/collective/pytest-jsonschema/actions/workflows/lint.yml)
![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)
[![Contributors](https://img.shields.io/github/contributors/collective/pytest-jsonschema)](https://github.com/collective/pytest-jsonschema/graphs/contributors)
[![Stars](https://img.shields.io/github/stars/collective/pytest-jsonschema?style=social)](https://github.com/collective/pytest-jsonschema/stargazers)
</div>
**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.
## Installation
Install **pytest-jsonschema** using pip from PyPI:
```bash
pip install pytest-jsonschema
```
## Features & Usage
The package introduces three pytest fixtures for validating JSON data:
### `schema_validate_file`
Validates a JSON file located in your test suite directory:
```python
from pathlib import Path
def test_package_json_is_valid(schema_validate_file):
path = Path("package.json")
assert schema_validate_file(path=path, schema_name="package")
```
### `schema_validate_string`
Validates a JSON string:
```python
from pathlib import Path
def test_package_json_is_valid(schema_validate_string):
data = Path("package.json").read_text()
assert schema_validate_string(data=data, schema_name="package", file_type="json")
```
### `schema_validate`
Validates a Python dictionary representing JSON data:
```python
import json
from pathlib import Path
def test_package_json_is_valid(schema_validate):
data = json.loads(Path("package.json").read_text())
assert schema_validate(data=data, schema_name="package")
```
## Requirements
- pytest >= 6.2.0
## Contributing
To contribute to **pytest-jsonschema**, please follow these steps:
1. Clone the repository:
```bash
git clone git@github.com:collective/pytest-jsonschema.git
```
2. Install the package for development:
```bash
make install
```
3. Format the codebase:
```bash
make format
```
4. Run tests:
- To run all tests:
```
make test
```
- To stop on the first error and open a pdb session:
```
make debug-test
```
Testing is conducted using [`pytest`](https://docs.pytest.org/en/stable/) and [`tox`](https://tox.readthedocs.io/en/latest/).
## License 📜
**pytest-jsonschema** is licensed under the [MIT License](./LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-jsonschema",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "\u00c9rico Andrei <ericof@plone.org>",
"keywords": "pytest, testing",
"author": null,
"author_email": "\u00c9rico Andrei <ericof@plone.org>",
"download_url": "https://files.pythonhosted.org/packages/15/66/29cb1ab714d33473415aa6232db1468b89c0623732beb26589bc6d75603e/pytest-jsonschema-1.0.0a2.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">pytest-jsonschema</h1>\n\n<div align=\"center\">\n\n[![PyPI](https://img.shields.io/pypi/v/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)\n[![Python Version](https://img.shields.io/pypi/pyversions/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)\n[![Wheel](https://img.shields.io/pypi/wheel/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)\n[![License](https://img.shields.io/pypi/l/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)\n[![Status](https://img.shields.io/pypi/status/pytest-jsonschema)](https://pypi.org/project/pytest-jsonschema/)\n[![Tests](https://github.com/collective/pytest-jsonschema/actions/workflows/code.yml/badge.svg)](https://github.com/collective/pytest-jsonschema/actions/workflows/code.yml)\n[![Linters](https://github.com/collective/pytest-jsonschema/actions/workflows/lint.yml/badge.svg)](https://github.com/collective/pytest-jsonschema/actions/workflows/lint.yml)\n![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)\n[![Contributors](https://img.shields.io/github/contributors/collective/pytest-jsonschema)](https://github.com/collective/pytest-jsonschema/graphs/contributors)\n[![Stars](https://img.shields.io/github/stars/collective/pytest-jsonschema?style=social)](https://github.com/collective/pytest-jsonschema/stargazers)\n\n</div>\n\n**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.\n\n## Installation\n\nInstall **pytest-jsonschema** using pip from PyPI:\n\n```bash\npip install pytest-jsonschema\n```\n\n## Features & Usage\n\nThe package introduces three pytest fixtures for validating JSON data:\n\n### `schema_validate_file`\n\nValidates a JSON file located in your test suite directory:\n\n```python\nfrom pathlib import Path\n\ndef test_package_json_is_valid(schema_validate_file):\n path = Path(\"package.json\")\n assert schema_validate_file(path=path, schema_name=\"package\")\n```\n\n### `schema_validate_string`\n\nValidates a JSON string:\n\n```python\nfrom pathlib import Path\n\ndef test_package_json_is_valid(schema_validate_string):\n data = Path(\"package.json\").read_text()\n assert schema_validate_string(data=data, schema_name=\"package\", file_type=\"json\")\n```\n\n### `schema_validate`\n\nValidates a Python dictionary representing JSON data:\n\n```python\nimport json\nfrom pathlib import Path\n\ndef test_package_json_is_valid(schema_validate):\n data = json.loads(Path(\"package.json\").read_text())\n assert schema_validate(data=data, schema_name=\"package\")\n```\n\n## Requirements\n\n- pytest >= 6.2.0\n\n## Contributing\n\nTo contribute to **pytest-jsonschema**, please follow these steps:\n\n1. Clone the repository:\n\n```bash\ngit clone git@github.com:collective/pytest-jsonschema.git\n```\n\n2. Install the package for development:\n\n```bash\nmake install\n```\n\n3. Format the codebase:\n\n```bash\nmake format\n```\n\n4. Run tests:\n- To run all tests:\n ```\n make test\n ```\n- To stop on the first error and open a pdb session:\n ```\n make debug-test\n ```\n\nTesting is conducted using [`pytest`](https://docs.pytest.org/en/stable/) and [`tox`](https://tox.readthedocs.io/en/latest/).\n\n## License \ud83d\udcdc\n\n**pytest-jsonschema** is licensed under the [MIT License](./LICENSE).\n",
"bugtrack_url": null,
"license": " The MIT License (MIT) Copyright (c) 2024 \u00c9rico Andrei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A pytest plugin to perform JSONSchema validations",
"version": "1.0.0a2",
"project_urls": {
"Repository": "https://github.com/collective/pytest-jsonschema"
},
"split_keywords": [
"pytest",
" testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cafe1b417a16d396c6b4272f8d3c853e840befc429a54e3ea80316c50d2f93ef",
"md5": "e08bf8ce0cb3615bbb11925ff689162c",
"sha256": "0140f0973b137d18a0e0527ba5be4bf811fad640388289d7d8a511a613b32bc3"
},
"downloads": -1,
"filename": "pytest_jsonschema-1.0.0a2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e08bf8ce0cb3615bbb11925ff689162c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 84255,
"upload_time": "2024-03-27T23:05:20",
"upload_time_iso_8601": "2024-03-27T23:05:20.737686Z",
"url": "https://files.pythonhosted.org/packages/ca/fe/1b417a16d396c6b4272f8d3c853e840befc429a54e3ea80316c50d2f93ef/pytest_jsonschema-1.0.0a2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "156629cb1ab714d33473415aa6232db1468b89c0623732beb26589bc6d75603e",
"md5": "0a5669d581c5fe53523b6a4bd5668647",
"sha256": "9d6e595921fc4bc42fdcb3d255c7fbad03d425ab85612ad7c6d86e4fca29f3bb"
},
"downloads": -1,
"filename": "pytest-jsonschema-1.0.0a2.tar.gz",
"has_sig": false,
"md5_digest": "0a5669d581c5fe53523b6a4bd5668647",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 88197,
"upload_time": "2024-03-27T23:05:22",
"upload_time_iso_8601": "2024-03-27T23:05:22.888119Z",
"url": "https://files.pythonhosted.org/packages/15/66/29cb1ab714d33473415aa6232db1468b89c0623732beb26589bc6d75603e/pytest-jsonschema-1.0.0a2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 23:05:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "collective",
"github_project": "pytest-jsonschema",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-jsonschema"
}