From 23b522734062e85b230bfa1945eb328f1deac6b9 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavalias-github@xavier.robin.name>
Date: Thu, 25 May 2023 12:04:28 +0200
Subject: [PATCH] refactor: move imports to beginning of file

---
 modules/base/pymod/testutils.py | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/modules/base/pymod/testutils.py b/modules/base/pymod/testutils.py
index af5f7b66c..ea21d9b9e 100644
--- a/modules/base/pymod/testutils.py
+++ b/modules/base/pymod/testutils.py
@@ -1,5 +1,13 @@
+import inspect
+import sys
+import unittest
+
+from ost import xmlrunner
+from ost.conop import GetDefaultLib
+
+
 def RunTests():
-  '''
+  """
   This function behaves as a custom TestLoader for python unittests.
 
   With no system arguments, the default unittest TestRunner is used.
@@ -31,20 +39,15 @@ def RunTests():
       from ost import testutils
       testutils.RunTests()
 
-  '''
-  import unittest
-  import sys
+  """
   try:
-    if len(sys.argv)>1 and sys.argv[1]=='xml':
-      import inspect
-      import types
+    if len(sys.argv) > 1 and sys.argv[1] == 'xml':
       import __main__
-      from ost import xmlrunner
       for name, obj in inspect.getmembers(__main__):
         if (isinstance(obj, type) and
                             issubclass(obj, unittest.TestCase)):
           suite = unittest.TestLoader().loadTestsFromTestCase(obj)
-          stream = open('PYTEST-%s.xml'%name, 'w')
+          stream = open('PYTEST-%s.xml' % name, 'w')
           xmlrunner.XMLTestRunner(stream).run(suite)
           stream.close()
 
@@ -55,13 +58,12 @@ def RunTests():
 
 
 def DefaultCompoundLibIsSet():
-  '''
+  """
   This function checks if a default compound library is set.
 
   :return: True, if a compound library was found and set to be accessed with
            :func:`ost.conop.GetDefaultLib`. False otherwise.
-  '''
-  from ost. conop import GetDefaultLib
+  """
   # check if already there
   if GetDefaultLib():
     return True
-- 
GitLab