There are several ways to extend an existing library explained in the
User Guide:
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.5.7#extending-existing-test-libraries
If you are creating a new library, the easiest approach would probably
be extending Telnet directly either via inheritance like
from robot.libraries.Telnet import Telnet
class MyCoolLibrary(Telnet):
def my_cool_keyword(self, arg):
self.write(...)
or via composition like
from robot.libraries.Telnet import Telnet
class MyCoolLibrary(object):
def __init__(self):
self._telnet = Telnet(...)
def my_cool_keyword(self, arg):
self._telnet.write(...)
In the former case you get all the keywords from Telnet automatically
so it's probably easier. If your users already use Telnet, and you
just want to add new functionality to it, you might want to get the
active Telnet library instance from Robot via
BuiltIn.get_library_instance method:
from robot.libraries.BuiltIn import BuiltIn
class MyCoolLibrary(object):
@property
def _telnet(self):
return BuiltIn().get_library_instance('Telnet')
def my_cool_keyword(self, arg):
self._telnet.write(...)
All the above approaches are explained in more detail in the User
Guide. Notice that in this last example you cannot assign
`self._telnet = Telnet(...)` in `__init__` due to this limitation in
Robot:
http://code.google.com/p/robotframework/issues/detail?id=646
Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org