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 15, 2024
1 parent c404f3d commit ffe4b2c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/test_pkg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import rpm
import subprocess
import unittest.mock as mock
from rpmlint.pkg import parse_deps, rangeCompare

from Testing import get_tested_package
Expand All @@ -25,5 +27,12 @@ def test_range_compare():


@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):
with mock.patch("shutil.which") as mock_which:
mock_which.return_value = None
# 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)
mock_which.assert_called_once_with("rpm2archive")
# check that it was rpm2cpio what failed
assert exc.match(r"rpm2cpio .*")

0 comments on commit ffe4b2c

Please sign in to comment.