Martin Taylor
unread,Sep 8, 2009, 1:47:12 PM9/8/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to robotframework-users
The Robot Framework documentation talks about how to import libraries
that are implemented as a class in a module:
"The name of a test library that is used when a library is imported is
the same as the name of the module or class implementing it. For
example, if you have a Python module MyLibrary (that is, the file
MyLibrary.py), it will create a library with a name MyLibrary.
Similarly, a Java class YourLibrary, when it is not in any package,
creates a library with exactly that name.
Python classes are always inside a module. If the name of a class
implementing a library is the same as the name of the module, Robot
Framework allows dropping the module name when importing the library.
For example, the class MyLib in the MyLib.py file can be used as a
library with the name MyLib. If the module name and class name are
different, libraries must be taken into use using both module and
class names, such as mymodule.MyLibrary."
All my libraries are structured as Classes inside Modules inside
Packages, which is not discussed above. For example:
MyPackage (a folder under C:\Python25\Lib\site-packages)
|
+-- __init__.py (The main "Module"? file containing the definition
of a class called "MyPackage")
|
+-- AnotherClass.py (Another module that I want to import as a
library. It contains the definition of a class called "AnotherClass")
I've tried using:
Library MyPackage.AnotherClass
and
Library MyPackage.AnotherClass.AnotherClass
in Robot Framework and neither imports correctly. What am I doing
wrong here? Does EVERY Robot Framework library need to be in its own
package with a __init__.py file containing the class definition?