【发布时间】:2019-11-01 16:25:22
【问题描述】:
我正在尝试创建一个 Pytest 夹具并在夹具中包含“user_type”参数。然后在 if 语句中评估传递的参数。
conftest.py
import pytest
# Some custom modules...
@pytest.fixture
def generate_random_user(_db, user_type):
# Do stuff
if user_type == "no-subscription":
# Do stuffs
yield _db
_db.drop_all()
elif user_type == "with-subscription":
pass
test.py
@pytest.mark.usefixtures("live_server", "client")
def test_checkout_new_customer(selenium, generate_random_user("no-subscription")):
pass
【问题讨论】:
标签: python-3.x flask pytest