|
1 | 1 | """pytest-trio implementation."""
|
| 2 | +import sys |
2 | 3 | from traceback import format_exception
|
3 | 4 | from inspect import iscoroutinefunction, isgeneratorfunction
|
4 |
| -try: |
5 |
| - from inspect import isasyncgenfunction |
6 |
| -except ImportError: |
7 |
| - # `inspect.isasyncgenfunction` not available with Python<3.6 |
8 |
| - def isasyncgenfunction(x): |
9 |
| - return False |
10 |
| - |
11 |
| - |
12 | 5 | import pytest
|
13 | 6 | import trio
|
14 | 7 | from trio._util import acontextmanager
|
15 | 8 | from trio.testing import MockClock, trio_test
|
16 | 9 | from async_generator import async_generator, yield_
|
17 | 10 |
|
| 11 | +if sys.version_info >= (3, 6): |
| 12 | + from inspect import isasyncgenfunction |
| 13 | + ORDERED_DICTS = True |
| 14 | +else: |
| 15 | + # `inspect.isasyncgenfunction` not available with Python<3.6 |
| 16 | + def isasyncgenfunction(x): |
| 17 | + return False |
| 18 | + |
| 19 | + # Ordered dict (and **kwargs) not available with Python<3.6 |
| 20 | + ORDERED_DICTS = False |
| 21 | + |
18 | 22 |
|
19 | 23 | def pytest_configure(config):
|
20 | 24 | """Inject documentation."""
|
@@ -69,6 +73,9 @@ async def _setup_async_fixtures_in(deps):
|
69 | 73 | need_resolved_deps_stack = [
|
70 | 74 | (k, v) for k, v in deps.items() if isinstance(v, BaseAsyncFixture)
|
71 | 75 | ]
|
| 76 | + if not ORDERED_DICTS: |
| 77 | + # Make the fixture resolution order determinist |
| 78 | + need_resolved_deps_stack = sorted(need_resolved_deps_stack) |
72 | 79 |
|
73 | 80 | if not need_resolved_deps_stack:
|
74 | 81 | await yield_(deps)
|
|
0 commit comments