我需要编写一些测试用例来测试用户的权限。在每个测试用例中,UserA 具有不同的权限并进行检查。我想使用管理员角色在 setup_method 中为 userA 提供不同的权限。如何将参数传递给 setup_method 以便在每个测试用例开始之前,我可以有不同的测试用例?我有类似以下的内容,但不确定如何将参数传递给 setup_method。
class TestPermission():
@classmethod
class setup_method(self, permission):
login as amdin
provide permission to userA
logout
login as userA
@classmethod
class teardown_method(self):
logout as userA
@fixure(permission1)
class test_permissionA(self):
assert drive.find_element_by_xpath('//div[@id="permission1"]') is True
assert drive.find_element_by_xpath('//div[@id="permission2"]') is False
assert drive.find_element_by_xpath('//div[@id="permission3"]') is False
@fixure(permission2)
class test_permissionB(self):
assert drive.find_element_by_xpath('//div[@id="permission1"]') is False
assert drive.find_element_by_xpath('//div[@id="permission2"]') is True
assert drive.find_element_by_xpath('//div[@id="permission3"]') is False