【发布时间】:2018-11-22 09:30:33
【问题描述】:
以下是使用user 夹具设置测试的测试代码示例。
@pytest.fixture
def user():
# Setup db connection
yield User('test@example.com')
# Close db connection
def test_change_email(user):
new_email = 'new@example.com'
change_email(user, new_email)
assert user.email == new_email
如果我想,有没有办法使用同一个夹具在同一个测试中生成多个用户对象?添加批量更改用户电子邮件的功能,并且需要在测试前设置 10 个用户?
【问题讨论】: