Commit fa3e2fbe5253a83093f06ae3f4adab77f5004c28

Authored by 175930106
Committed by liujiqiang
1 parent 4249d2d7

优化了邮件的代码,让to的语句可以接受列表形式的信息

src/commons/SendEmail.py
... ... @@ -30,10 +30,10 @@ def send_email(send_file,send_to=["lixi@diligrp.com"]):
30 30  
31 31 log_path=os.path.dirname(os.path.dirname(__file__))
32 32 log_path=log_path+"/report/test.log"
  33 + send_msg=(",".join(str(i) for i in send_to))
33 34 msg = MIMEMultipart() # 混合MIME格式
34 35 msg['From'] = 'autotest@diligrp.com' # 发件人
35   -# msg['To'] = 'lixi@diligrp.com' # 收件人
36   - msg['To'] = send_to[0] # 收件人
  36 + msg['To'] = send_msg # 收件人
37 37 msg['Subject'] = Header('接口测试报告', 'utf-8') # 中文邮件主题,指定utf-8编码
38 38  
39 39 text = MIMEText('this is a test email', 'plain', 'utf-8')
... ... @@ -54,7 +54,7 @@ def send_email(send_file,send_to=["lixi@diligrp.com"]):
54 54 try:
55 55 smtp = smtplib.SMTP_SSL('smtp.exmail.qq.com') # smtp服务器地址 使用SSL模式
56 56 re=smtp.login('autotest@diligrp.com', 'MvkuGGCfMtAdbJvE') # 用户名和密码
57   - smtp.sendmail("autotest@diligrp.com", send_to[0], msg.as_string())
  57 + smtp.sendmail("autotest@diligrp.com", send_to, msg.as_string())
58 58 print(re)
59 59 except Exception as e:
60 60 log.error(str(e))
... ...
src/commons/__pycache__/SendEmail.cpython-36.pyc
No preview for this file type
src/config/global_data.conf
... ... @@ -11,8 +11,8 @@ user02=87
11 11 user03=256
12 12  
13 13 [email]
14   -list=["tg@diligrp.com"]
15   -list1=["lixi@diligrp.com"]
  14 +list=["lixi@diligrp.com","175930106@qq.com"]
  15 +list11=["tg@diligrp.com","175930106@qq.com"]
16 16  
17 17 [mark]
18 18 list=["test"]
... ...
src/main.py
... ... @@ -33,8 +33,8 @@ def Run_Testcase(testsuit):
33 33  
34 34 runner=HTMLTestRunner_cn.HTMLTestRunner(
35 35 stream=fp,
36   - title=u'溯源重构项目接口测试报告',
37   - description=u'用例执行情况:',
  36 + title=u'重构项目接口测试报告',
  37 + description=u'用例简要执行情况如下:(注:报告详细信息需要下载report.html并用浏览器打开)',
38 38 verbosity = 2)
39 39 #执行用例
40 40 runner.run(testsuit)
... ...
src/report/2021-07-13 16_57_11_result.html renamed to src/report/2021-07-13 17_43_09_result.html
... ... @@ -2,7 +2,7 @@
2 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 3 <html xmlns="http://www.w3.org/1999/xhtml">
4 4 <head>
5   - <title>溯源重构项目接口测试报告</title>
  5 + <title>重构项目接口测试报告</title>
6 6 <meta name="generator" content="HTMLTestRunner 0.8.3"/>
7 7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
8 8  
... ... @@ -419,12 +419,12 @@ function hide_img(obj){
419 419 }
420 420 </script>
421 421 <div class='heading'>
422   -<h1>溯源重构项目接口测试报告</h1>
423   -<p class='attribute'><strong>开始时间:</strong> 2021-07-13 16:57:11</p>
424   -<p class='attribute'><strong>耗时:</strong> 0:00:02.935576</p>
425   -<p class='attribute'><strong>状态:</strong> <span class="tj passCase">Pass</span>:1 <span class="tj skipCase">Skip</span>:19 <span class="tj">通过率</span>:100.0%</p>
  422 +<h1>重构项目接口测试报告</h1>
  423 +<p class='attribute'><strong>开始时间:</strong> 2021-07-13 17:43:09</p>
  424 +<p class='attribute'><strong>耗时:</strong> 0:00:07.141812</p>
  425 +<p class='attribute'><strong>状态:</strong> <span class="tj errorCase">Error</span>:1 <span class="tj skipCase">Skip</span>:19 <span class="tj">通过率</span>:0.0%</p>
