pytest plugin that allows to dump environment variables, package version and generic attributes
Project description
pytest-echo
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
[!NOTE] The first attempt to retrieve the version is done via setuptools if it fails, the module is imported (
__import__(package)) to retrieve the version readingget_version,__version__,VERSION,versionso any module level code is executed. This should be not an issue as no problematic code should be present in the first level of the package
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
[!NOTE] Be careful when use
--echo-attr. It loads any module in the path and this will execute any module level code If you try to dump a property, relatedgetterwill be executed.
[!NOTE] You cannot dump callable result.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_echo-2.0.1.tar.gz.
File metadata
- Download URL: pytest_echo-2.0.1.tar.gz
- Upload date:
- Size: 68.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f5769af610fdace9f4a7c98773b469865d78149822d29c4b66fbdb39074364b
|
|
| MD5 |
9bc98eb8254ebdbd275e964deab5f9f8
|
|
| BLAKE2b-256 |
a917f05bdd7c15f33e1b537ea59199002ab3cbeeacfd2bb924116a22915c4b61
|
Provenance
The following attestation bundles were made for pytest_echo-2.0.1.tar.gz:
Publisher:
release.yml on pytest-dev/pytest-echo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_echo-2.0.1.tar.gz -
Subject digest:
5f5769af610fdace9f4a7c98773b469865d78149822d29c4b66fbdb39074364b - Sigstore transparency entry: 203343581
- Sigstore integration time:
-
Permalink:
pytest-dev/pytest-echo@5e488ff4e79157abb7916d2bb238bc54bdab1fcd -
Branch / Tag:
refs/tags/2.0.1 - Owner: https://github.com/pytest-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e488ff4e79157abb7916d2bb238bc54bdab1fcd -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_echo-2.0.1-py3-none-any.whl.
File metadata
- Download URL: pytest_echo-2.0.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03bb43d55c7f78a8a7ebd7b128db56c8b5ce9b86a0b871addd63a49640a41f92
|
|
| MD5 |
44edbf64ed0382f004ea4b540d1ba4d0
|
|
| BLAKE2b-256 |
607870fb01675955a5ad867e6b54511b663a05996cb394aa9df48d365b6a9ea5
|
Provenance
The following attestation bundles were made for pytest_echo-2.0.1-py3-none-any.whl:
Publisher:
release.yml on pytest-dev/pytest-echo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_echo-2.0.1-py3-none-any.whl -
Subject digest:
03bb43d55c7f78a8a7ebd7b128db56c8b5ce9b86a0b871addd63a49640a41f92 - Sigstore transparency entry: 203343583
- Sigstore integration time:
-
Permalink:
pytest-dev/pytest-echo@5e488ff4e79157abb7916d2bb238bc54bdab1fcd -
Branch / Tag:
refs/tags/2.0.1 - Owner: https://github.com/pytest-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e488ff4e79157abb7916d2bb238bc54bdab1fcd -
Trigger Event:
push
-
Statement type: