Skip to content

SQL Tests API

smallex.sqltests

SQL test file parsing utilities.

SQLTestCase dataclass

A single executable SQL expectation parsed from test files.

Attributes:

Name Type Description
path Path

Source SQL file path.

name str

Human-readable test name.

message str | None

Optional failure message authored by the developer.

query str

SQL query text to execute.

node_id: str property

Return pytest-like node id for terminal reporting.

parse_sql_file(path: Path) -> list[SQLTestCase]

Parse one SQL file into one or more test cases.

Marker semantics
  • test starts a new logical test block when encountered after SQL.
  • message attaches to the next finalized test block.
  • files without markers split into one test per SQL statement.

Parameters:

Name Type Description Default
path Path

SQL file to parse.

required

Returns:

Type Description
list[SQLTestCase]

list[SQLTestCase]: Parsed SQL test cases in file order.

parse_sql_files(paths: Iterable[Path]) -> list[SQLTestCase]

Parse multiple SQL files into a flat list of SQL test cases.