Varsnap
Project description
Varsnap Python
Installation
Install from PyPI - pip install varsnap
Requirements
The client depends on three environment variables to be set:
VARSNAP
- Should be eithertrue
orfalse
. Varsnap will be disabled if the variable is anything other thantrue
.ENV
- If set todevelopment
, the client will receive events from production. If set toproduction
, 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
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
varsnap-1.3.3.tar.gz
(9.6 kB
view hashes)
Built Distribution
varsnap-1.3.3-py3-none-any.whl
(15.2 kB
view hashes)