Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
willdesk_apiauto
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
29
Issues
29
List
Boards
Labels
Service Desk
Milestones
Merge Requests
29
Merge Requests
29
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
桦生 詹
willdesk_apiauto
Commits
d11bbce8
Commit
d11bbce8
authored
Mar 12, 2024
by
zhanhuasheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注释处理
parent
cf430e35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
10 deletions
+4
-10
Utils/req_handler.py
Utils/req_handler.py
+2
-4
main.py
main.py
+2
-6
No files found.
Utils/req_handler.py
View file @
d11bbce8
...
@@ -130,7 +130,7 @@ class ReqHandler:
...
@@ -130,7 +130,7 @@ class ReqHandler:
value
=
list
(
item_value
.
values
())[
0
]
value
=
list
(
item_value
.
values
())[
0
]
res_path_value
=
jsonpath
.
jsonpath
(
res
.
json
(),
path
)[
0
]
res_path_value
=
jsonpath
.
jsonpath
(
res
.
json
(),
path
)[
0
]
if
isinstance
(
res_path_value
,
str
)
and
'{"contentList":'
in
res_path_value
:
if
isinstance
(
res_path_value
,
str
)
and
'{"contentList":'
in
res_path_value
:
res_path_value
=
res_path_value
.
replace
(
'
\\
'
,
''
)
res_path_value
=
res_path_value
.
replace
(
'
\\
'
,
''
)
#兼容websocket,当遇到包含{"contentList":内容的值,且类型是字符串时,会自动去除所有\号
if
assert_way
==
'eq'
:
#eq代表完全相同
if
assert_way
==
'eq'
:
#eq代表完全相同
assert
value
==
res_path_value
assert
value
==
res_path_value
elif
assert_way
==
'like'
:
#代表值相同但是type可能不同
elif
assert_way
==
'like'
:
#代表值相同但是type可能不同
...
@@ -141,13 +141,11 @@ class ReqHandler:
...
@@ -141,13 +141,11 @@ class ReqHandler:
assert
round
(
value
,
2
)
==
round
(
res_path_value
,
2
)
assert
round
(
value
,
2
)
==
round
(
res_path_value
,
2
)
elif
assert_way
==
'in'
:
#in代表断言值在返回值中
elif
assert_way
==
'in'
:
#in代表断言值在返回值中
assert
value
in
res_path_value
assert
value
in
res_path_value
elif
assert_way
==
'ain'
:
elif
assert_way
==
'ain'
:
#ain代表返回值在断言值中
assert
res_path_value
in
value
assert
res_path_value
in
value
except
AssertionError
:
except
AssertionError
:
print
(
f
'期望值为
{
value
}
(
{
type
(
value
)
}
),实际返回值为
{
res_path_value
}
(
{
type
(
res_path_value
)
}
),完整的expected体为
{
expected
}
'
)
print
(
f
'期望值为
{
value
}
(
{
type
(
value
)
}
),实际返回值为
{
res_path_value
}
(
{
type
(
res_path_value
)
}
),完整的expected体为
{
expected
}
'
)
raise
AssertionError
raise
AssertionError
except
Exception
as
e
:
print
(
e
,
'-----------------'
)
def
set_value_handler
(
self
,
res
,
item
,
var_class
):
def
set_value_handler
(
self
,
res
,
item
,
var_class
):
'''
'''
:param res: 传response请求体
:param res: 传response请求体
...
...
main.py
View file @
d11bbce8
import
pytest
import
pytest
import
os
import
os
from
Utils.sql_handler
import
test_env_conn
from
Utils.sql_handler
import
test_env_conn
from
Utils
import
websocket_handler
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
try
:
try
:
pytest
.
main
([
'-vs'
,
'TestCase/inbox'
,
f
'--alluredir=./allureReports'
,
'--clean-alluredir'
])
pytest
.
main
([
'-vs'
,
f
'--alluredir=./allureReports'
,
'--clean-alluredir'
])
# result = subprocess.run(['allure', 'generate', './allureReports', '-o', './allure-report', '--clean'])
# os.system('allure generate ./allureReports -c -o ./allureOutput')
finally
:
finally
:
print
(
'finally'
)
test_env_conn
.
close_db
()
#关闭数据库链接
test_env_conn
.
close_db
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment