pytest_jsonschema_snapshot

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

Submodules

Classes

Package Contents

class SchemaShot(
root_dir: Path,
differ: jsonschema_diff.JsonSchemaDiff,
callable_regex: str = '{class_method=.}',
format_mode: str = 'on',
update_mode: bool = False,
reset_mode: bool = False,
update_actions: dict[str, bool] = {},
save_original: bool = False,
debug_mode: bool = False,
snapshot_dir_name: str = '__snapshots__',
)[source]
root_dir: Path
differ: jsonschema_diff.JsonSchemaDiff
callable_regex: str = '{class_method=.}'
format_mode: str = 'on'
update_mode: bool = False
reset_mode: bool = False
update_actions: dict[str, bool]
save_original: bool = False
debug_mode: bool = False
snapshot_dir: Path
used_schemas: Set[str]
logger
assert_json_match(
data: dict,
name: str | int | Callable | list[str | int | Callable],
) bool | None[source]

Asserts for JSON, converts it to schema and then compares.

Returns:

True – the schema has been updated, False – the schema has not changed, None – a new schema has been created.

assert_schema_match(
schema: dict[str, Any],
name: str | int | Callable | list[str | int | Callable],
*,
data: dict | None = None,
) bool | None[source]

Accepts a JSON-schema directly and compares it immediately.

Returns:

True – the schema has been updated, False – the schema has not changed, None – a new schema has been created.