logdata.log 273 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740
  1. 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2. 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
  3. 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  4. 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  5. 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
  6. 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  7. 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  8. 2024-11-04 20:25:36 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  9. 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P0] conftest.py pytest_runtest_makereport 68
  10. 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  11. 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  12. 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
  13. 2024-11-04 20:25:36 INFO 用例耗时:0.10566030000000004 conftest.py pytest_runtest_makereport 72
  14. 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
  15. 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  16. 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
  17. 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  18. 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  19. 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  20. 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  21. 2024-11-04 20:25:36 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  22. 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P1] conftest.py pytest_runtest_makereport 68
  23. 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  24. 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  25. 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
  26. 2024-11-04 20:25:36 INFO 用例耗时:0.08426139999999993 conftest.py pytest_runtest_makereport 72
  27. 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
  28. 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  29. 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}} ApiTestRunner.py test_case_execute 42
  30. 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  31. 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  32. 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
  33. 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  34. 2024-11-04 20:25:36 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
  35. 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P2] conftest.py pytest_runtest_makereport 68
  36. 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  37. 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  38. 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
  39. 2024-11-04 20:25:36 INFO 用例耗时:0.09925839999999986 conftest.py pytest_runtest_makereport 72
  40. 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
  41. 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
  42. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  43. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  44. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  45. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  46. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  47. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
  48. 2024-11-04 20:25:36 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  49. 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P3] conftest.py pytest_runtest_makereport 68
  50. 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  51. 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  52. 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
  53. 2024-11-04 20:25:36 INFO 用例耗时:0.08409670000000014 conftest.py pytest_runtest_makereport 72
  54. 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
  55. 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  56. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/aa51dc43ea3448bb91f269fb9c489aa3.png'}} ApiTestRunner.py test_case_execute 42
  57. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  58. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  59. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  60. 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  61. 2024-11-04 20:25:36 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  62. 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P4] conftest.py pytest_runtest_makereport 68
  63. 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  64. 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  65. 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
  66. 2024-11-04 20:25:36 INFO 用例耗时:0.11206969999999972 conftest.py pytest_runtest_makereport 72
  67. 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
  68. 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  69. 2024-11-04 20:25:36 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  70. 2024-11-04 20:25:36 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  71. 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P5] conftest.py pytest_runtest_makereport 68
  72. 2024-11-04 20:25:37 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  73. 2024-11-04 20:25:37 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBEFA0>
  74. caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  75. def test_case_execute(self, caseinfo):
  76. casename = caseinfo["_case_name"]
  77. # TODO 2-1 : 调用动态生成标题的方法
  78. dynamicTitle(caseinfo)
  79. # TODO 2-2: 基于我们步骤一步步进行执行
  80. try:
  81. # 实例化关键字对象
  82. keywords = KeyWords()
  83. # 获取当前用例变量,方便后续的渲染
  84. local_context = caseinfo.get("context",{})
  85. context = copy.deepcopy(g_context().show_dict())
  86. context.update(local_context)
  87. steps = caseinfo.get("steps", None)
  88. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  89. for index,step in enumerate(steps):
  90. # 提示信息
  91. step_name = list(step.keys())[0]
  92. step_value = list(step.values())[0]
  93. # TODO : 每一个步骤进行变量的渲染
  94. context = copy.deepcopy(g_context().show_dict())
  95. context.update(local_context)
  96. step_value = eval(refresh(step_value, context))
  97. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  98. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  99. # 通过【反射】的方式去找到对应的方法
  100. with allure.step(step_name):
  101. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  102. try:
  103. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  104. except AttributeError as e:
  105. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  106. > key_func(**step_value) # 调用方法
  107. core\ApiTestRunner.py:51:
  108. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  109. extend\keywords.py:183: in ex_mysqlData
  110. logger.info("数据库查询结果:", rs)
  111. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  112. self._log(INFO, msg, args, **kwargs)
  113. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  114. self.handle(record)
  115. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  116. self.callHandlers(record)
  117. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  118. hdlr.handle(record)
  119. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  120. self.emit(record)
  121. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  122. super().emit(record)
  123. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  124. self.handleError(record)
  125. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  126. msg = self.format(record)
  127. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  128. return fmt.format(record)
  129. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  130. return super().format(record)
  131. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  132. record.message = record.getMessage()
  133. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  134. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  135. def getMessage(self):
  136. """
  137. Return the message for this LogRecord.
  138. Return the message for this LogRecord after merging any user-supplied
  139. arguments with the message.
  140. """
  141. msg = str(self.msg)
  142. if self.args:
  143. > msg = msg % self.args
  144. E TypeError: not all arguments converted during string formatting
  145. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  146. 2024-11-04 20:25:37 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  147. 2024-11-04 20:25:37 INFO 用例耗时:0.24739699999999987 conftest.py pytest_runtest_makereport 72
  148. 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
  149. 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  150. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  151. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  152. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  153. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  154. 2024-11-04 20:25:37 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  155. 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P6] conftest.py pytest_runtest_makereport 68
  156. 2024-11-04 20:25:37 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  157. 2024-11-04 20:25:37 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE520>
  158. caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  159. def test_case_execute(self, caseinfo):
  160. casename = caseinfo["_case_name"]
  161. # TODO 2-1 : 调用动态生成标题的方法
  162. dynamicTitle(caseinfo)
  163. # TODO 2-2: 基于我们步骤一步步进行执行
  164. try:
  165. # 实例化关键字对象
  166. keywords = KeyWords()
  167. # 获取当前用例变量,方便后续的渲染
  168. local_context = caseinfo.get("context",{})
  169. context = copy.deepcopy(g_context().show_dict())
  170. context.update(local_context)
  171. steps = caseinfo.get("steps", None)
  172. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  173. for index,step in enumerate(steps):
  174. # 提示信息
  175. step_name = list(step.keys())[0]
  176. step_value = list(step.values())[0]
  177. # TODO : 每一个步骤进行变量的渲染
  178. context = copy.deepcopy(g_context().show_dict())
  179. context.update(local_context)
  180. step_value = eval(refresh(step_value, context))
  181. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  182. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  183. # 通过【反射】的方式去找到对应的方法
  184. with allure.step(step_name):
  185. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  186. try:
  187. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  188. except AttributeError as e:
  189. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  190. > key_func(**step_value) # 调用方法
  191. core\ApiTestRunner.py:51:
  192. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  193. self = <apirun.extend.keywords.KeyWords object at 0x00000215AE0115B0>
  194. kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
  195. comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFDBA60>, '<': <function KeyWords.as...at 0x00000215ADFDB9D0>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFDB8B0>, ...}
  196. message = None
  197. @allure.step("参数数据:断言当前文本内容")
  198. def assert_text_comparators(self, **kwargs):
  199. """
  200. 封装断言以进行不同的比较操作。
  201. 参数:
  202. value (Any): 要比较的值。
  203. expected (Any): 预期的值。
  204. op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
  205. message (str, optional): 自定义的错误消息。
  206. 返回:
  207. None: 如果断言成功,则不返回任何内容。
  208. 引发:
  209. AssertionError: 如果断言失败。
  210. """
  211. comparators = {
  212. '>': lambda a, b: a > b,
  213. '<': lambda a, b: a < b,
  214. '==': lambda a, b: a == b,
  215. '>=': lambda a, b: a >= b,
  216. '<=': lambda a, b: a <= b,
  217. '!=': lambda a, b: a != b,
  218. }
  219. message = kwargs.get("MESSAGE", None)
  220. if kwargs["OP_STR"] not in comparators:
  221. raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
  222. if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
  223. if message:
  224. raise AssertionError(message)
  225. else:
  226. > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
  227. E AssertionError: SUCCESS == 书籍ID不存在 失败
  228. extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
  229. 2024-11-04 20:25:37 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
  230. 2024-11-04 20:25:37 INFO 用例耗时:0.11110720000000018 conftest.py pytest_runtest_makereport 72
  231. 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
  232. 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  233. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  234. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  235. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  236. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  237. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  238. 2024-11-04 20:25:37 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  239. 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P7] conftest.py pytest_runtest_makereport 68
  240. 2024-11-04 20:25:37 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  241. 2024-11-04 20:25:37 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  242. 2024-11-04 20:25:37 INFO 异常:None conftest.py pytest_runtest_makereport 71
  243. 2024-11-04 20:25:37 INFO 用例耗时:0.09267849999999989 conftest.py pytest_runtest_makereport 72
  244. 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
  245. 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  246. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  247. 2024-11-04 20:25:37 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  248. 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P8] conftest.py pytest_runtest_makereport 68
  249. 2024-11-04 20:25:37 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  250. 2024-11-04 20:25:37 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE190>
  251. caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  252. def test_case_execute(self, caseinfo):
  253. casename = caseinfo["_case_name"]
  254. # TODO 2-1 : 调用动态生成标题的方法
  255. dynamicTitle(caseinfo)
  256. # TODO 2-2: 基于我们步骤一步步进行执行
  257. try:
  258. # 实例化关键字对象
  259. keywords = KeyWords()
  260. # 获取当前用例变量,方便后续的渲染
  261. local_context = caseinfo.get("context",{})
  262. context = copy.deepcopy(g_context().show_dict())
  263. context.update(local_context)
  264. steps = caseinfo.get("steps", None)
  265. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  266. for index,step in enumerate(steps):
  267. # 提示信息
  268. step_name = list(step.keys())[0]
  269. step_value = list(step.values())[0]
  270. # TODO : 每一个步骤进行变量的渲染
  271. context = copy.deepcopy(g_context().show_dict())
  272. context.update(local_context)
  273. step_value = eval(refresh(step_value, context))
  274. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  275. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  276. # 通过【反射】的方式去找到对应的方法
  277. with allure.step(step_name):
  278. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  279. try:
  280. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  281. except AttributeError as e:
  282. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  283. > key_func(**step_value) # 调用方法
  284. core\ApiTestRunner.py:51:
  285. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  286. extend\keywords.py:183: in ex_mysqlData
  287. logger.info("数据库查询结果:", rs)
  288. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  289. self._log(INFO, msg, args, **kwargs)
  290. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  291. self.handle(record)
  292. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  293. self.callHandlers(record)
  294. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  295. hdlr.handle(record)
  296. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  297. self.emit(record)
  298. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  299. super().emit(record)
  300. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  301. self.handleError(record)
  302. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  303. msg = self.format(record)
  304. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  305. return fmt.format(record)
  306. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  307. return super().format(record)
  308. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  309. record.message = record.getMessage()
  310. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  311. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  312. def getMessage(self):
  313. """
  314. Return the message for this LogRecord.
  315. Return the message for this LogRecord after merging any user-supplied
  316. arguments with the message.
  317. """
  318. msg = str(self.msg)
  319. if self.args:
  320. > msg = msg % self.args
  321. E TypeError: not all arguments converted during string formatting
  322. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  323. 2024-11-04 20:25:37 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  324. 2024-11-04 20:25:37 INFO 用例耗时:0.22507089999999996 conftest.py pytest_runtest_makereport 72
  325. 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
  326. 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  327. 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  328. 2024-11-04 20:25:38 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
  329. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P9] conftest.py pytest_runtest_makereport 68
  330. 2024-11-04 20:25:38 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  331. 2024-11-04 20:25:38 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE610>
  332. caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G0--P', ...}
  333. def test_case_execute(self, caseinfo):
  334. casename = caseinfo["_case_name"]
  335. # TODO 2-1 : 调用动态生成标题的方法
  336. dynamicTitle(caseinfo)
  337. # TODO 2-2: 基于我们步骤一步步进行执行
  338. try:
  339. # 实例化关键字对象
  340. keywords = KeyWords()
  341. # 获取当前用例变量,方便后续的渲染
  342. local_context = caseinfo.get("context",{})
  343. context = copy.deepcopy(g_context().show_dict())
  344. context.update(local_context)
  345. steps = caseinfo.get("steps", None)
  346. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  347. for index,step in enumerate(steps):
  348. # 提示信息
  349. step_name = list(step.keys())[0]
  350. step_value = list(step.values())[0]
  351. # TODO : 每一个步骤进行变量的渲染
  352. context = copy.deepcopy(g_context().show_dict())
  353. context.update(local_context)
  354. step_value = eval(refresh(step_value, context))
  355. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  356. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  357. # 通过【反射】的方式去找到对应的方法
  358. with allure.step(step_name):
  359. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  360. try:
  361. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  362. except AttributeError as e:
  363. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  364. > key_func(**step_value) # 调用方法
  365. core\ApiTestRunner.py:51:
  366. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  367. extend\keywords.py:183: in ex_mysqlData
  368. logger.info("数据库查询结果:", rs)
  369. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  370. self._log(INFO, msg, args, **kwargs)
  371. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  372. self.handle(record)
  373. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  374. self.callHandlers(record)
  375. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  376. hdlr.handle(record)
  377. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  378. self.emit(record)
  379. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  380. super().emit(record)
  381. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  382. self.handleError(record)
  383. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  384. msg = self.format(record)
  385. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  386. return fmt.format(record)
  387. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  388. return super().format(record)
  389. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  390. record.message = record.getMessage()
  391. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  392. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  393. def getMessage(self):
  394. """
  395. Return the message for this LogRecord.
  396. Return the message for this LogRecord after merging any user-supplied
  397. arguments with the message.
  398. """
  399. msg = str(self.msg)
  400. if self.args:
  401. > msg = msg % self.args
  402. E TypeError: not all arguments converted during string formatting
  403. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  404. 2024-11-04 20:25:38 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  405. 2024-11-04 20:25:38 INFO 用例耗时:0.2116956000000001 conftest.py pytest_runtest_makereport 72
  406. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  407. 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  408. 2024-11-04 20:25:38 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  409. 2024-11-04 20:25:38 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  410. 2024-11-04 20:25:38 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  411. 2024-11-04 20:25:38 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  412. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P10] conftest.py pytest_runtest_makereport 68
  413. 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  414. 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  415. 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
  416. 2024-11-04 20:25:38 INFO 用例耗时:0.12249089999999985 conftest.py pytest_runtest_makereport 72
  417. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  418. 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  419. 2024-11-04 20:25:38 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  420. 2024-11-04 20:25:38 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  421. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P11] conftest.py pytest_runtest_makereport 68
  422. 2024-11-04 20:25:38 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  423. 2024-11-04 20:25:38 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE8B0>
  424. caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  425. def test_case_execute(self, caseinfo):
  426. casename = caseinfo["_case_name"]
  427. # TODO 2-1 : 调用动态生成标题的方法
  428. dynamicTitle(caseinfo)
  429. # TODO 2-2: 基于我们步骤一步步进行执行
  430. try:
  431. # 实例化关键字对象
  432. keywords = KeyWords()
  433. # 获取当前用例变量,方便后续的渲染
  434. local_context = caseinfo.get("context",{})
  435. context = copy.deepcopy(g_context().show_dict())
  436. context.update(local_context)
  437. steps = caseinfo.get("steps", None)
  438. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  439. for index,step in enumerate(steps):
  440. # 提示信息
  441. step_name = list(step.keys())[0]
  442. step_value = list(step.values())[0]
  443. # TODO : 每一个步骤进行变量的渲染
  444. context = copy.deepcopy(g_context().show_dict())
  445. context.update(local_context)
  446. step_value = eval(refresh(step_value, context))
  447. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  448. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  449. # 通过【反射】的方式去找到对应的方法
  450. with allure.step(step_name):
  451. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  452. try:
  453. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  454. except AttributeError as e:
  455. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  456. > key_func(**step_value) # 调用方法
  457. core\ApiTestRunner.py:51:
  458. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  459. extend\keywords.py:183: in ex_mysqlData
  460. logger.info("数据库查询结果:", rs)
  461. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  462. self._log(INFO, msg, args, **kwargs)
  463. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  464. self.handle(record)
  465. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  466. self.callHandlers(record)
  467. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  468. hdlr.handle(record)
  469. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  470. self.emit(record)
  471. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  472. super().emit(record)
  473. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  474. self.handleError(record)
  475. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  476. msg = self.format(record)
  477. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  478. return fmt.format(record)
  479. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  480. return super().format(record)
  481. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  482. record.message = record.getMessage()
  483. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  484. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  485. def getMessage(self):
  486. """
  487. Return the message for this LogRecord.
  488. Return the message for this LogRecord after merging any user-supplied
  489. arguments with the message.
  490. """
  491. msg = str(self.msg)
  492. if self.args:
  493. > msg = msg % self.args
  494. E TypeError: not all arguments converted during string formatting
  495. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  496. 2024-11-04 20:25:38 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  497. 2024-11-04 20:25:38 INFO 用例耗时:0.20688920000000044 conftest.py pytest_runtest_makereport 72
  498. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  499. 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  500. 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
  501. 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  502. 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  503. 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
  504. 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  505. 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  506. 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  507. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P12] conftest.py pytest_runtest_makereport 68
  508. 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  509. 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  510. 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
  511. 2024-11-04 20:25:38 INFO 用例耗时:0.08122730000000011 conftest.py pytest_runtest_makereport 72
  512. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  513. 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  514. 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
  515. 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  516. 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  517. 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  518. 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  519. 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  520. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P13] conftest.py pytest_runtest_makereport 68
  521. 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  522. 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  523. 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
  524. 2024-11-04 20:25:38 INFO 用例耗时:0.08275990000000011 conftest.py pytest_runtest_makereport 72
  525. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  526. 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  527. 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}} ApiTestRunner.py test_case_execute 42
  528. 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  529. 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  530. 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
  531. 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  532. 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
  533. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P14] conftest.py pytest_runtest_makereport 68
  534. 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  535. 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  536. 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
  537. 2024-11-04 20:25:38 INFO 用例耗时:0.08612210000000076 conftest.py pytest_runtest_makereport 72
  538. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  539. 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
  540. 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  541. 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  542. 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  543. 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  544. 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  545. 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
  546. 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  547. 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P15] conftest.py pytest_runtest_makereport 68
  548. 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  549. 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  550. 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
  551. 2024-11-04 20:25:38 INFO 用例耗时:0.07912230000000076 conftest.py pytest_runtest_makereport 72
  552. 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
  553. 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  554. 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/058a645adf1640e4a9e857d75a4fbb31.png'}} ApiTestRunner.py test_case_execute 42
  555. 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  556. 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  557. 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  558. 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  559. 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  560. 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P16] conftest.py pytest_runtest_makereport 68
  561. 2024-11-04 20:25:39 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  562. 2024-11-04 20:25:39 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  563. 2024-11-04 20:25:39 INFO 异常:None conftest.py pytest_runtest_makereport 71
  564. 2024-11-04 20:25:39 INFO 用例耗时:0.10777579999999976 conftest.py pytest_runtest_makereport 72
  565. 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
  566. 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  567. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  568. 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  569. 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P17] conftest.py pytest_runtest_makereport 68
  570. 2024-11-04 20:25:39 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  571. 2024-11-04 20:25:39 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27280>
  572. caseinfo = {'_case_name': '备份_我的书评-发布正常的书评(可能会失败)', 'desc': '备份_我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  573. def test_case_execute(self, caseinfo):
  574. casename = caseinfo["_case_name"]
  575. # TODO 2-1 : 调用动态生成标题的方法
  576. dynamicTitle(caseinfo)
  577. # TODO 2-2: 基于我们步骤一步步进行执行
  578. try:
  579. # 实例化关键字对象
  580. keywords = KeyWords()
  581. # 获取当前用例变量,方便后续的渲染
  582. local_context = caseinfo.get("context",{})
  583. context = copy.deepcopy(g_context().show_dict())
  584. context.update(local_context)
  585. steps = caseinfo.get("steps", None)
  586. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  587. for index,step in enumerate(steps):
  588. # 提示信息
  589. step_name = list(step.keys())[0]
  590. step_value = list(step.values())[0]
  591. # TODO : 每一个步骤进行变量的渲染
  592. context = copy.deepcopy(g_context().show_dict())
  593. context.update(local_context)
  594. step_value = eval(refresh(step_value, context))
  595. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  596. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  597. # 通过【反射】的方式去找到对应的方法
  598. with allure.step(step_name):
  599. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  600. try:
  601. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  602. except AttributeError as e:
  603. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  604. > key_func(**step_value) # 调用方法
  605. core\ApiTestRunner.py:51:
  606. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  607. extend\keywords.py:183: in ex_mysqlData
  608. logger.info("数据库查询结果:", rs)
  609. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  610. self._log(INFO, msg, args, **kwargs)
  611. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  612. self.handle(record)
  613. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  614. self.callHandlers(record)
  615. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  616. hdlr.handle(record)
  617. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  618. self.emit(record)
  619. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  620. super().emit(record)
  621. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  622. self.handleError(record)
  623. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  624. msg = self.format(record)
  625. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  626. return fmt.format(record)
  627. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  628. return super().format(record)
  629. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  630. record.message = record.getMessage()
  631. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  632. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  633. def getMessage(self):
  634. """
  635. Return the message for this LogRecord.
  636. Return the message for this LogRecord after merging any user-supplied
  637. arguments with the message.
  638. """
  639. msg = str(self.msg)
  640. if self.args:
  641. > msg = msg % self.args
  642. E TypeError: not all arguments converted during string formatting
  643. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  644. 2024-11-04 20:25:39 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  645. 2024-11-04 20:25:39 INFO 用例耗时:0.21631909999999976 conftest.py pytest_runtest_makereport 72
  646. 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
  647. 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  648. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  649. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  650. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  651. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  652. 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  653. 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P18] conftest.py pytest_runtest_makereport 68
  654. 2024-11-04 20:25:39 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  655. 2024-11-04 20:25:39 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27DC0>
  656. caseinfo = {'_case_name': '备份_我的书评-发布不存在的书籍ID(BUG)', 'desc': '备份_我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  657. def test_case_execute(self, caseinfo):
  658. casename = caseinfo["_case_name"]
  659. # TODO 2-1 : 调用动态生成标题的方法
  660. dynamicTitle(caseinfo)
  661. # TODO 2-2: 基于我们步骤一步步进行执行
  662. try:
  663. # 实例化关键字对象
  664. keywords = KeyWords()
  665. # 获取当前用例变量,方便后续的渲染
  666. local_context = caseinfo.get("context",{})
  667. context = copy.deepcopy(g_context().show_dict())
  668. context.update(local_context)
  669. steps = caseinfo.get("steps", None)
  670. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  671. for index,step in enumerate(steps):
  672. # 提示信息
  673. step_name = list(step.keys())[0]
  674. step_value = list(step.values())[0]
  675. # TODO : 每一个步骤进行变量的渲染
  676. context = copy.deepcopy(g_context().show_dict())
  677. context.update(local_context)
  678. step_value = eval(refresh(step_value, context))
  679. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  680. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  681. # 通过【反射】的方式去找到对应的方法
  682. with allure.step(step_name):
  683. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  684. try:
  685. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  686. except AttributeError as e:
  687. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  688. > key_func(**step_value) # 调用方法
  689. core\ApiTestRunner.py:51:
  690. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  691. self = <apirun.extend.keywords.KeyWords object at 0x00000215ADFD67F0>
  692. kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
  693. comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFCBDC0>, '<': <function KeyWords.as...at 0x00000215ADFCB040>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFCB670>, ...}
  694. message = None
  695. @allure.step("参数数据:断言当前文本内容")
  696. def assert_text_comparators(self, **kwargs):
  697. """
  698. 封装断言以进行不同的比较操作。
  699. 参数:
  700. value (Any): 要比较的值。
  701. expected (Any): 预期的值。
  702. op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
  703. message (str, optional): 自定义的错误消息。
  704. 返回:
  705. None: 如果断言成功,则不返回任何内容。
  706. 引发:
  707. AssertionError: 如果断言失败。
  708. """
  709. comparators = {
  710. '>': lambda a, b: a > b,
  711. '<': lambda a, b: a < b,
  712. '==': lambda a, b: a == b,
  713. '>=': lambda a, b: a >= b,
  714. '<=': lambda a, b: a <= b,
  715. '!=': lambda a, b: a != b,
  716. }
  717. message = kwargs.get("MESSAGE", None)
  718. if kwargs["OP_STR"] not in comparators:
  719. raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
  720. if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
  721. if message:
  722. raise AssertionError(message)
  723. else:
  724. > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
  725. E AssertionError: SUCCESS == 书籍ID不存在 失败
  726. extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
  727. 2024-11-04 20:25:39 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
  728. 2024-11-04 20:25:39 INFO 用例耗时:0.11749030000000005 conftest.py pytest_runtest_makereport 72
  729. 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
  730. 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  731. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  732. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  733. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  734. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  735. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  736. 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  737. 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P19] conftest.py pytest_runtest_makereport 68
  738. 2024-11-04 20:25:39 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  739. 2024-11-04 20:25:39 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  740. 2024-11-04 20:25:39 INFO 异常:None conftest.py pytest_runtest_makereport 71
  741. 2024-11-04 20:25:39 INFO 用例耗时:0.10991980000000012 conftest.py pytest_runtest_makereport 72
  742. 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
  743. 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  744. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  745. 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  746. 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P20] conftest.py pytest_runtest_makereport 68
  747. 2024-11-04 20:25:39 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  748. 2024-11-04 20:25:39 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27940>
  749. caseinfo = {'_case_name': '备份_我的书评-发布不满五个字的书评(BUG)', 'desc': '备份_我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  750. def test_case_execute(self, caseinfo):
  751. casename = caseinfo["_case_name"]
  752. # TODO 2-1 : 调用动态生成标题的方法
  753. dynamicTitle(caseinfo)
  754. # TODO 2-2: 基于我们步骤一步步进行执行
  755. try:
  756. # 实例化关键字对象
  757. keywords = KeyWords()
  758. # 获取当前用例变量,方便后续的渲染
  759. local_context = caseinfo.get("context",{})
  760. context = copy.deepcopy(g_context().show_dict())
  761. context.update(local_context)
  762. steps = caseinfo.get("steps", None)
  763. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  764. for index,step in enumerate(steps):
  765. # 提示信息
  766. step_name = list(step.keys())[0]
  767. step_value = list(step.values())[0]
  768. # TODO : 每一个步骤进行变量的渲染
  769. context = copy.deepcopy(g_context().show_dict())
  770. context.update(local_context)
  771. step_value = eval(refresh(step_value, context))
  772. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  773. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  774. # 通过【反射】的方式去找到对应的方法
  775. with allure.step(step_name):
  776. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  777. try:
  778. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  779. except AttributeError as e:
  780. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  781. > key_func(**step_value) # 调用方法
  782. core\ApiTestRunner.py:51:
  783. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  784. extend\keywords.py:183: in ex_mysqlData
  785. logger.info("数据库查询结果:", rs)
  786. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  787. self._log(INFO, msg, args, **kwargs)
  788. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  789. self.handle(record)
  790. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  791. self.callHandlers(record)
  792. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  793. hdlr.handle(record)
  794. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  795. self.emit(record)
  796. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  797. super().emit(record)
  798. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  799. self.handleError(record)
  800. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  801. msg = self.format(record)
  802. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  803. return fmt.format(record)
  804. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  805. return super().format(record)
  806. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  807. record.message = record.getMessage()
  808. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  809. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  810. def getMessage(self):
  811. """
  812. Return the message for this LogRecord.
  813. Return the message for this LogRecord after merging any user-supplied
  814. arguments with the message.
  815. """
  816. msg = str(self.msg)
  817. if self.args:
  818. > msg = msg % self.args
  819. E TypeError: not all arguments converted during string formatting
  820. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  821. 2024-11-04 20:25:39 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  822. 2024-11-04 20:25:39 INFO 用例耗时:0.20216299999999965 conftest.py pytest_runtest_makereport 72
  823. 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
  824. 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  825. 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  826. 2024-11-04 20:25:40 INFO -------------------测试用例名称:备份_我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
  827. 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P21] conftest.py pytest_runtest_makereport 68
  828. 2024-11-04 20:25:40 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  829. 2024-11-04 20:25:40 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27760>
  830. caseinfo = {'_case_name': '备份_我的书评-发布超过200个字的书评', 'desc': '备份_我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G0--P', ...}
  831. def test_case_execute(self, caseinfo):
  832. casename = caseinfo["_case_name"]
  833. # TODO 2-1 : 调用动态生成标题的方法
  834. dynamicTitle(caseinfo)
  835. # TODO 2-2: 基于我们步骤一步步进行执行
  836. try:
  837. # 实例化关键字对象
  838. keywords = KeyWords()
  839. # 获取当前用例变量,方便后续的渲染
  840. local_context = caseinfo.get("context",{})
  841. context = copy.deepcopy(g_context().show_dict())
  842. context.update(local_context)
  843. steps = caseinfo.get("steps", None)
  844. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  845. for index,step in enumerate(steps):
  846. # 提示信息
  847. step_name = list(step.keys())[0]
  848. step_value = list(step.values())[0]
  849. # TODO : 每一个步骤进行变量的渲染
  850. context = copy.deepcopy(g_context().show_dict())
  851. context.update(local_context)
  852. step_value = eval(refresh(step_value, context))
  853. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  854. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  855. # 通过【反射】的方式去找到对应的方法
  856. with allure.step(step_name):
  857. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  858. try:
  859. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  860. except AttributeError as e:
  861. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  862. > key_func(**step_value) # 调用方法
  863. core\ApiTestRunner.py:51:
  864. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  865. extend\keywords.py:183: in ex_mysqlData
  866. logger.info("数据库查询结果:", rs)
  867. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  868. self._log(INFO, msg, args, **kwargs)
  869. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  870. self.handle(record)
  871. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  872. self.callHandlers(record)
  873. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  874. hdlr.handle(record)
  875. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  876. self.emit(record)
  877. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  878. super().emit(record)
  879. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  880. self.handleError(record)
  881. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  882. msg = self.format(record)
  883. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  884. return fmt.format(record)
  885. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  886. return super().format(record)
  887. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  888. record.message = record.getMessage()
  889. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  890. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  891. def getMessage(self):
  892. """
  893. Return the message for this LogRecord.
  894. Return the message for this LogRecord after merging any user-supplied
  895. arguments with the message.
  896. """
  897. msg = str(self.msg)
  898. if self.args:
  899. > msg = msg % self.args
  900. E TypeError: not all arguments converted during string formatting
  901. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  902. 2024-11-04 20:25:40 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  903. 2024-11-04 20:25:40 INFO 用例耗时:0.2145910999999998 conftest.py pytest_runtest_makereport 72
  904. 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
  905. 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  906. 2024-11-04 20:25:40 INFO 测试用例名称:备份_点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  907. 2024-11-04 20:25:40 INFO 测试用例名称:备份_点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  908. 2024-11-04 20:25:40 INFO 测试用例名称:备份_点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  909. 2024-11-04 20:25:40 INFO -------------------测试用例名称:备份_点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  910. 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P22] conftest.py pytest_runtest_makereport 68
  911. 2024-11-04 20:25:40 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  912. 2024-11-04 20:25:40 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  913. 2024-11-04 20:25:40 INFO 异常:None conftest.py pytest_runtest_makereport 71
  914. 2024-11-04 20:25:40 INFO 用例耗时:0.12154480000000056 conftest.py pytest_runtest_makereport 72
  915. 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
  916. 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  917. 2024-11-04 20:25:40 INFO 测试用例名称:备份_我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  918. 2024-11-04 20:25:40 INFO -------------------测试用例名称:备份_我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  919. 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P23] conftest.py pytest_runtest_makereport 68
  920. 2024-11-04 20:25:40 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  921. 2024-11-04 20:25:40 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27B20>
  922. caseinfo = {'_case_name': '备份_我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '备份_我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G0--P', ...}
  923. def test_case_execute(self, caseinfo):
  924. casename = caseinfo["_case_name"]
  925. # TODO 2-1 : 调用动态生成标题的方法
  926. dynamicTitle(caseinfo)
  927. # TODO 2-2: 基于我们步骤一步步进行执行
  928. try:
  929. # 实例化关键字对象
  930. keywords = KeyWords()
  931. # 获取当前用例变量,方便后续的渲染
  932. local_context = caseinfo.get("context",{})
  933. context = copy.deepcopy(g_context().show_dict())
  934. context.update(local_context)
  935. steps = caseinfo.get("steps", None)
  936. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  937. for index,step in enumerate(steps):
  938. # 提示信息
  939. step_name = list(step.keys())[0]
  940. step_value = list(step.values())[0]
  941. # TODO : 每一个步骤进行变量的渲染
  942. context = copy.deepcopy(g_context().show_dict())
  943. context.update(local_context)
  944. step_value = eval(refresh(step_value, context))
  945. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  946. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  947. # 通过【反射】的方式去找到对应的方法
  948. with allure.step(step_name):
  949. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  950. try:
  951. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  952. except AttributeError as e:
  953. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  954. > key_func(**step_value) # 调用方法
  955. core\ApiTestRunner.py:51:
  956. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  957. extend\keywords.py:183: in ex_mysqlData
  958. logger.info("数据库查询结果:", rs)
  959. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  960. self._log(INFO, msg, args, **kwargs)
  961. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  962. self.handle(record)
  963. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  964. self.callHandlers(record)
  965. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  966. hdlr.handle(record)
  967. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  968. self.emit(record)
  969. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  970. super().emit(record)
  971. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  972. self.handleError(record)
  973. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  974. msg = self.format(record)
  975. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  976. return fmt.format(record)
  977. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  978. return super().format(record)
  979. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  980. record.message = record.getMessage()
  981. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  982. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  983. def getMessage(self):
  984. """
  985. Return the message for this LogRecord.
  986. Return the message for this LogRecord after merging any user-supplied
  987. arguments with the message.
  988. """
  989. msg = str(self.msg)
  990. if self.args:
  991. > msg = msg % self.args
  992. E TypeError: not all arguments converted during string formatting
  993. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  994. 2024-11-04 20:25:40 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  995. 2024-11-04 20:25:40 INFO 用例耗时:0.2079285999999998 conftest.py pytest_runtest_makereport 72
  996. 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
  997. 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  998. 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
  999. 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1000. 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1001. 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
  1002. 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1003. 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1004. 2024-11-04 20:25:40 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1005. 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P0] conftest.py pytest_runtest_makereport 68
  1006. 2024-11-04 20:25:40 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1007. 2024-11-04 20:25:40 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1008. 2024-11-04 20:25:40 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1009. 2024-11-04 20:25:40 INFO 用例耗时:0.08391579999999976 conftest.py pytest_runtest_makereport 72
  1010. 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1011. 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1012. 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
  1013. 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1014. 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1015. 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1016. 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1017. 2024-11-04 20:25:40 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1018. 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P1] conftest.py pytest_runtest_makereport 68
  1019. 2024-11-04 20:25:40 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1020. 2024-11-04 20:25:40 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1021. 2024-11-04 20:25:40 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1022. 2024-11-04 20:25:40 INFO 用例耗时:0.08588750000000012 conftest.py pytest_runtest_makereport 72
  1023. 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1024. 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1025. 2024-11-04 20:25:40 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}} ApiTestRunner.py test_case_execute 42
  1026. 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1027. 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1028. 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
  1029. 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1030. 2024-11-04 20:25:41 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1031. 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P2] conftest.py pytest_runtest_makereport 68
  1032. 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1033. 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1034. 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1035. 2024-11-04 20:25:41 INFO 用例耗时:0.08128289999999971 conftest.py pytest_runtest_makereport 72
  1036. 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1037. 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
  1038. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  1039. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1040. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1041. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1042. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1043. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
  1044. 2024-11-04 20:25:41 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1045. 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P3] conftest.py pytest_runtest_makereport 68
  1046. 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1047. 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1048. 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1049. 2024-11-04 20:25:41 INFO 用例耗时:0.08287570000000066 conftest.py pytest_runtest_makereport 72
  1050. 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1051. 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1052. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/d56a313d79204bd5a200b6604b6af8ac.png'}} ApiTestRunner.py test_case_execute 42
  1053. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1054. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1055. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1056. 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1057. 2024-11-04 20:25:41 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1058. 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P4] conftest.py pytest_runtest_makereport 68
  1059. 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1060. 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1061. 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1062. 2024-11-04 20:25:41 INFO 用例耗时:0.08997049999999973 conftest.py pytest_runtest_makereport 72
  1063. 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1064. 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1065. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1066. 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1067. 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P5] conftest.py pytest_runtest_makereport 68
  1068. 2024-11-04 20:25:41 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1069. 2024-11-04 20:25:41 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27100>
  1070. caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G1--P', ...}
  1071. def test_case_execute(self, caseinfo):
  1072. casename = caseinfo["_case_name"]
  1073. # TODO 2-1 : 调用动态生成标题的方法
  1074. dynamicTitle(caseinfo)
  1075. # TODO 2-2: 基于我们步骤一步步进行执行
  1076. try:
  1077. # 实例化关键字对象
  1078. keywords = KeyWords()
  1079. # 获取当前用例变量,方便后续的渲染
  1080. local_context = caseinfo.get("context",{})
  1081. context = copy.deepcopy(g_context().show_dict())
  1082. context.update(local_context)
  1083. steps = caseinfo.get("steps", None)
  1084. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1085. for index,step in enumerate(steps):
  1086. # 提示信息
  1087. step_name = list(step.keys())[0]
  1088. step_value = list(step.values())[0]
  1089. # TODO : 每一个步骤进行变量的渲染
  1090. context = copy.deepcopy(g_context().show_dict())
  1091. context.update(local_context)
  1092. step_value = eval(refresh(step_value, context))
  1093. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1094. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1095. # 通过【反射】的方式去找到对应的方法
  1096. with allure.step(step_name):
  1097. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1098. try:
  1099. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1100. except AttributeError as e:
  1101. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1102. > key_func(**step_value) # 调用方法
  1103. core\ApiTestRunner.py:51:
  1104. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1105. extend\keywords.py:183: in ex_mysqlData
  1106. logger.info("数据库查询结果:", rs)
  1107. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1108. self._log(INFO, msg, args, **kwargs)
  1109. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1110. self.handle(record)
  1111. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1112. self.callHandlers(record)
  1113. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1114. hdlr.handle(record)
  1115. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1116. self.emit(record)
  1117. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1118. super().emit(record)
  1119. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1120. self.handleError(record)
  1121. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1122. msg = self.format(record)
  1123. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1124. return fmt.format(record)
  1125. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1126. return super().format(record)
  1127. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1128. record.message = record.getMessage()
  1129. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1130. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1131. def getMessage(self):
  1132. """
  1133. Return the message for this LogRecord.
  1134. Return the message for this LogRecord after merging any user-supplied
  1135. arguments with the message.
  1136. """
  1137. msg = str(self.msg)
  1138. if self.args:
  1139. > msg = msg % self.args
  1140. E TypeError: not all arguments converted during string formatting
  1141. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1142. 2024-11-04 20:25:41 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1143. 2024-11-04 20:25:41 INFO 用例耗时:0.2237430000000007 conftest.py pytest_runtest_makereport 72
  1144. 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1145. 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1146. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  1147. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1148. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1149. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1150. 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1151. 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P6] conftest.py pytest_runtest_makereport 68
  1152. 2024-11-04 20:25:41 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1153. 2024-11-04 20:25:41 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215AD7ED520>
  1154. caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G1--P', ...}
  1155. def test_case_execute(self, caseinfo):
  1156. casename = caseinfo["_case_name"]
  1157. # TODO 2-1 : 调用动态生成标题的方法
  1158. dynamicTitle(caseinfo)
  1159. # TODO 2-2: 基于我们步骤一步步进行执行
  1160. try:
  1161. # 实例化关键字对象
  1162. keywords = KeyWords()
  1163. # 获取当前用例变量,方便后续的渲染
  1164. local_context = caseinfo.get("context",{})
  1165. context = copy.deepcopy(g_context().show_dict())
  1166. context.update(local_context)
  1167. steps = caseinfo.get("steps", None)
  1168. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1169. for index,step in enumerate(steps):
  1170. # 提示信息
  1171. step_name = list(step.keys())[0]
  1172. step_value = list(step.values())[0]
  1173. # TODO : 每一个步骤进行变量的渲染
  1174. context = copy.deepcopy(g_context().show_dict())
  1175. context.update(local_context)
  1176. step_value = eval(refresh(step_value, context))
  1177. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1178. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1179. # 通过【反射】的方式去找到对应的方法
  1180. with allure.step(step_name):
  1181. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1182. try:
  1183. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1184. except AttributeError as e:
  1185. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1186. > key_func(**step_value) # 调用方法
  1187. core\ApiTestRunner.py:51:
  1188. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1189. self = <apirun.extend.keywords.KeyWords object at 0x00000215ADF63370>
  1190. kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
  1191. comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADF42160>, '<': <function KeyWords.as...at 0x00000215ADF420D0>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFCB280>, ...}
  1192. message = None
  1193. @allure.step("参数数据:断言当前文本内容")
  1194. def assert_text_comparators(self, **kwargs):
  1195. """
  1196. 封装断言以进行不同的比较操作。
  1197. 参数:
  1198. value (Any): 要比较的值。
  1199. expected (Any): 预期的值。
  1200. op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
  1201. message (str, optional): 自定义的错误消息。
  1202. 返回:
  1203. None: 如果断言成功,则不返回任何内容。
  1204. 引发:
  1205. AssertionError: 如果断言失败。
  1206. """
  1207. comparators = {
  1208. '>': lambda a, b: a > b,
  1209. '<': lambda a, b: a < b,
  1210. '==': lambda a, b: a == b,
  1211. '>=': lambda a, b: a >= b,
  1212. '<=': lambda a, b: a <= b,
  1213. '!=': lambda a, b: a != b,
  1214. }
  1215. message = kwargs.get("MESSAGE", None)
  1216. if kwargs["OP_STR"] not in comparators:
  1217. raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
  1218. if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
  1219. if message:
  1220. raise AssertionError(message)
  1221. else:
  1222. > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
  1223. E AssertionError: SUCCESS == 书籍ID不存在 失败
  1224. extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
  1225. 2024-11-04 20:25:41 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
  1226. 2024-11-04 20:25:41 INFO 用例耗时:0.1314056000000008 conftest.py pytest_runtest_makereport 72
  1227. 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1228. 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1229. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  1230. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1231. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1232. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1233. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1234. 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1235. 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P7] conftest.py pytest_runtest_makereport 68
  1236. 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1237. 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1238. 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1239. 2024-11-04 20:25:41 INFO 用例耗时:0.09981740000000006 conftest.py pytest_runtest_makereport 72
  1240. 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1241. 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1242. 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1243. 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1244. 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P8] conftest.py pytest_runtest_makereport 68
  1245. 2024-11-04 20:25:42 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1246. 2024-11-04 20:25:42 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215AD7ED3D0>
  1247. caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G1--P', ...}
  1248. def test_case_execute(self, caseinfo):
  1249. casename = caseinfo["_case_name"]
  1250. # TODO 2-1 : 调用动态生成标题的方法
  1251. dynamicTitle(caseinfo)
  1252. # TODO 2-2: 基于我们步骤一步步进行执行
  1253. try:
  1254. # 实例化关键字对象
  1255. keywords = KeyWords()
  1256. # 获取当前用例变量,方便后续的渲染
  1257. local_context = caseinfo.get("context",{})
  1258. context = copy.deepcopy(g_context().show_dict())
  1259. context.update(local_context)
  1260. steps = caseinfo.get("steps", None)
  1261. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1262. for index,step in enumerate(steps):
  1263. # 提示信息
  1264. step_name = list(step.keys())[0]
  1265. step_value = list(step.values())[0]
  1266. # TODO : 每一个步骤进行变量的渲染
  1267. context = copy.deepcopy(g_context().show_dict())
  1268. context.update(local_context)
  1269. step_value = eval(refresh(step_value, context))
  1270. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1271. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1272. # 通过【反射】的方式去找到对应的方法
  1273. with allure.step(step_name):
  1274. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1275. try:
  1276. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1277. except AttributeError as e:
  1278. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1279. > key_func(**step_value) # 调用方法
  1280. core\ApiTestRunner.py:51:
  1281. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1282. extend\keywords.py:183: in ex_mysqlData
  1283. logger.info("数据库查询结果:", rs)
  1284. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1285. self._log(INFO, msg, args, **kwargs)
  1286. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1287. self.handle(record)
  1288. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1289. self.callHandlers(record)
  1290. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1291. hdlr.handle(record)
  1292. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1293. self.emit(record)
  1294. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1295. super().emit(record)
  1296. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1297. self.handleError(record)
  1298. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1299. msg = self.format(record)
  1300. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1301. return fmt.format(record)
  1302. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1303. return super().format(record)
  1304. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1305. record.message = record.getMessage()
  1306. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1307. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1308. def getMessage(self):
  1309. """
  1310. Return the message for this LogRecord.
  1311. Return the message for this LogRecord after merging any user-supplied
  1312. arguments with the message.
  1313. """
  1314. msg = str(self.msg)
  1315. if self.args:
  1316. > msg = msg % self.args
  1317. E TypeError: not all arguments converted during string formatting
  1318. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1319. 2024-11-04 20:25:42 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1320. 2024-11-04 20:25:42 INFO 用例耗时:0.22421609999999959 conftest.py pytest_runtest_makereport 72
  1321. 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1322. 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1323. 2024-11-04 20:25:42 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1324. 2024-11-04 20:25:42 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1325. 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P9] conftest.py pytest_runtest_makereport 68
  1326. 2024-11-04 20:25:42 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1327. 2024-11-04 20:25:42 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91130>
  1328. caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G1--P', ...}
  1329. def test_case_execute(self, caseinfo):
  1330. casename = caseinfo["_case_name"]
  1331. # TODO 2-1 : 调用动态生成标题的方法
  1332. dynamicTitle(caseinfo)
  1333. # TODO 2-2: 基于我们步骤一步步进行执行
  1334. try:
  1335. # 实例化关键字对象
  1336. keywords = KeyWords()
  1337. # 获取当前用例变量,方便后续的渲染
  1338. local_context = caseinfo.get("context",{})
  1339. context = copy.deepcopy(g_context().show_dict())
  1340. context.update(local_context)
  1341. steps = caseinfo.get("steps", None)
  1342. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1343. for index,step in enumerate(steps):
  1344. # 提示信息
  1345. step_name = list(step.keys())[0]
  1346. step_value = list(step.values())[0]
  1347. # TODO : 每一个步骤进行变量的渲染
  1348. context = copy.deepcopy(g_context().show_dict())
  1349. context.update(local_context)
  1350. step_value = eval(refresh(step_value, context))
  1351. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1352. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1353. # 通过【反射】的方式去找到对应的方法
  1354. with allure.step(step_name):
  1355. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1356. try:
  1357. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1358. except AttributeError as e:
  1359. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1360. > key_func(**step_value) # 调用方法
  1361. core\ApiTestRunner.py:51:
  1362. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1363. extend\keywords.py:183: in ex_mysqlData
  1364. logger.info("数据库查询结果:", rs)
  1365. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1366. self._log(INFO, msg, args, **kwargs)
  1367. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1368. self.handle(record)
  1369. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1370. self.callHandlers(record)
  1371. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1372. hdlr.handle(record)
  1373. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1374. self.emit(record)
  1375. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1376. super().emit(record)
  1377. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1378. self.handleError(record)
  1379. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1380. msg = self.format(record)
  1381. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1382. return fmt.format(record)
  1383. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1384. return super().format(record)
  1385. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1386. record.message = record.getMessage()
  1387. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1388. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1389. def getMessage(self):
  1390. """
  1391. Return the message for this LogRecord.
  1392. Return the message for this LogRecord after merging any user-supplied
  1393. arguments with the message.
  1394. """
  1395. msg = str(self.msg)
  1396. if self.args:
  1397. > msg = msg % self.args
  1398. E TypeError: not all arguments converted during string formatting
  1399. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1400. 2024-11-04 20:25:42 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1401. 2024-11-04 20:25:42 INFO 用例耗时:0.21816670000000027 conftest.py pytest_runtest_makereport 72
  1402. 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1403. 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1404. 2024-11-04 20:25:42 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  1405. 2024-11-04 20:25:42 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1406. 2024-11-04 20:25:42 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1407. 2024-11-04 20:25:42 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1408. 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P10] conftest.py pytest_runtest_makereport 68
  1409. 2024-11-04 20:25:42 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1410. 2024-11-04 20:25:42 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1411. 2024-11-04 20:25:42 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1412. 2024-11-04 20:25:42 INFO 用例耗时:0.12021320000000024 conftest.py pytest_runtest_makereport 72
  1413. 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1414. 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1415. 2024-11-04 20:25:42 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1416. 2024-11-04 20:25:42 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1417. 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P11] conftest.py pytest_runtest_makereport 68
  1418. 2024-11-04 20:25:42 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1419. 2024-11-04 20:25:42 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD912B0>
  1420. caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G1--P', ...}
  1421. def test_case_execute(self, caseinfo):
  1422. casename = caseinfo["_case_name"]
  1423. # TODO 2-1 : 调用动态生成标题的方法
  1424. dynamicTitle(caseinfo)
  1425. # TODO 2-2: 基于我们步骤一步步进行执行
  1426. try:
  1427. # 实例化关键字对象
  1428. keywords = KeyWords()
  1429. # 获取当前用例变量,方便后续的渲染
  1430. local_context = caseinfo.get("context",{})
  1431. context = copy.deepcopy(g_context().show_dict())
  1432. context.update(local_context)
  1433. steps = caseinfo.get("steps", None)
  1434. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1435. for index,step in enumerate(steps):
  1436. # 提示信息
  1437. step_name = list(step.keys())[0]
  1438. step_value = list(step.values())[0]
  1439. # TODO : 每一个步骤进行变量的渲染
  1440. context = copy.deepcopy(g_context().show_dict())
  1441. context.update(local_context)
  1442. step_value = eval(refresh(step_value, context))
  1443. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1444. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1445. # 通过【反射】的方式去找到对应的方法
  1446. with allure.step(step_name):
  1447. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1448. try:
  1449. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1450. except AttributeError as e:
  1451. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1452. > key_func(**step_value) # 调用方法
  1453. core\ApiTestRunner.py:51:
  1454. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1455. extend\keywords.py:183: in ex_mysqlData
  1456. logger.info("数据库查询结果:", rs)
  1457. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1458. self._log(INFO, msg, args, **kwargs)
  1459. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1460. self.handle(record)
  1461. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1462. self.callHandlers(record)
  1463. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1464. hdlr.handle(record)
  1465. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1466. self.emit(record)
  1467. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1468. super().emit(record)
  1469. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1470. self.handleError(record)
  1471. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1472. msg = self.format(record)
  1473. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1474. return fmt.format(record)
  1475. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1476. return super().format(record)
  1477. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1478. record.message = record.getMessage()
  1479. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1480. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1481. def getMessage(self):
  1482. """
  1483. Return the message for this LogRecord.
  1484. Return the message for this LogRecord after merging any user-supplied
  1485. arguments with the message.
  1486. """
  1487. msg = str(self.msg)
  1488. if self.args:
  1489. > msg = msg % self.args
  1490. E TypeError: not all arguments converted during string formatting
  1491. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1492. 2024-11-04 20:25:42 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1493. 2024-11-04 20:25:42 INFO 用例耗时:0.2180433000000006 conftest.py pytest_runtest_makereport 72
  1494. 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1495. 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1496. 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
  1497. 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1498. 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1499. 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
  1500. 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1501. 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1502. 2024-11-04 20:25:42 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1503. 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P0] conftest.py pytest_runtest_makereport 68
  1504. 2024-11-04 20:25:42 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1505. 2024-11-04 20:25:42 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1506. 2024-11-04 20:25:42 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1507. 2024-11-04 20:25:42 INFO 用例耗时:0.08833190000000002 conftest.py pytest_runtest_makereport 72
  1508. 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1509. 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1510. 2024-11-04 20:25:42 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
  1511. 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1512. 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1513. 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1514. 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1515. 2024-11-04 20:25:43 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1516. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P1] conftest.py pytest_runtest_makereport 68
  1517. 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1518. 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1519. 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1520. 2024-11-04 20:25:43 INFO 用例耗时:0.08791390000000021 conftest.py pytest_runtest_makereport 72
  1521. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1522. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1523. 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}} ApiTestRunner.py test_case_execute 42
  1524. 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1525. 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1526. 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
  1527. 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1528. 2024-11-04 20:25:43 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1529. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P2] conftest.py pytest_runtest_makereport 68
  1530. 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1531. 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1532. 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1533. 2024-11-04 20:25:43 INFO 用例耗时:0.08571500000000043 conftest.py pytest_runtest_makereport 72
  1534. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1535. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
  1536. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  1537. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1538. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1539. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1540. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1541. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
  1542. 2024-11-04 20:25:43 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1543. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P3] conftest.py pytest_runtest_makereport 68
  1544. 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1545. 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1546. 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1547. 2024-11-04 20:25:43 INFO 用例耗时:0.08649390000000068 conftest.py pytest_runtest_makereport 72
  1548. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1549. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1550. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/570f407f9a3e466caa6f146b4f9b8af4.png'}} ApiTestRunner.py test_case_execute 42
  1551. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1552. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1553. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1554. 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1555. 2024-11-04 20:25:43 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1556. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P4] conftest.py pytest_runtest_makereport 68
  1557. 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1558. 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1559. 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1560. 2024-11-04 20:25:43 INFO 用例耗时:0.09365689999999915 conftest.py pytest_runtest_makereport 72
  1561. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1562. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1563. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1564. 2024-11-04 20:25:43 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1565. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P5] conftest.py pytest_runtest_makereport 68
  1566. 2024-11-04 20:25:43 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1567. 2024-11-04 20:25:43 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91730>
  1568. caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G3--P', ...}
  1569. def test_case_execute(self, caseinfo):
  1570. casename = caseinfo["_case_name"]
  1571. # TODO 2-1 : 调用动态生成标题的方法
  1572. dynamicTitle(caseinfo)
  1573. # TODO 2-2: 基于我们步骤一步步进行执行
  1574. try:
  1575. # 实例化关键字对象
  1576. keywords = KeyWords()
  1577. # 获取当前用例变量,方便后续的渲染
  1578. local_context = caseinfo.get("context",{})
  1579. context = copy.deepcopy(g_context().show_dict())
  1580. context.update(local_context)
  1581. steps = caseinfo.get("steps", None)
  1582. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1583. for index,step in enumerate(steps):
  1584. # 提示信息
  1585. step_name = list(step.keys())[0]
  1586. step_value = list(step.values())[0]
  1587. # TODO : 每一个步骤进行变量的渲染
  1588. context = copy.deepcopy(g_context().show_dict())
  1589. context.update(local_context)
  1590. step_value = eval(refresh(step_value, context))
  1591. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1592. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1593. # 通过【反射】的方式去找到对应的方法
  1594. with allure.step(step_name):
  1595. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1596. try:
  1597. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1598. except AttributeError as e:
  1599. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1600. > key_func(**step_value) # 调用方法
  1601. core\ApiTestRunner.py:51:
  1602. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1603. extend\keywords.py:183: in ex_mysqlData
  1604. logger.info("数据库查询结果:", rs)
  1605. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1606. self._log(INFO, msg, args, **kwargs)
  1607. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1608. self.handle(record)
  1609. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1610. self.callHandlers(record)
  1611. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1612. hdlr.handle(record)
  1613. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1614. self.emit(record)
  1615. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1616. super().emit(record)
  1617. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1618. self.handleError(record)
  1619. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1620. msg = self.format(record)
  1621. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1622. return fmt.format(record)
  1623. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1624. return super().format(record)
  1625. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1626. record.message = record.getMessage()
  1627. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1628. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1629. def getMessage(self):
  1630. """
  1631. Return the message for this LogRecord.
  1632. Return the message for this LogRecord after merging any user-supplied
  1633. arguments with the message.
  1634. """
  1635. msg = str(self.msg)
  1636. if self.args:
  1637. > msg = msg % self.args
  1638. E TypeError: not all arguments converted during string formatting
  1639. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1640. 2024-11-04 20:25:43 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1641. 2024-11-04 20:25:43 INFO 用例耗时:0.22499270000000138 conftest.py pytest_runtest_makereport 72
  1642. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1643. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1644. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  1645. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1646. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1647. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1648. 2024-11-04 20:25:43 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1649. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P6] conftest.py pytest_runtest_makereport 68
  1650. 2024-11-04 20:25:43 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1651. 2024-11-04 20:25:43 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD917F0>
  1652. caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G3--P', ...}
  1653. def test_case_execute(self, caseinfo):
  1654. casename = caseinfo["_case_name"]
  1655. # TODO 2-1 : 调用动态生成标题的方法
  1656. dynamicTitle(caseinfo)
  1657. # TODO 2-2: 基于我们步骤一步步进行执行
  1658. try:
  1659. # 实例化关键字对象
  1660. keywords = KeyWords()
  1661. # 获取当前用例变量,方便后续的渲染
  1662. local_context = caseinfo.get("context",{})
  1663. context = copy.deepcopy(g_context().show_dict())
  1664. context.update(local_context)
  1665. steps = caseinfo.get("steps", None)
  1666. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1667. for index,step in enumerate(steps):
  1668. # 提示信息
  1669. step_name = list(step.keys())[0]
  1670. step_value = list(step.values())[0]
  1671. # TODO : 每一个步骤进行变量的渲染
  1672. context = copy.deepcopy(g_context().show_dict())
  1673. context.update(local_context)
  1674. step_value = eval(refresh(step_value, context))
  1675. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1676. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1677. # 通过【反射】的方式去找到对应的方法
  1678. with allure.step(step_name):
  1679. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1680. try:
  1681. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1682. except AttributeError as e:
  1683. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1684. > key_func(**step_value) # 调用方法
  1685. core\ApiTestRunner.py:51:
  1686. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1687. self = <apirun.extend.keywords.KeyWords object at 0x00000215AE0D9490>
  1688. kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
  1689. comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADF675E0>, '<': <function KeyWords.as...at 0x00000215ADF67550>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADF67430>, ...}
  1690. message = None
  1691. @allure.step("参数数据:断言当前文本内容")
  1692. def assert_text_comparators(self, **kwargs):
  1693. """
  1694. 封装断言以进行不同的比较操作。
  1695. 参数:
  1696. value (Any): 要比较的值。
  1697. expected (Any): 预期的值。
  1698. op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
  1699. message (str, optional): 自定义的错误消息。
  1700. 返回:
  1701. None: 如果断言成功,则不返回任何内容。
  1702. 引发:
  1703. AssertionError: 如果断言失败。
  1704. """
  1705. comparators = {
  1706. '>': lambda a, b: a > b,
  1707. '<': lambda a, b: a < b,
  1708. '==': lambda a, b: a == b,
  1709. '>=': lambda a, b: a >= b,
  1710. '<=': lambda a, b: a <= b,
  1711. '!=': lambda a, b: a != b,
  1712. }
  1713. message = kwargs.get("MESSAGE", None)
  1714. if kwargs["OP_STR"] not in comparators:
  1715. raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
  1716. if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
  1717. if message:
  1718. raise AssertionError(message)
  1719. else:
  1720. > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
  1721. E AssertionError: SUCCESS == 书籍ID不存在 失败
  1722. extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
  1723. 2024-11-04 20:25:43 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
  1724. 2024-11-04 20:25:43 INFO 用例耗时:0.1124168000000001 conftest.py pytest_runtest_makereport 72
  1725. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1726. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1727. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  1728. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1729. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1730. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1731. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1732. 2024-11-04 20:25:43 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1733. 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P7] conftest.py pytest_runtest_makereport 68
  1734. 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1735. 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1736. 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1737. 2024-11-04 20:25:43 INFO 用例耗时:0.09828979999999987 conftest.py pytest_runtest_makereport 72
  1738. 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1739. 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1740. 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1741. 2024-11-04 20:25:44 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1742. 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P8] conftest.py pytest_runtest_makereport 68
  1743. 2024-11-04 20:25:44 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1744. 2024-11-04 20:25:44 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91970>
  1745. caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G3--P', ...}
  1746. def test_case_execute(self, caseinfo):
  1747. casename = caseinfo["_case_name"]
  1748. # TODO 2-1 : 调用动态生成标题的方法
  1749. dynamicTitle(caseinfo)
  1750. # TODO 2-2: 基于我们步骤一步步进行执行
  1751. try:
  1752. # 实例化关键字对象
  1753. keywords = KeyWords()
  1754. # 获取当前用例变量,方便后续的渲染
  1755. local_context = caseinfo.get("context",{})
  1756. context = copy.deepcopy(g_context().show_dict())
  1757. context.update(local_context)
  1758. steps = caseinfo.get("steps", None)
  1759. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1760. for index,step in enumerate(steps):
  1761. # 提示信息
  1762. step_name = list(step.keys())[0]
  1763. step_value = list(step.values())[0]
  1764. # TODO : 每一个步骤进行变量的渲染
  1765. context = copy.deepcopy(g_context().show_dict())
  1766. context.update(local_context)
  1767. step_value = eval(refresh(step_value, context))
  1768. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1769. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1770. # 通过【反射】的方式去找到对应的方法
  1771. with allure.step(step_name):
  1772. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1773. try:
  1774. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1775. except AttributeError as e:
  1776. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1777. > key_func(**step_value) # 调用方法
  1778. core\ApiTestRunner.py:51:
  1779. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1780. extend\keywords.py:183: in ex_mysqlData
  1781. logger.info("数据库查询结果:", rs)
  1782. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1783. self._log(INFO, msg, args, **kwargs)
  1784. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1785. self.handle(record)
  1786. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1787. self.callHandlers(record)
  1788. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1789. hdlr.handle(record)
  1790. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1791. self.emit(record)
  1792. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1793. super().emit(record)
  1794. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1795. self.handleError(record)
  1796. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1797. msg = self.format(record)
  1798. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1799. return fmt.format(record)
  1800. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1801. return super().format(record)
  1802. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1803. record.message = record.getMessage()
  1804. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1805. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1806. def getMessage(self):
  1807. """
  1808. Return the message for this LogRecord.
  1809. Return the message for this LogRecord after merging any user-supplied
  1810. arguments with the message.
  1811. """
  1812. msg = str(self.msg)
  1813. if self.args:
  1814. > msg = msg % self.args
  1815. E TypeError: not all arguments converted during string formatting
  1816. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1817. 2024-11-04 20:25:44 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1818. 2024-11-04 20:25:44 INFO 用例耗时:0.2153898999999999 conftest.py pytest_runtest_makereport 72
  1819. 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1820. 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1821. 2024-11-04 20:25:44 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1822. 2024-11-04 20:25:44 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1823. 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P9] conftest.py pytest_runtest_makereport 68
  1824. 2024-11-04 20:25:44 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1825. 2024-11-04 20:25:44 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91A30>
  1826. caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G3--P', ...}
  1827. def test_case_execute(self, caseinfo):
  1828. casename = caseinfo["_case_name"]
  1829. # TODO 2-1 : 调用动态生成标题的方法
  1830. dynamicTitle(caseinfo)
  1831. # TODO 2-2: 基于我们步骤一步步进行执行
  1832. try:
  1833. # 实例化关键字对象
  1834. keywords = KeyWords()
  1835. # 获取当前用例变量,方便后续的渲染
  1836. local_context = caseinfo.get("context",{})
  1837. context = copy.deepcopy(g_context().show_dict())
  1838. context.update(local_context)
  1839. steps = caseinfo.get("steps", None)
  1840. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1841. for index,step in enumerate(steps):
  1842. # 提示信息
  1843. step_name = list(step.keys())[0]
  1844. step_value = list(step.values())[0]
  1845. # TODO : 每一个步骤进行变量的渲染
  1846. context = copy.deepcopy(g_context().show_dict())
  1847. context.update(local_context)
  1848. step_value = eval(refresh(step_value, context))
  1849. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1850. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1851. # 通过【反射】的方式去找到对应的方法
  1852. with allure.step(step_name):
  1853. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1854. try:
  1855. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1856. except AttributeError as e:
  1857. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1858. > key_func(**step_value) # 调用方法
  1859. core\ApiTestRunner.py:51:
  1860. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1861. extend\keywords.py:183: in ex_mysqlData
  1862. logger.info("数据库查询结果:", rs)
  1863. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1864. self._log(INFO, msg, args, **kwargs)
  1865. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1866. self.handle(record)
  1867. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1868. self.callHandlers(record)
  1869. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1870. hdlr.handle(record)
  1871. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1872. self.emit(record)
  1873. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1874. super().emit(record)
  1875. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1876. self.handleError(record)
  1877. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1878. msg = self.format(record)
  1879. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1880. return fmt.format(record)
  1881. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1882. return super().format(record)
  1883. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1884. record.message = record.getMessage()
  1885. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1886. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1887. def getMessage(self):
  1888. """
  1889. Return the message for this LogRecord.
  1890. Return the message for this LogRecord after merging any user-supplied
  1891. arguments with the message.
  1892. """
  1893. msg = str(self.msg)
  1894. if self.args:
  1895. > msg = msg % self.args
  1896. E TypeError: not all arguments converted during string formatting
  1897. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1898. 2024-11-04 20:25:44 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1899. 2024-11-04 20:25:44 INFO 用例耗时:0.21632590000000107 conftest.py pytest_runtest_makereport 72
  1900. 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1901. 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1902. 2024-11-04 20:25:44 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  1903. 2024-11-04 20:25:44 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1904. 2024-11-04 20:25:44 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1905. 2024-11-04 20:25:44 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1906. 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P10] conftest.py pytest_runtest_makereport 68
  1907. 2024-11-04 20:25:44 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  1908. 2024-11-04 20:25:44 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  1909. 2024-11-04 20:25:44 INFO 异常:None conftest.py pytest_runtest_makereport 71
  1910. 2024-11-04 20:25:44 INFO 用例耗时:0.10466459999999955 conftest.py pytest_runtest_makereport 72
  1911. 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1912. 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1913. 2024-11-04 20:25:44 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  1914. 2024-11-04 20:25:44 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  1915. 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P11] conftest.py pytest_runtest_makereport 68
  1916. 2024-11-04 20:25:44 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  1917. 2024-11-04 20:25:44 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91BB0>
  1918. caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G3--P', ...}
  1919. def test_case_execute(self, caseinfo):
  1920. casename = caseinfo["_case_name"]
  1921. # TODO 2-1 : 调用动态生成标题的方法
  1922. dynamicTitle(caseinfo)
  1923. # TODO 2-2: 基于我们步骤一步步进行执行
  1924. try:
  1925. # 实例化关键字对象
  1926. keywords = KeyWords()
  1927. # 获取当前用例变量,方便后续的渲染
  1928. local_context = caseinfo.get("context",{})
  1929. context = copy.deepcopy(g_context().show_dict())
  1930. context.update(local_context)
  1931. steps = caseinfo.get("steps", None)
  1932. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  1933. for index,step in enumerate(steps):
  1934. # 提示信息
  1935. step_name = list(step.keys())[0]
  1936. step_value = list(step.values())[0]
  1937. # TODO : 每一个步骤进行变量的渲染
  1938. context = copy.deepcopy(g_context().show_dict())
  1939. context.update(local_context)
  1940. step_value = eval(refresh(step_value, context))
  1941. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  1942. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  1943. # 通过【反射】的方式去找到对应的方法
  1944. with allure.step(step_name):
  1945. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  1946. try:
  1947. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  1948. except AttributeError as e:
  1949. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  1950. > key_func(**step_value) # 调用方法
  1951. core\ApiTestRunner.py:51:
  1952. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1953. extend\keywords.py:183: in ex_mysqlData
  1954. logger.info("数据库查询结果:", rs)
  1955. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  1956. self._log(INFO, msg, args, **kwargs)
  1957. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  1958. self.handle(record)
  1959. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  1960. self.callHandlers(record)
  1961. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  1962. hdlr.handle(record)
  1963. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  1964. self.emit(record)
  1965. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  1966. super().emit(record)
  1967. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  1968. self.handleError(record)
  1969. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  1970. msg = self.format(record)
  1971. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  1972. return fmt.format(record)
  1973. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  1974. return super().format(record)
  1975. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  1976. record.message = record.getMessage()
  1977. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1978. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  1979. def getMessage(self):
  1980. """
  1981. Return the message for this LogRecord.
  1982. Return the message for this LogRecord after merging any user-supplied
  1983. arguments with the message.
  1984. """
  1985. msg = str(self.msg)
  1986. if self.args:
  1987. > msg = msg % self.args
  1988. E TypeError: not all arguments converted during string formatting
  1989. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  1990. 2024-11-04 20:25:44 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  1991. 2024-11-04 20:25:44 INFO 用例耗时:0.21585119999999947 conftest.py pytest_runtest_makereport 72
  1992. 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
  1993. 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  1994. 2024-11-04 20:25:44 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
  1995. 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  1996. 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  1997. 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
  1998. 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  1999. 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2000. 2024-11-04 20:25:45 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2001. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P0] conftest.py pytest_runtest_makereport 68
  2002. 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2003. 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2004. 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2005. 2024-11-04 20:25:45 INFO 用例耗时:0.08543449999999986 conftest.py pytest_runtest_makereport 72
  2006. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2007. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2008. 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
  2009. 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2010. 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  2011. 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2012. 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2013. 2024-11-04 20:25:45 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2014. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P1] conftest.py pytest_runtest_makereport 68
  2015. 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2016. 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2017. 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2018. 2024-11-04 20:25:45 INFO 用例耗时:0.09628380000000014 conftest.py pytest_runtest_makereport 72
  2019. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2020. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2021. 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}} ApiTestRunner.py test_case_execute 42
  2022. 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2023. 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2024. 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
  2025. 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2026. 2024-11-04 20:25:45 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2027. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P2] conftest.py pytest_runtest_makereport 68
  2028. 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2029. 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2030. 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2031. 2024-11-04 20:25:45 INFO 用例耗时:0.08434860000000022 conftest.py pytest_runtest_makereport 72
  2032. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2033. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
  2034. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  2035. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2036. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  2037. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2038. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2039. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
  2040. 2024-11-04 20:25:45 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2041. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P3] conftest.py pytest_runtest_makereport 68
  2042. 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2043. 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2044. 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2045. 2024-11-04 20:25:45 INFO 用例耗时:0.08542759999999916 conftest.py pytest_runtest_makereport 72
  2046. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2047. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2048. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/23464fa16c494ce7a9e26777e98ccf00.png'}} ApiTestRunner.py test_case_execute 42
  2049. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2050. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  2051. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2052. 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2053. 2024-11-04 20:25:45 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2054. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P4] conftest.py pytest_runtest_makereport 68
  2055. 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2056. 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2057. 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2058. 2024-11-04 20:25:45 INFO 用例耗时:0.09263550000000009 conftest.py pytest_runtest_makereport 72
  2059. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2060. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2061. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  2062. 2024-11-04 20:25:45 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2063. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P5] conftest.py pytest_runtest_makereport 68
  2064. 2024-11-04 20:25:45 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  2065. 2024-11-04 20:25:45 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91FD0>
  2066. caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G2--P', ...}
  2067. def test_case_execute(self, caseinfo):
  2068. casename = caseinfo["_case_name"]
  2069. # TODO 2-1 : 调用动态生成标题的方法
  2070. dynamicTitle(caseinfo)
  2071. # TODO 2-2: 基于我们步骤一步步进行执行
  2072. try:
  2073. # 实例化关键字对象
  2074. keywords = KeyWords()
  2075. # 获取当前用例变量,方便后续的渲染
  2076. local_context = caseinfo.get("context",{})
  2077. context = copy.deepcopy(g_context().show_dict())
  2078. context.update(local_context)
  2079. steps = caseinfo.get("steps", None)
  2080. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  2081. for index,step in enumerate(steps):
  2082. # 提示信息
  2083. step_name = list(step.keys())[0]
  2084. step_value = list(step.values())[0]
  2085. # TODO : 每一个步骤进行变量的渲染
  2086. context = copy.deepcopy(g_context().show_dict())
  2087. context.update(local_context)
  2088. step_value = eval(refresh(step_value, context))
  2089. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  2090. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  2091. # 通过【反射】的方式去找到对应的方法
  2092. with allure.step(step_name):
  2093. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  2094. try:
  2095. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  2096. except AttributeError as e:
  2097. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  2098. > key_func(**step_value) # 调用方法
  2099. core\ApiTestRunner.py:51:
  2100. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2101. extend\keywords.py:183: in ex_mysqlData
  2102. logger.info("数据库查询结果:", rs)
  2103. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  2104. self._log(INFO, msg, args, **kwargs)
  2105. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  2106. self.handle(record)
  2107. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  2108. self.callHandlers(record)
  2109. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  2110. hdlr.handle(record)
  2111. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  2112. self.emit(record)
  2113. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  2114. super().emit(record)
  2115. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  2116. self.handleError(record)
  2117. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  2118. msg = self.format(record)
  2119. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  2120. return fmt.format(record)
  2121. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  2122. return super().format(record)
  2123. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  2124. record.message = record.getMessage()
  2125. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2126. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  2127. def getMessage(self):
  2128. """
  2129. Return the message for this LogRecord.
  2130. Return the message for this LogRecord after merging any user-supplied
  2131. arguments with the message.
  2132. """
  2133. msg = str(self.msg)
  2134. if self.args:
  2135. > msg = msg % self.args
  2136. E TypeError: not all arguments converted during string formatting
  2137. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  2138. 2024-11-04 20:25:45 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  2139. 2024-11-04 20:25:45 INFO 用例耗时:0.21499640000000042 conftest.py pytest_runtest_makereport 72
  2140. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2141. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2142. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  2143. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2144. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  2145. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2146. 2024-11-04 20:25:45 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2147. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P6] conftest.py pytest_runtest_makereport 68
  2148. 2024-11-04 20:25:45 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  2149. 2024-11-04 20:25:45 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADC8DFA0>
  2150. caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G2--P', ...}
  2151. def test_case_execute(self, caseinfo):
  2152. casename = caseinfo["_case_name"]
  2153. # TODO 2-1 : 调用动态生成标题的方法
  2154. dynamicTitle(caseinfo)
  2155. # TODO 2-2: 基于我们步骤一步步进行执行
  2156. try:
  2157. # 实例化关键字对象
  2158. keywords = KeyWords()
  2159. # 获取当前用例变量,方便后续的渲染
  2160. local_context = caseinfo.get("context",{})
  2161. context = copy.deepcopy(g_context().show_dict())
  2162. context.update(local_context)
  2163. steps = caseinfo.get("steps", None)
  2164. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  2165. for index,step in enumerate(steps):
  2166. # 提示信息
  2167. step_name = list(step.keys())[0]
  2168. step_value = list(step.values())[0]
  2169. # TODO : 每一个步骤进行变量的渲染
  2170. context = copy.deepcopy(g_context().show_dict())
  2171. context.update(local_context)
  2172. step_value = eval(refresh(step_value, context))
  2173. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  2174. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  2175. # 通过【反射】的方式去找到对应的方法
  2176. with allure.step(step_name):
  2177. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  2178. try:
  2179. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  2180. except AttributeError as e:
  2181. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  2182. > key_func(**step_value) # 调用方法
  2183. core\ApiTestRunner.py:51:
  2184. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2185. self = <apirun.extend.keywords.KeyWords object at 0x00000215ADFEA310>
  2186. kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
  2187. comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215AE0B3430>, '<': <function KeyWords.as...at 0x00000215AE0B33A0>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215AE0B3700>, ...}
  2188. message = None
  2189. @allure.step("参数数据:断言当前文本内容")
  2190. def assert_text_comparators(self, **kwargs):
  2191. """
  2192. 封装断言以进行不同的比较操作。
  2193. 参数:
  2194. value (Any): 要比较的值。
  2195. expected (Any): 预期的值。
  2196. op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
  2197. message (str, optional): 自定义的错误消息。
  2198. 返回:
  2199. None: 如果断言成功,则不返回任何内容。
  2200. 引发:
  2201. AssertionError: 如果断言失败。
  2202. """
  2203. comparators = {
  2204. '>': lambda a, b: a > b,
  2205. '<': lambda a, b: a < b,
  2206. '==': lambda a, b: a == b,
  2207. '>=': lambda a, b: a >= b,
  2208. '<=': lambda a, b: a <= b,
  2209. '!=': lambda a, b: a != b,
  2210. }
  2211. message = kwargs.get("MESSAGE", None)
  2212. if kwargs["OP_STR"] not in comparators:
  2213. raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
  2214. if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
  2215. if message:
  2216. raise AssertionError(message)
  2217. else:
  2218. > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
  2219. E AssertionError: SUCCESS == 书籍ID不存在 失败
  2220. extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
  2221. 2024-11-04 20:25:45 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
  2222. 2024-11-04 20:25:45 INFO 用例耗时:0.11337829999999904 conftest.py pytest_runtest_makereport 72
  2223. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2224. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2225. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
  2226. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2227. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
  2228. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2229. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2230. 2024-11-04 20:25:45 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2231. 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P7] conftest.py pytest_runtest_makereport 68
  2232. 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2233. 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2234. 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2235. 2024-11-04 20:25:45 INFO 用例耗时:0.09990250000000067 conftest.py pytest_runtest_makereport 72
  2236. 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2237. 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2238. 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  2239. 2024-11-04 20:25:46 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2240. 2024-11-04 20:25:46 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P8] conftest.py pytest_runtest_makereport 68
  2241. 2024-11-04 20:25:46 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  2242. 2024-11-04 20:25:46 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADC4B100>
  2243. caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G2--P', ...}
  2244. def test_case_execute(self, caseinfo):
  2245. casename = caseinfo["_case_name"]
  2246. # TODO 2-1 : 调用动态生成标题的方法
  2247. dynamicTitle(caseinfo)
  2248. # TODO 2-2: 基于我们步骤一步步进行执行
  2249. try:
  2250. # 实例化关键字对象
  2251. keywords = KeyWords()
  2252. # 获取当前用例变量,方便后续的渲染
  2253. local_context = caseinfo.get("context",{})
  2254. context = copy.deepcopy(g_context().show_dict())
  2255. context.update(local_context)
  2256. steps = caseinfo.get("steps", None)
  2257. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  2258. for index,step in enumerate(steps):
  2259. # 提示信息
  2260. step_name = list(step.keys())[0]
  2261. step_value = list(step.values())[0]
  2262. # TODO : 每一个步骤进行变量的渲染
  2263. context = copy.deepcopy(g_context().show_dict())
  2264. context.update(local_context)
  2265. step_value = eval(refresh(step_value, context))
  2266. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  2267. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  2268. # 通过【反射】的方式去找到对应的方法
  2269. with allure.step(step_name):
  2270. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  2271. try:
  2272. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  2273. except AttributeError as e:
  2274. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  2275. > key_func(**step_value) # 调用方法
  2276. core\ApiTestRunner.py:51:
  2277. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2278. extend\keywords.py:183: in ex_mysqlData
  2279. logger.info("数据库查询结果:", rs)
  2280. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  2281. self._log(INFO, msg, args, **kwargs)
  2282. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  2283. self.handle(record)
  2284. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  2285. self.callHandlers(record)
  2286. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  2287. hdlr.handle(record)
  2288. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  2289. self.emit(record)
  2290. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  2291. super().emit(record)
  2292. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  2293. self.handleError(record)
  2294. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  2295. msg = self.format(record)
  2296. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  2297. return fmt.format(record)
  2298. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  2299. return super().format(record)
  2300. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  2301. record.message = record.getMessage()
  2302. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2303. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  2304. def getMessage(self):
  2305. """
  2306. Return the message for this LogRecord.
  2307. Return the message for this LogRecord after merging any user-supplied
  2308. arguments with the message.
  2309. """
  2310. msg = str(self.msg)
  2311. if self.args:
  2312. > msg = msg % self.args
  2313. E TypeError: not all arguments converted during string formatting
  2314. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  2315. 2024-11-04 20:25:46 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  2316. 2024-11-04 20:25:46 INFO 用例耗时:0.1959156999999987 conftest.py pytest_runtest_makereport 72
  2317. 2024-11-04 20:25:46 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2318. 2024-11-04 20:25:46 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2319. 2024-11-04 20:25:46 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  2320. 2024-11-04 20:25:46 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2321. 2024-11-04 20:25:46 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P9] conftest.py pytest_runtest_makereport 68
  2322. 2024-11-04 20:25:46 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  2323. 2024-11-04 20:25:46 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADCB21F0>
  2324. caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G2--P', ...}
  2325. def test_case_execute(self, caseinfo):
  2326. casename = caseinfo["_case_name"]
  2327. # TODO 2-1 : 调用动态生成标题的方法
  2328. dynamicTitle(caseinfo)
  2329. # TODO 2-2: 基于我们步骤一步步进行执行
  2330. try:
  2331. # 实例化关键字对象
  2332. keywords = KeyWords()
  2333. # 获取当前用例变量,方便后续的渲染
  2334. local_context = caseinfo.get("context",{})
  2335. context = copy.deepcopy(g_context().show_dict())
  2336. context.update(local_context)
  2337. steps = caseinfo.get("steps", None)
  2338. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  2339. for index,step in enumerate(steps):
  2340. # 提示信息
  2341. step_name = list(step.keys())[0]
  2342. step_value = list(step.values())[0]
  2343. # TODO : 每一个步骤进行变量的渲染
  2344. context = copy.deepcopy(g_context().show_dict())
  2345. context.update(local_context)
  2346. step_value = eval(refresh(step_value, context))
  2347. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  2348. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  2349. # 通过【反射】的方式去找到对应的方法
  2350. with allure.step(step_name):
  2351. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  2352. try:
  2353. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  2354. except AttributeError as e:
  2355. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  2356. > key_func(**step_value) # 调用方法
  2357. core\ApiTestRunner.py:51:
  2358. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2359. extend\keywords.py:183: in ex_mysqlData
  2360. logger.info("数据库查询结果:", rs)
  2361. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  2362. self._log(INFO, msg, args, **kwargs)
  2363. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  2364. self.handle(record)
  2365. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  2366. self.callHandlers(record)
  2367. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  2368. hdlr.handle(record)
  2369. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  2370. self.emit(record)
  2371. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  2372. super().emit(record)
  2373. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  2374. self.handleError(record)
  2375. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  2376. msg = self.format(record)
  2377. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  2378. return fmt.format(record)
  2379. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  2380. return super().format(record)
  2381. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  2382. record.message = record.getMessage()
  2383. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2384. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  2385. def getMessage(self):
  2386. """
  2387. Return the message for this LogRecord.
  2388. Return the message for this LogRecord after merging any user-supplied
  2389. arguments with the message.
  2390. """
  2391. msg = str(self.msg)
  2392. if self.args:
  2393. > msg = msg % self.args
  2394. E TypeError: not all arguments converted during string formatting
  2395. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  2396. 2024-11-04 20:25:46 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  2397. 2024-11-04 20:25:46 INFO 用例耗时:0.20920360000000038 conftest.py pytest_runtest_makereport 72
  2398. 2024-11-04 20:25:46 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2399. 2024-11-04 20:25:46 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2400. 2024-11-04 20:25:46 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
  2401. 2024-11-04 20:25:46 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
  2402. 2024-11-04 20:25:46 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
  2403. 2024-11-04 20:25:46 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2404. 2024-11-04 20:25:46 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P10] conftest.py pytest_runtest_makereport 68
  2405. 2024-11-04 20:25:46 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
  2406. 2024-11-04 20:25:46 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
  2407. 2024-11-04 20:25:46 INFO 异常:None conftest.py pytest_runtest_makereport 71
  2408. 2024-11-04 20:25:46 INFO 用例耗时:0.11341100000000104 conftest.py pytest_runtest_makereport 72
  2409. 2024-11-04 20:25:46 INFO ************************************** conftest.py pytest_runtest_makereport 73
  2410. 2024-11-04 20:25:46 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
  2411. 2024-11-04 20:25:46 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
  2412. 2024-11-04 20:25:46 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
  2413. 2024-11-04 20:25:47 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P11] conftest.py pytest_runtest_makereport 68
  2414. 2024-11-04 20:25:47 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
  2415. 2024-11-04 20:25:47 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADCB22E0>
  2416. caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G2--P', ...}
  2417. def test_case_execute(self, caseinfo):
  2418. casename = caseinfo["_case_name"]
  2419. # TODO 2-1 : 调用动态生成标题的方法
  2420. dynamicTitle(caseinfo)
  2421. # TODO 2-2: 基于我们步骤一步步进行执行
  2422. try:
  2423. # 实例化关键字对象
  2424. keywords = KeyWords()
  2425. # 获取当前用例变量,方便后续的渲染
  2426. local_context = caseinfo.get("context",{})
  2427. context = copy.deepcopy(g_context().show_dict())
  2428. context.update(local_context)
  2429. steps = caseinfo.get("steps", None)
  2430. logger.info(f"-----------------开始执行测试用例:{steps}-------------")
  2431. for index,step in enumerate(steps):
  2432. # 提示信息
  2433. step_name = list(step.keys())[0]
  2434. step_value = list(step.values())[0]
  2435. # TODO : 每一个步骤进行变量的渲染
  2436. context = copy.deepcopy(g_context().show_dict())
  2437. context.update(local_context)
  2438. step_value = eval(refresh(step_value, context))
  2439. logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
  2440. # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
  2441. # 通过【反射】的方式去找到对应的方法
  2442. with allure.step(step_name):
  2443. key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
  2444. try:
  2445. key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
  2446. except AttributeError as e:
  2447. logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
  2448. > key_func(**step_value) # 调用方法
  2449. core\ApiTestRunner.py:51:
  2450. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2451. extend\keywords.py:183: in ex_mysqlData
  2452. logger.info("数据库查询结果:", rs)
  2453. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
  2454. self._log(INFO, msg, args, **kwargs)
  2455. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
  2456. self.handle(record)
  2457. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
  2458. self.callHandlers(record)
  2459. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
  2460. hdlr.handle(record)
  2461. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
  2462. self.emit(record)
  2463. ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
  2464. super().emit(record)
  2465. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
  2466. self.handleError(record)
  2467. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
  2468. msg = self.format(record)
  2469. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
  2470. return fmt.format(record)
  2471. ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
  2472. return super().format(record)
  2473. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
  2474. record.message = record.getMessage()
  2475. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  2476. self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
  2477. def getMessage(self):
  2478. """
  2479. Return the message for this LogRecord.
  2480. Return the message for this LogRecord after merging any user-supplied
  2481. arguments with the message.
  2482. """
  2483. msg = str(self.msg)
  2484. if self.args:
  2485. > msg = msg % self.args
  2486. E TypeError: not all arguments converted during string formatting
  2487. C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
  2488. 2024-11-04 20:25:47 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
  2489. 2024-11-04 20:25:47 INFO 用例耗时:0.22291740000000004 conftest.py pytest_runtest_makereport 72
  2490. 2024-11-04 20:25:47 INFO ************************************** conftest.py pytest_runtest_makereport 73