Revision: 3596
Author: pekka.klarck
Date: Thu May 27 11:20:09 2010
Log: use inspect instead of type checks
http://code.google.com/p/robotframework/source/detail?r=3596

Modified:
 /trunk/src/robot/output/listeners.py
 /trunk/src/robot/running/testlibraries.py

=======================================
--- /trunk/src/robot/output/listeners.py        Wed May 26 04:50:18 2010
+++ /trunk/src/robot/output/listeners.py        Thu May 27 11:20:09 2010
@@ -12,8 +12,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-
-import types
+import inspect

 from robot import utils
 from robot.errors import DataError
@@ -172,7 +171,7 @@

     def _import_listener(self, name, args):
         listener, source = utils.import_(name, 'listener')
-        if not isinstance(listener, types.ModuleType):
+        if not inspect.ismodule(listener):
             listener = listener(*args)
         elif args:
raise DataError("Listeners implemented as modules do not take arguments")
=======================================
--- /trunk/src/robot/running/testlibraries.py   Thu May 27 07:11:21 2010
+++ /trunk/src/robot/running/testlibraries.py   Thu May 27 11:20:09 2010
@@ -14,7 +14,6 @@


 import os
-import types
 import inspect

 from robot import utils
@@ -36,7 +35,7 @@


 def _get_lib_class(libcode):
-    if isinstance(libcode, types.ModuleType):
+    if inspect.ismodule(libcode):
         return _ModuleLibrary
     if _get_dynamic_method(libcode, 'get_keyword_names'):
         if _get_dynamic_method(libcode, 'run_keyword'):
@@ -111,7 +110,7 @@
     def _valid_init(self, init_method):
if utils.is_jython and isinstance(init_method, PyReflectedConstructor):
             return True
-        if isinstance(init_method, (types.MethodType, types.FunctionType)):
+        if inspect.isroutine(init_method):
             return True
         return False

Reply via email to