0

我正在使用带有 pytest-django 和 pytest-cov 插件的 pytest 测试 Django 项目,当我告诉它在目录(pytest project -vv --cov --ds=proj.tests)中查找测试时,它不会在发生 AssertionError 时重写:

    def test_pytest():
>      assert 2 == 3
E      AssertionError

但是,它仍然总是在另一个目录 / django app 中工作,它是一个单独的 tests.py 文件,而不是在上述情况下包含 python 文件的目录

>       assert rec.action == 'updater'
E       assert 'update' == 'updater'
E         - update
E         + updater
E         ?       +

另外,我不知道它是否有帮助或只是混淆了一切,但是当直接查找文件 ( pytest project/core/tests/pytest.py -vv --cov --ds=proj.tests) 时,它按预期工作:

    def test_pytest():
>       assert 2 == 3
E       assert 2 == 3

它甚至比以前更奇怪,而且我没有触及它的任何配置(对我的同事来说一切都是一样的,据说他的提交时间更长)。

我正在使用 tox 来自动化测试。
这是pytest部分

[pytest]
python_files =
  tests/*.py
  tests*.py
  test_*.py
minversion = 3

为什么它不再像它应该的那样工作了?有没有办法解决这个问题?我不想回到使用 print 的日子 :(

我正在使用 Python 3.5.2、tox 2.4.1、pytest-django 3.0.0(及其 pytest dep)和 pytest-cov 2.4.0

4

1 回答 1

2

好的,这是因为我tests目录中的文件名不是以test_

一旦重命名它再次工作

错误引用@ pytest#2121

于 2016-12-06T12:13:25.317 回答