我是Python和Robot Framework的新手。对于学习的测试项目我创建:
general_scenario.robot:
*** Settings ***
Documentation Suite description
Resource ../resource.robot
*** Variables ***
...
*** Test Cases ***
[Config] Extend Config Model
[Tags] model
Extend Config Model
然后,创建关键字lib:
...
class ModelLibrary(ModelAbstract):
...
@keyword('Extend Config Model')
def extend_config_model(self):
moGen = ModelGeneral.__init__(self, 45.5, 2.04)
moAdd = ModelAdditional(True, 0.34)
moRoute = ModelRoute("path")
mo = Model("ship002", moGen, moAdd, moRoute)
print(mo.name, mo.general, mo.additional, mo.route)
pass
我想使用helper(数据模型类)helper.Model.py,它在这个关键字lib中导入,如下所示:
from helper.Model import ModelGeneral, ModelAdditional
也有resource.robot文件:
Library libs/ModelLibrary.py
Library libs/EmulationLibrary.py
Library helper/Model.py
所以>pybot general_scenarios.robot
:
[ ERROR ] Error in file 'C:\..\resource.robot': Importing test library 'C:\..\libs\ModelLibrary.py' failed: ModuleNotFoundError: No module named 'helper'
Traceback (most recent call last):
File "C:\..\libs\ModelLibrary.py", line 5, in <module>
from helper.Model import ModelGeneral, ModelAdditional
and:
[ ERROR ] Error in file 'C:\..\resource.robot': Test Library 'Model' expected 4 arguments, got 0.
修复args未修复导入测试库失败。无法理解导入普通py模块的错误。
答案 0 :(得分:1)
您缺少帮助程序模块,以下命令将在您的cmd中安装该模块
pip install helper
每当缺少模块名称时,您都可以通过pip或第三方进行安装