Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
62d46d13
Commit
62d46d13
authored
May 27, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通用请求中,增加allure打印 请求参数,请求头
parent
f0d64362
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
common/tools.py
+7
-1
test_case/bmc/test_ ElectronicLicense.py
+8
-8
No files found.
common/tools.py
View file @
62d46d13
...
...
@@ -2,7 +2,7 @@
import
json
import
logging
import
requests
import
requests
,
allure
from
config
import
*
...
...
@@ -19,11 +19,17 @@ def request_main(url, headers, method, data, has_token=False):
try
:
if
method
.
upper
()
==
"GET"
:
allure
.
attach
(
f
"{headers}"
,
"请求头"
,
allure
.
attachment_type
.
TEXT
)
allure
.
attach
(
f
"{data}"
,
"请求参数"
,
allure
.
attachment_type
.
TEXT
)
inner_res
=
requests
.
get
(
url
=
url
,
headers
=
headers
,
params
=
data
)
elif
method
.
upper
()
==
"POST"
:
if
header_content_type
==
"application/json"
:
allure
.
attach
(
f
"{headers}"
,
"请求头"
,
allure
.
attachment_type
.
TEXT
)
allure
.
attach
(
f
"{data}"
,
"请求参数"
,
allure
.
attachment_type
.
TEXT
)
inner_res
=
requests
.
post
(
url
=
url
,
headers
=
headers
,
json
=
data
)
elif
header_content_type
in
[
"application/x-www-form-urlencoded"
]:
allure
.
attach
(
f
"{headers}"
,
"请求头"
,
allure
.
attachment_type
.
TEXT
)
allure
.
attach
(
f
"{data}"
,
"请求参数"
,
allure
.
attachment_type
.
TEXT
)
inner_res
=
requests
.
post
(
url
=
url
,
headers
=
headers
,
data
=
data
)
return
inner_res
except
Exception
as
e
:
...
...
test_case/bmc/test_ ElectronicLicense.py
View file @
62d46d13
...
...
@@ -70,7 +70,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
@allure.story
(
"获取驾驶证图片状态"
)
...
...
@@ -86,7 +86,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
@pytest.mark.usefixtures
(
"imaAuditStatus"
)
...
...
@@ -103,7 +103,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
@allure.story
(
"图像上传页文案"
)
...
...
@@ -119,7 +119,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
...
...
@@ -137,7 +137,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
...
...
@@ -154,7 +154,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
@allure.story
(
"驾驶证图片接口"
)
...
...
@@ -188,7 +188,7 @@ class TestDrivingLicense():
headers
=
inData
[
'headers'
]
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
...
...
@@ -215,7 +215,7 @@ class TestDrivingLicense():
"""请求"""
res
=
request_main
(
url
,
headers
,
method
,
req_data
,
has_token
=
True
)
allure
.
attach
(
"{0}"
.
format
(
res
),
"用例结果"
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
"""把其他某个用例做为初始化,这种方式还需讨论,暂时不行"""
...
...
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