【发布时间】:2022-06-27 23:52:56
【问题描述】:
目前,我使用以下设置从名为 fixtures.py 的文件中导入 pytest 设备并使用它们运行测试:
from django.contrib.auth.models import User, Group
from django.core import mail
from main.tests.fixtures import user_a, group_dropoff_for_qc
def test_should_check_password(db, user_a: User) -> None:
user_a.set_password("secret")
assert user_a.check_password("secret") is True
# more tests here
随着我编写更多测试并使用更多固定装置,来自main.tests.fixtures 的导入列表变得非常长。是否有一些内置的 pytest 方法?这似乎是一种常见的操作,应该有一种更简化的方法。
【问题讨论】:
标签: pytest