首页 > 其他分享 >Pytest接口测试框架实战项目搭建(五)—— Streamlit首次应用

Pytest接口测试框架实战项目搭建(五)—— Streamlit首次应用

时间:2022-11-26 12:46:38浏览次数:48  
标签:set script 接口 st Pytest path import Streamlit os

一、源码,c_page.py

'''
@Date:2022/11/14  14:36
@Author:一加一
'''

import streamlit as st
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)
from testcase.test_cc import *
import pytest
from tools.operate_config import OperateConfig


class TestPage:
    # 实例化对象
    getCjson = GetcJson(None) # 实例化对象,获取业务系统C的json数据,即接口请求body

    side = ["C系统"]
    st.sidebar.title("使用左侧面板")
    system = st.sidebar.selectbox("请选择", side)
    env = ["QA1", "QA2"]
    testenv = st.sidebar.selectbox("请选择环境", env)

    if system == "C系统":
        script_list = ["查询客户","下订单"]
        script = st.selectbox("请选择脚本",script_list)
        if script == "查询客户":
            customer_name = st.text_input("请输入客户名称")
            submit = st.button("提交")
            if submit:
                # 将选择的环境set到config配置文件
                OperateConfig().set_node_value('ENV', 'env', testenv)
                # 将客户名称set到json文件
                getCjson.set_cuslist_customerName(customer_name)
                # 执行查询客户脚本
                pytest.main(['E:\\02Api test\\XX_ApiTest\\testcase\\test_cc.py'])
                st.write("提交成功\n"+customer_name)

二、效果图

在文件所在目录下执行命令 streamlit run c_page.py,执行完后会生成一个url,可进入到如下页面

 

 

 

 

 

标签:set,script,接口,st,Pytest,path,import,Streamlit,os
From: https://www.cnblogs.com/Chilam007/p/16927229.html

相关文章

  • 【Spring Cloud实战】OpenFeign服务接口调用
    gitee地址:https://gitee.com/javaxiaobear/spring-cloud_study.git在线阅读地址:https://javaxiaobear.gitee.io/1、概述官网:https://docs.spring.io/spring-cloud-openfeig......
  • 【Java】EasyCaptcha 封装验证码接口
     依赖坐标:<dependency><groupId>com.github.whvcse</groupId><artifactId>easy-captcha</artifactId><version>1.6.2......
  • 关于查询接口设计
    此篇博客记录自己在设计模糊查询接口时候犯的错误,以及个人的一些浅略的思考,再次说明此并非最优设计。前言此模糊查询是项目的一个小接口,大致功能如下图所示。产品的......
  • 函数式接口的案例详解
    ​ 1.无参无返回值方法的函数式接口1.1自定义类实现接口的方式 1.2匿名内部类的方式 1.3lambda表达式的方式​ 2.有参无返回值方法的函数式接口......
  • mt7688 接口网卡接口说明
    硬件平台:mt7688软件平台:原生sdkMediaTek_ApSoC_SDK_4300_201409161.使用 ifconfig-a 命令可以列出mt7688上面所有的逻辑网卡接口,常见接口如下:apcli0:Thewirelessa......
  • 使用Spring Security对接口实现访问权限
     1<!--加入security依赖-->2<dependency>3<groupId>org.springframework.boot</groupId>4<artifactId>spring-boot-......
  • java 接口限制访问次数
    1.通过注解的形式实现通用接口访问次数限制(1)pom.xml文件中引入expiringmap<dependency><groupId>net.jodah</groupId><artifactId>expiringmap</artifa......
  • Lock接口
    packagecom.google;importjava.util.concurrent.locks.Lock;importjava.util.concurrent.locks.ReentrantLock;classDemo{privateinti=100;Lock......
  • postMan 测试webService接口 参数传递问题
    一、参数没有子节点的方式<?xmlversion="1.0"encoding="utf-8"?><soap:Envelopexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.......
  • 使用 pytest 进行 python 脚本测试
    PytestTIPSpytest-tutorial[tips.1]pytest会执行指定目录下所有Test开头的类和函数默认为运行目录,可以通过--rootdir参数指定[tips.2]可以通过assert断言......