optparse_helpers: improve unit tests for version() (#59626)
optparse_helpers: improve unit tests for version()
This commit is contained in:
parent
fed6598e28
commit
7955405a23
1 changed files with 27 additions and 4 deletions
|
@ -5,10 +5,33 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from ansible import constants as C
|
||||||
from ansible.cli.arguments import option_helpers as opt_help
|
from ansible.cli.arguments import option_helpers as opt_help
|
||||||
|
from ansible import __path__ as ansible_path
|
||||||
|
from ansible.release import __version__ as ansible_version
|
||||||
|
|
||||||
|
if C.DEFAULT_MODULE_PATH is None:
|
||||||
|
cpath = u'Default w/o overrides'
|
||||||
|
else:
|
||||||
|
cpath = C.DEFAULT_MODULE_PATH
|
||||||
|
|
||||||
|
FAKE_PROG = u'ansible-cli-test'
|
||||||
|
VERSION_OUTPUT = opt_help.version(prog=FAKE_PROG)
|
||||||
|
|
||||||
|
|
||||||
def test_version():
|
@pytest.mark.parametrize(
|
||||||
ver = opt_help.version('ansible-cli-test')
|
'must_have', [
|
||||||
assert 'ansible-cli-test' in ver
|
FAKE_PROG + u' %s' % ansible_version,
|
||||||
assert 'python version' in ver
|
u'config file = %s' % C.CONFIG_FILE,
|
||||||
|
u'configured module search path = %s' % cpath,
|
||||||
|
u'ansible python module location = %s' % ':'.join(ansible_path),
|
||||||
|
u'executable location = ',
|
||||||
|
u'python version = %s' % ''.join(sys.version.splitlines()),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_option_helper_version(must_have):
|
||||||
|
assert must_have in VERSION_OUTPUT
|
||||||
|
|
Loading…
Reference in a new issue