class TestAddUser(unittest.TestCase): user = None address = None bank = None def setUp(self) -> None: self.user = User() self.address = Address() self.bank = Bank() def test_adduser1(self): # 1.准备测试数据 self.user.setAccount("plplpl") self.user.setPassword("123456") self.user.setUsername("q999") self.address.setCounrry("中国") self.address.setProvince("北京") self.address.setStreet("人民路") self.address.setDoor("666") # 2. 预期结果 teststart = 1 # 3.调用被测方法 start = self.bank.bank_addUser(self.user.getAccount(), self.user.getUsername(), self.user.getPassword(), self.address.getCounrry(), self.address.getProvicne(), self.address.getStreet(), self.address.getDoor()) # 4.断言 self.assertEqual(teststart, start)
def addUser(): # 随机生成账号 account = Utils.getRandom() User.setUsername(Utils.inputHelp("用户名")) User.setPassword(Utils.inputHelp("密码")) Address.setCounrry(Utils.inputHelp("国家")) Address.setProvince(Utils.inputHelp("省份")) Address.setStreet(Utils.inputHelp("街道")) Address.setDoor(Utils.inputHelp("门牌号")) # username = input("请输入您的姓名:") # password = input("请输入您的密码(6个数字):") # print("接下来请输入您的地址信息") # counrry = input("\t请输入您的国家:") # province = input("\t请输入省份:") # street = input("\t请输入街道:") # door = input("\t请输入门牌号:") # 余额不允许第一次输入,需要存钱 start = Bank.bank_addUser(account,User.getUsername(),User.getPassword(),Address.getCounrry(),Address.getProvicne(),Address.getStreet(),Address.getDoor()) if start == 1: print("开户成功!") info = ''' ----------- 个人信息------------- 账号: %s, 用户名: %s, 取款密码: %s, 地址信息: 国家: %s, 省份: %s, 街道: %s, 门牌号: %s, 余额: %s, 开户行: %s --------------------------------- ''' print(info % (account,User.getUsername(),User.getPassword(),Address.getCounrry(),Address.getProvicne(),Address.getStreet(),Address.getDoor(),0,Bank.getBankName())) if start == 2: print("该用户名已经存在!!!") if start == 3: print("银行用户库已满!!!")