Skip to content

plugin: Set unused_tcp_port_factory scope to 'session' #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Changelog
~~~~~~~~~~~~~~~~~~~
- Add support for Python 3.9
- Abandon support for Python 3.5. If you still require support for Python 3.5, please use pytest-asyncio v0.14 or earlier.
- Set ``unused_tcp_port_factory`` fixture scope to 'session'.
`#163 <https://github.com/pytest-dev/pytest-asyncio/pull/163>`_

0.14.0 (2020-06-24)
~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pytest_asyncio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def unused_tcp_port():
return _unused_tcp_port()


@pytest.fixture
@pytest.fixture(scope='session')
def unused_tcp_port_factory():
"""A factory function, producing different unused TCP ports."""
produced = set()
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ async def just_a_sleep():
event_loop.run_until_complete(just_a_sleep())

assert counter == 2


@pytest.fixture(scope='session', name='factory_involving_factories')
def factory_involving_factories_fixture(unused_tcp_port_factory):
def factory():
return unused_tcp_port_factory()
return factory
5 changes: 5 additions & 0 deletions tests/test_dependent_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@
async def test_dependent_fixture(dependent_fixture):
"""Test a dependent fixture."""
await asyncio.sleep(0.1)


@pytest.mark.asyncio
async def test_factory_involving_factories(factory_involving_factories):
factory_involving_factories()