test_allAPI2.py 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import json
  2. from pathlib import Path
  3. import allure
  4. import pytest
  5. from common.parameterize import ddt, read_testcase
  6. from common.request_util import RequestUtil
  7. path = Path(__file__).parent.glob("**/*.yaml")
  8. def creat_case(yaml_path):
  9. @pytest.mark.parametrize("arg_names", read_testcase(rf"{yaml_path}"))
  10. def test_fun(self, arg_names):
  11. allure.dynamic.title(arg_names["name"])
  12. RequestUtil("base_qccq_sc").standard_yaml(arg_names)
  13. return test_fun
  14. @allure.epic("青春重庆")
  15. @allure.feature("用户管理模块")
  16. class TestAPI:
  17. pass
  18. # data=[]
  19. # for yaml_path in path:
  20. # yaml_name = yaml_path.name[:-5]
  21. # print(yaml_path)
  22. # data.append(yaml_path)
  23. # setattr(TestAPI, yaml_name, creat_case(yaml_path))
  24. data=[]
  25. for yaml_path in path:
  26. data.append(yaml_path)
  27. data.sort()
  28. for yaml_path in data:
  29. yaml_name=yaml_path.name[:-5]
  30. setattr(TestAPI, yaml_name, creat_case(yaml_path))