docs fix/old test tweak

This commit is contained in:
laerus 2016-07-31 02:22:26 +03:00
parent c063bff450
commit 9a233e0c95
2 changed files with 18 additions and 17 deletions

View file

@ -72,16 +72,15 @@ cmds = ['ls', 'cat hello kitty', 'abc', 'def', 'touch me', 'grep from me']
@pytest.mark.parametrize('inp, commands, offset', [
('', cmds, (0, 1)),
('show', cmds, (0, 1)),
('show -r', list(reversed(cmds)), (len(cmds)- 1, -1)),
('show 0', cmds[0:1], (0, 1)),
('show 1', cmds[1:2], (1, 1)),
('show -2', cmds[-2:-1], (len(cmds) -2 , 1)),
('show 1:3', cmds[1:3], (1, 1)),
('show 1::2', cmds[1::2], (1, 2)),
('show -4:-2', cmds[-4:-2], (len(cmds) - 4, 1))
('-r', list(reversed(cmds)), (len(cmds)- 1, -1)),
('0', cmds[0:1], (0, 1)),
('1', cmds[1:2], (1, 1)),
('-2', cmds[-2:-1], (len(cmds) -2 , 1)),
('1:3', cmds[1:3], (1, 1)),
('1::2', cmds[1::2], (1, 2)),
('-4:-2', cmds[-4:-2], (len(cmds) - 4, 1))
])
def test_show_cmd(inp, commands, offset, hist, xonsh_builtins, capsys):
def test_show_cmd_numerate(inp, commands, offset, hist, xonsh_builtins, capsys):
"""Verify that CLI history commands work."""
base_idx, step = offset
xonsh_builtins.__xonsh_history__ = hist
@ -89,11 +88,11 @@ def test_show_cmd(inp, commands, offset, hist, xonsh_builtins, capsys):
for ts,cmd in enumerate(cmds): # populate the shell history
hist.append({'inp': cmd, 'rtn': 0, 'ts':(ts+1, ts+1.5)})
# exp = ('{}: {}'.format(base_idx + idx * step, cmd)
# for idx, cmd in enumerate(list(commands)))
exp = '\n'.join(commands)
exp = ('{}: {}'.format(base_idx + idx * step, cmd)
for idx, cmd in enumerate(list(commands)))
exp = '\n'.join(exp)
history.history_main(shlex.split(inp))
history.history_main(['show', '-n'] + shlex.split(inp))
out, err = capsys.readouterr()
assert out.rstrip() == exp

View file

@ -238,7 +238,8 @@ class CommandField(abc.Sequence):
def _find_histfile_var(file_list, default):
"""Return the path of the history file
from the value of the envvar HISTFILE."""
from the value of the envvar HISTFILE.
"""
for f in file_list:
f = expanduser_abs_path(f)
if not os.path.isfile(f):
@ -380,7 +381,7 @@ def _hist_create_parser():
def _hist_get_portion(commands, slices):
"""Yield from portions of history commands. """
"""Yield from portions of history commands."""
if len(slices) == 1:
s = ensure_slice(slices[0])
try:
@ -438,8 +439,9 @@ def _hist_get(session='session', slices=None,
def _hist_show(ns, *args, **kwargs):
"""Show the requested portion of shell history. Accepts same parameters
with `_hist_get`."""
"""Show the requested portion of shell history.
Accepts same parameters with `_hist_get`.
"""
commands = _hist_get(ns.session, ns.slices, **kwargs)
try:
if ns.reverse: