New issue 188 by pekka.klarck: Methods in Java libraries starting
with 'get' are executed at library load time
http://code.google.com/p/robotframework/issues/detail?id=188
Bug report and analysis by Torsten Kuepper:
We have this behaviour with Java test support library JVTInventoryLibrary:
It contains a method getMOPathConverter. At library load time the method
gets executed.
Reason is that Jython decorates methods which start on 'get' with an
attribute read access, having name MOPathConverter in this case. Robot goes
through the Python dictionary of the JVTInventoryLibrary class and invokes
getattr on each name found. So the the method gets executed. That is
irritating, because from Robot testwriter viewpoint methods starting with
'get' should not be treated in any special way.
Maybe Robot implemention could be changed to filter Methods in Java classes
by names returned from __class__.getDeclaredMethods() ?
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
Using __class__.getDeclaredMethods like Torsten suggested doesn't actually
work since
it doesn't return methods declared in possible parent classes. This problem
is easily
solved by using getMethods instead (we already have code to ignore methods
declared
only in Object).
Even getMethods isn't enough if a Java class is extended in Python. I'm not
sure is
there any other way to fix that than ignoring all attributes that match the
end of
any getter. Since that approach could also ignore valid methods we can't
really use
it. Unless we find some other way to fix it we may simply document this
behavior as a
known problem with Python libraries extending Java classes.
Anyway, we need to fix this with normal Java libraries ASAP. Thanks for
Torsten for
the bug report and detailed analysis.
Comment #2 on issue 188 by pekka.klarck: Methods in Java libraries starting
with 'get' are executed at library load time
http://code.google.com/p/robotframework/issues/detail?id=188
(No comment was entered for this change.)
Comment #3 on issue 188 by pekka.klarck: Methods in Java libraries starting
with 'get' are executed at library load time
http://code.google.com/p/robotframework/issues/detail?id=188
Fixed in r1227. Instead of using getMethods we decided to check attribute
types using
__dict__. This makes it possible to use the same code both with Python and
Jython
(apart from a small workaround for http://bugs.jython.org/issue1223) and it
also
avoids Python properties.
Comment #4 on issue 188 by pekka.klarck: Methods in Java libraries starting
with 'get' are executed at library load time
http://code.google.com/p/robotframework/issues/detail?id=188
(No comment was entered for this change.)
--
Comment #5 on issue 188 by pekka.klarck: Methods in Java libraries starting
with 'get' are executed at library load time
http://code.google.com/p/robotframework/issues/detail?id=188
In a retrospect, this wasn't actually a critical issue since it had pretty
easy
workaround.