From a2593b5e27b0907d4087726025f779952d2fd2fd Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 3 Nov 2020 14:07:24 +0100 Subject: [PATCH] CLI - Specify jinja version in --version output --- changelogs/fragments/version-jinja.yml | 2 ++ lib/ansible/cli/arguments/option_helpers.py | 3 +++ test/units/cli/test_adhoc.py | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/version-jinja.yml diff --git a/changelogs/fragments/version-jinja.yml b/changelogs/fragments/version-jinja.yml new file mode 100644 index 00000000000..12813c2ea7f --- /dev/null +++ b/changelogs/fragments/version-jinja.yml @@ -0,0 +1,2 @@ +minor_changes: + - CLI - Specify jinja version in ``--version`` output diff --git a/lib/ansible/cli/arguments/option_helpers.py b/lib/ansible/cli/arguments/option_helpers.py index b54687ba462..8465f7510bb 100644 --- a/lib/ansible/cli/arguments/option_helpers.py +++ b/lib/ansible/cli/arguments/option_helpers.py @@ -19,6 +19,8 @@ try: except ImportError: HAS_LIBYAML = False +from jinja2 import __version__ as j2_version + import ansible from ansible import constants as C from ansible.module_utils._text import to_native @@ -172,6 +174,7 @@ def version(prog=None): result.append(" ansible collection location = %s" % ':'.join(C.COLLECTIONS_PATHS)) result.append(" executable location = %s" % sys.argv[0]) result.append(" python version = %s" % ''.join(sys.version.splitlines())) + result.append(" jinja version = %s" % j2_version) result.append(" libyaml = %s" % HAS_LIBYAML) return "\n".join(result) diff --git a/test/units/cli/test_adhoc.py b/test/units/cli/test_adhoc.py index b0f30ea243c..6f1dfb0f1f3 100644 --- a/test/units/cli/test_adhoc.py +++ b/test/units/cli/test_adhoc.py @@ -104,7 +104,7 @@ def test_ansible_version(capsys, mocker): # Python 2.6 does return a named tuple, so get the first item version_lines = version[0].splitlines() - assert len(version_lines) == 8, 'Incorrect number of lines in "ansible --version" output' + assert len(version_lines) == 9, 'Incorrect number of lines in "ansible --version" output' assert re.match('ansible [0-9.a-z]+$', version_lines[0]), 'Incorrect ansible version line in "ansible --version" output' assert re.match(' config file = .*$', version_lines[1]), 'Incorrect config file line in "ansible --version" output' assert re.match(' configured module search path = .*$', version_lines[2]), 'Incorrect module search path in "ansible --version" output' @@ -112,4 +112,5 @@ def test_ansible_version(capsys, mocker): assert re.match(' ansible collection location = .*$', version_lines[4]), 'Incorrect collection location in "ansible --version" output' assert re.match(' executable location = .*$', version_lines[5]), 'Incorrect executable locaction in "ansible --version" output' assert re.match(' python version = .*$', version_lines[6]), 'Incorrect python version in "ansible --version" output' - assert re.match(' libyaml = .*$', version_lines[7]), 'Missing libyaml in "ansible --version" output' + assert re.match(' jinja version = .*$', version_lines[7]), 'Incorrect jinja version in "ansible --version" output' + assert re.match(' libyaml = .*$', version_lines[8]), 'Missing libyaml in "ansible --version" output'