示例#1
0
def empty_wallet():
    """
    Returns a Wallet instance with a zero balance
    """
    return Wallet()
示例#2
0
def wallet_wealthy():
    """
    Returns a Wallet instance with a balance of 20
    """
    return Wallet(1000000)
示例#3
0
def wallet():
    """
    Returns a Wallet instance with a balance of 20
    """
    return Wallet(20)
示例#4
0
def test_transactions(empty_wallet: Wallet, earned: float, spent: float,
                      expected: float) -> None:
    empty_wallet.add_cash(earned)
    empty_wallet.spend_cash(spent)
    assert empty_wallet.balance == expected
示例#5
0
def test_wallet_spend_cash_raises_exception_on_insufficient_amount(
        wallet: Wallet) -> None:
    with pytest.raises(InsufficientAmountException):
        wallet.spend_cash(100)
示例#6
0
def test_wallet_spend_cash(wallet: Wallet) -> None:
    wallet.spend_cash(10)
    assert wallet.balance == 10
示例#7
0
def test_wallet_add_cash(wallet: Wallet) -> None:
    wallet.add_cash(80)
    assert wallet.balance == 100