zoukankan      html  css  js  c++  java
  • 自动化创建pytest框架脚本:

    1、脚本内容:
    # 导入模块:
    import os

    # 分别创建文件夹:
    os.makedirs("py_tests/scripts")
    os.makedirs("py_tests/scripts/test_case_dir1")
    os.makedirs("py_tests/report")
    os.makedirs("py_tests/report/assets")
    os.makedirs("py_tests/report/result")
    os.makedirs("py_tests/report/allure_html")


    # 展示目录信息:
    py_tests_list = os.listdir("py_tests")
    print("您创建的项目目录有:", py_tests_list) # 展示创建的目录信息

    # 文件里面写入信息:
    with open("py_tests/scripts/test_case_dir1/test_case_02.py", "w", encoding="utf-8") as f,
    open("py_tests/scripts/test_case_dir1/__init__.py", "w", encoding="utf-8") as f1,
    open("py_tests/scripts/test_allure_case.py", "w", encoding="utf-8") as f2,
    open("py_tests/scripts/test_case_01.py", "w", encoding="utf-8") as f3,
    open("py_tests/scripts/__init__.py", "w", encoding="utf-8") as f4,
    open("py_tests/report/report.html", "w", encoding="utf-8") as f5,
    open("py_tests/report/allure_html/index.html", "w", encoding="utf-8") as f6,
    open("py_tests/case_set.py", "w", encoding="utf-8") as f7,
    open("py_tests/demo0.py", "w", encoding="utf-8") as f8,
    open("py_tests/demo1.py", "w", encoding="utf-8") as f9,
    open("py_tests/pytest.ini", "w", encoding="utf-8") as f10,
    open("py_tests/__init__.py", "w", encoding="utf-8") as f11,
    open("py_tests/README.md", "w", encoding="utf-8") as f12:
    f12.write("------------------ "
    "## 本程序实现的内容如下: "
    "### 1. "
    "### 2. "
    "### 3. "
    "### 4. "
    "### 5. "
    "### 6. "
    "### 7. 退出程序 "

    "--------------- "
    "## 本程序运行环境: "
    "### 1.Python3.6.8 解释器 "

    "---------------- "
    "## 系统环境: "
    "#### Windows "

    "----------------- "
    "## 开发信息: "
    "### 作者: Zhangda "
    "### 时间: 2020年1月1日15:11:08 "
    "### 数据来源 : "

    "------------- ")
    2、目录展示效果:
     
  • 相关阅读:
    1、vsCode插件开发流程入门
    node中MySQL的安装与使用
    sublime使用插件
    Node.js基础知识梳理
    第5章-11 字典合并 (40分)
    我的考研心得-zju-se
    解决 重启tomcat上传的文件被自动删除或未重启过段时间也自动删除(deloy path)
    org.hibernate.InstantiationException: No default constructor for entity
    UE.delEditor is not a function问题原因及解决方法
    javaweb开发过程中遇到的问题
  • 原文地址:https://www.cnblogs.com/zhang-da/p/12209297.html
Copyright © 2011-2022 走看看