def test_exception(self, exc, mocker, tmpdir): """Test with subprocess.check_output raising an exception. Args: exc: The exception to raise. """ m = mocker.patch("qutebrowser.utils.version.os") m.path.isdir.return_value = True mocker.patch("qutebrowser.utils.version.subprocess.check_output", side_effect=exc) ret = version._git_str_subprocess(str(tmpdir)) assert ret is None
def test_exception(self, exc, mocker, tmp_path): """Test with subprocess.run raising an exception. Args: exc: The exception to raise. """ m = mocker.patch('qutebrowser.utils.version.os') m.path.isdir.return_value = True mocker.patch('qutebrowser.utils.version.subprocess.run', side_effect=exc) ret = version._git_str_subprocess(str(tmp_path)) assert ret is None
def test_missing_dir(self, tmp_path): """Test with a directory which doesn't exist.""" ret = version._git_str_subprocess(str(tmp_path / 'does-not-exist')) assert ret is None
def test_real_git(self, git_repo): """Test with a real git repository.""" ret = version._git_str_subprocess(str(git_repo)) assert ret == '6e4b65a on master (1970-01-01 01:00:00 +0100)'
def test_missing_dir(self, tmpdir): """Test with a directory which doesn't exist.""" ret = version._git_str_subprocess(str(tmpdir / 'does-not-exist')) assert ret is None
def test_real_git(self, git_repo): """Test with a real git repository.""" ret = version._git_str_subprocess(str(git_repo)) assert ret == 'foobar (1970-01-01 01:00:00 +0100)'