-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexer10.py
More file actions
35 lines (26 loc) · 1.12 KB
/
exer10.py
File metadata and controls
35 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unittest
from exer7 import BankAccount, StudentAccount
class TestBankAccount(unittest.TestCase):
def setUp(self):
self.account = BankAccount("Test Test", "1000000", 1000)
def test_deposit(self):
self.account.deposit(500)
self.assertEqual(self.account.balance, 1500)
def test_withdraw(self):
self.account.withdraw(500)
self.assertEqual(self.account.balance, 500)
self.account.withdraw(1000) # check overdraft limit
self.assertEqual(self.account.balance, 500)
class TestStudentAccount(unittest.TestCase):
def setUp(self):
self.account = StudentAccount("Stud Stud", "2000000", 1000)
def test_deposit(self):
self.account.deposit(500)
self.assertEqual(self.account.balance, 1500)
def test_withdraw(self):
self.account.withdraw(500)
self.assertEqual(self.account.balance, 500)
self.account.withdraw(1000) # check overdraft limit
self.assertEqual(self.account.balance, 500)
if __name__ == '__main__':
unittest.main()