-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Added changelog entry for error for positional asyncio marker arguments.
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from textwrap import dedent | ||
|
||
import pytest | ||
|
||
|
||
def test_no_error_when_scope_passed_as_sole_keyword_argument( | ||
pytester: pytest.Pytester, | ||
): | ||
pytester.makepyfile( | ||
dedent( | ||
"""\ | ||
import pytest | ||
@pytest.mark.asyncio(loop_scope="session") | ||
async def test_anything(): | ||
pass | ||
""" | ||
) | ||
) | ||
result = pytester.runpytest_subprocess() | ||
result.assert_outcomes(passed=1) | ||
result.stdout.no_fnmatch_line("*ValueError*") | ||
|
||
|
||
def test_error_when_scope_passed_as_positional_argument( | ||
pytester: pytest.Pytester, | ||
): | ||
pytester.makepyfile( | ||
dedent( | ||
"""\ | ||
import pytest | ||
@pytest.mark.asyncio("session") | ||
async def test_anything(): | ||
pass | ||
""" | ||
) | ||
) | ||
result = pytester.runpytest_subprocess() | ||
result.assert_outcomes(errors=1) | ||
result.stdout.fnmatch_lines( | ||
["*ValueError: mark.asyncio accepts only a keyword argument*"] | ||
) | ||
|
||
|
||
def test_error_when_wrong_keyword_argument_is_passed( | ||
pytester: pytest.Pytester, | ||
): | ||
pytester.makepyfile( | ||
dedent( | ||
"""\ | ||
import pytest | ||
@pytest.mark.asyncio(cope="session") | ||
async def test_anything(): | ||
pass | ||
""" | ||
) | ||
) | ||
result = pytester.runpytest_subprocess() | ||
result.assert_outcomes(errors=1) | ||
result.stdout.fnmatch_lines( | ||
["*ValueError: mark.asyncio accepts only a keyword argument 'scope'*"] | ||
) | ||
|
||
|
||
def test_error_when_additional_keyword_arguments_are_passed( | ||
pytester: pytest.Pytester, | ||
): | ||
pytester.makepyfile( | ||
dedent( | ||
"""\ | ||
import pytest | ||
@pytest.mark.asyncio(loop_scope="session", more="stuff") | ||
async def test_anything(): | ||
pass | ||
""" | ||
) | ||
) | ||
result = pytester.runpytest_subprocess() | ||
result.assert_outcomes(errors=1) | ||
result.stdout.fnmatch_lines( | ||
["*ValueError: mark.asyncio accepts only a keyword argument*"] | ||
) |