Skip to content

Pytest Plugin⚓︎

pytest_plugin ⚓︎

Pytest integration for talika.

Installing the package registers a talika fixture. The fixture is a small facade around schema classmethods, useful when pytest dependency injection keeps BDD step functions cleaner.

Info

Direct schema parsing remains independent from pytest. This plugin adds convenience only; it does not create a separate table lifecycle.

TalikaParser ⚓︎

TalikaParser()

Convenience facade exposed through the talika fixture.

This facade intentionally delegates to the schema class. It does not own a second parser, registry, or pytest-specific table lifecycle.

Example

def step(datatable, talika):
    users = talika.parse(datatable, schema=UserTable)

parse ⚓︎

parse(
    datatable: RawTable | TableData,
    *,
    schema: type[TableT],
    context: Mapping[str, Any] | ParseContext | None = None,
    error_mode: str = "first",
) -> list[TableT]

Parse a table into validated schema records.

Parameters:

  • datatable (RawTable | TableData) –

    Raw pytest-bdd table or source-aware TableData.

  • schema (type[TableT]) –

    Concrete RowTable or ColumnTable subclass.

  • context (Mapping[str, Any] | ParseContext | None, default: None ) –

    Optional project data or existing parse context.

  • error_mode (str, default: 'first' ) –

    "first" or "collect".

Returns:

  • list[TableT]

    Validated instances of schema.

Raises:

  • ValueError

    If error_mode is unsupported.

  • TableError

    If parsing or validation fails in first-error mode.

  • TableErrors

    If collect mode finds error-severity failures.

Note

Warning-severity validation diagnostics are emitted as TalikaWarning and records are still returned.

Info

This method delegates directly to schema.parse.

parse_as ⚓︎

parse_as(
    datatable: RawTable | TableData,
    output_model: Callable[..., OutputT],
    *,
    schema: type[BaseTable],
    context: Mapping[str, Any] | ParseContext | None = None,
    error_mode: str = "first",
) -> list[OutputT]
parse_as(
    datatable: RawTable | TableData,
    output_model: None = None,
    *,
    schema: type[TableT],
    context: Mapping[str, Any] | ParseContext | None = None,
    error_mode: str = "first",
) -> list[Any]
parse_as(
    datatable: RawTable | TableData,
    output_model: Callable[..., OutputT] | None = None,
    *,
    schema: type[BaseTable],
    context: Mapping[str, Any] | ParseContext | None = None,
    error_mode: str = "first",
) -> list[OutputT] | list[Any]

Parse a table and convert records into public output objects.

Parameters:

  • datatable (RawTable | TableData) –

    Raw pytest-bdd table or source-aware TableData.

  • output_model (Callable[..., OutputT] | None, default: None ) –

    Optional callable receiving parsed record fields as keyword arguments. When omitted, use configured output hooks.

  • schema (type[BaseTable]) –

    Concrete RowTable or ColumnTable subclass.

  • context (Mapping[str, Any] | ParseContext | None, default: None ) –

    Optional project data or existing parse context.

  • error_mode (str, default: 'first' ) –

    "first" or "collect".

Returns:

  • list[OutputT] | list[Any]

    Converted output objects.

Raises:

  • TypeError

    If output_model is not callable.

  • ValueError

    If no explicit or configured conversion exists.

  • TableError

    If parsing, validation, or output construction fails.

  • TableErrors

    If collect mode finds multiple failures.

Note

Warning-severity validation diagnostics are emitted as TalikaWarning and converted objects are still returned.

validate ⚓︎

validate(
    datatable: RawTable | TableData,
    *,
    schema: type[TableT],
    context: Mapping[str, Any] | ParseContext | None = None,
) -> ValidationResult[TableT]

Validate a table without output conversion or raised table errors.

Parameters:

  • datatable (RawTable | TableData) –

    Raw pytest-bdd table or source-aware TableData.

  • schema (type[TableT]) –

    Concrete RowTable or ColumnTable subclass.

  • context (Mapping[str, Any] | ParseContext | None, default: None ) –

    Optional project data or existing parse context.

Returns:

  • ValidationResult[TableT]

    Complete schema records and ordered table diagnostics.

  • ValidationResult[TableT]

    Warning-only results remain valid and retain records.

pytest_bdd_before_step_call ⚓︎

pytest_bdd_before_step_call(
    feature: Any, step: Any, step_func_args: dict[str, object]
) -> None

Bind pytest-bdd feature provenance to the step's raw datatable.

pytest_bdd_after_step ⚓︎

pytest_bdd_after_step(step_func_args: dict[str, object]) -> None

Clear source bindings after a successful pytest-bdd step.

pytest_bdd_step_error ⚓︎

pytest_bdd_step_error(step_func_args: dict[str, object]) -> None

Clear source bindings after a failed pytest-bdd step.

talika ⚓︎

talika() -> TalikaParser

Provide the schema parsing facade to pytest tests.

Returns:

Info

Each fixture instance briefly stores pytest-bdd provenance for the current step, then clears it after success or failure. Instance-local state prevents source bindings from leaking between parallel tests.