pytest不会运行任何测试 [英] pytest doesn't run any test

查看:29
本文介绍了pytest不会运行任何测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pytest不运行任何测试,原因尚不清楚。我试图使用--debug,但没有获得任何有价值的信息。完全不清楚如何用pytest调试这类问题。(看起来可能是pytest配置/环境变量/测试名称模式有问题?)

测试文件示例:

import pytest


@pytest.mark.sanity
def test_me():
    """I'm a test."""

    assert True

但是pytest不运行任何测试,为什么?

$ pytest
================================================== test session starts ===================================================
platform linux2 -- Python 2.7.12, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/qawizard/pytest-hell, inifile:
plugins: xdist-1.15.0, timeout-1.2.0
collected 1 item s

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Exit: Done! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================== no tests ran in 0.13 seconds ==============================================

推荐答案

要确定测试未运行的原因,以下步骤很有用:

  1. 验证具有测试用例的所有文件是否都以"test_"Word开头。
  2. 验证所有测试用例名称是否也以"test_"单词开头。
  3. 请确认您已在根目录中创建了pytest.ini文件。
  4. 请确认您在项目的所有目录/子目录中都有__init__.py文件。

这篇关于pytest不会运行任何测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