Skip to content

Commit b54a79e

Browse files
CarstenGrohmannphilpep
authored andcommitted
Don't execute SysV fallback for systemd units
1 parent 5d5c51f commit b54a79e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

testinfra/modules/service.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,15 @@ def is_enabled(self):
184184
return True
185185
if cmd.stdout.strip() == "disabled":
186186
return False
187-
# Fallback on SysV
187+
# Fallback on SysV - only for non-systemd units
188188
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760616
189-
return super().is_enabled
189+
if not self._has_systemd_suffix():
190+
return super().is_enabled
191+
raise RuntimeError(
192+
"Unable to determine state of {0}. Does this service exist?".format(
193+
self.name
194+
)
195+
)
190196

191197
@property
192198
def is_valid(self):
@@ -290,9 +296,7 @@ def is_enabled(self):
290296
if self.name in self.check_output("rcctl ls off").splitlines():
291297
return False
292298
raise RuntimeError(
293-
"Unable to determine state of {0}. Does this service exist?".format(
294-
self.name
295-
)
299+
f"Unable to determine state of {self.name}. Does this service exist?"
296300
)
297301

298302

0 commit comments

Comments
 (0)