File: test_fixture_names.py

package info (click to toggle)
python-pytest-trio 0.8.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: python: 944; sh: 49; makefile: 20
file content (18 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pytest
from pytest_trio import trio_fixture
import trio


@trio_fixture
def fixture_with_unique_name(nursery):
    nursery.start_soon(trio.sleep_forever)


@pytest.mark.trio
async def test_fixture_names(fixture_with_unique_name):
    # This might be a bit fragile ... if we rearrange the nursery hierarchy
    # somehow so it breaks, then we can make it more robust.
    task = trio.lowlevel.current_task()
    assert task.name == "<test 'test_fixture_names'>"
    sibling_names = {task.name for task in task.parent_nursery.child_tasks}
    assert "<fixture 'fixture_with_unique_name'>" in sibling_names