pytest_jsonschema_snapshot.core

Core logic of the plugin.

Classes

Module 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[source]
differ: jsonschema_diff.JsonSchemaDiff[source]
callable_regex: str = '{class_method=.}'[source]
format_mode: str = 'on'[source]
update_mode: bool = False[source]
reset_mode: bool = False[source]
update_actions: dict[str, bool][source]
save_original: bool = False[source]
debug_mode: bool = False[source]
snapshot_dir: Path[source]
used_schemas: Set[str][source]
logger[source]
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.