"""test_n_plus_one.py""" from __future__ import annotations import pytest pytest.importorskip("sqlalchemy") from n_plus_one import USERS, build, count_statements, main def test_statement_counts() -> None: engine, users, posts = build() user_count, naive, joined = count_statements(engine, users, posts) assert user_count == USERS assert naive == USERS + 1 assert joined == 1 def test_main_runs(capsys: pytest.CaptureFixture[str]) -> None: main() out = capsys.readouterr().out assert "naive_statements: 6" in out assert "joined_statements: 1" in out