コード例 #1
0
ファイル: test_cli.py プロジェクト: pyqrcode/pyqrcodeNG
def test_output(arg, ext, expected, mode):
    f = tempfile.NamedTemporaryFile('w',
                                    suffix='.{0}'.format(ext),
                                    delete=False)
    f.close()
    try:
        cli.main(['test', arg, f.name])
        f = open(f.name, mode=mode)
        val = f.read(len(expected))
        f.close()
        assert expected == val
    finally:
        os.unlink(f.name)
コード例 #2
0
ファイル: test_cli.py プロジェクト: pyqrcode/pyqrcodeNG
def test_terminal(capsys):
    cli.main(['test'])
    out, err = capsys.readouterr()
    assert out
    assert '' == err
コード例 #3
0
ファイル: test_cli.py プロジェクト: pyqrcode/pyqrcodeNG
def test_unsupported_fileformat():
    with pytest.raises(SystemExit) as e:
        cli.main(['--output=test.pdf', '"This is a test"'])
        assert 1 == e.exception.code
        assert e.exception.message
コード例 #4
0
ファイル: test_cli.py プロジェクト: pyqrcode/pyqrcodeNG
def test_unsupported_color():
    with pytest.raises(SystemExit) as e:
        cli.main(['--color=test', '--output=test.png', '"This is a test"'])
        assert 1 == e.exception.code
        assert e.exception.message
コード例 #5
0
ファイル: test_cli.py プロジェクト: pyqrcode/pyqrcodeNG
def test_error_code():
    with pytest.raises(SystemExit) as e:
        cli.main(['--version=41', '"This is a test"'])
        assert 1 == e.exception.code
        assert e.exception.message