Skip to main content

pytest plugin with mechanisms for echoing environment variables, package version and generic attributes

Project description

PyPI package

Print environment variables, package version and generic attributes, as they are at the beginning of the test.

Useful in the continuous integration to dump test configuration/environment and or to check if attributes are properly set (ie. you change environment with os.environ)

Install

install via:

pip install pytest-echo

Examples

Dump environment variables

$ 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

Dump package version

$ 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

Dump attributes

$ 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

Configure via tox.ini/setup.cfg/pytest.cfg

Example of use in a django project:

[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

Globbing

Starting from version 1.5, is possible to glob packages version and environment variables, as:

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

or

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-echo-1.7.3.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

pytest_echo-1.7.3-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-echo-1.7.3.tar.gz.

File metadata

  • Download URL: pytest-echo-1.7.3.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pytest-echo-1.7.3.tar.gz
Algorithm Hash digest
SHA256 2307af560ebbdc77967579e577f24015467fbcf80cabb9b04d225348bb8d9474
MD5 70f7fd1c15bfff46f81e99eb47a07142
BLAKE2b-256 370ea5dcb4a634dcbdba8a97d1201c8c8a95405e6f504e055e1e9a10e4b939d3

See more details on using hashes here.

File details

Details for the file pytest_echo-1.7.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_echo-1.7.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 683f4d2fef8dd701aeaf47db834ccc114d43f580abcfea53f3ce2ffe8166c3c0
MD5 8a71356ae13d456c43982805e644c966
BLAKE2b-256 afd2155f0ffc8d5c1091c9b5aaec93325c4729b2474e00729f1ac320310268cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page