From 65760a8a2f0b5584ec573e4ccfb8c42131bd68bb Mon Sep 17 00:00:00 2001 From: "avey777@outlook.com" Date: Sun, 12 Apr 2020 21:42:35 +0800 Subject: [PATCH] 000000 --- .idea/APITestingFramework.iml | 11 + .idea/codeStyles/Project.xml | 5 + .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 222 +++++ "API\346\216\245\345\217\243.md" | 1 + Case/__init__.py | 0 Case/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 147 bytes Case/__pycache__/case.cpython-37.pyc | Bin 0 -> 2327 bytes Case/case.py | 96 +++ Dingtalk/Dingtalk.py | 24 + Dingtalk/__init__.py | 0 Dingtalk/__pycache__/Dingtalk.cpython-37.pyc | Bin 0 -> 637 bytes Dingtalk/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 150 bytes InterfaceBase/__init__.py | 0 .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 156 bytes InterfaceBase/__pycache__/base.cpython-37.pyc | Bin 0 -> 1347 bytes .../__pycache__/requests_base.cpython-37.pyc | Bin 0 -> 3695 bytes InterfaceBase/base.py | 37 + InterfaceBase/requests_base.py | 98 +++ Public/BSTestRunner.py | 805 ++++++++++++++++++ Public/__init__.py | 0 Public/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 148 bytes Public/__pycache__/assertion.cpython-37.pyc | Bin 0 -> 1930 bytes .../encapsulation_dict.cpython-37.pyc | Bin 0 -> 695 bytes Public/__pycache__/get_excel.cpython-37.pyc | Bin 0 -> 2034 bytes Public/__pycache__/log.cpython-37.pyc | Bin 0 -> 1523 bytes Public/__pycache__/py_Html.cpython-37.pyc | Bin 0 -> 6231 bytes .../__pycache__/pyreport_excel.cpython-37.pyc | Bin 0 -> 3410 bytes Public/assertion.py | 56 ++ Public/encapsulation_dict.py | 39 + Public/get_excel.py | 67 ++ Public/log.py | 41 + Public/py_Html.py | 153 ++++ Public/pyreport_excel.py | 113 +++ "Public/\350\257\264\346\230\216" | 8 + WechatTalk/__init__.py | 0 .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 152 bytes .../__pycache__/wechat_conf.cpython-37.pyc | Bin 0 -> 309 bytes .../__pycache__/wechat_msgs.cpython-37.pyc | Bin 0 -> 1681 bytes WechatTalk/wechat_conf.py | 14 + WechatTalk/wechat_msgs.py | 70 ++ api_pip.md | 3 + config/__init__.py | 0 config/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 149 bytes config/__pycache__/config.cpython-37.pyc | Bin 0 -> 474 bytes config/config.py | 22 + config/test_report.yaml | 7 + data/case.xlsx | Bin 0 -> 11542 bytes data/~$case.xlsx | Bin 0 -> 165 bytes demo.py | 33 + log/__init__.py | 0 run_http_excel_re.py | 28 + run_http_html.py | 41 + 56 files changed, 2020 insertions(+) create mode 100644 .idea/APITestingFramework.iml create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 "API\346\216\245\345\217\243.md" create mode 100644 Case/__init__.py create mode 100644 Case/__pycache__/__init__.cpython-37.pyc create mode 100644 Case/__pycache__/case.cpython-37.pyc create mode 100644 Case/case.py create mode 100644 Dingtalk/Dingtalk.py create mode 100644 Dingtalk/__init__.py create mode 100644 Dingtalk/__pycache__/Dingtalk.cpython-37.pyc create mode 100644 Dingtalk/__pycache__/__init__.cpython-37.pyc create mode 100644 InterfaceBase/__init__.py create mode 100644 InterfaceBase/__pycache__/__init__.cpython-37.pyc create mode 100644 InterfaceBase/__pycache__/base.cpython-37.pyc create mode 100644 InterfaceBase/__pycache__/requests_base.cpython-37.pyc create mode 100644 InterfaceBase/base.py create mode 100644 InterfaceBase/requests_base.py create mode 100644 Public/BSTestRunner.py create mode 100644 Public/__init__.py create mode 100644 Public/__pycache__/__init__.cpython-37.pyc create mode 100644 Public/__pycache__/assertion.cpython-37.pyc create mode 100644 Public/__pycache__/encapsulation_dict.cpython-37.pyc create mode 100644 Public/__pycache__/get_excel.cpython-37.pyc create mode 100644 Public/__pycache__/log.cpython-37.pyc create mode 100644 Public/__pycache__/py_Html.cpython-37.pyc create mode 100644 Public/__pycache__/pyreport_excel.cpython-37.pyc create mode 100644 Public/assertion.py create mode 100644 Public/encapsulation_dict.py create mode 100644 Public/get_excel.py create mode 100644 Public/log.py create mode 100644 Public/py_Html.py create mode 100644 Public/pyreport_excel.py create mode 100644 "Public/\350\257\264\346\230\216" create mode 100644 WechatTalk/__init__.py create mode 100644 WechatTalk/__pycache__/__init__.cpython-37.pyc create mode 100644 WechatTalk/__pycache__/wechat_conf.cpython-37.pyc create mode 100644 WechatTalk/__pycache__/wechat_msgs.cpython-37.pyc create mode 100644 WechatTalk/wechat_conf.py create mode 100644 WechatTalk/wechat_msgs.py create mode 100644 api_pip.md create mode 100644 config/__init__.py create mode 100644 config/__pycache__/__init__.cpython-37.pyc create mode 100644 config/__pycache__/config.cpython-37.pyc create mode 100644 config/config.py create mode 100644 config/test_report.yaml create mode 100644 data/case.xlsx create mode 100644 data/~$case.xlsx create mode 100644 demo.py create mode 100644 log/__init__.py create mode 100644 run_http_excel_re.py create mode 100644 run_http_html.py diff --git a/.idea/APITestingFramework.iml b/.idea/APITestingFramework.iml new file mode 100644 index 0000000..3562ccd --- /dev/null +++ b/.idea/APITestingFramework.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..a924271 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..13dffb5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..dac09a3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..0b19fa3 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1543040135901 + + + + + + + + + + + + \ No newline at end of file diff --git "a/API\346\216\245\345\217\243.md" "b/API\346\216\245\345\217\243.md" new file mode 100644 index 0000000..f9a7507 --- /dev/null +++ "b/API\346\216\245\345\217\243.md" @@ -0,0 +1 @@ +congig:配置文档 \ No newline at end of file diff --git a/Case/__init__.py b/Case/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Case/__pycache__/__init__.cpython-37.pyc b/Case/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c1fa431b8b19e4c1c1d38a3a8661bac3cf7bdf6 GIT binary patch literal 147 zcmZ?b<>g`kg4eu1qe1jz5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6wp#VW=nKe;qF zHLs*NCZMvQC_gJTxg^Fhz%wMZxFj<#-K{7wH?=&!DBCc`Ik7l3CO$qhFS8^*Uaz3? U7Kcr4eoARhsvXGGVjyM!0D*rbApigX literal 0 HcmV?d00001 diff --git a/Case/__pycache__/case.cpython-37.pyc b/Case/__pycache__/case.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4ba303a35a8707973a6187d72bfe63762ba4729 GIT binary patch literal 2327 zcmaJ@|7#pY6rb7M+uPgwnzX$({VAvwPC~5uL!s2tZz!#$9$G03C(HJBF5PBt_cA+6 zld=cJ6cpNOz!nuldl3sN+A1grmHJ2c+x}{ENkH^>QSr^}<$4L)J!bZOo6mdm=DnRe zRxFwbp1*%Vjbq~o{VJHvCkw<87~wKZ4kF0Gj^bg0Nyj4$aYed6Br+JySPIO6U zylmSbhNN{b*EWgS&Xc_4vtHpWqDrs0f*fNvA|-0j(jsnTNtsm07#Sx!$WF40noe#J zJEoJriWV`c(%nvBR$(90>LMb0=mg!fhyhP|6V-~*P6*NL|8Q;n{;jo}Up#tvZT;TE z^?NJk2FTHw8cxhN=v+iYezfBPm$So=GH$s(FnP!3cHL&7>(A7bME8Q38Ojp%^y{yJ z7C(2n+z=LxrXAAhc`uxg3ILkANnJLD7x7eJ7%+~*2;Wd3ZMZ82oBLhQU zQs$rHh-0pBm1~RI3ACiVU216EY}e@Ky5=4&uNJlr%vppj=R&ck# zbKH!xyHQ+-^Nw;u?H1!=FTaAiC0>Zlxa6oelx~?9&o@U3$%lmHvK7n}Qa(h_ST55<4%kxA+9~+XHkc0@y)Mq9dT@x1bj#`m++fG(^ux z^o&3Ul)*j#^VAUK;TDv#M46H(l_82IQ8XFjn2?IRIFhQPxg!HCg_&Eh#)akF5s9^9 zh&2+CvvU&*a=a_evA{cr=BCe~SdDQEp5jcbwR9-<>KTTiylQHqM$Aj}j?L_LnCNZF zF9c3aA*Stfx9N6lPD!3o9x>m#7zTc#H3Nr6FTr9_$_EAa^8Uky^ntDk?j{{7vJ zcW*#9KKk*SX!^fZ{jXQRFZ9vsz3YGcbiKcPWp(NOwFe*eZ!afW%XYmDXrK|`7ylo4 ztLh2B(F8#DKkA7{!RPi!pMR{K8r3}sQG9v^h*SOLuh#C|-MIP5`u+RSE}>Yyvi9J; zQ7Dm+1KTuPe1X9e+>soeZ_*BT;XL*9C~9MgdfDwHhUbRd5;c*R)Sxg@CasR7EHxtq zQaT>^EqBH`%NDFNQ9DsX&Jsz zv8Tb{&jTk8HckZ1s7-wyHtGu<7F?uF-Z)x6DG~w~#w*Z#^isfP8^@ui(mSHFkQ7CS zo%A_nExSo~09F{ogcJ>r{w8q=8`#vwVJ^TZ;i^&qs)SA8gk?$<6ccE$1b({=B%p=$ zLmRN&CJ`uXANWrU%WB)MZ&|gyN!GHQplMl5^lqXA(Bs39kBQ6fJWT2NSL)Gu&uvbp z_a+oydiI-QC&3fh-PEY|2ubPG5-*i<+05#Avx5g^$$*B2UtC z9g>!f51C~mb!<$4rsX|L7a06eK}@vWa7)6}vJ!lh?Ga*eb|cd>z$V6_cHl%FJuD&& Y_rfF+D$*`~6>O*lrK(n5Gq8^T1 参数:%s, url:%s ,返回:%s,预期:%s' % (list_params, list_url, api_json, list_anticipate)) + # print("预期",list_anticipate) + assert_re = assert_in(anticipate=listanticipate,return_json=api_json) + if assert_re['code'] == 0: + list_return_json.append(api_json['return_result_json']) + list_result_status.append('pass') + list_pass += 1 + error_num = 0 + break + elif assert_re['code'] == 1: + if error_num <= Config_Try_Num: + error_num += 1 + LOG.info("code=1 失败重试中") + else: + LOG.info("code=1 失败重试次数用完,最后结果") + error_num = 0 + list_fail += 1 + list_result_status.append('fail') + list_return_json.append(api_json['return_result_json']) + break + elif assert_re['code'] == 2: + if error_num < Config_Try_Num: + error_num += 1 + LOG.info('code=2 失败重试中') + else: + LOG.info("code=2 失败重试次数用完,最后结果") + error_num = 0 + list_abnormal += 1 + list_result_status.append(assert_re['return_result_json']) + break + else: + if error_num < Config_Try_Num: + error_num += 1 + LOG.info('无code,失败重试中') + else: + LOG.info('无code,失败重试次数用完,最后结果') + error_num = 0 + list_unknown += 1 + list_result_status.append('无code,未知错误') + list_return_json.append('无code,未知错误') + break + else: + if error_num gwGq7{_nkuAVMW zzP&tIemVZS{Q2p5YXu;*7h!v;pI2j(7SklnGNE;1oP5M{%7fQ*!RBn@@o-91m(v5pH^31PZS7fR#1mtK zOjbrzW)RUhDD~LPYN04x6$iQQnO;#GZSI^xZVX`WsFT)pk!PvNWp#6+Wfc+2cxqA` zJQ67vO0T{{`)=ebr=ty(IBbMA+Ok?|W0~u*9&gH8+jH8arqM|zxrjW)Tmx-X5&LyI zR-#nCTfw8xNS%k-@4Nl&VP9rV35@k{e^x6w5t$kG_8$!34iIx!rKNZ*)pU3!?Z3%Z zJ+m8HR6OAT4BNx00CL^-T-|HZaJu2DYTI!)^r duF-3H|AmeNhqp_~n?l@idTRF+Mml(t`~l&VttJ2f literal 0 HcmV?d00001 diff --git a/Dingtalk/__pycache__/__init__.cpython-37.pyc b/Dingtalk/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cae436c49e7a5945e70313b8fbb2213e7f1907d2 GIT binary patch literal 150 zcmZ?b<>g`kg6%&4qCxay5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6w>#VW=nKe;qF zHLs*NCZMvQC_gJTxg^Fhz%wMZxFj<#-K{7wH?=&!C_Bal$SXg`k0+F{rqCxay5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6w&#VW=nKe;qF zHLs*NCZMvQC_gJTxg^Fhz%wMZxFj<#-K{7wH?=&!DBCb5Gp{7IC@nEL)hV$!H6}hj dGcU6wK3=b&@)n0pZhlH>PO2Tq_+lVt000ALC*lAA literal 0 HcmV?d00001 diff --git a/InterfaceBase/__pycache__/base.cpython-37.pyc b/InterfaceBase/__pycache__/base.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e9a31ba74be089b218ca7d2d620d56e2380a6761 GIT binary patch literal 1347 zcmZux&2JPp6t_JeJ3ILhA89UBCz)6pT4~NXhr7ju`8JtawSg0#aM}2|B_Q~@e ztmX1%{Qy^WOHr-3Z34#9EY*w+*nE8u2>Zmx>qkFetL>dhu(iXmUz=A6av2s~)P$~p ziXYc_6QDK$Xw%)YpuKFmv=XpRYuxnrtlW9nvmY<*F4*f}uY76;-2=kB1>-J$b8U$_ zm*N8w8J7PxdkRAH8l5RkwR!gA00Z^voI*!mX@t&0oe<7;bcHPwi- z)pZaPXU^4CL*yMKJY`{R?HpB^tnp{X#&^Mo;a>_BfH{124v zVEla9K8zBKJOWOQ1NAM5paHCyEd#tnnP&R`m@&bZJyxe}C6uk8O9tVk92yPC2nnDx F?*W#oSgQa4 literal 0 HcmV?d00001 diff --git a/InterfaceBase/__pycache__/requests_base.cpython-37.pyc b/InterfaceBase/__pycache__/requests_base.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8e72686328a54720221fbc480ede25834f04dfd3 GIT binary patch literal 3695 zcmds)|8EpU6u|fU?d`Rt5=2onmnepda=oh-u^2;<(vU#gNJ;Q)vK}|n_S)<2F}rKq z%as(0g2)$Rs34Tm3ldQY#YB-n3IE6bh`nq1iC>Ms=zF_&XQ>eQ0Zn9cJ3Bk`_RX6& z^O^T#Paz?|Q_P5iQbHP( z6Ee>ciO6X_p-`D9<9r)O0z^H?5tRnU#c@8N(jW;A2+Ss0LL(tkLux05M2M>6T%v~7 zOxIG4h6+NWjxHm0<2>jSc5;zrP7@5TF}l~GmTk>nzC3q*taQ0hyt;qk!lznk;^(>R zKa_s?Vqs>YRQRkkb#4C4!Q%NF^Mx_(E_}$fM+8^g-qGeN8MC*SvYfWdqHJADFE#Ak z2RqDMI+IB@G(}_KwL6ljv|*c8-^TDZ!={-qG=w{LhIfbKv1mNDG0Z+`Zi+`^k#HML z4VVp$v3LxA@$l9(qdn$u19m#E!JrjueIrX>ADX*)?cVH}aE&(c= z;I`g?f^y(x&hxNvkV}X}BoaKqzeItj?0Yt$kRW(Sa|30?DIUJX3!kX)eYh=LVVlcy zIxHfH^X(Dd4fN3@q0EA+WYJ8|_Z$m=*dN=rG3~5KteYi05Yw4#0(6&^}6Sn>#Sv+x| zG;#HBVMc9-8O;l~PZrNk6~|`7cg7}TcgD_z=WbqDC|oKXzgRqRp?G3u?&igX+f(p* zZ}upN#6hGiaca6WaoCshC92AuXTkio)~@30Sn)fc2QBplBLYM8UB$Q3dBqnjYw-mS ze_1?o9!8r#a;-GBAGY=yD<|*j+PZFo^CE~>Mnt>&Ez_90T`29J@x&PJO<+<=nS{E_ z{VD2s~FtgOO{ zMpR)v4lg6^h-(>9pGW3Ld9^I|C^jDxN)`fr ztOg1vS=RioQphkg{09^UJ@8mP&h8l~TnVZ7m}7O=xB?425E(i?qIi_C=db~{Ia`Ir z3s~UkwiKk*(Dpjq7OLTt3Py_{0vx^cC5q!#DY`G@orX_wmzP6c`{Rc^_$mOwPOSzz zsmck2y(&*Z;OVRTf?c2*?2so6b{>1c)8b(FRPcmH+?LkutzE4Tjdwm#n7#RePoAk% zRrgatmFBav3}&^IFNM$yh3pXXh^27(A#4#`xHgX<>?IIsf!jhn7l*1vjMY^b^T%$F z1TY0PAY0XSSJU-DlQ`;4-jtMwV3Ny~y%n>gM{^x%I$k$N|v>%>gyx_7pD zi{fgX&Yny<6@~vi{@P%gT~6!FJ($varn8r^8MP-?RMUCgODS;qESG1VTU block as CDATA. + +Version in 0.7.1 +* Back port to Python 2.3 (Frank Horowitz). +* Fix missing scroll bars in detail log (Podi). +""" + +# TODO: color stderr +# TODO: simplify javascript using ,ore than 1 class in the class attribute? + +import datetime +from io import StringIO as StringIO +import sys +import time +import unittest +from xml.sax import saxutils + + +# ------------------------------------------------------------------------ +# The redirectors below are used to capture output during testing. Output +# sent to sys.stdout and sys.stderr are automatically captured. However +# in some cases sys.stdout is already cached before BSTestRunner is +# invoked (e.g. calling logging.basicConfig). In order to capture those +# output, use the redirectors for the cached stream. +# +# e.g. +# >>> logging.basicConfig(stream=BSTestRunner.stdout_redirector) +# >>> + +def to_unicode(s): + return s + # try: + # return unicode(s) + # except UnicodeDecodeError: + # # s is non ascii byte string + # return s.decode('unicode_escape') + +class OutputRedirector(object): + """ Wrapper to redirect stdout or stderr """ + def __init__(self, fp): + self.fp = fp + + def write(self, s): + self.fp.write(s) + + def writelines(self, lines): + lines = map(to_unicode, lines) + self.fp.writelines(lines) + + def flush(self): + self.fp.flush() + +stdout_redirector = OutputRedirector(sys.stdout) +stderr_redirector = OutputRedirector(sys.stderr) + + + +# ---------------------------------------------------------------------- +# Template + +class Template_mixin(object): + """ + Define a HTML template for report customerization and generation. + + Overall structure of an HTML report + + HTML + +------------------------+ + | | + | | + | | + | STYLESHEET | + | +----------------+ | + | | | | + | +----------------+ | + | | + | | + | | + | | + | | + | HEADING | + | +----------------+ | + | | | | + | +----------------+ | + | | + | REPORT | + | +----------------+ | + | | | | + | +----------------+ | + | | + | ENDING | + | +----------------+ | + | | | | + | +----------------+ | + | | + | | + | | + +------------------------+ + """ + + STATUS = { + 0: 'pass', + 1: 'fail', + 2: 'error', + } + + DEFAULT_TITLE = 'Unit Test Report' + DEFAULT_DESCRIPTION = '' + + # ------------------------------------------------------------------------ + # HTML Template + + HTML_TMPL = r""" + + + + + + + %(title)s + + + %(stylesheet)s + + + + + + + + +
+ %(heading)s + %(report)s + %(ending)s +
+ + + +""" + # variables: (title, generator, stylesheet, heading, report, ending) + + + # ------------------------------------------------------------------------ + # Stylesheet + # + # alternatively use a for external style sheet, e.g. + # + + STYLESHEET_TMPL = """ + +""" + + + + # ------------------------------------------------------------------------ + # Heading + # + + HEADING_TMPL = """
+

