Fix timezone and locale tests on photon

This commit is contained in:
Daniel A. Wozniak 2025-01-08 01:24:01 -07:00 committed by Daniel Wozniak
parent 78e06fdb42
commit 718654ae21
2 changed files with 14 additions and 2 deletions

View file

@ -1,13 +1,26 @@
import subprocess
import pytest
from tests.support.case import ModuleCase
def _check_systemctl():
if not hasattr(_check_systemctl, "memo"):
proc = subprocess.run(["localectl"], capture_output=True, check=False)
_check_systemctl.memo = (
b"Failed to get D-Bus connection: No such file or directory" in proc.stderr
or b"Failed to connect to bus: No such file or directory" in proc.stderr
)
return _check_systemctl.memo
@pytest.mark.skip_on_windows(reason="minion is windows")
@pytest.mark.skip_on_darwin(reason="locale method is not supported on mac")
@pytest.mark.skip_on_freebsd(
reason="locale method is supported only within login classes or environment variables"
)
@pytest.mark.skipif(_check_systemctl(), reason="localectl degraded")
@pytest.mark.requires_salt_modules("locale")
@pytest.mark.windows_whitelisted
class LocaleModuleTest(ModuleCase):

View file

@ -20,12 +20,11 @@ except ImportError:
def _check_systemctl():
if not hasattr(_check_systemctl, "memo"):
proc = subprocess.run(["systemctl"], capture_output=True, check=False)
proc = subprocess.run(["timedatectl"], capture_output=True, check=False)
_check_systemctl.memo = (
b"Failed to get D-Bus connection: No such file or directory" in proc.stderr
or b"Failed to connect to bus: No such file or directory" in proc.stderr
)
print(repr(proc.stderr))
return _check_systemctl.memo