-
4 votesanswersviews
pytest使用可变内省来断言消息定制
在pytest documentation中,它表示您可以在 assert 失败时自定义输出消息 . 我想在测试REST API方法时自定义 assert 消息,它返回一个无效的状态代码: def test_api_call(self, client): response = client.get(reverse('api:my_api_call')) assert respons... -
1 votesanswersviews
Py.test失败,但./manage.py测试工作正常
我最近接管了一个代码库,然后我开始添加Selenium测试并转移到py.test . 我喜欢py.test由于并行性和其他第三方包,但我注意到py.test的主要问题 . 代码库是Django堆栈(Python 2.7上的1.8,pytest-2.6.4,目前没有x-dist) . 1)py.test测试比正常的django测试套件运行得慢(不是很好,但我可以忍受) 2)当我通过执行 py.tes... -
1 votesanswersviews
如何不回滚在类范围的pytest-django fixture中创建的db事务
我正在使用带有Django的pytest(通过pytest-django)和我'm wondering if it'可能有一个范围 class 的夹具,它在数据库中创建了一些模型,然后在每次测试结束时都没有删除这些模型 . 例如; @pytest.fixture(scope='class') def expensive(): return MyModel.objects.create() ...