Reputation: 25
Basic problem is that although the library file name and the class name are the same (as the Robot Framework manual advice), the Library PywinautoLibrary
import does not find the class keywords. Library PywinautoLibrary.PywinautoLibrary
does work however.
I know that the Robot Framework Python file cannot have both class and static funtions, so there are no static functions.
I have made custom pip installable wheel file with this setup.py:
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='****',
)
The only other Python package file is empty __init__.py
Then my PywinautoLibrary.py
starts like this:
#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 installation directory looks like this:
(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
Am I missing something simple?
Upvotes: 0
Views: 1984
Reputation: 3384
With Library PywinautoLibrary
you say to import PywinautoLibrary but say nothing about the class you want to use from that file because __init__.py
is empty. Importing Library PywinautoLibrary.PywinautoLibrary
you import the PywinautoLibrary
class from that library and that is why it works.
So __init__.py
must contain at least the following:
from PywinautoLibrary.PywinautoLibrary import PywinautoLibrary
It imports the PywinautoLibrary
class from the PywinautoLibrary module and keywords are visible.
Upvotes: 2