Skip to content

Commit

Permalink
test_files_provider: Do not use pytest fixtures as functions
Browse files Browse the repository at this point in the history
test_files_provider.py::test_getpwnam_after_start
  src/tests/intg/test_files_provider.py:344: RemovedInPytest4Warning:
    Fixture "passwd_ops_setup" called directly. Fixtures are not meant
    to be called directly, are created automatically when test functions
    request them as parameters.
    See https://docs.pytest.org/en/latest/fixture.html for more information.

  src/tests/intg/test_files_provider.py:362: RemovedInPytest4Warning:
    Fixture "group_ops_setup" called directly. Fixtures are not meant
    to be called directly, are created automatically when test functions
    request them as parameters.
    See https://docs.pytest.org/en/latest/fixture.html for more information.
      return setup_gr_with_list(request, [GROUP1, CANARY_GR])

Resolves:
https://pagure.io/SSSD/sssd/issue/3942

Merges: https://pagure.io/SSSD/sssd/pull-request/3953

Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
  • Loading branch information
Lukas Slebodnik authored and jhrozek committed Feb 26, 2019
1 parent 713e4f9 commit 686a8f5
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/tests/intg/test_files_provider.py
Expand Up @@ -331,40 +331,38 @@ def override_homedir_and_shell(request):
return None


def setup_pw_with_list(request, user_list):
pwd_ops = passwd_ops_setup(request)
def setup_pw_with_list(pwd_ops, user_list):
for user in user_list:
pwd_ops.useradd(**user)
ent.assert_passwd_by_name(CANARY['name'], CANARY)
return pwd_ops


@pytest.fixture
def add_user_with_canary(request):
return setup_pw_with_list(request, [CANARY, USER1])
def add_user_with_canary(passwd_ops_setup):
return setup_pw_with_list(passwd_ops_setup, [CANARY, USER1])


@pytest.fixture
def setup_pw_with_canary(request):
return setup_pw_with_list(request, [CANARY])
def setup_pw_with_canary(passwd_ops_setup):
return setup_pw_with_list(passwd_ops_setup, [CANARY])


def setup_gr_with_list(request, group_list):
grp_ops = group_ops_setup(request)
def setup_gr_with_list(grp_ops, group_list):
for group in group_list:
grp_ops.groupadd(**group)
ent.assert_group_by_name(CANARY_GR['name'], CANARY_GR)
return grp_ops


@pytest.fixture
def add_group_with_canary(request):
return setup_gr_with_list(request, [GROUP1, CANARY_GR])
def add_group_with_canary(group_ops_setup):
return setup_gr_with_list(group_ops_setup, [GROUP1, CANARY_GR])


@pytest.fixture
def setup_gr_with_canary(request):
return setup_gr_with_list(request, [CANARY_GR])
def setup_gr_with_canary(group_ops_setup):
return setup_gr_with_list(group_ops_setup, [CANARY_GR])


def poll_canary(fn, name, threshold=20):
Expand Down Expand Up @@ -802,8 +800,8 @@ def test_mod_group_gid(add_group_with_canary, files_domain_only):


@pytest.fixture
def add_group_nomem_with_canary(request):
return setup_gr_with_list(request, [GROUP_NOMEM, CANARY_GR])
def add_group_nomem_with_canary(group_ops_setup):
return setup_gr_with_list(group_ops_setup, [GROUP_NOMEM, CANARY_GR])


def test_getgrnam_no_members(add_group_nomem_with_canary, files_domain_only):
Expand Down

0 comments on commit 686a8f5

Please sign in to comment.