VW
This module provides decorators that turn on or off the decorated method depending on whether it is running in a testing environment or not.
NOTE: The name vw was chosen for convenience and is not intended as commentary on any political topic real or imagined.
Why?
Have you ever found yourself wanting an easy way to turn off the logging when running in tests?
What about database access?
Mocking works well for your own code, but what about when a user imports your library?
This is what this tool is meant to solve.
Controlling
By using python-decouple, the following variables can be set in a settings.ini file, or a .env file, or as variables in the environment.
VW_IGNORE-> causes VW to ignore if it is in a test environment (no_opstill acts, andtests_onlywill not)VW_ALWAYS-> (NOTE:VW_IGNOREtakes precedence over this var) causes VW to behave like it is always in a test environment (no_opis always a no-op)
Examples
-
Using an in-memory db for tests:
import sqlite3 import vw _con = sqlite3.connect(":memory:" if vw.is_test_env() else "database.sqlite3")
-
Logging to a local file for tests
import logging import vw _root_logger = logging.getLogger(None) _root_logger.addHandler(logging.FileHandler("test.log" if vw.is_test_env() else "//path/to/server/log.txt"))
-
Avoid doing things in unit/component/integration tests that should only be done in production
import requests import vw @vw.no_op def send_tornado_warning(): requests.post(...)
Metadata
Release files for import-volkswagen 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| import_volkswagen-0.1.2.tar.gz | 4.6 kB | With provenance | Details for import_volkswagen-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| import_volkswagen-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for import_volkswagen-0.1.2-py3-none-any.whl |
Total release size: 10.1 kB
Release files / import_volkswagen-0.1.2.tar.gz
| Download URL | import_volkswagen-0.1.2.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
786fc3936c65112f9ee9cb6eee9e08596191f986bc8b1f23f3ec42f1a5399238
|
|
BLAKE2b-256 checksum How to use checksums |
4dfad0d05648705a41c6620c0d7b110a9291627b30a2709907251399703ef97a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 17, 2025.
Transparency logRelease files / import_volkswagen-0.1.2-py3-none-any.whl
| Download URL | import_volkswagen-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f661d294fc85f833bbcc824b2d03b1157bc149cc20fddcac234cce59c3d7b94c
|
|
BLAKE2b-256 checksum How to use checksums |
127eff072f94573e5f6e7d416406b38cde1a4b0968882a916a715953e492057a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 17, 2025.
Transparency logSecurity for import-volkswagen 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for import_volkswagen-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 17, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.