From 7b838f5c31c3219d13661ec612d750e58683cbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Tue, 2 Aug 2022 12:27:25 +0200 Subject: Disable a config test if ran under the root user The `test_conf_file_permission_denied` is designed to test if a config file can't be read due to missing file permissions. However if we run unit tests with the root user we will beneficiat from the root privileges and so this test will fails. This can be reproduced by running `tox` with `sudo`. These changes propose to skip this test if root privileges are detected. Closes-bug: #1983358 Change-Id: Idd124082265032c30f83242b612d002d7093aa61 --- oslo_config/tests/test_cfg.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index 16ec21d..ec2791e 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -21,6 +21,7 @@ import os import shutil import sys import tempfile +import unittest from unittest import mock import fixtures @@ -3839,6 +3840,8 @@ class SadPathTestCase(BaseTestCase): self.assertRaises(cfg.ConfigFilesNotFoundError, self.conf, ['--config-file', path]) + @unittest.skipIf(os.getuid() == 0, + "Not supported with the root privileges") def test_conf_file_permission_denied(self): (fd, path) = tempfile.mkstemp() -- cgit v1.2.1