def test_bank_account_overdraw_fails(self): account = _create_account() outcome = _overdraw(account) self._assert_withdraw_failed( outcome, account)
def _create_account(): settings = BankSettings(...) return Account(settings, BALANCE, ...)
def _overdraw(account): # Boilerplate code ...
return account.Withdraw(BALANCE + 1)
def _assert_withdraw_failed( self, outcome, account): self.assertEqual(outcome, FAILED) self.assertEqual( account.GetBalance(), BALANCE) | def test_bank_account_overdraw_fails(self): account = _create_account(BALANCE) outcome = _withdraw(account, BALANCE + 1) self.assertEqual(outcome, FAILED) self.assertEqual( account.GetBalance(), BALANCE)
def _create_account(balance): settings = BankSettings(...) return Account(settings, balance, ...)
def _withdraw(account, amount): # Boilerplate code ...
return account.Withdraw(amount) |