Commit d93e7c1d authored by 王超's avatar 王超

第一次提交9.12

parents
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from `dotnet new gitignore`
# dotenv files
.env
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET
project.lock.json
project.fragment.lock.json
artifacts/
# Tye
.tye/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
.idea
##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# Vim temporary swap files
*.swp
import time
import pytest
import os
if __name__ == '__main__':
pytest.main()
time.sleep(1)
os.system("allure generate ./temp -o ./reports --clean")
import logging
import time
from common.yaml_util import get_object_path, read_config_file
class LoggerUtil:
def creat_log(self,logger_name='log'):
#创建一个日志对象
self.logger = logging.getLogger(logger_name)
#设置全局的日志级别(critical>error>waring>info>debug)
self.logger.setLevel(logging.DEBUG)
#放置日志重复
if not self.logger.handlers:
#-----------文件日志----------
#获得日志文件的名称
self.file_log_path = get_object_path()+'/logs/'+ read_config_file('log','log_name')+str(int(time.time()))+'.log'
# print(self.file_log_path)
#创建文件日志的控制器
self.file_hander = logging.FileHandler(self.file_log_path,encoding='utf-8')
#设置文件日志的界别
file_log_lever = str(read_config_file('log','log_level')).lower()
if file_log_lever =='debug':
self.file_hander.setLevel(logging.DEBUG)
elif file_log_lever =='info':
self.file_hander.setLevel(logging.INFO)
elif file_log_lever =='warning':
self.file_hander.setLevel(logging.WARNING)
elif file_log_lever =='error':
self.file_hander.setLevel(logging.ERROR)
elif file_log_lever == 'critical':
self.file_hander.setLevel(logging.CRITICAL)
#设置文件日志的格式
self.file_hander.setFormatter(logging.Formatter(read_config_file('log','log_format')))
#将控制器加入到日志对象
self.logger.addHandler(self.file_hander)
#-----------控制台日志----------
# 创建控制台日志的控制器
self.console_hander = logging.StreamHandler()
# 设置控制台日志的界别
console_log_lever = str(read_config_file('log', 'log_level')).lower()
if console_log_lever == 'debug':
self.console_hander.setLevel(logging.DEBUG)
elif console_log_lever == 'info':
self.file_hander.setLevel(logging.INFO)
elif console_log_lever == 'warning':
self.console_hander.setLevel(logging.WARNING)
elif console_log_lever == 'error':
self.console_hander.setLevel(logging.ERROR)
elif console_log_lever == 'critical':
self.console_hander.setLevel(logging.CRITICAL)
# 设置控制台日志的格式
self.console_hander.setFormatter(logging.Formatter(read_config_file('log', 'log_format')))
# 将控制器加入到日志对象
self.logger.addHandler(self.console_hander)
return self.logger
#函数:输出正常日志
def write_log(log_message):
LoggerUtil().creat_log().info(log_message)
#函数:输出错误日志
def error_log(log_message):
LoggerUtil().creat_log().info(log_message)
raise Exception(log_message)
import pymysql
from common.yaml_util import read_config_file, get_object_path
class MysqlrUtil:
def __init__(self):
host = read_config_file('mysql','host')
user = read_config_file('mysql', 'user')
passwd = read_config_file('mysql', 'passwd')
database = read_config_file('mysql', 'database')
charset = read_config_file('mysql', 'charset')
self.connect = pymysql.connect(
host=host,
user=user,
passwd=passwd,
database=database,
charset=charset
)
self.cursor = self.connect.cursor()
def sql(self,sql):
self.cursor.execute(sql)
data_list = self.cursor.fetchall()
return data_list
def __del__(self):
self.connect.close()
self.cursor.close()
if __name__ == '__main__':
data = MysqlrUtil().sql('SELECT * FROM test01')
print(data[0][1])
\ No newline at end of file
import csv
import json
import traceback
import yaml
from common.logger_util import write_log, error_log
from common.yaml_util import get_object_path
#读取csv数据文件
def read_csv_file(csv_path):
csv_data_list = []
with open(get_object_path()+'/'+csv_path,encoding='utf-8') as f:
csv_data = csv.reader(f)
for row in csv_data:
csv_data_list.append(row)
return csv_data_list
#读取YAML测试用例文件
def read_testcase_file(yaml_path):
try:
with open(get_object_path()+yaml_path,encoding='utf-8') as f:
caseinfo = yaml.load(stream=f, Loader=yaml.FullLoader)
# print("==========读取yaml文件数据:",caseinfo)
if len(caseinfo) >= 2:
return caseinfo
else:
caseinfo_keys = dict(*caseinfo).keys()
if 'parameters' in caseinfo_keys:
new_caseinfo = analysis_parameters(*caseinfo)
return new_caseinfo
else:
return caseinfo
except Exception as f:
error_log("读取用例文件异常:异常信息: %s" %str(traceback.format_exc()))
#分析参数化
def analysis_parameters(caseinfo):
try:
caseinfo_keys = dict(caseinfo).keys()
if 'parameters' in caseinfo_keys:
for key, value in dict(caseinfo['parameters']).items():
caseinfo_str = json.dumps(caseinfo)
key_list = str(key).split('-')
# 规范csv数据的写法
length_flag = True
csv_data_list = read_csv_file(value)
one_row_csv_data = csv_data_list[0]
for csv_data in csv_data_list:
if len(csv_data) != len(one_row_csv_data):
length_flag = False
break
# 解析
new_caseinfo = []
if length_flag:
for x in range(1, len(csv_data_list)):
temp_caseinfo = caseinfo_str
for y in range(0, len(csv_data_list[x])):
if csv_data_list[0][y] in key_list:
temp_caseinfo = temp_caseinfo.replace("$csv{" + csv_data_list[0][y] + "}",
csv_data_list[x][y])
new_caseinfo.append(json.loads(temp_caseinfo))
# print("解析:",new_caseinfo)
return new_caseinfo
else:
return caseinfo
except Exception as f:
error_log("分析parameters参数化异常:异常信息: %s" %str(traceback.format_exc()))
\ No newline at end of file
This diff is collapsed.
import yaml
import os
#获取项目路径
def get_object_path():
return os.path.abspath(os.getcwd().split('common')[0])
#读取config.yml文件
def read_config_file(one_node,two_node):
with open(get_object_path()+"\\config.yml",encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
return value[one_node][two_node]
#读取extract.yml文件
def read_extract_file(one_node):
with open(get_object_path()+"\\extract.yml",encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
return value[one_node]
#写入extract.yml文件a
def write_extract_file(data):
with open(get_object_path()+"\\extract.yml",encoding='utf-8',mode='a') as f:
yaml.dump(data=data, stream=f,allow_unicode=True )
#清空extract.yml文件a
def clear_extract_file():
with open(get_object_path()+"\\extract.yml",encoding='utf-8',mode='w') as f:
f.truncate()
if __name__ == '__main__':
print(read_config_file('base','base_url'))
print(get_object_path())
base:
siot_url: http://127.0.0.1:6700
cms_url: http://127.0.0.1:18000
base_url: http://127.0.0.1:18000
tunnel:
device_ip: 127.0.0.1
log:
log_name: logs_
log_level: info
log_format: '[%(asctime)s] %(filename)s->%(funcName)s line:%(lineno)d [%(levelname)s] %(message)s'
project:
project_path: D:\QW\WXWork\1688857353444240\Cache\File\2024-08
x_project: 1739f9aac285443f973c035f205bcb4b
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiU3VwZXJBZG1pbiIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWVpZGVudGlmaWVyIjoiU3VwZXJBZG1pbiIsImlzcyI6IkNNU3YyIiwiYXVkIjoiQXBpIn0.AJUOE6YQ5MAxDqHOIz-yQbpCKPNq5tPoFBWUY381qns
mysql:
host: 127.0.0.1
port: 3306
user: root
password: 123456
database: TestDB
charset: utf8
sqlserver:
DRIVER: SQL Server
host: 127.0.0.1
user: sa
password: 123456
database: TestDB
import pytest
import pyodbc
from debug_talk import DubugTalk
import pymysql # 导入 pymysql 库(MySQL 数据库)
from common.yaml_util import clear_extract_file
@pytest.fixture(scope='session',autouse=True)
def clear_extract():
clear_extract_file()
import random
import os
import time
import datetime
from common.parameters_util import read_csv_file, read_testcase_file
from common.yaml_util import read_extract_file, read_config_file
from datetime import datetime
class DubugTalk:
#获取随机数的方法
def get_random_number(self,min,max):
return random.randint(int(min),int(max))
# 获取时间戳
def get_time_stamp(self):
now = datetime.now().timestamp()
# timestamp = now.timestamp()
# print(now)
return now
def get_data(self):
# 获取当前日期
current_date = datetime.now().date()
return current_date
#获取extract.yaml文件中的值
def get_extract_data(self,node_name):
return read_extract_file(node_name)
# 读取基础路径
def get_base_url(self,node_name):
return read_config_file('base',node_name)
#读取工程信息鉴权
def get_project_Authorization(self,node_name):
return read_config_file('project',node_name)
#获取项目路径,单斜杠
def get_project_path(self):
path = os.path.abspath(os.getcwd().split('debug_talk.py')[0])
return path
# 获取项目路径,双斜杠
def get_project_path2(self):
path = os.path.abspath(os.getcwd().split('debug_talk.py')[0])
path2 = path.replace("\\","\\\\")
return path2
def get_int(self,two_name,node_name):
csv_data = read_csv_file(two_name)
print('原始:',csv_data)
print('取值:',csv_data[0][1])
print('第一个:',csv_data)
print('参数:',node_name)
csv_len= len(csv_data)
for key in range(0,csv_len):
for value in range(0,len(csv_data[key])):
# print('第二层:',csv_data[key][value])
if csv_data[key][value] == node_name:
value_data = int(csv_data[key+1][value])
return value_data
# 读取config.
def get_config(self,one,two):
return read_config_file(one,two)
if __name__ == '__main__':
# re = DubugTalk().get_int('data\create_project.csv','type')
# re1 = read_testcase_file('/testcase/EngineeringManagement/create_project100.yml')
# print(type(re),re)
# print(re1)
DubugTalk().get_time_stamp()
BarcodeVerificationRule1_concurrencyStamp: f0447c6f41df4242b4b504b973761798
# 这是一个示例 Python 脚本。
# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。
def print_hi(name):
# 在下面的代码行中使用断点来调试脚本。
print(f'Hi, {name}') # 按 Ctrl+F8 切换断点。
# 按装订区域中的绿色按钮以运行脚本。
if __name__ == '__main__':
print_hi('PyCharm')
# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助
[pytest]
addopts=-vs --alluredir ./temp --clean-alluredir
testpaths=./testcase
python_files=test_*.py
python_classes=Test*
python_functions=test
\ No newline at end of file
import os
import jinja2
import yaml
import random
def render(tpl_path, **kwargs):
path, filename = os.path.split(tpl_path)
return jinja2.Environment(loader=jinja2.FileSystemLoader(path or './')
).get_template(filename).render(**kwargs)
# yaml 文件调用以下函数
def rand_str():
return str(random.randint(1000000, 2000000))
if __name__ == '__main__':
r = render("aa.yml", **{"rand_str": rand_str})
print(r)
print(yaml.safe_load(r))
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment