Skip to main content

Varsnap

Project description

Varsnap Python

Codeship Status for albertyw/varsnap-python

Python Varsnap Client

Installation

Install from PyPI - pip install varsnap

Requirements

The client depends on three environment variables to be set:

  • VARSNAP - Should be either true or false. Varsnap will be disabled if the variable is anything other than true.
  • ENV - If set to development, the client will receive events from production. If set to production, the client will emit events.
  • VARSNAP_PRODUCER_TOKEN - Only clients with this token may emit production snapshots. Copied from https://www.varsnap.com/user/
  • VARSNAP_CONSUMER_TOKEN - Only clients with this token may emit development snapshots. Copied from https://www.varsnap.com/user/

Usage

Add the varsnap decorator in front of any function you'd like to make better:

from varsnap import varsnap


@varsnap
def example(args, **kwargs):
    return 'output'

Testing

With the proper environment variables set, in a test file, add

import unittest
from varsnap import test

class TestIntegration(unittest.TestCase):
    def test_varsnap(self):
        matches, logs = test()
        if matches is None:
            raise unittest.case.SkipTest('No Snaps found')
        self.assertTrue(matches, logs)

Troubleshooting

Decorators changing function names

Using decorators may change the name of functions. In order to not confuse varsnap, set the decorated function's __qualname__ to the original __qualname__:

def decorator(func):
    def decorated(*args, **kwargs):
        func(*args, **kwargs)
    decorated.__qualname__ = func.__qualname__
    return decorated

Publishing

pip install twine
python setup.py sdist bdist_wheel
twine upload dist/*

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

varsnap-1.3.4.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

varsnap-1.3.4-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file varsnap-1.3.4.tar.gz.

File metadata

  • Download URL: varsnap-1.3.4.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.5

File hashes

Hashes for varsnap-1.3.4.tar.gz
Algorithm Hash digest
SHA256 bdaa24fbc4bbfc5fca3b4cca7fc7fde5055e01f629d2bed6ba386d36fd420a98
MD5 2e6bf93291c583eb34a3b34a5575dc66
BLAKE2b-256 d819906bad92bef963ed4f58caefdfd9a23cf19d1901d6b91a673d108da9f013

See more details on using hashes here.

File details

Details for the file varsnap-1.3.4-py3-none-any.whl.

File metadata

  • Download URL: varsnap-1.3.4-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.5

File hashes

Hashes for varsnap-1.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 54b2e9148f6fdead798f525adf71393ab09bf1118088d64bee8439c0472d3337
MD5 8aec8595aa7e83a075f4b57d873ebf93
BLAKE2b-256 af2a5e5f5ca10825c71d4b2e16bbcd75e310309b0194d606e631b416add2c186

See more details on using hashes here.

Supported by

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