示例#1
0
def test_help_displayed(args: List[str], capsys: CaptureFixture):
    try:  # -h raises it, no args doesn’t. Maybe not ideal but meh.
        main(args)
    except SystemExit as se:
        assert se.code == 0
    captured = capsys.readouterr()
    assert captured.out.startswith('usage: ')
示例#2
0
def test_help_output(set_path: type(None), capsys: CaptureFixture):
    with pytest.raises(SystemExit, match='^0$'):
        main(['-h'])
    captured = capsys.readouterr()
    assert re.search(
        r'^positional arguments:\n\s+\{settings,[\w,-]*testbin[\w,-]*\}$',
        captured.out,
        re.MULTILINE,
    )
示例#3
0
def test_external(set_path: type(None)):
    # We need to capture the output manually, since subprocesses don’t write to sys.stderr
    cmd = main(['testbin', '-t', '--testarg', 'testpos'],
               stdout=PIPE,
               encoding='utf-8',
               check=True)
    assert cmd.stdout == 'test -t --testarg testpos\n'
示例#4
0
def test_error_wrong_command(capsys: CaptureFixture):
    with pytest.raises(SystemExit, match='^2$'):
        main(['idonotexist--'])
    captured = capsys.readouterr()
    assert 'No command “idonotexist--”. Choose from' in captured.err
示例#5
0
def test_builtin_settings(capsys: CaptureFixture):
    main(['settings'])
    captured = capsys.readouterr()
    assert captured.out == f'{scanpy.settings}\n'