-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-enable xdist when it's supported
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 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
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,37 @@ | ||
"""An early plugin enabling pytest-xdist in supported envs.""" | ||
|
||
from contextlib import suppress | ||
from sys import platform | ||
from typing import TYPE_CHECKING, List | ||
|
||
try: | ||
from asyncio import ThreadedChildWatcher | ||
except ImportError: | ||
SUPPORTS_XDIST = platform == "win32" | ||
else: | ||
SUPPORTS_XDIST = True | ||
del ThreadedChildWatcher | ||
|
||
|
||
if TYPE_CHECKING: | ||
from _pytest.config import Config | ||
from _pytest.config.argparsing import Parser | ||
|
||
|
||
def pytest_load_initial_conftests( | ||
early_config: "Config", | ||
parser: "Parser", | ||
args: List[str], | ||
) -> None: | ||
"""Auto-enable pytest-xdist when supported and not disabled.""" | ||
if not SUPPORTS_XDIST: | ||
return | ||
|
||
with suppress(ValueError): | ||
p_pos = args.index("no:xdist") - 1 | ||
if p_pos >= 0: | ||
# NOTE: allow disabling xdist with `-p no:xdist` | ||
return | ||
|
||
xdist_args = "-n", "auto" | ||
args[:0] = xdist_args # Prepend to allow user-supplied overrides |
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