# vedro-fn
[![Codecov](https://img.shields.io/codecov/c/github/vedro-universe/vedro-fn/main.svg?style=flat-square)](https://codecov.io/gh/vedro-universe/vedro-fn)
[![PyPI](https://img.shields.io/pypi/v/vedro-fn.svg?style=flat-square)](https://pypi.python.org/pypi/vedro-fn/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/vedro-fn?style=flat-square)](https://pypi.python.org/pypi/vedro-fn/)
[![Python Version](https://img.shields.io/pypi/pyversions/vedro-fn.svg?style=flat-square)](https://pypi.python.org/pypi/vedro-fn/)
A plugin for the [Vedro](https://vedro.io) framework that enables a functional-style syntax for defining Vedro scenarios.
## Installation
<details open>
<summary>Quick</summary>
<p>
For a quick installation, you can use a plugin manager as follows:
```shell
$ vedro plugin install vedro-fn
```
</p>
</details>
<details>
<summary>Manual</summary>
<p>
To install manually, follow these steps:
1. Install the package using pip:
```shell
$ pip3 install vedro-fn
```
2. Next, activate the plugin in your `vedro.cfg.py` configuration file:
```python
# ./vedro.cfg.py
import vedro
import vedro_fn
class Config(vedro.Config):
class Plugins(vedro.Config.Plugins):
class VedroFn(vedro_fn.VedroFn):
enabled = True
```
</p>
</details>
## Usage
### Basic Example
```python
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:
```shell
$ vedro run
```
### Using Scenario Decorators
Scenario decorators (such as `@skip`, `@only`, etc.) can be passed via an extended syntax:
```python
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:
```python
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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/vedro-universe/vedro-fn",
"name": "vedro-fn",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Nikita Tsvetkov",
"author_email": "tsv1@fastmail.com",
"download_url": "https://files.pythonhosted.org/packages/14/0f/dca8572e6eb016381886cf481d7147ce67d82201f86fa8c2eb5185b340e5/vedro_fn-0.1.0.tar.gz",
"platform": null,
"description": "# vedro-fn\n\n[![Codecov](https://img.shields.io/codecov/c/github/vedro-universe/vedro-fn/main.svg?style=flat-square)](https://codecov.io/gh/vedro-universe/vedro-fn)\n[![PyPI](https://img.shields.io/pypi/v/vedro-fn.svg?style=flat-square)](https://pypi.python.org/pypi/vedro-fn/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/vedro-fn?style=flat-square)](https://pypi.python.org/pypi/vedro-fn/)\n[![Python Version](https://img.shields.io/pypi/pyversions/vedro-fn.svg?style=flat-square)](https://pypi.python.org/pypi/vedro-fn/)\n\nA plugin for the [Vedro](https://vedro.io) framework that enables a functional-style syntax for defining Vedro scenarios.\n\n## Installation\n\n<details open>\n<summary>Quick</summary>\n<p>\n\nFor a quick installation, you can use a plugin manager as follows:\n\n```shell\n$ vedro plugin install vedro-fn\n```\n\n</p>\n</details>\n\n<details>\n<summary>Manual</summary>\n<p>\n\nTo install manually, follow these steps:\n\n1. Install the package using pip:\n\n```shell\n$ pip3 install vedro-fn\n```\n\n2. Next, activate the plugin in your `vedro.cfg.py` configuration file:\n\n```python\n# ./vedro.cfg.py\nimport vedro\nimport vedro_fn\n\n\nclass Config(vedro.Config):\n class Plugins(vedro.Config.Plugins):\n class VedroFn(vedro_fn.VedroFn):\n enabled = True\n```\n\n</p>\n</details>\n\n## Usage\n\n### Basic Example\n\n```python\nimport base64\nfrom vedro_fn import scenario, given, when, then\n\n@scenario()\ndef decode_base64_encoded_str():\n with given:\n encoded = \"YmFuYW5h\"\n\n with when:\n decoded = base64.b64decode(encoded)\n\n with then:\n assert decoded == b\"banana\"\n```\n\nTo run scenarios, use:\n\n```shell\n$ vedro run\n```\n\n### Using Scenario Decorators\n\nScenario decorators (such as `@skip`, `@only`, etc.) can be passed via an extended syntax:\n\n```python\nimport base64\nfrom vedro import skip\nfrom vedro_fn import scenario, given, when, then\n\n@scenario[skip]()\ndef decode_base64_encoded_str():\n with given:\n encoded = \"YmFuYW5h\"\n\n with when:\n decoded = base64.b64decode(encoded)\n\n with then:\n assert decoded == b\"banana\"\n```\n\n### Parametrization\n\nYou can also use Vedro\u2019s built-in `@params` decorator with `@scenario` for parametrized scenarios:\n\n```python\nimport base64\nfrom vedro import params\nfrom vedro_fn import scenario, when, then\n\n@scenario([\n params(\"YmFuYW5h\", b\"banana\"),\n params(\"\", b\"\"),\n])\ndef decode_base64_encoded_str(encoded, expected):\n with when:\n decoded = base64.b64decode(encoded)\n\n with then:\n assert decoded == expected\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Enables a functional-style syntax for defining Vedro scenarios",
"version": "0.1.0",
"project_urls": {
"Docs": "https://github.com/vedro-universe/vedro-fn",
"GitHub": "https://github.com/vedro-universe/vedro-fn",
"Homepage": "https://github.com/vedro-universe/vedro-fn"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25e04764ec791810d29b4cde34d928cb7aab853cb2416ca84dde687a266b5ecb",
"md5": "15a431b723adf3346c3563839d8113bd",
"sha256": "ec3732cd3dc689bf157261c522adef1ad1793d8515929283c276e141bef2bcd0"
},
"downloads": -1,
"filename": "vedro_fn-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "15a431b723adf3346c3563839d8113bd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10316,
"upload_time": "2025-01-19T14:38:50",
"upload_time_iso_8601": "2025-01-19T14:38:50.046487Z",
"url": "https://files.pythonhosted.org/packages/25/e0/4764ec791810d29b4cde34d928cb7aab853cb2416ca84dde687a266b5ecb/vedro_fn-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "140fdca8572e6eb016381886cf481d7147ce67d82201f86fa8c2eb5185b340e5",
"md5": "5aaeaa6d8b268f9f524c7dea8aa8a2f9",
"sha256": "e2670dd3d2de72979ff1f58d4de9f82dd5fa0ebeef2a62bd5ad8e000c8d64502"
},
"downloads": -1,
"filename": "vedro_fn-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "5aaeaa6d8b268f9f524c7dea8aa8a2f9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 11493,
"upload_time": "2025-01-19T14:38:51",
"upload_time_iso_8601": "2025-01-19T14:38:51.405653Z",
"url": "https://files.pythonhosted.org/packages/14/0f/dca8572e6eb016381886cf481d7147ce67d82201f86fa8c2eb5185b340e5/vedro_fn-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-19 14:38:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vedro-universe",
"github_project": "vedro-fn",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "vedro",
"specs": [
[
">=",
"1.12"
],
[
"<",
"2.0"
]
]
}
],
"lcname": "vedro-fn"
}