-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ nav: | |
- doses/8.md | ||
- doses/9.md | ||
- doses/10.md | ||
- doses/11.md | ||
|
||
markdown_extensions: | ||
- attr_list: | ||
|