如何在pytest中将变量从一个测试传递到另一个测试

时间:2020-08-25 20:42:01

标签: python python-3.x unit-testing pytest

我使用pytest并执行下一个测试,我必须将一个变量(product_id)传递给它们,例如:

def test_1():
    product = Product()
    product.enter_name('product1')
    product.add_price(2)
    product.add()
    product_id = driver.find_element_by_name('id')

def test_2():
    driver.get('http://example.com/{}'.format(product_id)
    ...

我该怎么做?

0 个答案:

没有答案