示例#1
0
def test_fyoo_context_wrong_format(context, context_format,
                                   expected_exception_cls):
    with pytest.raises(expected_exception_cls):
        main([
            f'--context={context}', f'--context-format={context_format}', '--',
            'echo', '-n', r'{{ a }} {{ date() }}'
        ])
示例#2
0
def test_fyoo_context_auto_format(os_execvp):
    main([
        r'--context={"a": {"b": "AAA"}}', '--', 'echo', '-n',
        r'{{ a.b }} {{ date() }}'
    ])
    os_execvp.assert_called_once_with('echo',
                                      ['echo', '-n', f'AAA {TODAY_DT_DS}'])
示例#3
0
def test_double_exec(os_execvp):
    main([f'--', 'echo', '--', '-n', r'{{ a }} {{ date() }}'])
    os_execvp.assert_called_once_with('echo',
                                      ['echo', '--', '-n', f' {TODAY_DT_DS}'])
示例#4
0
def test_fyoo_command_not_exist_error():
    with pytest.raises(SystemExit):
        main(['--', 'idontexistascommand'])
示例#5
0
def test_fyoo_dry_run_stops(os_execvp):
    main([f'--dry-run', '--', 'echo', '-n', 'hello'])
    os_execvp.assert_not_called()
示例#6
0
def test_fyoo_context_bad_format():
    with pytest.raises(ValueError):
        main([
            f'--context=a: b: 333', '--', 'echo', '-n', r'{{ a }} {{ date() }}'
        ])
示例#7
0
def test_unknown_arg_fails(capsys):
    with pytest.raises(SystemExit) as e:
        main(['asdf'])
    out: CaptureResult = capsys.readouterr()
    assert e.value.code == 2
    assert 'invalid choice' in out.err
示例#8
0
def test_no_arg_fails(capsys):
    with pytest.raises(SystemExit) as e:
        main([])
    out: CaptureResult = capsys.readouterr()
    assert e.value.code == 2
    assert 'Please provide a subcommand' in out.err
示例#9
0
文件: __main__.py 项目: brian-bk/fyoo
from fyoo.cli import main

if __name__ == '__main__':
    main()