PyTest expected exceptions (bank deposit) - different exception is raised
examples/pytest/b3/banks.py
class NegativeDeposite(Exception): pass class Bank: def __init__(self, start): self.balance = start def deposit(self, money): if money < 0: raise ValueError('Cannot deposit negative sum') self.balance += money return
examples/pytest/b3/error.txt
def test_negative_deposit(): b = Bank(10) with pytest.raises(Exception) as exinfo: b.deposit(-1) > assert exinfo.type == NegativeDeposite E AssertionError: assert <class 'ValueError'> == NegativeDeposite E + where <class 'ValueError'> = <ExceptionInfo ValueError tblen=2>.type