Skip to main content

vedro-fn

Codecov PyPI PyPI - Downloads Python Version

A plugin for the Vedro framework that enables a functional-style syntax for defining Vedro scenarios.

(!) Starting with Vedro v1.14, the functional‑style scenario syntax is available directly in Vedro core. Use vedro-fn only if your project is on Vedro v1.13 or earlier, or if you need backward‑compatibility with older versions.

Installation

Quick

For a quick installation, you can use a plugin manager as follows:

$ vedro plugin install vedro-fn

Manual

To install manually, follow these steps:

  1. Install the package using pip:
$ pip3 install vedro-fn
  1. Next, activate the plugin in your vedro.cfg.py configuration file:
# ./vedro.cfg.py
import vedro
import vedro_fn


class Config(vedro.Config):
    class Plugins(vedro.Config.Plugins):
        class VedroFn(vedro_fn.VedroFn):
            enabled = True

Usage

Basic Example

import base64
from vedro_fn import scenario, given, when, then

@scenario()
def decode_base64_encoded_str():
    with given:
        encoded = "YmFuYW5h"

    with when:
        decoded = base64.b64decode(encoded)

    with then:
        assert decoded == b"banana"

To run scenarios, use:

$ vedro run

Using Scenario Decorators

Scenario decorators (such as @skip, @only, etc.) can be passed via an extended syntax:

import base64
from vedro import skip
from vedro_fn import scenario, given, when, then

@scenario[skip]()
def decode_base64_encoded_str():
    with given:
        encoded = "YmFuYW5h"

    with when:
        decoded = base64.b64decode(encoded)

    with then:
        assert decoded == b"banana"

Parametrization

You can also use Vedro’s built-in @params decorator with @scenario for parametrized scenarios:

import base64
from vedro import params
from vedro_fn import scenario, when, then

@scenario([
    params("YmFuYW5h", b"banana"),
    params("", b""),
])
def decode_base64_encoded_str(encoded, expected):
    with when:
        decoded = base64.b64decode(encoded)

    with then:
        assert decoded == expected

Async Example

Here’s an example of an asynchronous scenario:

from vedro_fn import scenario, when, then
from interfaces.api import fetch_users

@scenario()
async def fetch_users_from_api():
    with when:
        users = await fetch_users()

    with then:
        assert users == [
            {"id": 1, "name": "Bob"},
            {"id": 2, "name": "Alice"},
        ]

Metadata

Release files for vedro-fn 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 vedro-fn 0.1.2
File Size Uploaded Provenance Actions
vedro_fn-0.1.2.tar.gz 12.0 kB Without provenance Details for vedro_fn-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vedro-fn 0.1.2
File Interpreter ABI Platform Actions
vedro_fn-0.1.2-py3-none-any.whl Python 3 none any Details for vedro_fn-0.1.2-py3-none-any.whl

Total release size: 22.6 kB

Release files / vedro_fn-0.1.2.tar.gz

Download URL vedro_fn-0.1.2.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bcfe2ca88c6082ed8572ff2c06c574945351511e3a20d8abc2ddad070f9cded2
BLAKE2b-256 checksum
How to use checksums
e0dc29ac3cd3c1a92b25629643ca066dd103de07e9d442c3ea47babdd8a36fe0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / vedro_fn-0.1.2-py3-none-any.whl

Download URL vedro_fn-0.1.2-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eec5a5da769b04b60f100d7ba562f0feed39b947950c8cd81a8fd5bee0cd2553
BLAKE2b-256 checksum
How to use checksums
3d2bd89f0e1f7fcde9de590049d5bc9a5c3c02a2544552650409d49fa6672650
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Security for vedro-fn 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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