python执行脚本时,报Time Elapsed: 0:00:00,大神们这个咋破?
python执行脚本时,报Time Elapsed: 0:00:00,大神们这个咋破
贴下完整的日志,和脚本 qqq911 发表于 2018-4-25 11:20
贴下完整的日志,和脚本
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import requests
import unittest
import json
class LoginAPiTest(unittest.TestCase):
def setUp(self):
print 'start !~~'
def tearDown(self):
print 'end !~~'
def login_verify(self,userName,password):
url = "http://192.168.18.17:3102/user/V1/oper/logn/login.json"
headers = {
'cliv': "1",
'ctype': "1"
}
data={
"userName":userName,
"password":password
}
res = requests.post(url, data=data,headers=headers)
return res.text
def test_login_success(self):
r=self.login_verify("S09208","123qwe")
r1 = json.JSONDecoder().decode(r)
self.assertEqual(r1['code'],1)
def test_login_error_username(self):
r=self.login_verify("1","123qwe")
r1 = json.JSONDecoder().decode(r)
self.assertEqual(r1['code'],2)
if __name__ == '__main__':
unittest.main() qqq911 发表于 2018-4-25 11:20
贴下完整的日志,和脚本
报错就提示这个
C:\Python27\python.exe D:/SMI_Api_project/Run.py
Time Elapsed: 0:00:00
Process finished with exit code 0 qqq911 发表于 2018-4-25 11:20
贴下完整的日志,和脚本
# coding:utf-8
import unittest
import copy
import time
from HTMLTestRunner import HTMLTestRunner
from libs.ShareModules import InsertLog
from libs.ShareModules import GetSkipScripts
from libs.ShareModules import GetSkipTestCases
m = GetSkipScripts()
t = GetSkipTestCases()
def get_test_suite(discover):
#筛选出并去除不需要执行的脚本
suite_m = copy.deepcopy(discover)
for i in range(len(m)):
for j in range(discover._tests.__len__()):
d = discover._tests
if m in str(d):
suite_m._tests.remove(d)
#筛选出并去除不需要执行的用例
suite_c = copy.deepcopy(suite_m)
for i in range(len(t)):
for j in range(suite_m._tests.__len__()):
s_m =suite_m._tests
for z in range(s_m._tests.__len__()):
s_c = s_m._tests
for k in range(s_c._tests.__len__()):
s_t = s_c._tests
if t == s_t._testMethodName:
suite_c._tests._tests._tests.remove(s_t)
return suite_c
if __name__ == '__main__':
try:
dirpath = './scripts'
discover = unittest.defaultTestLoader.discover(dirpath,pattern='*_tc.py')
suite = get_test_suite(discover)
currenttime = time.strftime('%y%m%d%H%M%S ')
filedir = './reports/' + 'report' + currenttime + '.html'
fp = open(filedir,'w')
runner = HTMLTestRunner(stream=fp,title=u'EDU系统后台自动化测试报告',description=u'填写项目描述信息' )
runner.run(suite)
fp.close()
except BaseException as msg:
log = InsertLog()
log.error(msg)
def tearDown(self):
print 'end !~~'
挪到
if __name__ == '__main__':
unittest.main()
上面试试 qqq911 发表于 2018-4-25 12:38
def tearDown(self):
print 'end !~~'
还是一样的报这个 运行时总是忽略把搜帖的标题填入输入框,就只点击搜帖按钮:'( 你真正的用例操作没有以test带头
页:
[1]