From ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 12 Jun 2023 14:16:59 +0100 Subject: Tests: prerequisites checking reworked. Prerequisites check moved to the module level to simplify class structure. Discovery and prerequisites checks functions moved to the separate files. Introduced "require" fixture to provide per-test requirements check. --- test/test_java_isolation_rootfs.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'test/test_java_isolation_rootfs.py') diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py index 28bc4a0d..bbd2c915 100644 --- a/test/test_java_isolation_rootfs.py +++ b/test/test_java_isolation_rootfs.py @@ -5,15 +5,12 @@ import pytest from unit.applications.lang.java import TestApplicationJava from unit.option import option +prerequisites = {'modules': {'java': 'all'}, 'privileged_user': True} -class TestJavaIsolationRootfs(TestApplicationJava): - prerequisites = {'modules': {'java': 'all'}} +class TestJavaIsolationRootfs(TestApplicationJava): @pytest.fixture(autouse=True) - def setup_method_fixture(self, is_su, temp_dir): - if not is_su: - pytest.skip('require root') - + def setup_method_fixture(self, temp_dir): os.makedirs(f'{temp_dir}/jars') os.makedirs(f'{temp_dir}/tmp') os.chmod(f'{temp_dir}/tmp', 0o777) @@ -35,10 +32,7 @@ class TestJavaIsolationRootfs(TestApplicationJava): except subprocess.CalledProcessError: pytest.fail("Can't run mount process.") - def teardown_method(self, is_su): - if not is_su: - return - + def teardown_method(self): try: subprocess.run( ["umount", "--lazy", f"{option.temp_dir}/jars"], @@ -51,13 +45,8 @@ class TestJavaIsolationRootfs(TestApplicationJava): except subprocess.CalledProcessError: pytest.fail("Can't run umount process.") - def test_java_isolation_rootfs_chroot_war(self, is_su, temp_dir): - if not is_su: - pytest.skip('require root') - - isolation = { - 'rootfs': temp_dir, - } + def test_java_isolation_rootfs_chroot_war(self, temp_dir): + isolation = {'rootfs': temp_dir} self.load('empty_war', isolation=isolation) -- cgit