Skip to content

Commit

Permalink
Add ep 11
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-git committed Apr 10, 2022
1 parent 8abc733 commit 43485b0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions code/11/pytest_test_cases_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pytest_cases import fixture, parametrize


@fixture
def fixture1() -> str:
return "foo"


@fixture
@parametrize("value", ["bar", "baz"])
def fixture2(value: str) -> str:
return value


@parametrize("value", [fixture1, fixture2])
def test_just_a_dummy_example(value: str) -> None:
assert value in ("foo", "bar", "baz")
23 changes: 23 additions & 0 deletions docs/doses/11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: 11 - pytest-cases
tags:
- Interesting projects
---
# 11 - pytest-cases

The core idea behind pytest-cases is to separate test code from test cases. One of its cool features is the possibility to use fixtures inside parametrize. Additionally, it enables familiar syntax for parametrizing fixtures.

![code-example](../img/11.png)

The output looks like this:

![terminal-example](../img/11-terminal.png)

??? info "Read more"
* pytest-cases docs: [https://smarie.github.io/python-pytest-cases/](https://smarie.github.io/python-pytest-cases/)
* pytest-cases GitHub repo: [https://github.com/smarie/python-pytest-cases/](https://github.com/smarie/python-pytest-cases/)

??? tip "The code"
```python
--8<-- "code/11/pytest_test_cases_example.py"
```
Binary file added docs/img/11-terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nav:
- doses/8.md
- doses/9.md
- doses/10.md
- doses/11.md

markdown_extensions:
- attr_list:
Expand Down

0 comments on commit 43485b0

Please sign in to comment.