426 426  
427   -<p class='description'>用例执行情况:</p>
  427 +<p class='description'>用例简要执行情况如下:(注:报告详细信息需要下载report.html并用浏览器打开)</p>
428 428 </div>
429 429  
430 430  
... ... @@ -435,10 +435,10 @@ function hide_img(obj){
435 435 </div>
436 436  
437 437 <div id='show_detail_line' style=" float: left; width: 100%;">
438   -<a class="abstract detail_button" href='javascript:showCase(0,1)'>概要[100.00%]</a>
439   -<a class="passed detail_button" href='javascript:showCase(1,1)'>通过[1]</a>
  438 +<a class="abstract detail_button" href='javascript:showCase(0,1)'>概要[0.00%]</a>
  439 +<a class="passed detail_button" href='javascript:showCase(1,1)'>通过[0]</a>
440 440 <a class="failed detail_button" href='javascript:showCase(2,1)'>失败[0]</a>
441   -<a class="errored detail_button" href='javascript:showCase(3,1)'>错误[0]</a>
  441 +<a class="errored detail_button" href='javascript:showCase(3,1)'>错误[1]</a>
442 442 <a class="skiped detail_button" href='javascript:showCase(4,1)'>跳过[19]</a>
443 443 <a class="all detail_button" href='javascript:showCase(5,1)'>所有[1]</a>
444 444 </div>
... ... @@ -463,33 +463,83 @@ function hide_img(obj){
463 463 <th>错误截图</th>
464 464 </tr>
465 465  
466   -<tr class='passClass'>
  466 +<tr class='errorClass'>
467 467 <td>doAdd.test_doAdd.test_doAdd: 新增登记接口</td>
468 468 <td>1</td>
469   - <td>1</td>
470 469 <td>0</td>
471 470 <td>0</td>
  471 + <td>1</td>
472 472 <td><a href="javascript:showClassDetail('c1.1',1)">详情</a></td>
473 473 <td>&nbsp;</td>
474 474 </tr>
475 475  
476   -<tr id='pt1.1.1' class='hiddenRow'>
  476 +<tr id='et1.1.1' class='none'>
477 477 <td ><div class='testcase'>test_doAdd_01: 成功新增一个商品为大白菜的报备单,重量为111</div></td>
478 478 <td colspan='5' align='center'>
479 479  
480 480 <!--css div popup start-->
481   - <span class='status passCase'>
482   - <a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.1.1')" >
483   - 通过</a></span>
  481 + <span class='status errorCase'>
  482 + <a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_et1.1.1')" >
  483 + 错误</a></span>
484 484  
485   - <div id='div_pt1.1.1' class="popup_window">
  485 + <div id='div_et1.1.1' class="popup_window">
486 486 <div style='text-align: right; color:red;cursor:pointer'>
487   - <a onfocus='this.blur();' onclick="document.getElementById('div_pt1.1.1').style.display = 'none' " >
  487 + <a onfocus='this.blur();' onclick="document.getElementById('div_et1.1.1').style.display = 'none' " >
488 488 [x]</a>
489 489 </div>
490 490 <pre>
491 491  
492   -pt1.1.1: {'code': '200', 'message': 'OK', 'result': 'OK', 'success': True}
  492 +et1.1.1: Traceback (most recent call last):
  493 + File "C:\Python367\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
  494 + six.raise_from(e, None)
  495 + File "&lt;string&gt;", line 3, in raise_from
  496 + File "C:\Python367\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
  497 + httplib_response = conn.getresponse()
  498 + File "C:\Python367\lib\http\client.py", line 1331, in getresponse
  499 + response.begin()
  500 + File "C:\Python367\lib\http\client.py", line 297, in begin
  501 + version, status, reason = self._read_status()
  502 + File "C:\Python367\lib\http\client.py", line 258, in _read_status
  503 + line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  504 + File "C:\Python367\lib\socket.py", line 586, in readinto
  505 + return self._sock.recv_into(b)
  506 +socket.timeout: timed out
  507 +
  508 +During handling of the above exception, another exception occurred:
  509 +
  510 +Traceback (most recent call last):
  511 + File "C:\Python367\lib\site-packages\requests\adapters.py", line 449, in send
  512 + timeout=timeout
  513 + File "C:\Python367\lib\site-packages\urllib3\connectionpool.py", line 720, in urlopen
  514 + method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  515 + File "C:\Python367\lib\site-packages\urllib3\util\retry.py", line 400, in increment
  516 + raise six.reraise(type(error), error, _stacktrace)
  517 + File "C:\Python367\lib\site-packages\urllib3\packages\six.py", line 735, in reraise
  518 + raise value
  519 + File "C:\Python367\lib\site-packages\urllib3\connectionpool.py", line 672, in urlopen
  520 + chunked=chunked,
  521 + File "C:\Python367\lib\site-packages\urllib3\connectionpool.py", line 423, in _make_request
  522 + self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  523 + File "C:\Python367\lib\site-packages\urllib3\connectionpool.py", line 331, in _raise_timeout
  524 + self, url, "Read timed out. (read timeout=%s)" % timeout_value
  525 +urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='test.trace.diligrp.com', port=8393): Read timed out. (read timeout=5)
  526 +
  527 +During handling of the above exception, another exception occurred:
  528 +
  529 +Traceback (most recent call last):
  530 + File "E:\EclipseWorkspace\WorksapceDemo\Request-demo-dili\src\testcase\doAdd\test_doAdd.py", line 26, in test_doAdd_01
  531 + re=my.post(url=do.url,headers=do.header,json=do.body)
  532 + File "E:\EclipseWorkspace\WorksapceDemo\Request-demo-dili\src\commons\MySession.py", line 100, in post
  533 + re=self.se.post(url, data=data, json=json,proxies=self.proxies, **kwargs,timeout=self.timeout)
  534 + File "C:\Python367\lib\site-packages\requests\sessions.py", line 590, in post
  535 + return self.request('POST', url, data=data, json=json, **kwargs)
  536 + File "C:\Python367\lib\site-packages\requests\sessions.py", line 542, in request
  537 + resp = self.send(prep, **send_kwargs)
  538 + File "C:\Python367\lib\site-packages\requests\sessions.py", line 655, in send
  539 + r = adapter.send(request, **kwargs)
  540 + File "C:\Python367\lib\site-packages\requests\adapters.py", line 529, in send
  541 + raise ReadTimeout(e, request=request)
  542 +requests.exceptions.ReadTimeout: HTTPConnectionPool(host='test.trace.diligrp.com', port=8393): Read timed out. (read timeout=5)
493 543  
494 544  
495 545 </pre>
... ... @@ -1057,16 +1107,16 @@ st1.7.2: mark_skip
1057 1107 <tr id='total_row'>
1058 1108 <th>统计</th>
1059 1109 <th>1</th>
1060   - <th>1</th>
1061 1110 <th>0</th>
1062 1111 <th>0</th>
  1112 + <th>1</th>
1063 1113 <th>&nbsp;</th>
1064 1114 <th>&nbsp;</th>
1065 1115 </tr>
1066 1116 </table>
1067 1117 <script>
1068 1118 showCase(0,1);
1069   - drawCircle('circle1',1, 0, 0);
  1119 + drawCircle('circle1',0, 0, 1);
1070 1120 </script>
1071 1121  
1072 1122 <div id='ending'>&nbsp;</div>
... ...
src/report/test.log
1   -[2021-07-13 16:57:11] [INFO] : ======================================================================================
2   -[2021-07-13 16:57:11] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
  1 +[2021-07-13 17:43:09] [INFO] : ======================================================================================
  2 +[2021-07-13 17:43:09] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
3 3 None
4 4 {'moduleType': '1', 'marketId': '8', 'fieldConfigDetailList': [{'fieldName': 'unitPrice', 'jsonPath': '$.unitPrice', 'defaultId': '3', 'displayed': '1', 'required': '0'}, {'fieldName': 'arrivalTallynos', 'jsonPath': '$.arrivalTallynos', 'defaultId': '10', 'displayed': '1', 'required': '0'}, {'fieldName': 'brandName', 'jsonPath': '$.brandName', 'defaultId': '5', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckTareWeight', 'jsonPath': '$.truckTareWeight', 'defaultId': '1', 'displayed': '1', 'required': '0'}, {'fieldName': 'originId', 'jsonPath': '$.originId', 'defaultId': '7', 'displayed': '1', 'required': '0'}, {'fieldName': 'specName', 'jsonPath': '$.specName', 'defaultId': '4', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckType', 'jsonPath': '$.truckType', 'defaultId': '2', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}, {'fieldName': 'imageCertList', 'jsonPath': '$.imageCertList[*]certType', 'defaultId': '11', 'displayed': '1', 'required': '0', 'availableValueList': ['2', '3']}, {'fieldName': 'arrivalDatetime', 'jsonPath': '$.arrivalDatetime', 'defaultId': '9', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '8', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '6', 'displayed': '1', 'required': '0'}, {'fieldName': 'measureType', 'jsonPath': '$.measureType', 'defaultId': '12', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}]}
5 5 {'headers': {'Host': 'test.trace.diligrp.com:8393', 'Connection': 'keep-alive', 'Content-Length': '1378', 'Accept': 'application/json,text/javascript,*/*;q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/91.0.4472.77Safari/537.36', 'Content-Type': 'application/json', 'Origin': 'http://test.trace.diligrp.com:8393', 'Referer': 'http://test.trace.diligrp.com:8393/fieldConfig/bill.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7'}}
6   -[2021-07-13 16:57:12] [INFO] : ======================================================================================
7   -[2021-07-13 16:57:12] [INFO] : http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action
  6 +[2021-07-13 17:43:10] [INFO] : ======================================================================================
  7 +[2021-07-13 17:43:10] [INFO] : http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action
8 8 None
9 9 {'registerHeadWeight': '0', 'registerHeadRemainWeight': '0', 'imageCertList': [], 'measureType': 20, 'registType': 10, 'userId': 516, 'arrivalTallynos': [], 'arrivalDatetime': '', 'truckType': 10, 'weight': '111', 'weightUnit': 1, 'productName': '大白菜', 'productId': 2190, 'originName': '', 'originId': '', 'unitPrice': '', 'truckTareWeight': '', 'remark': '', 'specName': '', 'brandName': '', 'plate': '川A123456'}
10 10 {'headers': {'Host': 'test.trace.diligrp.com', 'Connection': 'keep-alive', 'Content-Length': '325', 'Accept': 'application/json,text/javascript,*/*;q=0.01', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.212Safari/537.36', 'Content-Type': 'application/json', 'Origin': 'http://test.trace.diligrp.com:8393', 'Referer': 'http://test.trace.diligrp.com:8393/newRegisterBill/add.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7'}}
11   -[2021-07-13 16:57:12] [INFO] : ======================================================================================
12   -[2021-07-13 16:57:12] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
  11 +[2021-07-13 17:43:15] [INFO] : ======================================================================================
  12 +[2021-07-13 17:43:15] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
13 13 None
14 14 {'moduleType': '1', 'marketId': '8', 'fieldConfigDetailList': [{'fieldName': 'unitPrice', 'jsonPath': '$.unitPrice', 'defaultId': '3', 'displayed': '1', 'required': '0'}, {'fieldName': 'arrivalTallynos', 'jsonPath': '$.arrivalTallynos', 'defaultId': '10', 'displayed': '1', 'required': '0'}, {'fieldName': 'brandName', 'jsonPath': '$.brandName', 'defaultId': '5', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckTareWeight', 'jsonPath': '$.truckTareWeight', 'defaultId': '1', 'displayed': '1', 'required': '0'}, {'fieldName': 'originId', 'jsonPath': '$.originId', 'defaultId': '7', 'displayed': '1', 'required': '0'}, {'fieldName': 'specName', 'jsonPath': '$.specName', 'defaultId': '4', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckType', 'jsonPath': '$.truckType', 'defaultId': '2', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}, {'fieldName': 'imageCertList', 'jsonPath': '$.imageCertList[*]certType', 'defaultId': '11', 'displayed': '1', 'required': '0', 'availableValueList': ['2', '3']}, {'fieldName': 'arrivalDatetime', 'jsonPath': '$.arrivalDatetime', 'defaultId': '9', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '8', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '6', 'displayed': '1', 'required': '0'}, {'fieldName': 'measureType', 'jsonPath': '$.measureType', 'defaultId': '12', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}]}
15 15 {'headers': {'Host': 'test.trace.diligrp.com:8393', 'Connection': 'keep-alive', 'Content-Length': '1378', 'Accept': 'application/json,text/javascript,*/*;q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/91.0.4472.77Safari/537.36', 'Content-Type': 'application/json', 'Origin': 'http://test.trace.diligrp.com:8393', 'Referer': 'http://test.trace.diligrp.com:8393/fieldConfig/bill.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7'}}
16   -[2021-07-13 16:57:13] [INFO] : ======================================================================================
17   -[2021-07-13 16:57:13] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
  16 +[2021-07-13 17:43:15] [INFO] : ======================================================================================
  17 +[2021-07-13 17:43:15] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
18 18 None
19 19 {'moduleType': '1', 'marketId': '8', 'fieldConfigDetailList': [{'fieldName': 'unitPrice', 'jsonPath': '$.unitPrice', 'defaultId': '3', 'displayed': '1', 'required': '0'}, {'fieldName': 'arrivalTallynos', 'jsonPath': '$.arrivalTallynos', 'defaultId': '10', 'displayed': '1', 'required': '0'}, {'fieldName': 'brandName', 'jsonPath': '$.brandName', 'defaultId': '5', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckTareWeight', 'jsonPath': '$.truckTareWeight', 'defaultId': '1', 'displayed': '1', 'required': '0'}, {'fieldName': 'originId', 'jsonPath': '$.originId', 'defaultId': '7', 'displayed': '1', 'required': '0'}, {'fieldName': 'specName', 'jsonPath': '$.specName', 'defaultId': '4', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckType', 'jsonPath': '$.truckType', 'defaultId': '2', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}, {'fieldName': 'imageCertList', 'jsonPath': '$.imageCertList[*]certType', 'defaultId': '11', 'displayed': '1', 'required': '0', 'availableValueList': ['2', '3']}, {'fieldName': 'arrivalDatetime', 'jsonPath': '$.arrivalDatetime', 'defaultId': '9', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '8', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '6', 'displayed': '1', 'required': '0'}, {'fieldName': 'measureType', 'jsonPath': '$.measureType', 'defaultId': '12', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}]}
20 20 {'headers': {'Host': 'test.trace.diligrp.com:8393', 'Connection': 'keep-alive', 'Content-Length': '1378', 'Accept': 'application/json,text/javascript,*/*;q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/91.0.4472.77Safari/537.36', 'Content-Type': 'application/json', 'Origin': 'http://test.trace.diligrp.com:8393', 'Referer': 'http://test.trace.diligrp.com:8393/fieldConfig/bill.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7'}}
21   -[2021-07-13 16:57:14] [INFO] : 发送邮件
22   -[2021-07-13 16:57:17] [INFO] : 邮件发送完毕
  21 +[2021-07-13 17:43:16] [INFO] : 发送邮件
  22 +[2021-07-13 17:43:19] [INFO] : 邮件发送完毕
... ...