Пример #1
0
def test_version_parsefail_mocked(check_output):
    check_output.return_value = b'nonversioninfo'
    with pytest.raises(RuntimeError):
        version()
    check_output.assert_called_once_with(['dot', '-V'],
                                         startupinfo=STARTUPINFO,
                                         stderr=subprocess.STDOUT)
Пример #2
0
def test_version_parsefail_mocked(mocker, Popen):  # noqa: N803
    proc = Popen.return_value
    proc.returncode = 0
    proc.communicate.return_value = (b'nonversioninfo', None)

    with pytest.raises(RuntimeError, match=r'nonversioninfo'):
        version()

    Popen.assert_called_once_with(['dot', '-V'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT,
                                  startupinfo=mocker.ANY)
    check_startupinfo(Popen)
    proc.communicate.assert_called_once_with(None)
Пример #3
0
def test_version_parsefail_mocked(mocker, Popen):  # noqa: N803
    proc = Popen.return_value
    proc.returncode = 0
    proc.communicate.return_value = (b'nonversioninfo', None)

    with pytest.raises(RuntimeError, match=r'nonversioninfo'):
        version()

    Popen.assert_called_once_with(['dot', '-V'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT,
                                  startupinfo=mocker.ANY)
    check_startupinfo(Popen)
    proc.communicate.assert_called_once_with(None)
Пример #4
0
def test_version_mocked(mocker, Popen, stdout, expected):  # noqa: N803
    proc = Popen.return_value
    proc.returncode = 0
    proc.communicate.return_value = (stdout, None)

    assert version() == expected

    Popen.assert_called_once_with(['dot', '-V'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT,
                                  startupinfo=mocker.ANY)
    check_startupinfo(Popen.call_args.kwargs['startupinfo'])
    proc.communicate.assert_called_once_with(None)
Пример #5
0
def test_version_mocked(mocker, Popen):
    proc = Popen.return_value
    proc.returncode = 0
    proc.communicate.return_value = (b'dot - graphviz version 1.2.3 (mocked)', None)

    assert version() == (1, 2, 3)

    Popen.assert_called_once_with(['dot', '-V'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT,
                                  startupinfo=mocker.ANY)
    check_startupinfo(Popen)
    proc.communicate.assert_called_once_with(None)
Пример #6
0
def test_version_mocked(mocker, Popen):  # noqa: N803
    proc = Popen.return_value
    proc.returncode = 0
    proc.communicate.return_value = (b'dot - graphviz version 1.2.3 (mocked)',
                                     None)

    assert version() == (1, 2, 3)

    Popen.assert_called_once_with(['dot', '-V'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT,
                                  startupinfo=mocker.ANY)
    check_startupinfo(Popen)
    proc.communicate.assert_called_once_with(None)
Пример #7
0
def test_version_mocked(check_output):
    check_output.return_value = b'dot - graphviz version 1.2.3 (mocked)'
    assert version() == (1, 2, 3)
    check_output.assert_called_once_with(['dot', '-V'],
                                         startupinfo=STARTUPINFO,
                                         stderr=subprocess.STDOUT)
Пример #8
0
def test_version(capsys):
    assert version() is not None
    assert capsys.readouterr() == ('', '')
Пример #9
0
def test_version_missing_executable():
    with pytest.raises(ExecutableNotFound, match=r'execute'):
        version()
Пример #10
0
def test_version(capsys):
    result = version()
    assert isinstance(result, tuple) and result
    assert all(isinstance(d, int) for d in result)
    assert capsys.readouterr() == ('', '')
Пример #11
0
def test_version_mocked(check_output):
    check_output.return_value = b'dot - graphviz version 1.2.3 (mocked)'
    assert version() == (1, 2, 3)
    check_output.assert_called_once_with(['dot', '-V'],
                                         stderr=subprocess.STDOUT,
                                         **POPEN_KWARGS)
Пример #12
0
def test_version(capsys):
    result = version()
    assert isinstance(result, tuple) and result
    assert all(isinstance(d, int) for d in result)
    assert capsys.readouterr() == ('', '')
Пример #13
0
def test_version_missing_executable():
    with pytest.raises(ExecutableNotFound, match=r'execute'):
        version()