-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In Trio mode, auto-convert async fixtures to Trio fixtures
The main benefit of this is that it lets us catch more cases where these fixtures are accidentally misused. Closes gh-18 Closes gh-51
- Loading branch information
Showing
5 changed files
with
97 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
|
||
def enable_trio_mode_via_pytest_ini(testdir): | ||
testdir.makefile(".ini", pytest="[pytest]\ntrio_mode = true\n") | ||
|
||
|
||
def enable_trio_mode_via_conftest_py(testdir): | ||
testdir.makeconftest("from pytest_trio.enable_trio_mode import *") | ||
|
||
|
||
enable_trio_mode = pytest.mark.parametrize( | ||
"enable_trio_mode", | ||
[enable_trio_mode_via_pytest_ini, enable_trio_mode_via_conftest_py] | ||
) |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
__all__ = ["pytest_collection_modifyitems"] | ||
__all__ = ["pytest_collection_modifyitems", "pytest_fixture_setup"] | ||
|
||
from .plugin import automark | ||
from .plugin import automark, handle_fixture | ||
|
||
|
||
def pytest_collection_modifyitems(items): | ||
automark(items) | ||
|
||
|
||
def pytest_fixture_setup(fixturedef, request): | ||
return handle_fixture(fixturedef, request, force_trio_mode=True) |
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