class TestTransfer(unittest.TestCase): user1 = None user2 = None bank = None def setUp(self) -> None: self.user1 = User() self.user2 = User() self.bank = Bank() def test_transfer1(self): # 1.准备数据 self.user1.setAccount("qqq666") self.user2.setAccount("jen666") self.user1.setPassword("123456") self.bank.setMoney(666) # 2.预期结果 teststart = 0 # 3.调用被测方法 start = self.bank.bank_transfer(self.user1.getAccount(), self.user2.getAccount(), self.user1.getPassword(), self.bank.getMoney()) # 4.断言 self.assertEqual(teststart, start)
def transfer(): account1 = Utils.inputHelp("转出的账号") account2 = Utils.inputHelp("要转入的账号") password = Utils.inputHelp("您转出账号的密码") money = Utils.inputHelp("您要转出的金额") start = Bank.bank_transfer(account1,account2,password,money) if start == 0: print("转账成功!") if start == 1: print("您输入的账号不正确!") if start == 2: print("您输入的密码不正确!") if start == 3: print("您的账户余额不足!")