Exemple #1
0
def test_base_history(base_app):
    run_cmd(base_app, 'help')
    run_cmd(base_app, 'shortcuts')
    out = run_cmd(base_app, 'history')
    expected = _normalize("""
-------------------------[1]
help
-------------------------[2]
shortcuts
""")
    assert out == expected

    out = run_cmd(base_app, 'history he')
    expected = _normalize("""
-------------------------[1]
help
""")
    assert out == expected

    out = run_cmd(base_app, 'history sh')
    expected = _normalize("""
-------------------------[2]
shortcuts
""")
    assert out == expected
Exemple #2
0
def test_base_history(base_app):
    run_cmd(base_app, 'help')
    run_cmd(base_app, 'shortcuts')
    out = run_cmd(base_app, 'history')
    expected = _normalize("""
-------------------------[1]
help
-------------------------[2]
shortcuts
""")
    assert out == expected

    out = run_cmd(base_app, 'history he')
    expected = _normalize("""
-------------------------[1]
help
""")
    assert out == expected

    out = run_cmd(base_app, 'history sh')
    expected = _normalize("""
-------------------------[2]
shortcuts
""")
    assert out == expected
Exemple #3
0
def _get_transcript_blocks(transcript):
    cmd = None
    expected = ''
    for line in transcript.splitlines():
        if line.startswith('(Cmd) '):
            if cmd is not None:
                yield cmd, _normalize(expected)

            cmd = line[6:]
            expected = ''
        else:
            expected += line + '\n'
    yield cmd, _normalize(expected)
Exemple #4
0
def _get_transcript_blocks(transcript):
    cmd = None
    expected = ""
    for line in transcript.splitlines():
        if line.startswith("(Cmd) "):
            if cmd is not None:
                yield cmd, _normalize(expected)

            cmd = line[6:]
            expected = ""
        else:
            expected += line + "\n"
    yield cmd, _normalize(expected)
Exemple #5
0
def test_base_list(base_app):
    run_cmd(base_app, 'help')
    run_cmd(base_app, 'shortcuts')
    out = run_cmd(base_app, 'list')
    expected = _normalize("""
-------------------------[2]
shortcuts
""")
    assert out == expected
Exemple #6
0
def test_base_list(base_app):
    run_cmd(base_app, 'help')
    run_cmd(base_app, 'shortcuts')
    out = run_cmd(base_app, 'list')
    expected = _normalize("""
-------------------------[2]
shortcuts
""")
    assert out == expected
Exemple #7
0
def test_base_load(base_app):
    base_app.read_file_or_url = mock.Mock(
        return_value=StringIO('set quiet True\n'))
    out = run_cmd(base_app, 'load myfname')
    expected = _normalize("""
quiet - was: False
now: True
""")
    assert out == expected
Exemple #8
0
def test_base_set(base_app):
    out = run_cmd(base_app, 'set quiet True')
    expected = _normalize("""
quiet - was: False
now: True
""")
    assert out == expected

    out = run_cmd(base_app, 'show quiet')
    assert out == ['quiet: True']
Exemple #9
0
def test_base_shortcuts(base_app):
    out = run_cmd(base_app, 'shortcuts')
    expected = _normalize("""
Single-key shortcuts for other commands:
!: shell
?: help
@: load
@@: _relative_load
""")
    assert out == expected
Exemple #10
0
def test_base_load(base_app):
    base_app.read_file_or_url = mock.Mock(
        return_value=StringIO('set quiet True\n')
    )
    out = run_cmd(base_app, 'load myfname')
    expected = _normalize("""
quiet - was: False
now: True
""")
    assert out == expected
Exemple #11
0
def test_base_set(base_app):
    out = run_cmd(base_app, 'set quiet True')
    expected = _normalize("""
quiet - was: False
now: True
""")
    assert out == expected

    out = run_cmd(base_app, 'show quiet')
    assert out == ['quiet: True']
Exemple #12
0
def test_base_shortcuts(base_app):
    out = run_cmd(base_app, 'shortcuts')
    expected = _normalize("""
Single-key shortcuts for other commands:
!: shell
?: help
@: load
@@: _relative_load
""")
    assert out == expected
Exemple #13
0
def test_base_help(base_app):
    out = run_cmd(base_app, 'help')
    expected = _normalize("""
Documented commands (type help <topic>):
========================================
_load           ed    history  list   py   save   shortcuts
_relative_load  edit  l        load   r    set    show
cmdenvironment  hi    li       pause  run  shell

Undocumented commands:
======================
EOF  eof  exit  help  q  quit
""")
    assert out == expected
Exemple #14
0
def test_base_help(base_app):
    out = run_cmd(base_app, 'help')
    expected = _normalize("""
Documented commands (type help <topic>):
========================================
_load           ed    history  list   py   save   shortcuts
_relative_load  edit  l        load   r    set    show
cmdenvironment  hi    li       pause  run  shell

Undocumented commands:
======================
EOF  eof  exit  help  q  quit
""")
    assert out == expected
Exemple #15
0
def test_base_help_history(base_app):
    out = run_cmd(base_app, 'help history')
    expected = _normalize("""
history [arg]: lists past commands issued

        | no arg:         list all
        | arg is integer: list one history item, by index
        | arg is string:  string search
        | arg is /enclosed in forward-slashes/: regular expression search

Usage: history [options] (limit on which commands to include)

Options:
  -h, --help    show this help message and exit
  -s, --script  Script format; no separation lines
""")
    assert out == expected
Exemple #16
0
def test_base_help_history(base_app):
    out = run_cmd(base_app, 'help history')
    expected = _normalize("""
history [arg]: lists past commands issued

        | no arg:         list all
        | arg is integer: list one history item, by index
        | arg is string:  string search
        | arg is /enclosed in forward-slashes/: regular expression search

Usage: history [options] (limit on which commands to include)

Options:
  -h, --help    show this help message and exit
  -s, --script  Script format; no separation lines
""")
    assert out == expected
Exemple #17
0
def test_base_show(base_app):
    out = run_cmd(base_app, 'show')
    expected = _normalize("""
abbrev: True
case_insensitive: True
colors: True
continuation_prompt: >
debug: False
default_file_name: command.txt
echo: False
feedback_to_output: False
prompt: (Cmd)
quiet: False
timing: False
""")
    # ignore "editor: vi" (could be others)
    out = [l for l in out if not l.startswith('editor: ')]
    assert out == expected
Exemple #18
0
def test_base_show(base_app):
    out = run_cmd(base_app, 'show')
    expected = _normalize("""
abbrev: True
case_insensitive: True
colors: True
continuation_prompt: >
debug: False
default_file_name: command.txt
echo: False
feedback_to_output: False
prompt: (Cmd)
quiet: False
timing: False
""")
    # ignore "editor: vi" (could be others)
    out = [l for l in out if not l.startswith('editor: ')]
    assert out == expected
Exemple #19
0
def notest_base_(base_app):
    out = run_cmd(base_app, 'shortcuts')
    expected = _normalize("""
""")
    assert out == expected
Exemple #20
0
def notest_base_(base_app):
    out = run_cmd(base_app, 'shortcuts')
    expected = _normalize("""
""")
    assert out == expected