Skip to content

Commit

Permalink
Rewrite test_extract to *_fail variant that tests an expected failure…
Browse files Browse the repository at this point in the history
… in rpm2cpio
  • Loading branch information
dmach committed Aug 14, 2024
1 parent c404f3d commit c6a63e2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/test_pkg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytest
import rpm
import shutil
import subprocess
import unittest.mock as mock
from rpmlint.pkg import parse_deps, rangeCompare

from Testing import get_tested_package
Expand All @@ -24,6 +27,16 @@ def test_range_compare():
assert not rangeCompare(req, prov)


def mock_which_rpm2archive(cmd, *args, **kwargs):
# pretend that there's no rpm2archive because we're testing a rpm2cpio failure
if cmd == "rpm2archive":
return None
return shutil.which(cmd, *args, **kwargs)


@mock.patch('shutil.which', new=mock_which_rpm2archive)
@pytest.mark.parametrize('package', ['binary/python311-pytest-xprocess'])
def test_extract(package, tmp_path):
get_tested_package(package, tmp_path)
def test_extract_fail(package, tmp_path):
# the package cannot be extracted using rpm2cpio because it contains a directory without 'x' permission
with pytest.raises(subprocess.CalledProcessError) as exc:
get_tested_package(package, tmp_path)

0 comments on commit c6a63e2

Please sign in to comment.