-
Notifications
You must be signed in to change notification settings - Fork 5
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
19 changed files
with
274 additions
and
196 deletions.
There are no files selected for viewing
27 changes: 19 additions & 8 deletions
27
helpers/alt_pytest_asyncio_test_driver/contextvars_for_test.py
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 |
---|---|---|
@@ -1,22 +1,33 @@ | ||
import string | ||
from collections.abc import Iterable | ||
from contextvars import ContextVar | ||
|
||
allvars = {} | ||
allvars: dict[str, ContextVar[str]] = {} | ||
|
||
|
||
class Empty: | ||
pass | ||
|
||
|
||
def assertVarsEmpty(excluding=None): | ||
def assertVarsEmpty(excluding: Iterable[str] | None = None) -> None: | ||
for letter, var in allvars.items(): | ||
if not excluding or letter not in excluding: | ||
assert var.get(Empty) is Empty | ||
|
||
|
||
for letter in string.ascii_letters: | ||
var = ContextVar(letter) | ||
locals()[letter] = var | ||
allvars[letter] = var | ||
a: ContextVar[str] = ContextVar("a") | ||
allvars["a"] = a | ||
|
||
__all__ = ["allvars", "Empty", "assertVarsEmpty", *allvars] | ||
b: ContextVar[str] = ContextVar("b") | ||
allvars["b"] = b | ||
|
||
c: ContextVar[str] = ContextVar("c") | ||
allvars["c"] = c | ||
|
||
d: ContextVar[str] = ContextVar("d") | ||
allvars["d"] = d | ||
|
||
e: ContextVar[str] = ContextVar("e") | ||
allvars["e"] = e | ||
|
||
f: ContextVar[str] = ContextVar("f") | ||
allvars["f"] = f |
24 changes: 12 additions & 12 deletions
24
helpers/alt_pytest_asyncio_test_driver/examples/example_fixture_failures/expected
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
=======* ERRORS =====* | ||
_______* ERROR at setup of test_fails_on_fixture_returns _____* | ||
*test_fails.py:14: in fixture_returns | ||
*test_fails.py:17: in fixture_returns | ||
await one*() | ||
*test_fails.py:5: in one | ||
return await two*() | ||
*test_fails.py:9: in two | ||
*test_fails.py:8: in one | ||
await two*() | ||
*test_fails.py:12: in two | ||
raise ValueError*("WAT") | ||
E ValueError: WAT | ||
_______* ERROR at setup of test_fails_on_fixture_yields _____* | ||
*test_fails.py:19: in fixture_yields | ||
*test_fails.py:22: in fixture_yields | ||
yield await one*() | ||
*test_fails.py:5: in one | ||
return await two*() | ||
*test_fails.py:9: in two | ||
*test_fails.py:8: in one | ||
await two*() | ||
*test_fails.py:12: in two | ||
raise ValueError*("WAT") | ||
E ValueError: WAT | ||
_______* ERROR at teardown of test_fails_on_fixture_fails_in_finally _____* | ||
*test_fails.py:27: in fixture_fails_in_finally | ||
*test_fails.py:30: in fixture_fails_in_finally | ||
await one*() | ||
*test_fails.py:5: in one | ||
return await two*() | ||
*test_fails.py:9: in two | ||
*test_fails.py:8: in one | ||
await two*() | ||
*test_fails.py:12: in two | ||
raise ValueError*("WAT") | ||
E ValueError: WAT | ||
=======* 1 passed, 3 error* in * ===* |
21 changes: 12 additions & 9 deletions
21
helpers/alt_pytest_asyncio_test_driver/examples/example_fixture_failures/test_fails.py
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 |
---|---|---|
@@ -1,39 +1,42 @@ | ||
from collections.abc import AsyncGenerator | ||
from typing import NoReturn | ||
|
||
import pytest | ||
|
||
|
||
async def one(): | ||
return await two() | ||
async def one() -> NoReturn: | ||
await two() | ||
|
||
|
||
async def two(): | ||
async def two() -> NoReturn: | ||
raise ValueError("WAT") | ||
|
||
|
||
@pytest.fixture() | ||
async def fixture_returns(): | ||
async def fixture_returns() -> NoReturn: | ||
await one() | ||
|
||
|
||
@pytest.fixture() | ||
async def fixture_yields(): | ||
async def fixture_yields() -> AsyncGenerator[None]: | ||
yield await one() | ||
|
||
|
||
@pytest.fixture() | ||
async def fixture_fails_in_finally(): | ||
async def fixture_fails_in_finally() -> AsyncGenerator[int]: | ||
try: | ||
yield 1 | ||
finally: | ||
await one() | ||
|
||
|
||
def test_fails_on_fixture_returns(fixture_returns): | ||
def test_fails_on_fixture_returns(fixture_returns: int) -> None: | ||
pass | ||
|
||
|
||
def test_fails_on_fixture_yields(fixture_yields): | ||
def test_fails_on_fixture_yields(fixture_yields: int) -> None: | ||
pass | ||
|
||
|
||
def test_fails_on_fixture_fails_in_finally(fixture_fails_in_finally): | ||
def test_fails_on_fixture_fails_in_finally(fixture_fails_in_finally: int) -> None: | ||
pass |
7 changes: 4 additions & 3 deletions
7
helpers/alt_pytest_asyncio_test_driver/examples/example_timeouts/conftest.py
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
Oops, something went wrong.