From 84ba41e0e18fb8f8f2936ffc850e479a3351bf4f Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 19 Feb 2019 21:14:28 +0100 Subject: [PATCH] ansible-doc: fix traceback when passing `-a` arg (#52036) Fixes #52034 --- lib/ansible/cli/doc.py | 6 +++++- test/units/cli/test_doc.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/units/cli/test_doc.py diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index 4853d9c975..8454af29e3 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -80,7 +80,7 @@ class DocCLI(CLI): # process all plugins of type if options.all_plugins: - args = self.get_all_plugins_of_type(options['type']) + args = self.get_all_plugins_of_type(options.type) if options.module_path: display.warning('Ignoring "--module-path/-M" option as "--all/-a" only displays builtins') @@ -283,6 +283,10 @@ class DocCLI(CLI): display.vvvv("%s does not exist" % path) return plugin_list + if not os.path.isdir(path): + display.vvvv("%s is not a directory" % path) + return plugin_list + bkey = ptype.upper() for plugin in os.listdir(path): display.vvvv("Found %s" % plugin) diff --git a/test/units/cli/test_doc.py b/test/units/cli/test_doc.py new file mode 100644 index 0000000000..eb117dc56d --- /dev/null +++ b/test/units/cli/test_doc.py @@ -0,0 +1,12 @@ +# Copyright: (c) 2019, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from ansible.cli.doc import DocCLI + + +def test_parsing_all_option(): + doc_cli = DocCLI(['/n/ansible-doc', '-a']) + doc_cli.parse()