Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
study_api
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
lin
study_api
Commits
df298aa8
Commit
df298aa8
authored
Jan 03, 2025
by
lin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update test_case.py
parent
576bd596
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
72 additions
and
21 deletions
+72
-21
APITest_1226/common/read_excel.py
+17
-2
APITest_1226/test_case/conftest.py
+7
-7
APITest_1226/test_case/test_ls/__pycache__/__init__.cpython-313.pyc
+0
-0
APITest_1226/test_case/test_ls/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
+0
-0
APITest_1226/test_case/test_ls/__pycache__/test_case.cpython-313-pytest-8.3.4.pyc
+0
-0
APITest_1226/test_case/test_ls/test_case.py
+18
-4
APITest_1226/test_case/test_ww/__pycache__/__init__.cpython-313.pyc
+0
-0
APITest_1226/test_case/test_ww/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
+0
-0
APITest_1226/test_case/test_ww/__pycache__/test_case.cpython-313-pytest-8.3.4.pyc
+0
-0
APITest_1226/test_case/test_ww/test_case.py
+15
-4
APITest_1226/test_case/test_zs/__pycache__/__init__.cpython-313.pyc
+0
-0
APITest_1226/test_case/test_zs/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
+0
-0
APITest_1226/test_case/test_zs/__pycache__/test_case.cpython-313-pytest-8.3.4.pyc
+0
-0
APITest_1226/test_case/test_zs/test_case.py
+15
-4
No files found.
APITest_1226/common/read_excel.py
View file @
df298aa8
...
...
@@ -8,6 +8,7 @@
#
# ---------------------------------------------------------------------------
import
openpyxl
from
openpyxl.styles.builtins
import
title
from
APITest_1226
import
log
from
APITest_1226.common.read_basic_ini
import
ReadBasicIni
...
...
@@ -47,6 +48,16 @@ class ReadExcel:
return
self
.
__get_value
(
"b"
,
row
)
@log
def
title_name
(
self
,
row
):
"""获取用例标题"""
return
self
.
__get_value
(
"d"
,
row
)
@log
def
level_name
(
self
,
row
):
"""获取用例级别"""
return
self
.
__get_value
(
"e"
,
row
)
@log
def
api_name
(
self
,
row
):
"""获取接口名称"""
return
self
.
__get_value
(
"c"
,
row
)
...
...
@@ -123,8 +134,12 @@ class ReadExcel:
sql
=
self
.
sql_data1
(
row
)
sql_type
=
self
.
sql_type
(
row
)
update_key
=
self
.
update_key
(
row
)
level
=
self
.
level_name
(
row
)
title_name
=
self
.
title_name
(
row
)
module
=
self
.
module_name
(
row
)
api
=
self
.
api_name
(
row
)
if
url
is
not
None
and
expect
is
not
None
and
req
is
not
None
:
case_dict
.
append
([
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
])
case_dict
.
append
([
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
,
level
,
title_name
,
module
,
api
])
return
case_dict
...
...
@@ -133,7 +148,7 @@ class ReadExcel:
if
__name__
==
'__main__'
:
res
=
ReadExcel
(
"lisi"
)
print
(
res
.
case_dict
())
print
(
res
.
case_url
(
3
))
#
print(res.case_url(3))
...
...
APITest_1226/test_case/conftest.py
View file @
df298aa8
...
...
@@ -8,9 +8,9 @@
#
# ---------------------------------------------------------------------------
# """直接复制,不要做任何改动,必须放在用例层目录下的conftest.py文件类"""
# def pytest_collection_modifyitems(items):
# # item表示每个测试用例,解决用例名称中文显示问题
# for item in items:
# item.name = item.name.encode("utf-8").decode("unicode-escape")
# item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
\ No newline at end of file
"""直接复制,不要做任何改动,必须放在用例层目录下的conftest.py文件类"""
def
pytest_collection_modifyitems
(
items
):
# item表示每个测试用例,解决用例名称中文显示问题
for
item
in
items
:
item
.
name
=
item
.
name
.
encode
(
"utf-8"
)
.
decode
(
"unicode-escape"
)
item
.
_nodeid
=
item
.
_nodeid
.
encode
(
"utf-8"
)
.
decode
(
"unicode-escape"
)
\ No newline at end of file
APITest_1226/test_case/test_ls/__pycache__/__init__.cpython-313.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_ls/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_ls/__pycache__/test_case.cpython-313-pytest-8.3.4.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_ls/test_case.py
View file @
df298aa8
...
...
@@ -7,19 +7,33 @@
# Description:
#
# ---------------------------------------------------------------------------
from
allure_pytest.utils
import
allure_label
from
APITest_1226
import
log
from
APITest_1226.common.read_excel
import
ReadExcel
import
pytest
import
allure
dict_case
=
ReadExcel
(
"lisi"
)
.
case_dict
()
class
TestBpm
:
@log
@pytest.mark.parametrize
(
"url,mime,req,case,expect,sql,sql_type,update_key"
,
dict_case
)
def
test_bpm
(
self
,
req2_fix
,
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
):
@pytest.mark.parametrize
(
"url,mime,req,case,expect,sql,sql_type,update_key
,level,title_name,module,api
"
,
dict_case
)
def
test_bpm
(
self
,
req2_fix
,
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
,
level
,
title_name
,
module
,
api
):
res
=
req2_fix
.
req_all
(
req_url
=
url
,
req_mime
=
mime
,
req_req
=
req
,
req_case
=
case
,
sql_type
=
sql_type
,
sql_data
=
sql
,
update_key
=
update_key
)
for
key
in
expect
:
assert
res
.
json
()
.
get
(
key
)
==
expect
[
key
]
allure
.
dynamic
.
feature
(
module
)
allure
.
dynamic
.
story
(
api
)
allure
.
dynamic
.
title
(
title_name
)
allure
.
dynamic
.
severity
(
level
)
try
:
for
key
in
expect
:
assert
res
.
json
()
.
get
(
key
)
==
expect
[
key
]
except
AssertionError
:
raise
AssertionError
(
f
"
\n\t
断言失败:失败的用例为{case},期望数据为:{expect},服务器返回的数据:{res.text}"
)
except
Exception
as
e
:
raise
e
if
__name__
==
'__main__'
:
...
...
APITest_1226/test_case/test_ww/__pycache__/__init__.cpython-313.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_ww/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_ww/__pycache__/test_case.cpython-313-pytest-8.3.4.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_ww/test_case.py
View file @
df298aa8
...
...
@@ -7,6 +7,8 @@
# Description:
#
# ---------------------------------------------------------------------------
import
allure
from
APITest_1226
import
log
from
APITest_1226.common.read_excel
import
ReadExcel
import
pytest
...
...
@@ -15,11 +17,20 @@ dict_case = ReadExcel("ww").case_dict()
class
TestBpm
:
@log
@pytest.mark.parametrize
(
"url,mime,req,case,expect,sql,sql_type,update_key"
,
dict_case
)
def
test_bpm
(
self
,
req2_fix
,
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
):
@pytest.mark.parametrize
(
"url,mime,req,case,expect,sql,sql_type,update_key
,level,title_name,module,api
"
,
dict_case
)
def
test_bpm
(
self
,
req2_fix
,
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
,
level
,
title_name
,
module
,
api
):
res
=
req2_fix
.
req_all
(
req_url
=
url
,
req_mime
=
mime
,
req_req
=
req
,
req_case
=
case
,
sql_type
=
sql_type
,
sql_data
=
sql
,
update_key
=
update_key
)
for
key
in
expect
:
assert
res
.
json
()
.
get
(
key
)
==
expect
[
key
]
allure
.
dynamic
.
feature
(
module
)
allure
.
dynamic
.
story
(
api
)
allure
.
dynamic
.
title
(
title_name
)
allure
.
dynamic
.
severity
(
level
)
try
:
for
key
in
expect
:
assert
res
.
json
()
.
get
(
key
)
==
expect
[
key
]
except
AssertionError
:
raise
AssertionError
(
f
"
\n\t
断言失败:失败的用例为{case},期望数据为:{expect},服务器返回的数据:{res.text}"
)
except
Exception
as
e
:
raise
e
if
__name__
==
'__main__'
:
...
...
APITest_1226/test_case/test_zs/__pycache__/__init__.cpython-313.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_zs/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_zs/__pycache__/test_case.cpython-313-pytest-8.3.4.pyc
deleted
100644 → 0
View file @
576bd596
File deleted
APITest_1226/test_case/test_zs/test_case.py
View file @
df298aa8
...
...
@@ -7,6 +7,8 @@
# Description:
#
# ---------------------------------------------------------------------------
import
allure
from
APITest_1226
import
log
from
APITest_1226.common.read_excel
import
ReadExcel
import
pytest
...
...
@@ -15,11 +17,20 @@ dict_case = ReadExcel("zs").case_dict()
class
TestBpm
:
@log
@pytest.mark.parametrize
(
"url,mime,req,case,expect,sql,sql_type,update_key"
,
dict_case
)
def
test_bpm
(
self
,
req2_fix
,
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
):
@pytest.mark.parametrize
(
"url,mime,req,case,expect,sql,sql_type,update_key
,level,title_name,module,api
"
,
dict_case
)
def
test_bpm
(
self
,
req2_fix
,
url
,
mime
,
req
,
case
,
expect
,
sql
,
sql_type
,
update_key
,
level
,
title_name
,
module
,
api
):
res
=
req2_fix
.
req_all
(
req_url
=
url
,
req_mime
=
mime
,
req_req
=
req
,
req_case
=
case
,
sql_type
=
sql_type
,
sql_data
=
sql
,
update_key
=
update_key
)
for
key
in
expect
:
assert
res
.
json
()
.
get
(
key
)
==
expect
[
key
]
allure
.
dynamic
.
feature
(
module
)
allure
.
dynamic
.
story
(
api
)
allure
.
dynamic
.
title
(
title_name
)
allure
.
dynamic
.
severity
(
level
)
try
:
for
key
in
expect
:
assert
res
.
json
()
.
get
(
key
)
==
expect
[
key
]
except
AssertionError
:
raise
AssertionError
(
f
"
\n\t
断言失败:失败的用例为{case},期望数据为:{expect},服务器返回的数据:{res.text}"
)
except
Exception
as
e
:
raise
e
if
__name__
==
'__main__'
:
...
...
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