示例#1
0
def test_cmd2_with_force_option_false():
    global result
    result = {}

    cmd.dispatch({
        '--force': False,
        '--help': False,
        'cmd1': False,
        'cmd2_no_force': True,
        'cmd3': False,
        '<dest>': None}
    )
    assert result == {'cmd2': 1}
示例#2
0
def test_cmd2_is_called():
    global result
    result = {}

    cmd.dispatch({
        '--force': True,
        '--help': False,
        'cmd1': False,
        'cmd2': True,
        'cmd3': False,
        '<dest>': None}
    )
    assert result == {'cmd2': 1}
示例#3
0
def test_cmd_exception_on_missing_option():
    global result
    result = {}

    with pytest.raises(Exception) as einfo:
        cmd.dispatch({
            '--force': True,
            '--help': False,
            'cmd1': False,
            'cmd2': False,
            'cmd3': True,
            '<dest>': None}
        )
    assert result == {}
    assert einfo.match(r'No implementation for spec: .*')
示例#4
0
def test_cmd1_is_called():
    global result
    result = {}

    # note: no parsing of args here!!
    # args = docopt(DOC)
    cmd.dispatch({
        '--force': False,
        '--help': False,
        'cmd1': True,
        'cmd2': False,
        'cmd3': False,
        '<dest>': None}
    )
    assert result == {'cmd1': 1}
示例#5
0
def test_cmd_exception_when_not_spec_does_not_match():
    global result
    result = {}

    with pytest.raises(Exception) as einfo:
        cmd.dispatch({
            '--force': False,
            '--help': False,
            'cmd1': False,
            'cmd2': False,
            'cmd3': False,
            'cmd4': True}
        )
    assert result == {}
    assert einfo.match(r'No implementation for spec: .*')