URL: https://github.com/freeipa/freeipa/pull/1277
Author: tomaskrizek
 Title: #1277: [Backport][ipa-4-5] ipatests: fix circular import for 
collect_logs ack
Action: opened

PR body:
"""
Move collect_logs function from util to avoid a circular import.

Signed-off-by: Tomas Krizek <tkri...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1277/head:pr1277
git checkout pr1277
From 2370179922a304542639a22bb28a3d2487dd931e Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tkri...@redhat.com>
Date: Wed, 8 Nov 2017 12:47:56 +0100
Subject: [PATCH] ipatests: fix circular import for collect_logs

Move collect_logs function from util to avoid a circular import.

Signed-off-by: Tomas Krizek <tkri...@redhat.com>
---
 ipatests/pytest_plugins/integration/tasks.py  | 16 ++++++++++++++++
 ipatests/test_integration/test_external_ca.py |  3 +--
 ipatests/util.py                              | 18 ------------------
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/ipatests/pytest_plugins/integration/tasks.py b/ipatests/pytest_plugins/integration/tasks.py
index eddb1e20a2..421bddb72d 100644
--- a/ipatests/pytest_plugins/integration/tasks.py
+++ b/ipatests/pytest_plugins/integration/tasks.py
@@ -88,6 +88,22 @@ def setup_server_logs_collecting(host):
     # setup_sssd_debugging)
 
 
+def collect_logs(func):
+    def wrapper(*args):
+        try:
+            func(*args)
+        finally:
+            if hasattr(args[0], 'master'):
+                setup_server_logs_collecting(args[0].master)
+            if hasattr(args[0], 'replicas') and args[0].replicas:
+                for replica in args[0].replicas:
+                    setup_server_logs_collecting(replica)
+            if hasattr(args[0], 'clients') and args[0].clients:
+                for client in args[0].clients:
+                    setup_server_logs_collecting(client)
+    return wrapper
+
+
 def check_arguments_are(slice, instanceof):
     """
     :param: slice - tuple of integers denoting the beginning and the end
diff --git a/ipatests/test_integration/test_external_ca.py b/ipatests/test_integration/test_external_ca.py
index 171c0ee0d4..adb857b338 100644
--- a/ipatests/test_integration/test_external_ca.py
+++ b/ipatests/test_integration/test_external_ca.py
@@ -21,7 +21,6 @@
 
 from ipatests.pytest_plugins.integration import tasks
 from ipatests.test_integration.base import IntegrationTest
-from ipatests.util import collect_logs
 
 
 EXTERNAL_CA_KEY_ID = base64.b64encode(os.urandom(64))
@@ -32,7 +31,7 @@ class TestExternalCA(IntegrationTest):
     """
     Test of FreeIPA server installation with exernal CA
     """
-    @collect_logs
+    @tasks.collect_logs
     def test_external_ca(self):
         # Step 1 of ipa-server-install
         self.master.run_command([
diff --git a/ipatests/util.py b/ipatests/util.py
index fb43b6db80..76e102fc5a 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -43,8 +43,6 @@
 from ipalib.request import context
 from ipapython.dn import DN
 from ipapython.ipautil import run
-from ipatests.pytest_plugins.integration.tasks import (
-    setup_server_logs_collecting)
 
 
 try:
@@ -837,19 +835,3 @@ def get_group_dn(cn):
 
 def get_user_dn(uid):
     return DN(('uid', uid), api.env.container_user, api.env.basedn)
-
-
-def collect_logs(func):
-    def wrapper(*args):
-        try:
-            func(*args)
-        finally:
-            if hasattr(args[0], 'master'):
-                setup_server_logs_collecting(args[0].master)
-            if hasattr(args[0], 'replicas') and args[0].replicas:
-                for replica in args[0].replicas:
-                    setup_server_logs_collecting(replica)
-            if hasattr(args[0], 'clients') and args[0].clients:
-                for client in args[0].clients:
-                    setup_server_logs_collecting(client)
-    return wrapper
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to