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 class name when importing the library.
For example, class MyLib in MyLib.py file can be used as a library
with just name MyLib. This also works with submodules so that if, for
example, parent.MyLib module has class MyLib, importing it using just
parent.MyLib works. 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 or parent.submodule.MyLib.
纯粹从语言的角度来看,除了可能与导入类的人产生一些混淆之外,它不会有任何区别。在
如果将此模块用作robotframework测试套件中的库,那么robot将自动实例化与库文件同名的类。该类中的方法将作为该库中的关键字公开。在
robotframework用户指南有一个标题为Creating test library class or module的部分,上面写着(emphasis mine):
相关问题 更多 >
编程相关推荐