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)
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)
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)
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)
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)
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)
def test_version(capsys): assert version() is not None assert capsys.readouterr() == ('', '')
def test_version_missing_executable(): with pytest.raises(ExecutableNotFound, match=r'execute'): version()
def test_version(capsys): result = version() assert isinstance(result, tuple) and result assert all(isinstance(d, int) for d in result) assert capsys.readouterr() == ('', '')
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)