【发布时间】:2019-09-26 05:38:58
【问题描述】:
基本问题是,虽然库文件名和类名相同(如 Robot Framework 手册建议),但 Library PywinautoLibrary 导入找不到类关键字。 Library PywinautoLibrary.PywinautoLibrary 确实有效。
我知道 Robot Framework Python 文件不能同时具有类和静态函数,所以没有静态函数。
我用这个 setup.py 制作了自定义 pip 可安装的轮子文件:
setup(
name='robotframework-pywinautolibrary',
description='Robot Framework wrapper for pywinauto',
version='1.0',
classifiers=['Programming Language :: Python :: >=3.6'],
package_dir={'' : 'src'},
packages=['PywinautoLibrary'],
include_package_data=True,
install_requires=['pywinauto>=0.6.6'],
author='****',
author_email='****',
)
唯一的其他Python包文件为空__init__.py
然后我的PywinautoLibrary.py 是这样开始的:
#LIBRARY DEFINITIONS-----------------------------------------------------------
DEFAULT_TIMEOUT = 15
DEFAULT_INTERVAL = 0.5
#Kwargs definitions
TIMEOUT = 'timeout'
RETRY_INTERVAL = 'retry_interval'
UNIQUE_ID = 'unique_id'
INIT_TEXT = 'init_text'
WINDOW_GETTER = 'window_getter'
WINDOW_KWARGS = 'window_kwargs'
USER_TIMEOUT = 'user_timeout'
COMPARE_FUNCTION = 'compare_func'
#Props definitions
FONTS_KEY = 'fonts'
RECTANGE_KEY = 'rectangle'
CLIENT_RECTS_KEY = 'client_rects'
#-----------------------------------------------------------------------------
class PywinautoLibrary:
def __init__(self):
...
Python安装目录如下:
(python32_env) PS C:\python32_env\lib\site-packages\PywinautoLibrary>
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8.5.2019 10.36 __pycache__
-a---- 8.5.2019 10.36 23088 PywinautoLibrary.py
-a---- 8.5.2019 10.36 0 __init__.py
我错过了一些简单的东西吗?
【问题讨论】:
-
在
__init__.py中尝试from PywinautoLibrary.PywinautoLibrary import PywinautoLibrary -
谢谢,它有效!你能解释一下是什么问题吗?
标签: python robotframework