import pytest

@pytest.mark.parametrize("name, enabled, running", [
  ("cron", "enabled", "running"),
  ("docker", "enabled", "running"),
  ("firewalld", "enabled", "running"),
  ("haveged", "enabled", "running"),
  ("ssh", "enabled", "running"),
])

def test_services(Service, name, enabled, running):
  is_enabled = Service(name).is_enabled
  print(is_enabled)
  if enabled == "enabled":
    assert is_enabled
  else:
    assert not is_enabled

  is_running = Service(name).is_running
  print(is_running)
  if running == "running":
    assert is_running
  else:
    assert not is_running


import pytest

@pytest.mark.parametrize("name, enabled, running", [
  ("cron", "enabled", "running"),
  ("docker", "enabled", "running"),
  ("firewalld", "enabled", "running"),
  ("haveged", "enabled", "running"),
  ("ssh", "enabled", "running"),
])

def test_services(host, name, enabled, running):

  svc = host.service(name)

  is_enabled = svc.is_enabled
  print(is_enabled)
  if enabled == "enabled":
    assert is_enabled
  else:
    assert not is_enabled

  is_running = svc.is_running
  print(is_running)
  if running == "running":
    assert is_running
  else:
    assert not is_running

Change test function as existing method deprecated
Change test function as existing method deprecated

  import pytest
  
  @pytest.mark.parametrize("name, enabled, running", [
    ("cron", "enabled", "running"),
    ("docker", "enabled", "running"),
    ("firewalld", "enabled", "running"),
    ("haveged", "enabled", "running"),
    ("ssh", "enabled", "running"),
  ])
  
- def test_services(Service, name, enabled, running):
+ def test_services(host, name, enabled, running):
+ 
+   svc = host.service(name)
+ 
-   is_enabled = Service(name).is_enabled
+   is_enabled = svc.is_enabled
    print(is_enabled)
    if enabled == "enabled":
      assert is_enabled
    else:
      assert not is_enabled
  
-   is_running = Service(name).is_running
+   is_running = svc.is_running
    print(is_running)
    if running == "running":
      assert is_running
    else:
      assert not is_running
  
- 
Change test function as existing method deprecated
## Code Before:
import pytest

@pytest.mark.parametrize("name, enabled, running", [
  ("cron", "enabled", "running"),
  ("docker", "enabled", "running"),
  ("firewalld", "enabled", "running"),
  ("haveged", "enabled", "running"),
  ("ssh", "enabled", "running"),
])

def test_services(Service, name, enabled, running):
  is_enabled = Service(name).is_enabled
  print(is_enabled)
  if enabled == "enabled":
    assert is_enabled
  else:
    assert not is_enabled

  is_running = Service(name).is_running
  print(is_running)
  if running == "running":
    assert is_running
  else:
    assert not is_running


## Instruction:
Change test function as existing method deprecated
## Code After:
import pytest

@pytest.mark.parametrize("name, enabled, running", [
  ("cron", "enabled", "running"),
  ("docker", "enabled", "running"),
  ("firewalld", "enabled", "running"),
  ("haveged", "enabled", "running"),
  ("ssh", "enabled", "running"),
])

def test_services(host, name, enabled, running):

  svc = host.service(name)

  is_enabled = svc.is_enabled
  print(is_enabled)
  if enabled == "enabled":
    assert is_enabled
  else:
    assert not is_enabled

  is_running = svc.is_running
  print(is_running)
  if running == "running":
    assert is_running
  else:
    assert not is_running
