Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
API-Automation
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
文鑫
API-Automation
Commits
cced2d1a
Commit
cced2d1a
authored
Jul 10, 2020
by
文鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改文件路径
parent
8c955d9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
18 deletions
+9
-18
TestCase/test_Source.py
+9
-18
No files found.
TestCase/test_Source.py
View file @
cced2d1a
...
@@ -6,6 +6,7 @@ import allure
...
@@ -6,6 +6,7 @@ import allure
import
pytest
import
pytest
import
sys
import
sys
import
os
import
os
sys
.
path
.
append
(
'../'
)
sys
.
path
.
append
(
'../'
)
import
logging
import
logging
import
datetime
import
datetime
...
@@ -13,30 +14,21 @@ from common import getSourceId
...
@@ -13,30 +14,21 @@ from common import getSourceId
from
common.getData
import
DoExcelByPandas
from
common.getData
import
DoExcelByPandas
dt
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
dt
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
#
控制台打印的日志级别
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
#
控制台打印的日志级别
filename
=
os
.
path
.
join
(
'../log'
,
str
(
dt
)
+
'.log'
),
#
定义保存日志的路径,使用os.path.join()方法拼接文件路径,其展现为层级关系
filename
=
os
.
path
.
join
(
'./log'
,
str
(
dt
)
+
'.log'
),
#
定义保存日志的路径,使用os.path.join()方法拼接文件路径,其展现为层级关系
filemode
=
'a'
,
#
模式,有w和a,w就是写模式,每次都会重新写日志,覆盖之前的日志
filemode
=
'a'
,
#
模式,有w和a,w就是写模式,每次都会重新写日志,覆盖之前的日志
#a是追加模式,默认如果不写的话,就是追加模式
#
a是追加模式,默认如果不写的话,就是追加模式
format
=
format
=
'
%(asctime)
s -
%(pathname)
s[line:
%(lineno)
d] -
%(levelname)
s:
%(message)
s'
'
%(asctime)
s -
%(pathname)
s[line:
%(lineno)
d] -
%(levelname)
s:
%(message)
s'
#日志格式
#
日志格式
)
)
@allure.feature
(
'数据源'
)
@allure.feature
(
'数据源'
)
class
TestSource
():
class
TestSource
():
'''
@allure.severity装饰器按严重性级别来标记case
parametrize
=
DoExcelByPandas
()
.
get_data_for_pytest
(
'./data/DataA_Source.xlsx'
,
'Sheet1'
)
执行指定测试用例 --allure-severities blocker
BLOCKER = 'blocker' 阻塞缺陷
CRITICAL = 'critical' 严重缺陷
NORMAL = 'normal' 一般缺陷
MINOR = 'minor' 次要缺陷
TRIVIAL = 'trivial' 轻微缺陷
'''
parametrize
=
DoExcelByPandas
()
.
get_data_for_pytest
(
'../data/DataA_Source.xlsx'
,
'Sheet1'
)
@allure.severity
(
'{severity}'
)
@allure.title
(
'{title}'
)
@allure.title
(
'{title}'
)
# @allure.severity('{severity}')
@pytest.mark.parametrize
(
'id,url,data,title,method,severity,condition,except_result'
,
parametrize
)
@pytest.mark.parametrize
(
'id,url,data,title,method,severity,condition,except_result'
,
parametrize
)
def
test
(
self
,
id
,
url
,
data
,
title
,
method
,
severity
,
condition
,
except_result
):
# test开头的测试函数
def
test
(
self
,
id
,
url
,
data
,
title
,
method
,
severity
,
condition
,
except_result
):
# test开头的测试函数
# 测试删除数据源接口
# 测试删除数据源接口
...
@@ -61,6 +53,5 @@ class TestSource():
...
@@ -61,6 +53,5 @@ class TestSource():
# print (type(response[condition]))
# print (type(response[condition]))
assert
response
[
condition
]
==
str
(
except_result
)
assert
response
[
condition
]
==
str
(
except_result
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
pytest
.
main
([
'-s'
,
'test_Source.py'
])
# -s参数是为了显示用例的打印信息。 -q参数只显示结果,不显示过程
pytest
.
main
([
'-s'
,
'test_Source.py'
])
# -s参数是为了显示用例的打印信息。 -q参数只显示结果,不显示过程
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