From c01f2afcca8a08c808e486971dea5810def27492 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Feb 09 2019 21:31:41 +0000
Subject: [PATCH 1/2] test_files_provider: Do not use pytest fixtures as functions


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

---

diff --git a/src/tests/intg/test_files_provider.py b/src/tests/intg/test_files_provider.py
index b5e5c3f..4c151b1 100644
--- a/src/tests/intg/test_files_provider.py
+++ b/src/tests/intg/test_files_provider.py
@@ -331,8 +331,7 @@ 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)
@@ -340,17 +339,16 @@ def setup_pw_with_list(request, user_list):
 
 
 @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)
@@ -358,13 +356,13 @@ def setup_gr_with_list(request, group_list):
 
 
 @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):
@@ -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):

From 2730e03a4808f8383eb574d5c47849658f92c4d7 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Feb 09 2019 21:31:56 +0000
Subject: [PATCH 2/2] test_ldap: Do not uses pytest fixtures as functions


test_ldap.py::test_local_negative_timeout_enabled_by_default
  /usr/lib/python3.7/site-packages/_pytest/fixtures.py:827:
    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.
    res = fixturefunc(**kwargs)
  /usr/lib/python3.7/site-packages/_pytest/fixtures.py:827:
    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.
    res = fixturefunc(**kwargs)
  /usr/lib/python3.7/site-packages/_pytest/fixtures.py:827:
    RemovedInPytest4Warning: Fixture "user_and_group_rfc2307" 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.

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

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

---

diff --git a/src/tests/intg/test_ldap.py b/src/tests/intg/test_ldap.py
index 3385fee..43edc6d 100644
--- a/src/tests/intg/test_ldap.py
+++ b/src/tests/intg/test_ldap.py
@@ -1596,13 +1596,14 @@ def test_rename_incomplete_group_rdn_changed(ldap_conn, rename_setup_cleanup):
 
 
 @pytest.fixture
-def user_and_group_rfc2307_lcl(request, ldap_conn):
-    pwd_ops = passwd_ops_setup(request)
+def user_and_group_rfc2307_lcl(passwd_ops_setup, group_ops_setup,
+                               user_and_group_rfc2307):
+    pwd_ops = passwd_ops_setup
     pwd_ops.useradd(**PASSWD_USER)
-    grp_ops = group_ops_setup(request)
+    grp_ops = group_ops_setup
     grp_ops.groupadd(**PASSWD_GROUP)
 
-    return user_and_group_rfc2307(request, ldap_conn)
+    return user_and_group_rfc2307
 
 
 def test_local_negative_timeout_enabled_by_default(ldap_conn,
@@ -1660,15 +1661,16 @@ def test_local_negative_timeout_enabled_by_default(ldap_conn,
 
 
 @pytest.fixture
-def usr_and_grp_rfc2307_no_local_ncache(request, ldap_conn):
+def usr_and_grp_rfc2307_no_local_ncache(request, passwd_ops_setup,
+                                        group_ops_setup, ldap_conn):
     """
     Create an RFC2307 directory fixture with interactive SSSD conf,
     one user and one group but with the local negative timeout
     disabled
     """
-    pwd_ops = passwd_ops_setup(request)
+    pwd_ops = passwd_ops_setup
     pwd_ops.useradd(**PASSWD_USER)
-    grp_ops = group_ops_setup(request)
+    grp_ops = group_ops_setup
     grp_ops.groupadd(**PASSWD_GROUP)
 
     ent_list = ldap_ent.List(ldap_conn.ds_inst.base_dn)

