Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/test_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import logging
from unittest.mock import patch

from testcloud import util


def test_has_selinux_missing_command_does_not_configure_root_logging():
root_logger = logging.getLogger()
handlers = root_logger.handlers[:]

try:
root_logger.handlers = []

with patch("testcloud.util.subprocess.call", side_effect=FileNotFoundError):
assert util.has_selinux() is False

assert root_logger.handlers == []
finally:
root_logger.handlers = handlers
4 changes: 2 additions & 2 deletions testcloud/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def has_selinux() -> bool:
selinux_active = subprocess.call(["selinuxenabled"])
return not bool(selinux_active)
except FileNotFoundError:
logging.debug("selinuxenabled is not present (libselinux-utils package missing?)")
logging.debug("Assuming selinux is not installed and therefore disabled")
log.debug("selinuxenabled is not present (libselinux-utils package missing?)")
log.debug("Assuming selinux is not installed and therefore disabled")
return False


Expand Down