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.
This commit is contained in:
@@ -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'}}
|
||||
|
||||
@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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user