Question: Consider the following class definition: class Account(object): Represent a bank account. Argument: account_holder (string): account holder's name. Attributes: holder (string): account holder's name. balance
Consider the following class definition:
class Account(object): """ Represent a bank account. Argument: account_holder (string): account holder's name. Attributes: holder (string): account holder's name. balance (float): account balance in dollars. """ def __init__(self, account_holder): self.holder = account_holder self.balance = 0 def deposit(self, amount): """ Deposit amount to the account Parameter: amount (float): the amount to be deposited in dollars. Returns: the updated account object """ self.balance += amount return self
Our task is to write a unit test for the method deposit using the unittest framework.
We'll assume that the Account class definition is included in the file account.py.
We start with the following in the module testaccount.py:
from account import Account import unittest class TestAccount(unittest.TestCase): """ Test case for the normal execution of Account methods """ def setUp(self): """ Create an account for testing """ self.foothill_account = Account("Footsie the Owl") def test_deposit(self): """ test the deposit method in the Account class""" # Missing code goes here
Which of the following statements are the correct statements to add to the test_deposit method definition?
self.foothill_account.deposit(1000) self.assertEqual(self.foothill_account.balance, 100) self.assertEqual(self.foothill_account.holder, "Footsie the Owl") self.assertIsInstance(self.foothill_account.deposit(100), Account) |
self.foothill_account.deposit(100) self.assertEqual(self.foothill_account.balance, 100) self.assertEqual(self.foothill_account.holder, "Footsie the Owl") self.assertIsInstance(self.foothill_account.deposit(1000), account.Account) |
foothill_account.deposit(100) self.assertEqual(foothill_account.balance, 100) self.assertEqual(foothill_account.holder, "Footsie the Owl") self.assertIsInstance(foothill_account.deposit(1000), account.Account) |
self.foothill_account.deposit(1000) self.assertEqual(self.foothill_account.balance, 1000) self.assertEqual(self.foothill_account.holder, "Footsie the Owl") self.assertIsInstance(self.foothill_account.deposit(100), Account) |
account.foothill_account.deposit(100) self.assertEqual(account.foothill_account.balance, 100) self.assertEqual(account.foothill_account.holder, "Footsie the Owl") self.assertIsInstance(account.foothill_account.deposit(1000), Account) |
self.foothill_account.deposit(1000) assertEqual(self.foothill_account.balance, 1000) assertEqual(self.foothill_account.holder, "Footsie the Owl") assertIsInstance(self.foothill_account.deposit(100), account.Account) |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
