跳转到主要内容

pytest插件,具有回显环境变量、包版本和通用属性的机制

项目描述

PyPI package

打印环境变量、包版本和通用属性,如测试开始时所示。

在持续集成中很有用,可以转储测试配置/环境,或者检查属性是否正确设置(即您使用os.environ更改环境)

安装

通过以下方式安装

pip install pytest-echo

示例

转储环境变量

$ pytest --echo-env=HOME
============================= test session starts =========================
platform linux2 -- Python 2.7.4 -- py-1.4.22 -- pytest-2.6.0 -- /bin/python
Environment:
    HOME: /Users/sax
plugins: echo, pydev, cov, cache, django

转储包版本

$ pytest --echo-version=pytest_echo
============================= test session starts =========================
platform linux2 -- Python 2.7.4 -- py-1.4.22 -- pytest-2.6.0 -- /bin/python
Package version:
    pytest_echo: 0.1
plugins: echo, pydev, cov, cache, django

转储属性

$ pytest --echo-attr=django.conf.settings.DEBUG
============================= test session starts =========================
platform linux2 -- Python 2.7.4 -- py-1.4.22 -- pytest-2.6.0 -- /bin/python
Inspections
    django.conf.settings.DEBUG: False
plugins: echo, pydev, cov, cache, django

通过 tox.ini/setup.cfg/pytest.cfg 进行配置

在 django 项目中使用示例

[pytest]
addopts = -vvv
        --tb=short
        --capture=no
        --echo-env PWD
        --echo-env VIRTUAL_ENV
        --echo-env DBENGINE
        --echo-version django
        --echo-version pip
        --echo-version pytest-echo
        --echo-attr django.conf.settings.DATABASES.default.ENGINE
$ pytest
============================= test session starts =========================
platform linux2 -- Python 2.7.4 -- py-1.4.22 -- pytest-2.6.0 -- /bin/python
Environment:
    DJANGO_SETTINGS_MODULE: tests.settings
    PWD: /data/PROGETTI/sem
    VIRTUAL_ENV: /data/VENV/sem
    DBENGINE: <not set>
Package version:
    django: 1.6.5
    pip: 1.5.6
    pytest_echo: 1.2
Inspections:
    django.conf.settings.DATABASES.default.ENGINE: 'django.db.backends.postgresql_psycopg2'
plugins: echo, cache, capturelog, contextfixture, cov, django, pydev
collected 14 items
.............
14 passed in 4.95 seconds

通配符

从版本 1.5 开始,可以通配包版本和环境变量,如下所示

$ pytest --echo-version=pytest-* --echo-env=VIRTUAL*

[pytest]
addopts = -vvv
        --echo-env VIRTUAL*
        --echo-version pytest-*

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源分布

pytest-echo-1.7.3.tar.gz (13.9 kB 查看哈希值)

上传时间

构建分布

pytest_echo-1.7.3-py2.py3-none-any.whl (5.7 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下机构支持