Skip to content

Commit 43485b0

Browse files
committed
Add ep 11
1 parent 8abc733 commit 43485b0

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

code/11/pytest_test_cases_example.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pytest_cases import fixture, parametrize
2+
3+
4+
@fixture
5+
def fixture1() -> str:
6+
return "foo"
7+
8+
9+
@fixture
10+
@parametrize("value", ["bar", "baz"])
11+
def fixture2(value: str) -> str:
12+
return value
13+
14+
15+
@parametrize("value", [fixture1, fixture2])
16+
def test_just_a_dummy_example(value: str) -> None:
17+
assert value in ("foo", "bar", "baz")

docs/doses/11.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: 11 - pytest-cases
3+
tags:
4+
- Interesting projects
5+
---
6+
# 11 - pytest-cases
7+
8+
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.
9+
10+
![code-example](../img/11.png)
11+
12+
The output looks like this:
13+
14+
![terminal-example](../img/11-terminal.png)
15+
16+
??? info "Read more"
17+
* pytest-cases docs: [https://smarie.github.io/python-pytest-cases/](https://smarie.github.io/python-pytest-cases/)
18+
* pytest-cases GitHub repo: [https://github.com/smarie/python-pytest-cases/](https://github.com/smarie/python-pytest-cases/)
19+
20+
??? tip "The code"
21+
```python
22+
--8<-- "code/11/pytest_test_cases_example.py"
23+
```

docs/img/11-terminal.png

199 KB
Loading

docs/img/11.png

144 KB
Loading

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ nav:
3838
- doses/8.md
3939
- doses/9.md
4040
- doses/10.md
41+
- doses/11.md
4142

4243
markdown_extensions:
4344
- attr_list:

0 commit comments

Comments
 (0)