Skip to main content

Pytest plugin for automatic JSON Schema generation and validation from examples

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

pytest: Typed Schema Shot

PyPI - Python Version PyPI - Package Version PyPI - Downloads Discord Telegram

Plugin for pytest that automatically generates JSON Schemas based on data examples and validates data against saved schemas.

Плагин для pytest, который автоматически генерирует JSON Schema на основе примеров данных и проверяет данные по сохраненным схемам.

Features

  • Automatic JSON Schema generation from data examples (using the genson library).

    Автоматическая генерация JSON Schema по примерам данных (на основе библиотеки genson).

  • Schema storage and management.

    Хранение и управление схемами.

  • Validation of data against saved schemas.

    Валидация данных по сохраненным схемам.

  • Schema update via --schema-update (create new schemas, remove unused ones, update existing).

    Обновление схем через --schema-update (создание новых, удаление неиспользуемых, обновление существующих).

  • Support for both async and synchronous functions.

    Поддержка асинхронных (async) и синхронных функций.

  • Support for Union types and optional fields.

    Поддержка Union типов и опциональных полей.

Installation

pip install pytest-typed-schema-shot

Usage

  1. Use the schemashot fixture in your tests

    В тестах используйте фикстуру schemashot:

    from typed_schema_shot import SchemaShot
    
    @pytest.mark.asyncio
    async def test_something(schemashot: SchemaShot):
        data = await API.data()
        schemashot.assert_match(data, "data")
    
  2. On first run, generate schemas with the --schema-update flag

    При первом запуске создайте схемы --schema-update:

    pytest --schema-update
    
  3. On subsequent runs, tests will validate data against saved schemas

    В последующих запусках тесты будут проверять данные по сохраненным схемам:

    pytest
    

Key Capabilities

  • Union Types: support multiple possible types for fields

    Поддержка множественных типов полей.

  • Optional Fields: automatic detection of required and optional fields

    Автоматическое определение обязательных и необязательных полей.

  • Cleanup: automatic removal of unused schemas when running in update mode

    Автоматическое удаление неиспользуемых схем в режиме обновления.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_typed_schema_shot-0.1.2.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_typed_schema_shot-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_typed_schema_shot-0.1.2.tar.gz.

File metadata

  • Download URL: pytest_typed_schema_shot-0.1.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_typed_schema_shot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f7106a4eccedd061c8094959134d0ebb31bd45cb53fd0439823877d46de2f33a
MD5 60a7da530ee05f01aca99f43e1948296
BLAKE2b-256 11f834690e3e2d2507d5482d341c04219b04793800bdbabef12797c434cb9447

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_typed_schema_shot-0.1.2.tar.gz:

Publisher: python-publish.yml on Open-Inflation/pytest-typed-schema-shot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_typed_schema_shot-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_typed_schema_shot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1225b85be7d36240b5b99565655f1a35509ac71543f74e3aa9b2cacde8c34518
MD5 a177a546e82d71e1c20bc7dc97e1aa6b
BLAKE2b-256 20c361ad7a31a932f2e5cceb84f82e1fe6a61b35076283183f3d6015dc12bbde

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_typed_schema_shot-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on Open-Inflation/pytest-typed-schema-shot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page