forked from pytest-dev/pytest-asyncio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pytest_skip.py
90 lines (69 loc) · 2.21 KB
/
test_pytest_skip.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from textwrap import dedent
from pytest import Pytester
def test_asyncio_strict_mode_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest_plugins = "pytest_asyncio"
@pytest.mark.asyncio
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")
"""
)
)
result = pytester.runpytest("--asyncio-mode=strict")
result.assert_outcomes(skipped=1)
def test_asyncio_auto_mode_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest_plugins = "pytest_asyncio"
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")
"""
)
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(skipped=1)
def test_asyncio_strict_mode_module_level_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest.skip("Skip all tests", allow_module_level=True)
@pytest.mark.asyncio
async def test_is_skipped():
pass
"""
)
)
result = pytester.runpytest("--asyncio-mode=strict")
result.assert_outcomes(skipped=1)
def test_asyncio_auto_mode_module_level_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest.skip("Skip all tests", allow_module_level=True)
async def test_is_skipped():
pass
"""
)
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(skipped=1)
def test_asyncio_auto_mode_wrong_skip_usage(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest.skip("Skip all tests")
async def test_is_skipped():
pass
"""
)
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(errors=1)