|
1 | 1 | import asyncio |
2 | | -from typing import ( |
3 | | - Any, |
4 | | - AsyncIterable, |
5 | | - Awaitable, |
6 | | - Callable, |
7 | | - Dict, |
8 | | - List, |
9 | | - Optional, |
10 | | - TypeVar, |
11 | | - Union, |
12 | | - cast, |
13 | | -) |
| 2 | +from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar, Union |
14 | 3 |
|
15 | 4 | from pytest import mark, raises |
16 | 5 |
|
|
33 | 22 | GraphQLString, |
34 | 23 | ) |
35 | 24 |
|
| 25 | +from ..utils.assert_equal_awaitables_or_values import assert_equal_awaitables_or_values |
| 26 | + |
36 | 27 |
|
37 | 28 | try: |
38 | 29 | from typing import TypedDict |
@@ -150,27 +141,6 @@ def transform(new_email): |
150 | 141 | DummyQueryType = GraphQLObjectType("Query", {"dummy": GraphQLField(GraphQLString)}) |
151 | 142 |
|
152 | 143 |
|
153 | | -def assert_equal_awaitables_or_values( |
154 | | - value1: AwaitableOrValue[T], value2: AwaitableOrValue[T] |
155 | | -) -> AwaitableOrValue[T]: |
156 | | - if is_awaitable(value1): |
157 | | - awaitable1 = cast(Awaitable[T], value1) |
158 | | - assert is_awaitable(value2) |
159 | | - awaitable2 = cast(Awaitable[T], value2) |
160 | | - |
161 | | - # noinspection PyShadowingNames |
162 | | - async def awaited_equal_value(): |
163 | | - value1 = await awaitable1 |
164 | | - value2 = await awaitable2 |
165 | | - assert value1 == value2 |
166 | | - return value1 |
167 | | - |
168 | | - return awaited_equal_value() |
169 | | - assert not is_awaitable(value2) |
170 | | - assert value1 == value2 |
171 | | - return value1 |
172 | | - |
173 | | - |
174 | 144 | def subscribe_with_bad_fn( |
175 | 145 | subscribe_fn: Callable, |
176 | 146 | ) -> AwaitableOrValue[Union[ExecutionResult, AsyncIterable[Any]]]: |
|
0 commit comments