Skip to content

Commit

Permalink
Fixes issue #419. Mixed old an new formatters
Browse files Browse the repository at this point in the history
One ClickException statement mixed the old and new formatters using the
{} from the new but the % template/variable list separator from the new
formatter.

Includes documentation in docs/changes.rst
  • Loading branch information
KSchopmeyer authored and andy-maier committed Oct 1, 2019
1 parent 2a412c9 commit 28ec9d0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Released: not yet

**Bug fixes:**

* Fix issue with mixed old and new formats on click.echo statement.
(See issue #419)

**Enhancements:**

**Known issues:**
Expand Down
5 changes: 2 additions & 3 deletions pywbemtools/pywbemcli/pywbemcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import os
import sys
import traceback
from copy import deepcopy
import click
import click_repl
from copy import deepcopy
from prompt_toolkit.history import FileHistory

import pywbem
Expand Down Expand Up @@ -406,8 +406,7 @@ def create_server_instance(svr_name):
exc_traceback)
raise click.ClickException(
"Mock Python process-at-startup script '{}' "
"failed:\n{}" %
(file_path, "\n".join(tb)))
"failed:\n{}".format(file_path, "\n".join(tb)))
else: # not processed during startup
resolved_mock_server.append(file_path)

Expand Down
14 changes: 14 additions & 0 deletions tests/unit/py_err_processatstartup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# !PROCESS!AT!STARTUP!
"""
This is an error test of the code that processes a script at startup. This
python code specifically includes a syntax error to be caught by pywbemcli.
Note that this file is marked to process at startup which is really a private
extension for the test environment.
"""


def mock?prompt(msg): # noqa: E999
"""Mock function to replace pywbemcli_prompt and return a value"""
# pylint: disable=undefined-variable
print(msg)
return "HaHa"
16 changes: 16 additions & 0 deletions tests/unit/test_general_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
PYTHON_MOCK_FILE_PATH = os.path.join(SCRIPT_DIR, 'simple_python_mock_script.py')
BAD_MOF_FILE_PATH = os.path.join(SCRIPT_DIR, 'mof_with_error.mof')
BAD_PY_FILE_PATH = os.path.join(SCRIPT_DIR, 'py_with_error.py')
BAD_PY_ERR_STRTUP_PATH = os.path.join(SCRIPT_DIR, 'py_err_processatstartup.py')


GENERAL_HELP = """
Expand Down Expand Up @@ -403,6 +404,21 @@ class Command group for CIM classes.
'test': 'regex'},
None, OK],

['Verify -m option, file with python startup file containing syntax error',
{'general': ['-m', SIMPLE_MOCK_FILE_PATH],
'cmdgrp': 'class',
'args': ['enumerate']},
{'stderr': ['Mock Python process-at-startup',
'Traceback (most recent call last)',
'pywbemtools', 'pywbemcli.py',
'line ', 'in cli',
'py_err_processatstartup.py',
'def mock?prompt(msg):',
'SyntaxError: invalid syntax'],
'rc': 1,
'test': 'innows'},
BAD_PY_ERR_STRTUP_PATH, OK],

['Verify -n option with new name but not in repo fails',
{'general': ['-n', 'fred'],
'cmdgrp': 'connection',
Expand Down

0 comments on commit 28ec9d0

Please sign in to comment.