Skip to main content

No project description provided

Project description

Vedro

Codecov PyPI PyPI - Downloads Python Version

(!) Work in progress, breaking changes are possible until v2.0 is released

Installation

$ pip3 install vedro

Usage

# ./scenarios/decode_base64_encoded_string.py
from aiohttp import ClientSession
import vedro

class Scenario(vedro.Scenario):
    subject = "decode base64 encoded string"

    def given(self):
        self.encoded = "YmFuYW5h"

    async def when(self):
        async with ClientSession() as session:
            self.response = await session.get(f"https://httpbin.org/base64/{self.encoded}")

    async def then(self):
        assert (await self.response.text()) == "banana"
$ python3 -m vedro .

Documentation


Selecting Scenarios

Select File or Directory

$ python3 -m vedro <file_or_dir>

Skip File or Directory

$ python3 -m vedro -i (--ignore) <file_or_dir>

Select Specific Scenario

import vedro

@vedro.only
class Scenario(vedro.Scenario):
    subject = "register user"

Skip Specific Scenario

import vedro

@vedro.skip
class Scenario(vedro.Scenario):
    subject = "register user"

Reporters

Rich Reporter (default)

$ python3 -m vedro -r rich -vvv

Verbose Levels

Verbose Show Scenario Show Steps Show Exception Show Scope (scenario variables)
-v
-vv
-vvv

Silent Reporter

$ python3 -m vedro -r silent

Parametrized Scenario

from aiohttp import ClientSession
import vedro
from vedro import params

class Scenario(vedro.Scenario):
    subject = "get status ({status})"

    @params(200)
    @params(404)
    def __init__(self, status: int):
        self.status = status

    def given(self):
        self.url = f"https://httpbin.org/status/{self.status}"

    async def when(self):
        async with ClientSession() as session:
            self.response = await session.get(self.url)

    async def then(self):
        assert self.response.status == self.status

Plugins

Register Plugin

# ./bootstrap.py
import vedro
from vedro import Dispatcher, Plugin

class DoNothing(Plugin):
    def subscribe(self, dispatcher: Dispatcher) -> None:
        pass

vedro.run(plugins=[DoNothing()])
$ python3 bootstrap.py

Available Plugins

Core

Reporters

External

And more

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

vedro-1.3.1.tar.gz (39.5 kB view hashes)

Uploaded Source

Built Distribution

vedro-1.3.1-py3-none-any.whl (72.7 kB view hashes)

Uploaded Python 3

Supported by

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