Skip to content

Commit

Permalink
refactor: Grouped test cases together that are related to the use of …
Browse files Browse the repository at this point in the history
…the asyncio marker in class-based tests.

Rephrased test names and comments to make the test intention more clear.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
  • Loading branch information
seifertm authored and Tinche committed May 30, 2021
1 parent b27abe8 commit 70989fd
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,18 @@ def mock_unused_tcp_port():
assert unused_tcp_port_factory() > 10000


class Test:
"""Test that asyncio marked functions work in test methods."""
class TestMarkerInClassBasedTests:
"""Test that asyncio marked functions work for methods of test classes."""

@pytest.mark.asyncio
async def test_asyncio_marker_method(self, event_loop):
"""Test the asyncio pytest marker in a Test class."""
async def test_asyncio_marker_with_explicit_loop_fixture(self, event_loop):
"""Test the "asyncio" marker works on a method in a class-based test with explicit loop fixture."""
ret = await async_coro()
assert ret == "ok"


class TestUnexistingLoop:
@pytest.mark.asyncio
async def test_asyncio_marker_without_loop(self):
"""Test the asyncio pytest marker in a Test class."""
async def test_asyncio_marker_with_implicit_loop_fixture(self):
"""Test the "asyncio" marker works on a method in a class-based test with implicit loop fixture."""
ret = await async_coro()
assert ret == "ok"

Expand Down

0 comments on commit 70989fd

Please sign in to comment.