From 65afb0272dc2b735f56733a576ad9cf62244007f Mon Sep 17 00:00:00 2001 From: kschopmeyer Date: Wed, 12 Aug 2020 11:48:34 -0500 Subject: [PATCH] Fixes issue #725 - Exception python 2.7 Fixed issue where the help for the --deprecated command is not unicode. Adds test for this option. --- docs/changes.rst | 3 +++ pywbemtools/pywbemcli/_common_options.py | 8 ++++---- tests/unit/common_options_help_lines.py | 5 +++++ tests/unit/test_class_cmds.py | 26 +++++++++++++++++++++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index d178e61fd..245063841 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -45,6 +45,9 @@ Released: not yet * Test: Fixed attempt in test_class_cmds.py to invoke a non-static method on a class object. (see issue #707) +* Fix help message for "--deprecated" to be unicode so python 2.7 help does not + fail. (see issue #725). This error was added with issue #678 + **Enhancements:** * Modify general help to display the full path of the default connections file. diff --git a/pywbemtools/pywbemcli/_common_options.py b/pywbemtools/pywbemcli/_common_options.py index 5e2665e7a..546c17964 100644 --- a/pywbemtools/pywbemcli/_common_options.py +++ b/pywbemtools/pywbemcli/_common_options.py @@ -116,10 +116,10 @@ deprecated_filter_option = [ # pylint: disable=invalid-name click.option('--deprecated/--no-deprecated', default=None, - help='Filter the returned classes to return only deprecated ' - 'classes (--deprecated) or classes that are not ' - 'deprecated (--no-deprecated). If the option is not ' - 'defined no filtering occurs')] + help=u'Filter the returned classes to return only deprecated ' + u'classes (--deprecated) or classes that are not ' + u'deprecated (--no-deprecated). If the option is not ' + u'defined no filtering occurs')] # List of the class filter options that are common to multiple class commands # Since the filters are in a list to allow them to be used individually, the diff --git a/tests/unit/common_options_help_lines.py b/tests/unit/common_options_help_lines.py index d7f6c0d49..19a7b1f7f 100644 --- a/tests/unit/common_options_help_lines.py +++ b/tests/unit/common_options_help_lines.py @@ -82,6 +82,8 @@ CMD_OPTION_KEYS_HELP_LINE = \ '-k, --key KEYNAME=VALUE Value for a key in keybinding of' +# NOTE: The FILTER help lines should exist as a group wherever used. + CMD_OPTION_ASSOCIATION_FILTER_HELP_LINE = \ '--association / --no-association' @@ -91,5 +93,8 @@ CMD_OPTION_EXPERIMENTAL_FILTER_HELP_LINE = \ '--experimental / --no-experimental' +CMD_OPTION_DEPRECATED_FILTER_HELP_LINE = \ + '--deprecated / --no-deprecated' + CMD_OPTION_HELP_INSTANCENAME_HELP_LINE = \ '--hi, --help-instancename Show help message for specifying INSTANCENAME' diff --git a/tests/unit/test_class_cmds.py b/tests/unit/test_class_cmds.py index 25a06c6d9..c181858dc 100644 --- a/tests/unit/test_class_cmds.py +++ b/tests/unit/test_class_cmds.py @@ -33,7 +33,9 @@ CMD_OPTION_MULTIPLE_NAMESPACE_HELP_LINE, \ CMD_OPTION_ASSOCIATION_FILTER_HELP_LINE, \ CMD_OPTION_INDICATION_FILTER_HELP_LINE, \ - CMD_OPTION_EXPERIMENTAL_FILTER_HELP_LINE + CMD_OPTION_EXPERIMENTAL_FILTER_HELP_LINE, \ + CMD_OPTION_DEPRECATED_FILTER_HELP_LINE + _PYWBEM_VERSION = parse_version(pywbem_version) # pywbem 1.0.0 or later @@ -112,9 +114,11 @@ CMD_OPTION_NAMES_ONLY_HELP_LINE, CMD_OPTION_NAMESPACE_HELP_LINE, CMD_OPTION_SUMMARY_HELP_LINE, + # NOTE: The FILTER options are a group. Define all of them. CMD_OPTION_ASSOCIATION_FILTER_HELP_LINE, CMD_OPTION_INDICATION_FILTER_HELP_LINE, CMD_OPTION_EXPERIMENTAL_FILTER_HELP_LINE, + CMD_OPTION_DEPRECATED_FILTER_HELP_LINE, CMD_OPTION_HELP_HELP_LINE, ] @@ -127,6 +131,7 @@ CMD_OPTION_ASSOCIATION_FILTER_HELP_LINE, CMD_OPTION_INDICATION_FILTER_HELP_LINE, CMD_OPTION_EXPERIMENTAL_FILTER_HELP_LINE, + CMD_OPTION_DEPRECATED_FILTER_HELP_LINE, CMD_OPTION_HELP_HELP_LINE, ] @@ -675,6 +680,25 @@ class CIM_Foo_sub_sub : CIM_Foo_sub { 'test': 'innows'}, QUALIFIER_FILTER_MODEL, OK], + ['Verify class command enumerate with --deprecated,' + '--no-association', + ['enumerate', '--deprecated', + '--names-only'], + {'stdout': ['TST_IndicationDeprecated', + 'TST_MemberOfFamilyCollectionDep'], + 'test': 'innows'}, + QUALIFIER_FILTER_MODEL, OK], + + ['Verify class command enumerate with --no-deprecated, --association' + '--no-association', + ['enumerate', '--no-deprecated', '--association', + '--names-only'], + {'stdout': ['TST_Lineage', + 'TST_MemberOfFamilyCollection', + 'TST_MemberOfFamilyCollectionExp'], + 'test': 'innows'}, + QUALIFIER_FILTER_MODEL, OK], + ['Verify instance command enumerate CIM_Foo_sub2, w --verbose rtns msg.', {'args': ['enumerate', 'CIM_Foo_sub2'], 'general': ['--verbose']},