copilotDiffState.xml 7.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project version="4">
  3. <component name="CopilotDiffPersistence">
  4. <option name="pendingDiffs">
  5. <map>
  6. <entry key="$PROJECT_DIR$/conftest.py">
  7. <value>
  8. <PendingDiffInfo>
  9. <option name="filePath" value="$PROJECT_DIR$/conftest.py" />
  10. <option name="updatedContent" value="import os&#10;&#10;def pytest_sessionfinish(session, exitstatus):&#10; # pytest 结束后自动生成 allure 报告&#10; os.system(&quot;allure generate 测试报告 -o 测试报告/html --clean&quot;)&#10;" />
  11. </PendingDiffInfo>
  12. </value>
  13. </entry>
  14. <entry key="$PROJECT_DIR$/demo/main/test_a.py">
  15. <value>
  16. <PendingDiffInfo>
  17. <option name="filePath" value="$PROJECT_DIR$/demo/main/test_a.py" />
  18. <option name="originalContent" value="import pytest,json&#10;import jsonpath&#10;from demo.utils import get_excel as gexcel&#10;from demo.utils.send import ApiClient&#10;from demo.utils.write_log import write_log&#10;from demo.dic.global_value import GlobalInfo&#10;client = ApiClient()&#10;&#10;@pytest.mark.parametrize(&quot;case_info&quot;, gexcel.get_excel(&quot;demo&quot;, 0))&#10;def test_case(case_info):&#10; #初始化全局变量&#10; dic = GlobalInfo().show_info()&#10;&#10; # 拼接请求参数&#10; url = case_info[&quot;url&quot;]&#10; method = case_info[&quot;method&quot;]&#10; headers = eval(case_info[&quot;headers&quot;]) if case_info[&quot;headers&quot;] else {}&#10; params = eval(case_info[&quot;params&quot;]) if case_info[&quot;params&quot;] else {}&#10; data = eval(case_info[&quot;data&quot;]) if case_info[&quot;data&quot;] else {}&#10; _json = eval(case_info[&quot;json&quot;]) if case_info[&quot;json&quot;] else {}&#10;&#10; # 写日志&#10; write_log(&quot;url&quot;,url)&#10; write_log(&quot;headers&quot;,headers)&#10; write_log(&quot;params&quot;,params)&#10; write_log(&quot;data&quot;,data)&#10;&#10; # 前置操作&#10;&#10;&#10; res = client.send_request(method, url, headers=headers, params=params, data=data, json=_json)&#10; write_log(&quot;respose&quot;, res.json())&#10;&#10;&#10; # assert res.status_code == 200&#10;&#10;&#10; # 后置操作&#10; ## 提取变量&#10; if case_info[&quot;提取变量&quot;] != &quot;&quot;:&#10; vars_to_extract = [v.strip() for v in case_info[&quot;提取变量&quot;].split(&quot;,&quot;) if v.strip()]&#10; for var in vars_to_extract:&#10; value = jsonpath.jsonpath(res.json(), f&quot;$..{var}&quot;)&#10; if value:&#10; GlobalInfo().set_info(var, value[0])&#10; write_log(&quot;globalInfo.txt&quot;, json.dumps(GlobalInfo().show_info()))&#10;&#10; print(_json)" />
  19. <option name="updatedContent" value="import pytest, json&#10;import jsonpath&#10;from demo.utils import get_excel as gexcel&#10;from demo.utils.send import ApiClient&#10;from demo.utils.write_log import write_log&#10;from demo.dic.global_value import GlobalInfo&#10;client = ApiClient()&#10;&#10;@pytest.mark.parametrize(&quot;case_info&quot;, gexcel.get_excel(&quot;demo&quot;, 0))&#10;def test_case(case_info):&#10; #初始化全局变量&#10; dic = GlobalInfo().show_info()&#10;&#10; # 拼接请求参数&#10; url = case_info[&quot;url&quot;]&#10; method = case_info[&quot;method&quot;]&#10; headers = eval(case_info[&quot;headers&quot;]) if case_info[&quot;headers&quot;] else {}&#10; params = eval(case_info[&quot;params&quot;]) if case_info[&quot;params&quot;] else {}&#10; data = eval(case_info[&quot;data&quot;]) if case_info[&quot;data&quot;] else {}&#10; _json = eval(case_info[&quot;json&quot;]) if case_info[&quot;json&quot;] else {}&#10;&#10; # 写日志&#10; write_log(&quot;url&quot;,url)&#10; write_log(&quot;headers&quot;,headers)&#10; write_log(&quot;params&quot;,params)&#10; write_log(&quot;data&quot;,data)&#10;&#10; # 前置操作&#10;&#10;&#10; res = client.send_request(method, url, headers=headers, params=params, data=data, json=_json)&#10; write_log(&quot;respose&quot;, res.json())&#10;&#10;&#10; # assert res.status_code == 200&#10;&#10;&#10; # 后置操作&#10; ## 提取变量&#10; if case_info[&quot;提取变量&quot;] != &quot;&quot;:&#10; vars_to_extract = [v.strip() for v in case_info[&quot;提取变量&quot;].split(&quot;,&quot;) if v.strip()]&#10; for var in vars_to_extract:&#10; value = jsonpath.jsonpath(res.json(), f&quot;$..{var}&quot;)&#10; if value:&#10; GlobalInfo().set_info(var, value[0])&#10; write_log(&quot;globalInfo.txt&quot;, json.dumps(GlobalInfo().show_info()))&#10;&#10; print(_json)" />
  20. </PendingDiffInfo>
  21. </value>
  22. </entry>
  23. <entry key="$PROJECT_DIR$/demo/utils/get_excel.py">
  24. <value>
  25. <PendingDiffInfo>
  26. <option name="filePath" value="$PROJECT_DIR$/demo/utils/get_excel.py" />
  27. <option name="originalContent" value="import pandas as pd&#10;from pathlib import Path&#10;from . import write_log as log&#10;def get_excel(file_name, sheet_name=0):&#10; &quot;&quot;&quot;&#10; 读取excel文件目录下.xlsx文件内容到DataFrame,并用空字符串填充缺失值&#10; :param file_name:&#10; :param sheet_name: 工作表名称或索引,默认读取第一个工作表&#10; :return: 填充缺失值后的DataFrame&#10; &quot;&quot;&quot;&#10;&#10;&#10; project_root = Path(__file__).parent.parent&#10; # 拼接 demo/demo.xlsx 路径&#10; file_path = project_root / &quot;excel&quot; / (file_name+&quot;.xlsx&quot;)&#10;&#10; df = pd.read_excel(file_path, sheet_name=sheet_name)&#10; df = df.fillna(&quot;&quot;) # 用空字符串填充缺失值&#10; df = df.to_dict(orient=&quot;records&quot;)&#10; # print(df)&#10;&#10; log.clear_log(file_name)&#10; log.write_log(file_name, df)&#10; return df&#10;&#10;# print(file_path)" />
  28. <option name="updatedContent" value="import pandas as pd&#10;from pathlib import Path&#10;from . import write_log as log&#10;def get_excel(file_name, sheet_name=0):&#10; &quot;&quot;&quot;&#10; 读取excel文件目录下.xlsx文件内容到DataFrame,并用空字符串填充缺失值&#10; :param file_name:&#10; :param sheet_name: 工作表名称或索引,默认读取第一个工作表&#10; :return: 填充缺失值后的DataFrame&#10; &quot;&quot;&quot;&#10;&#10;&#10; project_root = Path(__file__).parent.parent&#10; # 拼接 demo/demo.xlsx 路径&#10; file_path = project_root / &quot;excel&quot; / (file_name+&quot;.xlsx&quot;)&#10;&#10; df = pd.read_excel(file_path, sheet_name=sheet_name)&#10; df = df.fillna(&quot;&quot;) # 用空字符串填充缺失值&#10; df = df.to_dict(orient=&quot;records&quot;)&#10; # print(df)&#10;&#10; log.clear_log(file_name)&#10; log.write_log(file_name, df)&#10; return df&#10;&#10;# print(file_path)" />
  29. </PendingDiffInfo>
  30. </value>
  31. </entry>
  32. </map>
  33. </option>
  34. </component>
  35. </project>