PyTest expected exceptions (bank deposit)



examples/pytest/b1/test_bank.py
import pytest
from banks import Bank, NegativeDeposite


def test_negative_deposit():
    b = Bank(10)
    with pytest.raises(Exception) as exinfo:
        b.deposit(-1)
    assert exinfo.type == NegativeDeposite
    assert str(exinfo.value) == 'Cannot deposit negative sum'

pytest test_bank.py

test_bank.py .