Skip to main content

testing.assert_engines_agree()

Assert that every engine gives the same rows for a node on data.

Usage

Source

testing.assert_engines_agree(
    node,
    data,
    *,
    engines=None,
)

The rows are compared as bags (doubles to 12 significant digits). The data must meet the node’s preconditions: outside them the engines may rightly disagree. Each output is also checked against the node’s postconditions.

Parameters

node: Node

A node: a source or node piped into contracted transforms.

data: Mapping[str, Rows]

The rows of each table the node reads, by name (see assert_contract).

engines: Sequence[str] | None = None
The engines to compare. Default: installed_engines().

Returns

pa.Table
The first engine’s output.

Raises

AssertionError

The data violates a precondition, an engine fails or violates a postcondition, or two engines give different rows (the message lists the rows that differ from the first engine’s).

ValueError
Fewer than two engines, or data does not match the tables the node reads.

Examples

With doubled and orders from assert_contract’s example:

from sverify.testing import assert_engines_agree

assert_engines_agree(orders.pipe(doubled), {"orders": [(1, 30), (2, 7)]})