1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
from __future__ import annotations
from textwrap import dedent
from pytest import Pytester
def test_import_warning_does_not_cause_internal_error(pytester: Pytester):
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
pytester.makepyfile(
dedent(
"""\
raise ImportWarning()
async def test_errors_out():
pass
"""
)
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(errors=1)
def test_import_warning_in_package_does_not_cause_internal_error(pytester: Pytester):
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
pytester.makepyfile(
__init__=dedent(
"""\
raise ImportWarning()
"""
),
test_a=dedent(
"""\
async def test_errors_out():
pass
"""
),
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(errors=1)
def test_does_not_import_unrelated_packages(pytester: Pytester):
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
pkg_dir = pytester.mkpydir("mypkg")
pkg_dir.joinpath("__init__.py").write_text(
dedent(
"""\
raise ImportError()
"""
),
)
test_dir = pytester.mkdir("tests")
test_dir.joinpath("test_a.py").write_text(
dedent(
"""\
async def test_passes():
pass
"""
),
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(passed=1)
|