示例工程 26-debugging-diagnostics

26-debugging-diagnostics/02-pdb-walkthrough/test_pdb_walkthrough.py

python · 0.5 KB

"""test_pdb_walkthrough.py"""
 
from __future__ import annotations
 
import pytest
from pdb_walkthrough import add, main, scripted
 
 
def test_add() -> None:
    assert add(2, 3) == 5
 
 
def test_scripted_session() -> None:
    text = scripted()
    assert "(Pdb)" in text
    assert "total = left + right" in text
    assert "5" in text
 
 
def test_main_runs(capsys: pytest.CaptureFixture[str]) -> None:
    main()
    out = capsys.readouterr().out
    assert "printed_total: True" in out