[stable-2.13] ansible-test - Prefer unittest.mock for core.

(cherry picked from commit 81351022d8)

Co-authored-by: Matt Clay <matt@mystile.com>
pull/77986/head
Matt Clay 4 years ago
parent 44ce9fe998
commit 2ac74197af

@ -0,0 +1,3 @@
minor_changes:
- ansible-test - Avoid using the ``mock_use_standalone_module`` setting for ``pytest`` when running ansible-core unit tests.
This has no effect on unit tests for collections.

@ -0,0 +1,4 @@
[pytest]
xfail_strict = true
# avoid using 'mock_use_standalone_module = true' so package maintainers can avoid packaging 'mock'
junit_family = xunit1

@ -234,6 +234,11 @@ def command_units(args): # type: (UnitsConfig) -> None
if args.requirements_mode == 'only': if args.requirements_mode == 'only':
sys.exit() sys.exit()
if data_context().content.is_ansible:
config_name = 'ansible-core.ini'
else:
config_name = 'default.ini'
for test_context, python, paths, env in test_sets: for test_context, python, paths, env in test_sets:
cmd = [ cmd = [
'pytest', 'pytest',
@ -243,7 +248,7 @@ def command_units(args): # type: (UnitsConfig) -> None
'--color', '--color',
'yes' if args.color else 'no', 'yes' if args.color else 'no',
'-p', 'no:cacheprovider', '-p', 'no:cacheprovider',
'-c', os.path.join(ANSIBLE_TEST_DATA_ROOT, 'pytest.ini'), '-c', os.path.join(ANSIBLE_TEST_DATA_ROOT, 'pytest', 'config', config_name),
'--junit-xml', os.path.join(ResultType.JUNIT.path, 'python%s-%s-units.xml' % (python.version, test_context)), '--junit-xml', os.path.join(ResultType.JUNIT.path, 'python%s-%s-units.xml' % (python.version, test_context)),
'--strict-markers', # added in pytest 4.5.0 '--strict-markers', # added in pytest 4.5.0
'--rootdir', data_context().content.root, '--rootdir', data_context().content.root,

Loading…
Cancel
Save