예제 #1
0
def test_arg_top_err(top, mocker, capsys):
    csft2data = mocker.patch('csft.__main__.csft2data')

    with raises(SystemExit):
        main.main(argv=[curdir, '--top', top])

    csft2data.assert_not_called()
    out, err = capsys.readouterr()
    assert not out
    assert err
예제 #2
0
def test_show_version(capsys):
    try:
        main.main(argv=['-V'])
    except SystemExit as err:
        assert 0 == err.code

    from csft import __version__
    if LooseVersion(sys.version) < LooseVersion('3.0'):
        _, out = capsys.readouterr()
    else:
        out, _ = capsys.readouterr()
    assert __version__ == out.strip()
    assert LooseVersion(__version__) == LooseVersion(out.strip())
예제 #3
0
def test_arg_with_raw(data, mocker, capsys):
    csft2data = mocker.patch('csft.__main__.csft2data', return_value=data)

    assert 0 == main.main(argv=[curdir, '--with-raw'])

    csft2data.assert_called_once_with(main._dir(curdir))
    out, err = capsys.readouterr()
    assert out
    assert not err
예제 #4
0
def test_arg_top(data, mocker, capsys):
    csft2data = mocker.patch('csft.__main__.csft2data', return_value=data)
    head = mocker.patch.object(data, 'head', return_value=data)

    assert 0 == main.main(argv=[curdir, '--top', '5'])

    csft2data.assert_called_once_with(main._dir(curdir))
    head.assert_called_once()
    out, err = capsys.readouterr()
    assert out
    assert not err
예제 #5
0
def test_main(argv, data, mocker, capsys):
    mocker.patch('sys.argv', ['src'])
    csft2data = mocker.patch('csft.__main__.csft2data', return_value=data)

    assert 0 == main.main(argv=argv)

    if argv:
        csft2data.assert_called_once_with(main._dir(argv[0]))
    else:
        csft2data.assert_called_once_with(main._dir(curdir))

    out, err = capsys.readouterr()
    assert out
    assert not err
예제 #6
0
def test_wrong_path(path, capsys):
    with raises(SystemExit):
        main.main(argv=[path])
    out, err = capsys.readouterr()
    assert not out
    assert err