コード例 #1
0
ファイル: cases.py プロジェクト: Amyli0601/python
 def test_register(self):
     '''注册模块的用例'''
     # 预期结果
     excepted = self.excepted
     # 入参参数data
     data = self.data
     # 执行功能函数,获取实际结果
     res = register_check(*data)
     try:
         # 对比预期结果和实际结果
         self.assertEqual(excepted, res)
     except AssertionError as a:
         print('测试用例不通过')
         print('预期结果:{}'.format(excepted))
         print('实际结果:{}'.format(res))
         raise a
     else:
         print('测试用例通过')
         print('预期结果:{}'.format(excepted))
         print('实际结果:{}'.format(res))
コード例 #2
0
 def test_password_outlen6(self):
     '''密码小于6位的用例'''
     # 入参
     username = '******'
     pwd1 = '1234'
     pwd2 = '1234'
     # 预期结果
     excepted01 = {"code": 0, "msg": "账号和密码必须在6-18位之间"}
     # 执行功能函数,获取实际结果
     user = register_check(username, pwd1, pwd2)
     try:
         # 对比预期结果和实际结果
         self.assertEqual(excepted01, user)
     except AssertionError as a:
         print('测试用例不通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
         raise a
     else:
         print('测试用例通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
コード例 #3
0
 def test_password_different(self):
     '''密码不一致的测试用例'''
     # 入参
     username = '******'
     pwd1 = '123456a'
     pwd2 = '123456'
     # 预期结果
     excepted01 = {"code": 0, "msg": "两次密码不一致"}
     # 执行功能函数,获取实际结果
     user = register_check(username, pwd1, pwd2)
     try:
         # 对比预期结果和实际结果
         self.assertEqual(excepted01, user)
     except AssertionError as a:
         print('测试用例不通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
         raise a
     else:
         print('测试用例通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
コード例 #4
0
 def test_register_failed(self):
     '''账号已存在的测试用例'''
     # 入参
     username = '******'
     pwd1 = '123456a'
     pwd2 = '123456a'
     # 预期结果
     excepted01 = {"code": 0, "msg": "该账户已存在"}
     # 执行功能函数,获取实际结果
     user = register_check(username, pwd1, pwd2)
     try:
         # 对比预期结果和实际结果
         self.assertEqual(excepted01, user)
     except AssertionError as a:
         print('测试用例不通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
         raise a
     else:
         print('测试用例通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
コード例 #5
0
 def test_register_pass(self):
     '''注册成功的用例'''
     # 入参
     username = '******'
     pwd1 = '123456a'
     pwd2 = '123456a'
     # 预期结果
     excepted01 = {"code": 1, "msg": "注册成功"}
     # 执行功能函数,获取实际结果
     user = register_check(username, pwd1, pwd2)
     try:
         # 对比预期结果和实际结果
         self.assertEqual(excepted01, user)
     except AssertionError as a:
         print('测试用例不通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
         raise a
     else:
         print('测试用例通过')
         print('预期结果:{}'.format(excepted01))
         print('实际结果:{}'.format(user))
コード例 #6
0
ファイル: testcases.py プロジェクト: Amyli0601/python
 def test_register(self, case):
     #     '''注册模块的用例'''
     # 预期结果
     excepted = eval(case.excepted)
     # print(excepted)
     # 入参参数data
     data = eval(case.data)
     # print(data)
     # 执行功能函数,获取实际结果
     res = register_check(*data)
     try:
         # 对比预期结果和实际结果
         self.assertEqual(excepted, res)
     except AssertionError as error:
         print('测试用例不通过')
         self.excel.write_data(case.case_id + 1, 4, 'failed')
         print('预期结果:{}'.format(excepted))
         print('实际结果:{}'.format(res))
         raise error
     else:
         print('测试用例通过')
         self.excel.write_data(case.case_id + 1, 4, 'passed')
         print('预期结果:{}'.format(excepted))
         print('实际结果:{}'.format(res))