我正在编写我的第一个py.test测试,我编写了类似下面的测试
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Example permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789:user/jerdak"
},
"Action": [
"s3:GetBucketLocation",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::my_bucket"
]
}
]
}
所以我决定写一个函数
class Test_X_Values(object):
def test_value_1(self, fix_A):
A = fix_A['first']
B = fix_A['second']
# some statements here
#the following part is common for all
if ( A.X == True and B.Y == True):
#perform something. for example
print 'performing'
def test_value_2(self, fix_A):
#some statements
if ( A.X == True and B.Y == True):
#perform something. for example
print 'performing'
是否有任何优雅的方式来执行此功能'检查'在每次测试结束时,除了在每次测试结束时写入支票(A,B)之外?