我们delete_product
在 assert 中调用了多次调用的函数,如何删除 delete_product 的所有实例并使用 pytest 夹具编写一个函数。
这是代码:
try:
output = subprocess.check_output(cmd, shell=True).decode()
except subprocess.CalledProcessError as error:
logger.error("error: {}".format(error))
assert delete_product(role, product_name), (
"Product " + product_name + " could not be deleted by role " + role
)
assert False, error
try:
assert "assumed-role/" + storagerole + "/kiam-kiam" in output, (
"Expected role " + storagerole + " was not assumed within container"
)
except AssertionError as error:
logger.error("error: {}".format(error))
assert delete_product(role, product_name), (
"Product " + product_name + " could not be deleted by role " + role
)
assert False, error
logger.info("All steps passed, deleting pod: {}".format(launched_pod))
assert delete_product(role, product_name), (
"Product " + product_name + " could not be deleted by role " + role
)