我在conftest.py中找到了fixtue,我需要在不同的测试类中使用来自灯具的信息。
conftest.py:
@fixture(scope="module")
def init_environment():
ip1 = "1.2.3.4"
ip2 = "1.2.3.5"
ips_tuple = (ip1, ip2)
差异测试类:
class testClass():
def test1(self, init_environment):
ip_tuple_in_class = {here I want ips_tuple from the fixture}
我可以在测试类中获取数据吗?
答案 0 :(得分:0)
请尝试下一个:
conftest.py:
@fixture(scope="module")
def init_environment():
ip1 = "1.2.3.4"
ip2 = "1.2.3.5"
ips_tuple = (ip1, ip2)
return ips_tuple
不同的测试班级:
class fakeTests():
def test_fake_1(self, init_environment):
print(init_environment)