Revision: 4075
Author: pekka.klarck
Date: Sun Sep 19 07:38:56 2010
Log: Changing getName() to __name__ in r4072 didn't work because they have different values with Jython's proxy classes. Noticed that Jython classes extending Java classes have __supernames__ attribute which seems to contain the exact names we want to avoid. Using that fixes the failing acceptance tests as well as the new unit test I created.
http://code.google.com/p/robotframework/source/detail?r=4075

Modified:
 /trunk/src/robot/running/testlibraries.py
 /trunk/utest/running/test_testlibrary.py

=======================================
--- /trunk/src/robot/running/testlibraries.py   Sun Sep 19 03:55:41 2010
+++ /trunk/src/robot/running/testlibraries.py   Sun Sep 19 07:38:56 2010
@@ -241,15 +241,15 @@
             return False
         for signature in handler.argslist[:handler.nargs]:
             cls = signature.declaringClass
-            if not (cls is Object or self._is_created_by_jython(cls)):
+ if not (cls is Object or self._is_created_by_jython(handler, cls)):
                 return False
         return True

     def _is_created_in_java(self, handler):
         return hasattr(handler, 'argslist')

-    def _is_created_by_jython(self, cls):
-        return cls.__name__.startswith('org.python.proxies.')
+    def _is_created_by_jython(self, handler, cls):
+        return handler.__name__ in getattr(cls, '__supernames__', [])


 class _ModuleLibrary(_BaseTestLibrary):
=======================================
--- /trunk/utest/running/test_testlibrary.py    Sat Sep 18 16:36:48 2010
+++ /trunk/utest/running/test_testlibrary.py    Sun Sep 19 07:38:56 2010
@@ -419,6 +419,12 @@
             handlers = TestLibrary('OverrideGetName').handlers
assert_equals(sorted(handlers.keys()), ['doNothing', 'getName'])

+        def test_extending_java_lib_in_python(self):
+            handlers = TestLibrary('extendingjava.ExtendJavaLib').handlers
+            assert_equals(len(handlers), 22)
+            for handler in 'kw_in_java_extender', 'javaSleep', 'divByZero':
+                assert_true(handler in handlers)
+

 class TestDynamicLibrary(unittest.TestCase):

Reply via email to