Imported Debian patch 4.8.10-2

This commit is contained in:
Timo Aaltonen
2020-11-23 20:48:56 +02:00
committed by Mario Fetka
parent 8bc559c5a1
commit 358acdd85f
917 changed files with 1185414 additions and 1069733 deletions

View File

@@ -22,13 +22,12 @@
"""Pytest wrapper for running an installed (not in-tree) IPA test suite
Any command-line arguments are passed directly to py.test.
The current directory is changed to the locaition of the ipatests package,
so any relative paths given will be based on the ipatests module's path
Any command-line arguments are passed directly to pytest.
The current directory is changed to the location of the ipatests package,
so any relative paths given will be based on the ipatests module's path.
"""
import os
import copy
import sys
import pytest
@@ -40,50 +39,36 @@ os.environ['IPATEST_XUNIT_PATH'] = os.path.join(os.getcwd(), 'nosetests.xml')
HERE = os.path.dirname(os.path.abspath(ipatests.__file__))
def has_option(option):
if option in sys.argv:
return True
for arg in sys.argv:
for argi in arg.split("="):
if option in argi:
return True
return False
class ArgsManglePlugin(object):
"""Modify pytest arguments
# don't override specified command line options
if not has_option("confcutdir"):
sys.argv.insert(1, "--confcutdir={}".format(HERE))
# for backward compatibility
if not has_option("cache_dir"):
sys.argv[1:1] = ["-o", 'cache_dir={}'.format(os.path.join(os.getcwd(),
".pytest_cache"))]
# Pytest 5.2 deprecation: The default value of junit_family option will change
# to xunit2 in pytest 6.0. Current XML scheme is xunit1.
if not has_option("junit_family"):
sys.argv[1:1] = ["-o", 'junit_family=xunit1']
* Add confcutdir if hasn't been set already
* Mangle paths to support tests both relative to basedir and ipatests/
* Default to ipatests/ if no tests are specified
"""
def pytest_load_initial_conftests(self, early_config, parser, args):
# During initial loading, parser supports only basic options
ns = early_config.known_args_namespace
if not ns.confcutdir:
# add config cut directory to only load fixtures from ipatests/
args.insert(0, '--confcutdir={}'.format(HERE))
if not ns.file_or_dir:
# No file or directory found, run all tests
args.append(HERE)
else:
for name in ns.file_or_dir:
idx = args.index(name)
# split on pytest separator
# ipatests/test_ipaplatform/test_importhook.py::test_override
filename, sep, suffix = name.partition('::')
# a file or directory relative to cwd or already absolute
if os.path.exists(filename):
continue
# a file or directory relative to ipatests package
args[idx] = sep.join((os.path.join(HERE, filename), suffix))
# replace ignores, e.g. "--ignore test_integration" is changed to
# "--ignore path/to/ipatests/test_integration"
if ns.ignore:
for ignore in ns.ignore:
idx = args.index(ignore)
if os.path.exists(ignore):
continue
args[idx] = os.path.join(HERE, ignore)
# rebuild early_config's known args with new args. The known args
# are used for initial conftest.py from ipatests, which adds
# additional arguments.
early_config.known_args_namespace = parser.parse_known_args(
args, namespace=copy.copy(early_config.option))
sys.exit(pytest.main(plugins=[ArgsManglePlugin()]))
pyt_args = [sys.executable, "-c",
"import sys,pytest;sys.exit(pytest.main())"] + sys.argv[1:]
# shell is needed to perform globbing
sh_args = ["/bin/bash", "--norc", "--noprofile", "-c", "--"]
pyt_args_esc = [
f"'{x}'" if not x or " " in x else x
for x in pyt_args
]
args = sh_args + [" ".join(pyt_args_esc)]
os.chdir(HERE)
sys.stdout.flush()
os.execv(args[0], args)