%(title)s

+%(parameters)s +

%(description)s

+
+ +""" # variables: (title, parameters, description) + + HEADING_ATTRIBUTE_TMPL = """

%(name)s: %(value)s

+""" # variables: (name, value) + + + + # ------------------------------------------------------------------------ + # Report + # + + REPORT_TMPL = """ +

+Summary +Failed +All +

+ + + + + + + %(test_list)s + + + + + + + + + + + +
Test Group/Test case + Count + Pass + Fail + Error + View +
Total%(count)s%(Pass)s%(fail)s%(error)s 
+""" # variables: (test_list, count, Pass, fail, error) + + REPORT_CLASS_TMPL = r""" + + %(desc)s + %(count)s + %(Pass)s + %(fail)s + %(error)s + Detail + +""" # variables: (style, desc, count, Pass, fail, error, cid) + + + REPORT_TEST_WITH_OUTPUT_TMPL = r""" + +
%(desc)s
+ + + + + %(status)s + + + + + + +""" # variables: (tid, Class, style, desc, status) + + + REPORT_TEST_NO_OUTPUT_TMPL = r""" + +
%(desc)s
+ %(status)s + +""" # variables: (tid, Class, style, desc, status) + + + REPORT_TEST_OUTPUT_TMPL = r""" +%(id)s: %(output)s +""" # variables: (id, output) + + + + # ------------------------------------------------------------------------ + # ENDING + # + + ENDING_TMPL = """
 
