Skip to content

Commit

Permalink
Fixes issue #725 - Exception python 2.7
Browse files Browse the repository at this point in the history
Fixed issue where the help for the --deprecated command is not unicode.

Adds test for this option.
  • Loading branch information
KSchopmeyer committed Aug 12, 2020
1 parent 9b3d8a1 commit 65afb02
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions pywbemtools/pywbemcli/_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/common_options_help_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
26 changes: 25 additions & 1 deletion tests/unit/test_class_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
]

Expand All @@ -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,
]

Expand Down Expand Up @@ -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']},
Expand Down

0 comments on commit 65afb02

Please sign in to comment.