forked from ansible/ansible-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
27 lines (23 loc) · 795 Bytes
/
conftest.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
"""PyTest Fixtures."""
import os
import re
import sys
from typing import List
os.environ["NO_COLOR"] = "1"
pytest_plugins = ["ansiblelint.testing.fixtures"]
def pytest_cmdline_preparse(args: List[str]) -> None:
"""Pytest hook."""
# disable xdist when called with -k args (filtering)
# https://stackoverflow.com/questions/66407583/how-to-disable-pytest-xdist-only-when-pytest-is-called-with-filters
if "xdist" in sys.modules and "-k" in args:
for i, arg in enumerate(args):
# remove -n # option
if arg == "-n":
del args[i]
del args[i]
break
# remove -n# option
if re.match(r"-n\d+", arg):
del args[i]
break
args[:] = ["-n0"] + args