Skip to main content

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_op still acts, and tests_only will not)
  • VW_ALWAYS -> (NOTE: VW_IGNORE takes precedence over this var) causes VW to behave like it is always in a test environment (no_op is always a no-op)

Examples

  1. Using an in-memory db for tests:

    import sqlite3
    
    import vw
    
    _con = sqlite3.connect(":memory:" if vw.is_test_env() else "database.sqlite3")
    
  2. 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"))
    
  3. 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)

Source distribution for import-volkswagen 0.1.2
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)

Table of built distributions (wheels) for import-volkswagen 0.1.2
File Interpreter ABI Platform Actions
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 log

Release 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 log

Security 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.

Select from 2 files

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 log

A 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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page