test: convert to shared helpers
Use the `can_modify_immutable()` helper from the TestBase parent class so we do not duplicate the code in multiple places. Similarly, make use of the `have_rpm_ostree()` helper.
This commit is contained in:
parent
851d949027
commit
5c0e6f5964
3 changed files with 9 additions and 37 deletions
|
|
@ -11,22 +11,11 @@ import unittest
|
|||
|
||||
from osbuild.util import rmrf
|
||||
|
||||
|
||||
def can_set_immutable():
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||
try:
|
||||
os.makedirs(f"{tmp}/f")
|
||||
# fist they give it ...
|
||||
subprocess.run(["chattr", "+i", f"{tmp}/f"], check=True)
|
||||
# ... then they take it away
|
||||
subprocess.run(["chattr", "-i", f"{tmp}/f"], check=True)
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
return False
|
||||
return True
|
||||
from .. import test
|
||||
|
||||
|
||||
class TestUtilLinux(unittest.TestCase):
|
||||
@unittest.skipUnless(can_set_immutable(), "Need root permissions")
|
||||
@unittest.skipUnless(test.TestBase.can_modify_immutable("/var/tmp"), "root-only")
|
||||
def test_rmtree_immutable(self):
|
||||
#
|
||||
# Test the `rmrf.rmtree()` helper and verify it can correctly unlink
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue