Skip to content

Commit 7ab204f

Browse files
garethgreenawaydwoz
authored andcommitted
fixes to test_mac_service.py
1 parent e6eaedf commit 7ab204f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/pytests/functional/modules/test_mac_service.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def service(modules):
2222

2323

2424
@pytest.fixture(scope="function", autouse=True)
25-
def service_name(service, service_name):
25+
def service_name(service):
2626

2727
service_name = "com.salt.integration.test"
2828
service_path = "/Library/LaunchDaemons/com.salt.integration.test.plist"
@@ -41,7 +41,11 @@ def service_name(service, service_name):
4141
try:
4242
yield service_name
4343
finally:
44-
service.stop(service_name)
44+
# Try to stop the service if it's running
45+
try:
46+
service.stop(service_name)
47+
except CommandExecutionError:
48+
pass
4549
salt.utils.files.safe_rm(service_path)
4650

4751

@@ -52,7 +56,7 @@ def test_show(service, service_name):
5256
# Existing Service
5357
service_info = service.show(service_name)
5458
assert isinstance(service_info, dict)
55-
assert service_info.data["plist"]["Label"] == service_name
59+
assert service_info["plist"]["Label"] == service_name
5660

5761
# Missing Service
5862
with pytest.raises(CommandExecutionError) as exc:
@@ -228,7 +232,7 @@ def test_get_all(service, service_name):
228232
"""
229233
services = service.get_all()
230234
assert isinstance(services, list)
231-
assert service_name in services.data
235+
assert service_name in services
232236

233237

234238
def test_get_enabled(service, service_name):
@@ -237,7 +241,7 @@ def test_get_enabled(service, service_name):
237241
"""
238242
services = service.get_enabled()
239243
assert isinstance(services, list)
240-
assert service_name in services.data
244+
assert service_name in services
241245

242246

243247
def test_service_laoded(service, service_name):

0 commit comments

Comments
 (0)