""" + +# -------------------- The end of the Template class ------------------- + + +TestResult = unittest.TestResult + +class _TestResult(TestResult): + # note: _TestResult is a pure representation of results. + # It lacks the output and reporting ability compares to unittest._TextTestResult. + + def __init__(self, verbosity=1): + TestResult.__init__(self) + self.outputBuffer = StringIO() + self.stdout0 = None + self.stderr0 = None + self.success_count = 0 + self.failure_count = 0 + self.error_count = 0 + self.verbosity = verbosity + + # result is a list of result in 4 tuple + # ( + # result code (0: success; 1: fail; 2: error), + # TestCase object, + # Test output (byte string), + # stack trace, + # ) + self.result = [] + + + def startTest(self, test): + TestResult.startTest(self, test) + # just one buffer for both stdout and stderr 更改 + self.outputBuffer = StringIO() + stdout_redirector.fp = self.outputBuffer + stderr_redirector.fp = self.outputBuffer + self.stdout0 = sys.stdout + self.stderr0 = sys.stderr + sys.stdout = stdout_redirector + sys.stderr = stderr_redirector + + + def complete_output(self): + """ + Disconnect output redirection and return buffer. + Safe to call multiple times. + """ + if self.stdout0: + sys.stdout = self.stdout0 + sys.stderr = self.stderr0 + self.stdout0 = None + self.stderr0 = None + return self.outputBuffer.getvalue() + + + def stopTest(self, test): + # Usually one of addSuccess, addError or addFailure would have been called. + # But there are some path in unittest that would bypass this. + # We must disconnect stdout in stopTest(), which is guaranteed to be called. + self.complete_output() + + + def addSuccess(self, test): + self.success_count += 1 + TestResult.addSuccess(self, test) + output = self.complete_output() + self.result.append((0, test, output, '')) + if self.verbosity > 1: + sys.stderr.write('ok ') + sys.stderr.write(str(test)) + sys.stderr.write('\n') + else: + sys.stderr.write('.') + + def addError(self, test, err): + self.error_count += 1 + TestResult.addError(self, test, err) + _, _exc_str = self.errors[-1] + output = self.complete_output() + self.result.append((2, test, output, _exc_str)) + if self.verbosity > 1: + sys.stderr.write('E ') + sys.stderr.write(str(test)) + sys.stderr.write('\n') + else: + sys.stderr.write('E') + + def addFailure(self, test, err): + self.failure_count += 1 + TestResult.addFailure(self, test, err) + _, _exc_str = self.failures[-1] + output = self.complete_output() + self.result.append((1, test, output, _exc_str)) + if self.verbosity > 1: + sys.stderr.write('F ') + sys.stderr.write(str(test)) + sys.stderr.write('\n') + else: + sys.stderr.write('F') + + +class BSTestRunner(Template_mixin): + """ + """ + def __init__(self, stream=sys.stdout, verbosity=1, title=None, description=None): + self.stream = stream + self.verbosity = verbosity + if title is None: + self.title = self.DEFAULT_TITLE + else: + self.title = title + if description is None: + self.description = self.DEFAULT_DESCRIPTION + else: + self.description = description + + self.startTime = datetime.datetime.now() + + + def run(self, test): + "Run the given test case or test suite." + result = _TestResult(self.verbosity) + try: + test(result) + except TypeError: + pass + self.stopTime = datetime.datetime.now() + self.generateReport(test, result) + print('\n测试耗时: %s' % (self.stopTime-self.startTime)) + return result + + + def sortResult(self, result_list): + # unittest does not seems to run in any particular order. + # Here at least we want to group them together by class. + rmap = {} + classes = [] + for n,t,o,e in result_list: + cls = t.__class__ + if not cls in rmap: + rmap[cls] = [] + classes.append(cls) + rmap[cls].append((n,t,o,e)) + r = [(cls, rmap[cls]) for cls in classes] + return r + + + def getReportAttributes(self, result): + """ + Return report attributes as a list of (name, value). + Override this to add custom attributes. + """ + startTime = str(self.startTime)[:19] + duration = str(self.stopTime - self.startTime) + status = [] + if result.success_count: status.append('Pass %s' % result.success_count) + if result.failure_count: status.append('Failure %s' % result.failure_count) + if result.error_count: status.append('Error %s' % result.error_count ) + if status: + status = ' '.join(status) + else: + status = 'none' + return [ + ('Start Time', startTime), + ('Duration', duration), + ('Status', status), + ] + + + def generateReport(self, test, result): + report_attrs = self.getReportAttributes(result) + generator = 'BSTestRunner %s' % __version__ + stylesheet = self._generate_stylesheet() + heading = self._generate_heading(report_attrs) + report = self._generate_report(result) + ending = self._generate_ending() + output = self.HTML_TMPL % dict( + title = saxutils.escape(self.title), + generator = generator, + stylesheet = stylesheet, + heading = heading, + report = report, + ending = ending, + ) + self.stream.write(output.encode('utf-8')) + + + def _generate_stylesheet(self): + return self.STYLESHEET_TMPL + + + def _generate_heading(self, report_attrs): + a_lines = [] + for name, value in report_attrs: + line = self.HEADING_ATTRIBUTE_TMPL % dict( + name = saxutils.escape(name),####更改 + # value = saxutils.escape(value), + + value = value, + ) + a_lines.append(line) + heading = self.HEADING_TMPL % dict( + title = saxutils.escape(self.title), + parameters = ''.join(a_lines), + description = saxutils.escape(self.description), + ) + return heading + + + def _generate_report(self, result): + rows = [] + sortedResult = self.sortResult(result.result) + for cid, (cls, cls_results) in enumerate(sortedResult): + # subtotal for a class + np = nf = ne = 0 + for n,t,o,e in cls_results: + if n == 0: np += 1 + elif n == 1: nf += 1 + else: ne += 1 + + # format class description + if cls.__module__ == "__main__": + name = cls.__name__ + else: + name = "%s.%s" % (cls.__module__, cls.__name__) + doc = cls.__doc__ and cls.__doc__.split("\n")[0] or "" + desc = doc and '%s: %s' % (name, doc) or name + + row = self.REPORT_CLASS_TMPL % dict( + style = ne > 0 and 'text text-warning' or nf > 0 and 'text text-danger' or 'text text-success', + desc = desc, + count = np+nf+ne, + Pass = np, + fail = nf, + error = ne, + cid = 'c%s' % (cid+1), + ) + rows.append(row) + + for tid, (n,t,o,e) in enumerate(cls_results): + self._generate_report_test(rows, cid, tid, n, t, o, e) + + report = self.REPORT_TMPL % dict( + test_list = ''.join(rows), + count = str(result.success_count+result.failure_count+result.error_count), + Pass = str(result.success_count), + fail = str(result.failure_count), + error = str(result.error_count), + ) + return report + + + def _generate_report_test(self, rows, cid, tid, n, t, o, e): + # e.g. 'pt1.1', 'ft1.1', etc + has_output = bool(o or e) + tid = (n == 0 and 'p' or 'f') + 't%s.%s' % (cid+1,tid+1) + name = t.id().split('.')[-1] + doc = t.shortDescription() or "" + desc = doc and ('%s: %s' % (name, doc)) or name + tmpl = has_output and self.REPORT_TEST_WITH_OUTPUT_TMPL or self.REPORT_TEST_NO_OUTPUT_TMPL + + # o and e should be byte string because they are collected from stdout and stderr? + if isinstance(o,str): + # TODO: some problem with 'string_escape': it escape \n and mess up formating + # uo = unicode(o.encode('string_escape')) + uo = o + else: + uo = o + if isinstance(e,str): + # TODO: some problem with 'string_escape': it escape \n and mess up formating + # ue = unicode(e.encode('string_escape')) + ue = e + else: + ue = e + + script = self.REPORT_TEST_OUTPUT_TMPL % dict( + id = tid, + output = saxutils.escape(uo+ue), + ) + + row = tmpl % dict( + tid = tid, + Class = (n == 0 and 'hiddenRow' or 'none'), + # Class = (n == 0 and 'hiddenRow' or 'text text-success'), + # style = n == 2 and 'errorCase' or (n == 1 and 'failCase' or 'none'), + style = n == 2 and 'text text-warning' or (n == 1 and 'text text-danger' or 'text text-success'), + desc = desc, + script = script, + status = self.STATUS[n], + ) + rows.append(row) + if not has_output: + return + + def _generate_ending(self): + return self.ENDING_TMPL + + +############################################################################## +# Facilities for running tests from the command line +############################################################################## + +# Note: Reuse unittest.TestProgram to launch test. In the future we may +# build our own launcher to support more specific command line +# parameters like test title, CSS, etc. +class TestProgram(unittest.TestProgram): + """ + A variation of the unittest.TestProgram. Please refer to the base + class for command line parameters. + """ + def runTests(self): + # Pick BSTestRunner as the default test runner. + # base class's testRunner parameter is not useful because it means + # we have to instantiate BSTestRunner before we know self.verbosity. + if self.testRunner is None: + self.testRunner = BSTestRunner(verbosity=self.verbosity) + unittest.TestProgram.runTests(self) + +main = TestProgram + +############################################################################## +# Executing this module from the command line +############################################################################## + +if __name__ == "__main__": + main(module=None) diff --git a/Public/__init__.py b/Public/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Public/__pycache__/__init__.cpython-37.pyc b/Public/__pycache__/__init__.cpython-37.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V?d00001 diff --git a/Public/__pycache__/encapsulation_dict.cpython-37.pyc b/Public/__pycache__/encapsulation_dict.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..34f09900fd7e2342282786322d7addb57dcf551a GIT binary patch literal 695 zcmYk4ON$dh5XY+@lZ=BKbdkjs{Q$Yh9z{e}9TYu;;0gf)@`yjtkyB`3d^qMG_w$!Hd>J-AzGNcXe0)>fcRYURrVh?ewePw?hu_wNCyU z#mPE)c@l$wEf7S|F>Db@1&e5LLhub}Th%GtcBXG%P9N=mfB$j%^u_e`_}jC`v*#aX zPu@8}jj64HZlPa6FMnd#h7nbuL6IF=tZAZQm+nE-z&U8L3L~cJF4Js}5YTi3=Cxc| z_bAqn2kRPKxN~mARYP-)46J8@M6}d6LSz>rcU4of9h8l7i`+frKp7s%VQCtEmdQjI9*3nema4K?8dk{CuvjMThM@vWgH%YFB4Vvy2GqU@5?~-E_JWplBEih?W={~mk-k- z>UFETaTxSu68IT1eHEsOSF1Xk4T~d4YoeEH7=UoHLTuvT*uv^QhH!}&co0kzi$19#hIpwMqroPafa99Yvgfo+J3F(SnUz9j zuu=#hmo|}BLL0gjFJOR5yin=N-{AASx-;88@#2$-(eKQ(%Nn0NlkYp{yPWUL`M%$G zUeD(Z1mm|){{HZgeG@8Vw0Dt;AEabi7RMWcF-x<>yC@i}9tI)`i=dXf&5E#S0Ib4=y)X zR+_)gJa(G;Zf$;I^_x$#2(4?UJA$mPJX(ux-^sBGs|Kb z3XqO&;2b$`0C~@W_V^z@s^b9a83H~6ToeLa7Z;&&+fXP3!l)FABPf)BWFQ4d1=4_Y zAOomt{JJj_F%Tz(LG;mdmGkI#Y20SS%)3?U6py)V?6B*OMH+R=F0q^uQ}K>a z>U)vwF!vZttmKT)NGVmppO_M~lpV<*m+Tsi^f#fys=nnqjQ>_7SPnXt>K}1Qq@@BNc6|l-UU#ULSgGPgJ*h*< z@vX82C(tYsqjt@YuoYo?3$dr*s6Y1(?kNnqDJUS;kmE&GMnh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g0{-7s} zUpAg`m6p)D9)=jd3VUB)zRYrq1&tg3;`timxdCt%+@dC z&_k7A&AJRhYu_-{IA$V^V~L$98z7=4xZ}0!`KmH%iW7 z;5-T>E^62t1Qq2;ZhZblUuk86JlW^0FO}_gxrE*!3cM88ggtq1Cl{>9_+9vgm%ZxI U0G=j19-W8Tq;=}Kt)S`t3;fQO761SM literal 0 HcmV?d00001 diff --git a/Public/__pycache__/py_Html.cpython-37.pyc b/Public/__pycache__/py_Html.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e6813ada0a941594bb6095f82c334977530ea535 GIT binary patch literal 6231 zcmdTI?~@e8b!LC>9*1{_0b>!wv#8Q5gh5%|vG*yAJ#9xubzaaUPPxCeIa(wc;RjK5?p4r>wZm&2)_>ifZ zp6)lV`@Md@yC3WCPbu*H?H|hif8V1h|HMK22|?#kc%8k_P^F|$m4-~Uq|$IHL?bkM zOeuwFtQ4Vfnt*mmD9S4aCnd>d>@C`K`g4e%4%gs zbyZk1w5PEytSE(bJAeH6zMt=Xf>dGIVye*oFpU;d$$~J1$%^ZpLf-EIsK$gw^s2@k zCPvaf-M1^dJ&mXmZfP|(l0Iy(iMq{2n&`GAm<4zf1{Kv2$_^Vk%gVtfVpxVSG&Aey zn#o4C{wk;RvqPNj4k&H4ST=R5`1Rq^m;Io#A|5r&g{E zn7ZTSbi0=)+@gt61{nR_WIR}fZqJ$>tFum zjn;)rb64K!@Qu4_efVDM*vYT1y+xY8KiWEf?#7X~=Dv85Nag19q`m7da;-Bje);*w zUtN2p`O=$nS1$R(*4c}#4^Pj1^hxXVOR&mKG@dsq#1z0B`N08SVx-{c+^7rUaJ?fl z8)Q|}CQ)=KGSetKdDQ;HPSrRJa@&^M+!@2h)5SvGU+0^y%IAfb-va8`oNohA5sMct ztb3kW)TkVo*SJ&>5mR-rEx{%Q>N8Ll+Doo#P|B<<1 zsz8mygy^Q`I3pW$+sxKzb}P7(?AVnGIA3<_1|qp0*-+E?s9|MIRuRJwt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WmGov)+mxAsL-#$ah^VUohp{z^ zh{H{RpB-1acg-Rsu|{zR;G0~d%&fACx55Q}qJCa=lWxlGb62?ivoP16@2-OUn%wiX zN;u}`Qan(ltTMcKU@;tXHr%JmrQ3@IgkfFYOAirNOS+x>_W07qsUN%nr;93b^^9>TKxbYOt1} ziy?RLVwi^BR^L`tl$Jt@)r(-Yz|mKvK)twMDLDLo1WElzQFtKD$^rp;DIHEi zg6)R8%`<@Q$h$A~L69HM!#K0Tiyu5lZT;XuFJwDDgLosyzl#mlhMZu7rJ`><>#&D9 ol?!yylQ)C%A|p|#*|Y(7C%BS>xDhBj;k_5$47{mC4%)&00P=VgasU7T literal 0 HcmV?d00001 diff --git a/Public/__pycache__/pyreport_excel.cpython-37.pyc b/Public/__pycache__/pyreport_excel.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..133473be02ad789c02690f42e5356cf09be5cca9 GIT binary patch literal 3410 zcmZ`*>u(#!5#PN#9*@U2#mI3Uj?>mo=sIeh7Hv@kMO@25T?C3?3vod(ASmupI_kuu z_KuMyoPeT?n$&?~1x;(THXNy~`v6)w0n&$)Hu)?1WxqD0#DAfmIk-L9P{-FP3InbBeISX2djh4aTbA@E`0#b1PdGGn6$7mZT}GMX>#-=H?Tu7I7S$cV}~B#N$gN_ z9>p#VT|p7LG|PpMfCiCP;SiH#pw){fVCCUf)M`kZ#{d~<12P83P7(-O2w^mF* zw~QdWP0O+6sq4fyfh!lJ>v7=1X0mvYVToHhB@#`tq(oCAXqsgtnhkOT-UQ15HYO2G z?oO~gAdih8CLrS@hylon5hTab?C}vK56H<8#02Dt5hMraKRJTr0eNZ!F#&mc1j(^v zkYuMImQa%exeeb1VaI_|hRXFVQa_LQRQ&;qpCsc4T3{?>`>`+NM{l9vg4dQZdCLG%|^xdYq{1SLIwUrIXHryc$3xW&NYbPg4 zRku;I=Sx0h*m9UmCsr#<&RV49*IxJz6exz(sJaZYuPh(Be|=}~;V*VS{dxEPz1adS zW+Cr7Wf!vj3b%c$>@IT520ctD_J>cy43ovs*6z&*o%e1QsJuUW$SX(>lSU7-#}MP* z!{2w?8$GxML$tU3X!q_;XYlW-;F#}!_>p*BOzot^FO)<2MpV)uUh>%Gt4lGD!bKHB^ELHLTdH#;{! z*nRh{V!U6XV7XMx*bPWAwMx}`&ElTzHi~iIuGHQ)#DT+`1?yjVMPriV$ve)$=&1kQHf|Kk^*y>n$!st_)~ES{!Iy;Znv{;KfLvZ((k2?Rn9cuWSH@o*fkhIRu{ob!O_C9~VbN9Zag-$Ny zgyuFOsYaR{G!z;}htM3i!h~@hYOy)jT`a~bjFmxf%a>VKL^zaTmQW#WipYx1`~{gh zi}5f@AbkQgA{Rn+tcI*3gzEWRW<;TRl{c(HUKlkSs925092+83X8CYhtJsc+B5E@) zBqO6I48*_?o=D&f0vu`rzmJ0@`gkoY6g?3~u4Q`#*ZpJa;38on&Ml|q`Jo(85G)kq zC=rwc_|-sh3=0wQD|1d*5D03^`l+Z(?84#NK(BJE;#=PaFM3Vrh>}pSj5BBo>Vph4 zosP?vqeojv+3%5l3ige|t{lxDY2);%k#?FsPx%y_Sulj+dSQKf9@b%@gr$vigY + + + %s + + + + + + + + + + + '''%(titles) + return title +connent=''' +
+

接口测试的结果

''' +def shouye(starttime,endtime,passge,fail,excepthions,weizhicuowu): + beijing=''' + + + + + + + + + +
开始时间: %s
结束时间: %s
耗时: %s
结果: + Pass: %s + Fail: %s + exception: %s + weizhicuowu : %s
+
'''%(starttime,endtime,(endtime-starttime),passge,fail,excepthions,weizhicuowu) + return beijing +shanghai='''
+
+
+ + + + + +
+
+
+ + + + + + + + + + + + + ''' +def passfail(tend): + if tend =='pass': + htl='''''' + elif tend =='fail': + htl='''''' + elif tend=='weizhi': + htl='''''' + else: + htl = '' + return htl +def ceshixiangqing(reslt,id,name,key,params,url,method,yuqi,json,relust): + xiangqing=''' + + + + + + + + + + %s + + '''%(reslt,id,name,key,params,url,method,yuqi,json,passfail(relust)) + return xiangqing +weibu='''
用例ID 用例名字key请求内容url请求方式预期实际返回结果
passfailerrorexect
%s%s%s%s%s%s%s%s
+ + +''' +def relust(titles,starttime,endtime,passge,fail,id,name,key,params,url,method,anticipate,json,relust,exceptions,weizhi): + if type(name) ==list: + relus=' ' + for i in range(len(name)): + if relust[i] == "pass": + clazz = "success" + elif relust[i]== "fail": + clazz = "warning" + elif relust[i]== "weizhi": + clazz = "danger" + else: + clazz='error' + relus+=(ceshixiangqing(clazz,id[i],name[i],key[i],params[i],url[i],method[i],anticipate[i],json[i],relust[i])) + text=title(titles)+connent+shouye(starttime,endtime,passge,fail,exceptions,weizhi)+shanghai+relus+weibu + else: + text=title(titles)+connent+shouye(starttime,endtime,passge,fail,exceptions,weizhi)+shanghai+ceshixiangqing(id,name,key,params,url,method,anticipate,json,relust)+weibu + return text +def createHtml(filepath,titles,starttime,endtime,passge,fail,id,name,key,coneent,url,meth,yuqi,json,relusts,exceptions,weizhi): + texts=relust(titles,starttime,endtime,passge,fail,id,name,key,coneent,url,meth,yuqi,json,relusts,exceptions,weizhi) + with open(filepath,'wb') as f: + f.write(texts.encode('utf-8')) \ No newline at end of file diff --git a/Public/pyreport_excel.py b/Public/pyreport_excel.py new file mode 100644 index 0000000..49a67d8 --- /dev/null +++ b/Public/pyreport_excel.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# coding: utf-8 +import os + +import xlwt, yaml +from xlwt import * + + +def yangshi1(): + style = XFStyle() + fnt = Font() + fnt.name = u'微软雅黑' + fnt.bold = True + style.font = fnt + alignment = xlwt.Alignment() + alignment.horz = xlwt.Alignment.HORZ_CENTER + alignment.vert = xlwt.Alignment.VERT_CENTER + style.alignment = alignment # 给样式添加文字居中属性 + style.font.height = 430 # 设置字体大小 + return style + + +def yangshi2(): + style1 = XFStyle() + alignment = xlwt.Alignment() + alignment.horz = xlwt.Alignment.HORZ_CENTER + alignment.vert = xlwt.Alignment.VERT_CENTER + style1.alignment = alignment # 给样式添加文字居中属性 + style1.font.height = 330 # 设置字体大小 + return style1 + + +def yangshi3(): + style1 = XFStyle() + style1.font.height = 330 # 设置字体大小 + return style1 + + +def yangshique(me): + if me == 'pass': + style = yangshi1() + Pattern = xlwt.Pattern() + Pattern.pattern = xlwt.Pattern.SOLID_PATTERN + Pattern.pattern_fore_colour = xlwt.Style.colour_map['green'] + style.pattern = Pattern + else: + style = yangshi2() + Pattern = xlwt.Pattern() + Pattern.pattern = xlwt.Pattern.SOLID_PATTERN + Pattern.pattern_fore_colour = xlwt.Style.colour_map['red'] + style.pattern = Pattern + return style + + +def create(filename, list_pass, list_fail, listids, listnames, listkeys, listconeents, listurls, listfangshis, + listqiwangs, list_json, listrelust): + filepath = open(r'.\config\test_report.yaml', encoding='utf-8') + # filepath = open(os.path.dirname(os.getcwd())+'\\config\\test_report.yaml', encoding='utf-8') + print(filepath) + file_config = yaml.load(filepath) + file = Workbook(filename) + table = file.add_sheet('测试结果', cell_overwrite_ok=True) + style = yangshi1() + for i in range(0, 7): + table.col(i).width = 380 * 20 + style1 = yangshi2() + table.write_merge(0, 0, 0, 6, '测试报告', style=style) + table.write_merge(1, 1, 0, 6, '', style=style) + table.write_merge(2, 3, 0, 6, '测试详情', style=style1) + table.write(4, 0, '项目名称', style=style1) + table.write(5, 0, '接口版本', style=style1) + table.write(6, 0, '提测时间', style=style1) + table.write(7, 0, '提测人', style=style1) + table.write(4, 2, '测试人', style=style1) + table.write(5, 2, '测试时间', style=style1) + table.write(6, 2, '审核人', style=style1) + table.write(4, 4, '通过', style=style1) + table.write(5, 4, '失败', style=style1) + table.write(6, 4, '成功率', style=style1) + table.write(4, 1, (file_config['projectname']), style=style1) + table.write(5, 1, file_config['interfaceVersion'], style=style1) + table.write(6, 1, file_config['tijiao_time'], style=style1) + table.write(7, 1, file_config['tijiao_person'], style=style1) + table.write(4, 3, file_config['ceshi_person'], style=style1) + table.write(5, 3, file_config['ceshi_time'], style=style1) + table.write(6, 3, file_config['shenhename'], style=style1) + table.write(4, 5, (list_pass), style=style1) + table.write(5, 5, (list_fail), style=style1) + table.write(6, 5, ('%.2f%%' % ((list_pass) / (len(listrelust)))), style=style1) + table1 = file.add_sheet('测试详情', cell_overwrite_ok=True) + table1.write_merge(0, 0, 0, 8, '测试详情', style=style) + for i in range(0, 8): + table1.col(i).width = 400 * 20 + table1.write(1, 0, '用例ID', style=yangshi3()) + table1.write(1, 1, '用例名字', style=yangshi3()) + table1.write(1, 2, 'key', style=yangshi3()) + table1.write(1, 3, '请求内容', style=yangshi3()) + table1.write(1, 4, ' url', style=yangshi3()) + table1.write(1, 5, '请求方式', style=yangshi3()) + table1.write(1, 6, '预期', style=yangshi3()) + table1.write(1, 7, '实际返回', style=yangshi3()) + table1.write(1, 8, '结果', style=yangshi3()) + for i in range(len(listids)): + table1.write(i + 1, 0, listids[i], style=yangshi3()) + table1.write(i + 1, 1, listnames[i], style=yangshi3()) + table1.write(i + 1, 2, listkeys[i], style=yangshi3()) + table1.write(i + 1, 3, listconeents[i], style=yangshi3()) + table1.write(i + 1, 4, listurls[i], style=yangshi3()) + table1.write(i + 1, 5, listfangshis[i], style=yangshi3()) + table1.write(i + 1, 6, listqiwangs[i], style=yangshi3()) + table1.write(i + 1, 7, str(list_json[i]), style=yangshi3()) + table1.write(i + 1, 8, listrelust[i], style=yangshique(listrelust[i])) + file.save(filename) diff --git "a/Public/\350\257\264\346\230\216" "b/Public/\350\257\264\346\230\216" new file mode 100644 index 0000000..e409664 --- /dev/null +++ "b/Public/\350\257\264\346\230\216" @@ -0,0 +1,8 @@ +可正常使用文件 +get_excel.py 读取用例表格 +log.py 日志 + +已调试文件按 +assertion.py 断言 +encapsulation_dict.py 字典数据解析 +get_excel_new.py 表格操作 diff --git a/WechatTalk/__init__.py b/WechatTalk/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/WechatTalk/__pycache__/__init__.cpython-37.pyc b/WechatTalk/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..772fa959555adca5bc162b2f1bcce6fa9413dda7 GIT binary patch literal 152 zcmZ?b<>g`kf*DsCVnFm`5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6w!#VW=nKe;qF zHLs*NCZMvQC_gJTxg^Fhz%wMZxFj<#-K{7wH?=&!C_5%RH8~@(BqT8>J0?CpGcU6w ZK3=b&@)n0pZhlH>PO2Tq=wcvd000mfCEfr4 literal 0 HcmV?d00001 diff --git a/WechatTalk/__pycache__/wechat_conf.cpython-37.pyc b/WechatTalk/__pycache__/wechat_conf.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..433118d7be2655f09008fa2224d47327869708f6 GIT binary patch literal 309 zcmZ?b<>g`k0-0+JG46~E439w^7y$Aa9Dul31W2SXL@}f=Mlq%^MKPr?M=__c1T$!| zmP!GoxSs53e6nNK(|zln>|gk@wfFg65aU_ndafv;^75n<%OnGHlN1w6Q&Y#0qo^nE2)5Vin_(pIn*? zR8kxhP+3rvpOuydmb$(GK=X6tAH2*dy?amI6}`(Coo~6-F@)9mN^SaAs_o zr%>CJsEeghGrLx1_Hftkp{~il#}u(3OAL@*>1{&R4y2j28)%& znNO8NS&&dxwv`DJ%IP1XicgO43c2Hop0;!GJH&?}vA^f%FK)~yL0V_A6dTLU22W}% zkQ?tU-&lpC!nnG?{W{xA_|C=}3$}f^>PI^pd%0Mti>jDxG*tl-?8iQ&A#U?9ju|yJgjSK^xZpUaFnE`l`rIvNsk0NDB zwlBl^E2BucK@v*{n``%F+jC@+3dWTSQORb5d9GiD>5%dl zEXPdJ*&b)S4oaU%TSlKpHON$=8m^g{nE{tSH-Jx84_GAau9I0^H|LcJys|T!TEOH* zNvPey7{vr6M@tj|Lhe%Ql@p8`L^&l`OfQ`z7qG2t@B)OQEb2>Nxr}p7pB%>Y984VE zKREpP?t@>xKm4_K^wXzD2lpO)dFRo`2Y=nayOL_2ZlzJw^qd7hj2JB!xCNWIE*h?L zRqo9`Pr0j28ey()o zuuW(O2$%2+c-$bkXz(+j9}`Z8qk}t9$Zeop8%U?i7(j=j?w9~K6nF=>ZE1kb%IuCg zfYn-3<9mCXbZ&F{!VI06o1LAbud~+qeYU-_DkeU7U*1}~HFy2$wS_mYtzZ9eaXMZT zi?=VVy>WAKeP)Hv-r&{N^V?E3#Kozp-KO6NC-+#mAI6iryOTjuFPnLZg`kg8y%RM1$zZAOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;!HWi&czEesXDU zYFg`kf@uiDF4% zjbcq6)Qb;UIt>k(-f7kPc4NvwjeAc-BWoz&Az3blZ z>3Ozb=d<2*PxkJAK4ry=hSnGDtDaBU2$AKglFBG4DX`MlFE20GE6zyFORoYFhGrIe z$$2k<#xq0-m6s=_SSA^mo1~annwnas7^Y^rIPo)7X;-9X1cwysdV7?FhKE|ZJG;6W zyGFQ&`55Gd7yCq-hZ_a?M3@8@nR*tb-(v97WWU88AD@z+93LOW9gYR~S67QT}RN(0nC5|rcn4X$fl9__3 zAviU;D77R?)Fm@7y(BRwJ3cWvIkmVrz9c_8HE$(D5ev{?VB(jyi&czEesXCp(4^v+ zfXafR{H)aEk{HJT&zNMev!Ik-LFFwDo80`A(wtN~cA)-Z9w5QO2!t#w%peE=UcsLi literal 0 HcmV?d00001 diff --git a/config/config.py b/config/config.py new file mode 100644 index 0000000..96b9539 --- /dev/null +++ b/config/config.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# @File : 基础信息配置 + +""" +@author +基础信息配置,根据使用者自由配置 +""" +TestPlanUrl="http://www.XXX" #基础url +Config_Try_Num=0 #接口失败重试次数 + +'''企业微信''' +# 此为企业的ID号 +nterpriseWeChat_CorpID = 'wwbd9b074d49559d1e' + +# 企业微信应用的ID +nterpriseWeChat_Agentid = 1000004 + +# 认证信息,企业ID+认证信息可获取tokent,获取之后向此tokent发送内容 +nterpriseWeChat_Secret = 'xehSTs-KHtUWU9GCEF3EXGVL0nWsLY7W2RLX4Sr5Irg' + +'''钉钉''' +Dingtalk_access_token="" #钉钉配置 \ No newline at end of file diff --git a/config/test_report.yaml b/config/test_report.yaml new file mode 100644 index 0000000..cc6e48a --- /dev/null +++ b/config/test_report.yaml @@ -0,0 +1,7 @@ +projectname:XXX +interfaceVersion:1.0 +tijiao_time:2016/02/03 +tijiao_person:BBB +ceshi_person:CCC +ceshi_time:2016/02/03 +shenhename:DDD diff --git a/data/case.xlsx b/data/case.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..983e1ae8e3e6ac6572e1ca6104423c1ef9b95fb4 GIT binary patch literal 11542 zcmeHN1zVe2)(yqo-HW?Bg(9W6ySuwn+$ru9cPLierMMO^UK|P(Xz<{Cxp!v1-ph1; z!OY8(kUY=3SCVtqK6`CZl!1i80>A*^0000vV1uq%&jkViAcg?|FadBcbi^F&UCr!W z4OG1x&0O@DJ?(7C3ZP!l<^f)S@BiQRU%UcelJ#tQS+T-^uy?3b&4n@icqW>ii$lBA zUmgM~`5JqC5-_tL@3JL`Oo8W2^`aq3$@+O)#e0)4KzXZC3&KYC4Qsn1!FWi7H^CyL-KAI91vW#fuhLxAj$B z*dT@WFYP^dZJ`Ly7p-fiPav#or`Wu8r}vPh05Od1>x{OY($pObJ9zh)v4_H25w4GcrF#cDiKZyF zfWbx>K@gj4L3kD+`s=R2*HTXI0l?)u-hC3epmWLh7#r8jM=uMjCSJjdL?CpD79O7Y z@+lK!e{;7ymk$!0Z`U?-{cd^}BOA`Auqkv41pqufK>`&2=Bt?cU1l%9zPb)}MMSW# z8aSKTy09?+@%%p@{V#URzx?#dL^&BqHncEc&=dKWPJtErmov63Z}#O(A0XJ$9}IcY zk2&!(Y)O;Qs2M_Wtq>mtM|%0w6wsYCpk;R97*;D zzO*erthnTeq2JA4ycCM8+$soRrg{p%b9<{k5cH~5*NRs&#TifgLK?N4N;hSfIBcCj zah!8tLK05E1+qZsy5pvUn@6tNYV4iENHGONe2Mr(yw-L6lIV|ft^)P^V#=NxztMw; z(Yu!>kR&wP54rn5n`vcb398Tx$n5VoN4(Gt9Yt?kF#W%!OZe=ucCe$CYTC1m6oA-j zU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Wk9n&h89iqGCcd!W@dqP@E=3OJl!GtB51{x;tja&LU4#;KWitH#eo1 zeVWhHF&i2e>zXn#+M-w85;MpQ&$||4+!u$CI;>*CieziLs&;oPrW#@|MAsNOP=V1#AkTX=)tFTNxJpB% z7I;_5A`!E%a5{GO=tRV&X1RM>_D5{qxEKx1k8x&<25_9eoAu zRgHS0Y}%oToYzwr!Nluo$CVnYsW?`3i@vG4&TtpV&Z8@w@k9GZ%~ROl&VDVHehO~JzxJ0mn~s9iw;Fvg-d z%;uHil_gnk^?D@+$VXz6d&6TyrTa4O3Rnr4JGzzv#DwH$RZw)G(!_*5qJ&ktWX)fH zE@@prHqd4Az=n`HZ7i>xMzE5;>D%8ZWMRE&nlpq3Mg{HT!vAebqPZU6P zE9C-TFH3L76~{IRtF_Z?dB3?>Z811))4oLvtueTEQeu?GCMzW*MscQ%z(3|+9Ng(p zwMV|`+N+upj8g-_?(DmMkXLT=siwXjvq^gb@6ErTqr0oyn2=yb`-30gDY?I#qi!y) z4tD<|^}i?$0Ax*#TZgb>L2vlx1JUZ@-qX29i-(tUWHM{-yIx^z%XU*HitEt%g3R|P zkJ>x3#)ewc9M&)4a1J`^NJpz_0v`04N$$4#Wut&ZtWW+QXNxB>?>9XACHbG z^%Q4?v}esHN!)YM zWYf$L0uNjTA5M4a>K+(HUsco!OXD6;VQpW053Zmcp_QJcd}Lj!$#U`;=Y6bFbn!rT{=6{GZ1EVanh+&hzf_FC=Ji-u=%n@o&B6=P1wnSievH~?Uc902$?&H3E??{eX<=Bku` rG5@D{cy9goqxrAa)HHvwHu?X9T2TfX%zXd=1^kx-b{}K9Ki>Tx*b{=x literal 0 HcmV?d00001 diff --git a/data/~$case.xlsx b/data/~$case.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..6e5ea456fdcffa248d5e5166543fa8495f2e5b6f GIT binary patch literal 165 ZcmZRsO085N9WXOgF{Cn7GAPgm0stH{4|f0n literal 0 HcmV?d00001 diff --git a/demo.py b/demo.py new file mode 100644 index 0000000..1001920 --- /dev/null +++ b/demo.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +""" +接口封装文件 +""" +import requests +from config.config import * +# url = "http://cpright.xinhua-news.cn/api/match/image/getjson" +# +# querystring = {"category":"image","offset":"0","limit":"30","sourceId":"0","metaTitle":"","metaId":"0","classify":"unclassify","startTime":"","endTime":"","createStart":"","createEnd":"","sourceType":"","isTracking":"true","metaGroup":"","companyId":"0","lastDays":"1","author":""} +# +# headers = { +# 'cache-control': "no-cache", +# 'postman-token': "e97a99b0-424b-b2a5-7602-22cd50223c15" +# } +# +# response = requests.request("POST", url, headers=headers, params=querystring) + +################################ +url = "http://www.shangzhan168.cn/Account/Login" +# url = "http://xxxXXXsys/login" +# querystring = {"username":"16895654212","password":"123456"} +headers = { + 'cache-control': "no-cache" + } +querystring = {"hnAccount":"15020579681","hnPassword":"123456"} +#Post接口调用 +response = requests.request("POST", url,headers=headers, params=querystring) +print(response.json()) +print(response.text) +print(response.cookies) +print(response.apparent_encoding) +print(response.headers) +print(response.content) diff --git a/log/__init__.py b/log/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/run_http_excel_re.py b/run_http_excel_re.py new file mode 100644 index 0000000..4a964ab --- /dev/null +++ b/run_http_excel_re.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# coding: utf-8 +# from Public.email_send import send_mali_byQQ, send_mali_by163 +from Case.case import caseInterface +from Public.pyreport_excel import create +import os, datetime +from Public.get_excel import dataParsing + + +def start_excel_report_http(): + m = datetime.datetime.now().strftime("%Y-%m%d-%H%M") + basdir = os.path.abspath(os.path.dirname(__file__)) + path = os.getcwd() + '\\data\\case.xlsx' + listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = dataParsing(path) + listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = caseInterface() + filepath = os.path.join(basdir + '\\Report\\%s-result.xls' % m) + if os.path.exists(filepath) is False: + os.system(r'touch %s' % filepath) + create(filename=filepath, list_fail=list_fail, list_pass=list_pass, list_json=list_json, listurls=listurl, + listkeys=listkey, listconeents=listconeent, listfangshis=listfangshi, listqiwangs=listqiwang, + listids=listid, listrelust=listrelust, listnames=listname) + # contec = 'dubbo接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( + # list_pass, list_fail, list_exption, list_weizhi, filepath) + # send_mali_byQQ("123456@qq.com", "yvghvyhqcbdbb","1234564@qq.com","123", filepath) + + +if __name__ == '__main__': + start_excel_report_http() diff --git a/run_http_html.py b/run_http_html.py new file mode 100644 index 0000000..f6349ed --- /dev/null +++ b/run_http_html.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# @Author +import os,datetime,time + +from Case.case import caseInterface +from Dingtalk.Dingtalk import send_ding +from Public.py_Html import createHtml +from Public.get_excel import dataParsing +from WechatTalk.wechat_msgs import wechatSendmessages + +'''执行测试的主要文件''' +def start_interface_html_http(): + starttime=datetime.datetime.now() + day= time.strftime("%Y%m%d%H%M", time.localtime(time.time())) + basdir=os.path.abspath(os.path.dirname(__file__)) + path = os.getcwd() + '\\data\\case.xlsx' + print(path) + listid, listname, listmethod, listurl, listkey, listparams, listanticipate = dataParsing(path) + listrelust, list_fail, list_pass, list_json,list_abnormal,list_unknown = caseInterface() + filepath =os.path.join(basdir+'\\Report\\%s-result.html'%day) + if os.path.exists(filepath) is False: + os.system(r'touch %s' % filepath) + endtime=datetime.datetime.now() + createHtml(titles=u'http接口自动化测试报告',filepath=filepath,starttime=starttime, + endtime=endtime,passge=list_pass,fail=list_fail, + id=listid,name=listname,key=listkey,coneent=listparams,url=listurl,meth=listmethod, + yuqi=listanticipate,json=list_json,relusts=listrelust,weizhi=list_unknown,exceptions=list_abnormal) + contec_messages = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( + list_pass, list_fail, list_abnormal, list_unknown, filepath) + try: + send_ding(content=contec_messages) + except: + print("钉钉发送消息失败") + try: + open(filepath) + wechatSendmessages(msg=contec_messages+filepath) + except: + print("企业微信消息发送失败") + +if __name__ == '__main__': + start_interface_html_http() \ No newline at end of file