Skip to content
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: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ install_requires =

[options.extras_require]
testing =
coverage == 7.13.1
coverage == 7.13.2
mypy == 1.19.1

[options.entry_points]
Expand Down
30 changes: 10 additions & 20 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


def test_aiohttp_plugin(testdir: pytest.Testdir) -> None:
testdir.makepyfile(
"""\
testdir.makepyfile("""\
import pytest
from unittest import mock

Expand Down Expand Up @@ -102,15 +101,13 @@ async def test_custom_port_test_server(aiohttp_server, unused_tcp_port):
app = await create_app()
server = await aiohttp_server(app, port=unused_tcp_port)
assert server.port == unused_tcp_port
"""
)
""")
result = testdir.runpytest("--asyncio-mode=auto")
result.assert_outcomes(passed=8)


def test_aiohttp_raw_server(testdir: pytest.Testdir) -> None:
testdir.makepyfile(
"""\
testdir.makepyfile("""\
import pytest

from aiohttp import web
Expand All @@ -136,15 +133,13 @@ async def test_hello(cli) -> None:
assert resp.status == 200
text = await resp.text()
assert 'OK' in text
"""
)
""")
result = testdir.runpytest("--asyncio-mode=auto")
result.assert_outcomes(passed=1)


def test_aiohttp_client_cls_fixture_custom_client_used(testdir: pytest.Testdir) -> None:
testdir.makepyfile(
"""
testdir.makepyfile("""
import pytest
from aiohttp.web import Application
from aiohttp.test_utils import TestClient
Expand All @@ -163,24 +158,20 @@ async def test_hello(aiohttp_client) -> None:
client = await aiohttp_client(Application())
assert isinstance(client, CustomClient)

"""
)
""")
result = testdir.runpytest("--asyncio-mode=auto")
result.assert_outcomes(passed=1)


def test_aiohttp_client_cls_fixture_factory(testdir: pytest.Testdir) -> None:
testdir.makeconftest(
"""\
testdir.makeconftest("""\

def pytest_configure(config):
config.addinivalue_line("markers", "rest: RESTful API tests")
config.addinivalue_line("markers", "graphql: GraphQL API tests")

"""
)
testdir.makepyfile(
"""
""")
testdir.makepyfile("""
import pytest
from aiohttp.web import Application
from aiohttp.test_utils import TestClient
Expand Down Expand Up @@ -214,7 +205,6 @@ async def test_graphql(aiohttp_client) -> None:
client = await aiohttp_client(Application())
assert isinstance(client, GraphQLClient)

"""
)
""")
result = testdir.runpytest("--asyncio-mode=auto")
result.assert_outcomes(passed=2)
18 changes: 6 additions & 12 deletions tests/test_switch_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,37 @@


def test_warning_for_legacy_mode(testdir: pytest.Testdir) -> None:
testdir.makepyfile(
"""\
testdir.makepyfile("""\
async def test_a():
pass

"""
)
""")
result = testdir.runpytest_subprocess("--asyncio-mode=legacy")
result.assert_outcomes(passed=1)
result.stdout.fnmatch_lines(["*" + str(LEGACY_MODE) + "*"])


def test_auto_mode(testdir: pytest.Testdir) -> None:
testdir.makepyfile(
"""\
testdir.makepyfile("""\
async def test_a():
pass

"""
)
""")
result = testdir.runpytest_subprocess("--asyncio-mode=auto")
result.assert_outcomes(passed=1)
result.stdout.no_fnmatch_line("*" + str(LEGACY_MODE) + "*")


def test_strict_mode(testdir: pytest.Testdir) -> None:
testdir.makepyfile(
"""\
testdir.makepyfile("""\
import pytest


@pytest.mark.asyncio
async def test_a():
pass

"""
)
""")
result = testdir.runpytest_subprocess("--asyncio-mode=strict")
result.assert_outcomes(passed=1)
result.stdout.no_fnmatch_line("*" + str(LEGACY_MODE) + "*")