08 2023 档案

摘要:背景 非单例 class A: pass a1=A() a2=A() print(id(a1)) print(id(a2)) ''' 1618986824272 1618986826096a1和a2的id不一样 ''' 单例 class Single: _self = None def __new_ 阅读全文
posted @ 2023-08-31 21:24 胖豆芽 阅读(2) 评论(0) 推荐(0) 编辑
摘要:转载来源 https://www.lmlphp.com/user/107993/article/item/2699346/ 使用Moco模拟接口以下功能: 拦截服务:http,https。 请求方式:GET,POST。 模拟请求地址:URL。 模拟参数:包括header和cookie的数据。 模拟响 阅读全文
posted @ 2023-08-30 15:06 胖豆芽 阅读(37) 评论(0) 推荐(0) 编辑
摘要:无法连接仓库:Command "git ls-remote -h -- https://gitee.com/xxx/xxxrned status code 128: stdout: stderr: remote: [session-554c92af] Username for 'https 阅读全文
posted @ 2023-08-23 15:01 胖豆芽 阅读(1091) 评论(0) 推荐(0) 编辑
摘要:import os # 1 获取当前文件的绝对路径目录 Dir=os.path.abspath(__file__) print(f"1 绝对路径:{Dir}") # 2 去掉文件名称 保留获取目录 DirNo=os.path.dirname(Dir) print(f'2 去掉名称保留路径:{DirN 阅读全文
posted @ 2023-08-22 15:59 胖豆芽 阅读(14) 评论(0) 推荐(0) 编辑
摘要:import json class MyClass(): # 类变量 can1 = "dog" can2 = "wang" # 方法2 def is_json(self, data): try: return json.load(data) except: return data # 方法1 def 阅读全文
posted @ 2023-08-22 12:36 胖豆芽 阅读(4) 评论(0) 推荐(0) 编辑
摘要:一个参数传递时结果:(参数1) 两个参数传递时: 参数1 参数2 对(a,)暴力解决办法: 下标取值a[0] >a 阅读全文
posted @ 2023-08-22 10:44 胖豆芽 阅读(14) 评论(0) 推荐(0) 编辑
摘要:#\libs\request_test.pyfrom libs.login_my import Login from libs.food_my import Food # 调用登录获得token l=Login() t=l.login(is_need_token=True) # 将登录获得的toke 阅读全文
posted @ 2023-08-21 12:42 胖豆芽 阅读(8) 评论(0) 推荐(0) 编辑
摘要:import inspect def fun1(): fun2() def fun2(): who=inspect.stack()[1][3] # 记录被谁调用了 print(f"{who}") print(type(who)) fun1() ''' 'fun1' <class 'list'> '' 阅读全文
posted @ 2023-08-18 16:29 胖豆芽 阅读(2) 评论(0) 推荐(0) 编辑
摘要:一般的文件 读取的包含换行符 是数组格式 # open def get_yaml(file_path): with open(file_path,encoding='utf-8') as fo: print(fo.readlines()) if __name__ == '__main__': get 阅读全文
posted @ 2023-08-16 15:53 胖豆芽 阅读(20) 评论(0) 推荐(0) 编辑
摘要:# *args **kwargs的用法 def get_data(name,age,*args,**kwargs): print(f"name:{name},age:{age},可变参数:{args},可变键值对参数:{kwargs}") if __name__ == '__main__': get 阅读全文
posted @ 2023-08-16 15:30 胖豆芽 阅读(2) 评论(0) 推荐(0) 编辑
摘要:没有使用类时 # 练习基本语法 求班级中小于3岁孩子的男生是 女生是 def get_m(students, minage=3): # 男生的列表 malelist = [] # 遍历全部的学生 for student in students: # 筛选出小于3岁的孩子 if student['ag 阅读全文
posted @ 2023-08-16 14:45 胖豆芽 阅读(3) 评论(0) 推荐(0) 编辑
摘要:numbers = [4, 2, 1, 3, 5] numbers.sort() print(numbers) # 输出: [1, 2, 3, 4, 5] 阅读全文
posted @ 2023-08-14 16:51 胖豆芽 阅读(5) 评论(0) 推荐(0) 编辑
摘要:def example_func(**kwargs): for key, value in kwargs.items(): print(f"{key}: {value}") example_func(name="Alice", age=25, city="New York") 阅读全文
posted @ 2023-08-14 16:33 胖豆芽 阅读(2) 评论(0) 推荐(0) 编辑
摘要:# 导入正则表达式 import re # 参数2 str1 = "<html>a='as1d32as1d654as54d65asd465asd4'</html>" # 参数1 pattern = r"<html>a=(.*?)</html>" # 调用re中的寻找方法search result = 阅读全文
posted @ 2023-08-14 16:31 胖豆芽 阅读(4) 评论(0) 推荐(0) 编辑
摘要:with open("file.txt", "r") as file: lines = file.readlines() print(lines) # ['Line 1\n', 'Line 2\n', 'Line 3\n'] with open("file.txt", "r") as file: c 阅读全文
posted @ 2023-08-14 15:55 胖豆芽 阅读(41) 评论(0) 推荐(0) 编辑
摘要:alist1=["apple","banana","orange"] alist2=["pear","peach","watermelon"] alist1.append(alist2) print(alist1) ''' ['apple', 'banana', 'orange', ['pear', 阅读全文
posted @ 2023-08-14 15:46 胖豆芽 阅读(54) 评论(0) 推荐(0) 编辑
摘要:str1 = 'agcadssadjkl' one=str1.index('a',) t=str1.index('a',one+1) s=str1.index('a',t+1) print(one) print(t) print(s) ''' 037 ''' 阅读全文
posted @ 2023-08-14 15:30 胖豆芽 阅读(11) 评论(0) 推荐(0) 编辑
摘要:import inspect def func1(): caller = inspect.stack()[1].function ''' stack 堆栈;[0] 是自己所在的方法; [1]是被调用的方法 ''' print(f"func1方法被{caller}方法调用了") def func2() 阅读全文
posted @ 2023-08-14 14:44 胖豆芽 阅读(5) 评论(0) 推荐(0) 编辑
摘要:项目工程格式如下 1.写一个flask功能 app/app.py from flask import Flask app = Flask(__name__) @app.route("/index") def index(): return "Hello World!" if __name__ == 阅读全文
posted @ 2023-08-11 20:20 胖豆芽 阅读(147) 评论(0) 推荐(0) 编辑
摘要:1. 新建一个flask工程文件 2. 将工程文件,打包成一个txt 文件 pip freeze >req.txt 未完待续 阅读全文
posted @ 2023-08-10 17:32 胖豆芽 阅读(8) 评论(0) 推荐(0) 编辑
摘要:去掉了注册signup.html页,因为是最简单的一个工程,不验证账号的唯一性 /**创建flask数据库**/ CREATE DATABASE flask CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; /**创建用户表**/ CREATE TA 阅读全文
posted @ 2023-08-09 18:08 胖豆芽 阅读(39) 评论(0) 推荐(0) 编辑
摘要:# configs/configs.ini [servers] DEV = http://ip:port #libs/login_sig.pyimport requests import hashlib import configparser def get_host(): conf_info=co 阅读全文
posted @ 2023-08-08 22:20 胖豆芽 阅读(75) 评论(0) 推荐(0) 编辑
摘要:#引入相关的库 import pymysql mysql_host = "localhost" mysql_port = 3306 mysql_db = "db001" mysql_user = "root" mysql_passwd = "111111" try: #连接操作:编码格式的指定,默认 阅读全文
posted @ 2023-08-08 20:00 胖豆芽 阅读(115) 评论(0) 推荐(0) 编辑
摘要:from flask import Flask # 初始化对象 app = Flask(__name__) # 创建函数 @app.route('/moke') def get_res(): res='hello moke' return res if __name__ == '__main__': 阅读全文
posted @ 2023-08-08 18:25 胖豆芽 阅读(8) 评论(0) 推荐(0) 编辑
摘要:1.怎样在docker中jenkins里设置一个镜像 一行命令的事儿 拉取push 新建一个容器 run 2.在docker中设置一个镜像文件 挂载下载了的mysql 等 阅读全文
posted @ 2023-08-07 19:45 胖豆芽 阅读(3) 评论(0) 推荐(0) 编辑
摘要:docker run -it -d -p 8082:8080 -p 50000:50000 --name myjenkins01 jenkins/jenkins:2.417 以下是对给定的命令参数的解释: docker run: 运行一个新的容器 -it: 在一个交互式终端中运行容器 -d: 在后台 阅读全文
posted @ 2023-08-07 19:33 胖豆芽 阅读(157) 评论(0) 推荐(0) 编辑
摘要:https://mirrors.tuna.tsinghua.edu.cn/jenkins/windows-stable/2.346.3/ 阅读全文
posted @ 2023-08-07 13:25 胖豆芽 阅读(470) 评论(0) 推荐(0) 编辑
摘要:net user jenkins psw /add net user username psw /add 1.第一步 管理员身份打开dos窗口,命令行形式添加一个账号比如 jenkins 密码比如psw 2.第二步 进入安全策略 添加一个账号 大功告成 阅读全文
posted @ 2023-08-07 12:39 胖豆芽 阅读(133) 评论(0) 推荐(0) 编辑
摘要:pushd "%~dp0" dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /nor 阅读全文
posted @ 2023-08-04 22:32 胖豆芽 阅读(16) 评论(0) 推荐(0) 编辑
摘要:解決辦法 wsl -- update 阅读全文
posted @ 2023-08-04 22:30 胖豆芽 阅读(3) 评论(0) 推荐(0) 编辑
摘要:python allure将生成报告和打开报告写到命令文件,并默认使用谷歌打开 bat文件内容 pytest test_login.py --alluredir=./allure-results&& allure generate ./allure-results -o ./allure-repor 阅读全文
posted @ 2023-08-04 13:20 胖豆芽 阅读(157) 评论(0) 推荐(0) 编辑
摘要:问题:从excel中读取的数据应是什么格式呢? 1pytest中需要参数化时,需要的[(valuea,valueb)(valuex,valuey)] 列表内是元祖 import pytest def add(x, y): return x + y @pytest.mark.parametrize(" 阅读全文
posted @ 2023-08-04 12:02 胖豆芽 阅读(121) 评论(0) 推荐(0) 编辑
摘要:1.从excel中读数据 返回【{字典}{字典}】;当传参数时,可以获得对应单元格内容 import xlrd import json from configs.configs import HOST from utils.md5 import get_md5 # 在创建excel时,将登录接口的返 阅读全文
posted @ 2023-08-03 20:46 胖豆芽 阅读(77) 评论(0) 推荐(0) 编辑
摘要:1.读excel表 2.登录 发请求 3.生成allure 报告 阅读全文
posted @ 2023-08-03 15:24 胖豆芽 阅读(5) 评论(0) 推荐(0) 编辑
摘要:x = 5 print(isinstance(x, int)) # True,x是int类型的对象 y = "Hello" print(isinstance(y, str)) # True,y是str类型的对象 z = [1, 2, 3] print(isinstance(z, list)) # T 阅读全文
posted @ 2023-08-03 14:43 胖豆芽 阅读(10) 评论(0) 推荐(0) 编辑
摘要:#D:\pythonProject0726\test_case\test_one.py import time def setup_module(): print('准备测试数据') def teardown_module(): print('清理测试数据') def test_oneone(): 阅读全文
posted @ 2023-08-03 11:42 胖豆芽 阅读(198) 评论(0) 推荐(0) 编辑
摘要:#下载包 清华镜像 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytest-rerunfailures # D:\pythonProject0726\test_case\all_test_case.py import pytest 阅读全文
posted @ 2023-08-03 11:27 胖豆芽 阅读(11) 评论(0) 推荐(0) 编辑
摘要:#D:\pythonProject0726\test_case\test_one.py import time def setup_module(): print('准备测试数据') def teardown_module(): print('清理测试数据') def test_one(): ex= 阅读全文
posted @ 2023-08-03 11:12 胖豆芽 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2023-08-03 10:03 胖豆芽 阅读(8) 评论(0) 推荐(0) 编辑
摘要:[pytest] testpaths = ./test_case/test_params.py addopts = -vs --alluredir ./report import pytest import requests from utils.read_yaml import get_yaml_ 阅读全文
posted @ 2023-08-02 22:00 胖豆芽 阅读(84) 评论(0) 推荐(0) 编辑
摘要:import pytest import requests from utils.read_yaml import get_yaml_data # 多个参数(’class1,class2‘,[('age','eat'),('age','eat')]) @pytest.mark.parametrize 阅读全文
posted @ 2023-08-02 21:16 胖豆芽 阅读(125) 评论(0) 推荐(0) 编辑
摘要:import pytest # 多个参数(’class1,class2‘,[('age','eat'),('age','eat')]) @pytest.mark.parametrize('dog,cat',[('2','bone'),('1','fish')]) def test_params(do 阅读全文
posted @ 2023-08-02 20:45 胖豆芽 阅读(16) 评论(0) 推荐(0) 编辑
摘要:上图示例 def setup_module(): print('准备测试数据') def teardown_module(): print('清理测试数据') def test_one(): ex=1 real=1 assert ex==real 仅在模块中执行一次 阅读全文
posted @ 2023-08-02 18:09 胖豆芽 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2023-08-02 18:06 胖豆芽 阅读(4) 评论(0) 推荐(0) 编辑
摘要:import requests HOST = 'https://ip.com' URL = '/posts/' url=HOST+URL jsons={# 尽量不要使用json作为变量 防止和json关键字冲突 "title": "foo", "body":" bar", "userId": 1 } 阅读全文
posted @ 2023-08-02 13:18 胖豆芽 阅读(23) 评论(2) 推荐(0) 编辑
摘要:class BaseAPI: # 基类 相当于动物类 ; 登录 属于继承类,相当于老虎类 # 属性 def __init__(self,token=None): # 店铺类,订单类,支付模块等都需要使用token 所以过滤一下 if token:# 如果接口需要token 店铺类,订单类,支付模块等 阅读全文
posted @ 2023-08-02 12:13 胖豆芽 阅读(11) 评论(0) 推荐(0) 编辑
摘要:import requests from http.client import HTTPConnection HTTPConnection.debuglevel=1 import requests # 请求url url = "http://ip:port/file" # 请求头 headers = 阅读全文
posted @ 2023-08-01 20:15 胖豆芽 阅读(218) 评论(0) 推荐(0) 编辑