forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add `datacases()` and `named_datacases()` * correct DataCasesProtocol * add back the tests for testing the test utilities
- Loading branch information
Showing
3 changed files
with
73 additions
and
2 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
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
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,38 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
|
||
import pytest | ||
|
||
from tests.util.misc import Marks, datacases, named_datacases | ||
|
||
|
||
@dataclass | ||
class DataCase: | ||
id: str | ||
marks: Marks | ||
|
||
|
||
sample_cases = [ | ||
DataCase(id="id_a", marks=[pytest.mark.test_mark_a1, pytest.mark.test_mark_a2]), | ||
DataCase(id="id_b", marks=[pytest.mark.test_mark_b1, pytest.mark.test_mark_b2]), | ||
] | ||
|
||
|
||
def sample_result(name: str) -> pytest.MarkDecorator: | ||
return pytest.mark.parametrize( | ||
argnames=name, | ||
argvalues=[pytest.param(case, id=case.id, marks=case.marks) for case in sample_cases], | ||
) | ||
|
||
|
||
def test_datacases() -> None: | ||
result = datacases(*sample_cases) | ||
|
||
assert result == sample_result(name="case") | ||
|
||
|
||
def test_named_datacases() -> None: | ||
result = named_datacases("Sharrilanda")(*sample_cases) | ||
|
||
assert result == sample_result(name="Sharrilanda") |