Why don’t you make the class B in module B derive from Class A in module A? That way B would expose all of the KW methods in A, plus you could add your new KW methods for B that use methods from A. The result would be a single import from RF that should work fine. (I offer this solution ‘cause I’ve done it myself.)
Cheers,
Martin
From: robotframe...@googlegroups.com [mailto:robotframe...@googlegroups.com]
On Behalf Of Martin Cosyns
Sent: Wednesday, May 08, 2013 3:10 AM
To: robotframe...@googlegroups.com
Subject: creating new library using other libraries for Robot Framework
Dear all,
currently I’m writing a new library (module B) for Robot Framework in Python. This library uses keywords from a second library (module A). So I imported module A into module B. Maybe I have to mention that the constructor of the class A has a parameter. So my solution was to add a parameter to class B’s constructor too and load an instance of class A within the constructor of class B (check attached code snippet). So far so good. This works fine both in Python environment and in the Robot Framework when I use the library standalone (means I use just the new library and its keywords).
I want to extend the tests by using different keywords from library A. So I have to import the library A into Robot Framework as well to access those keywords. Here an excerpt from the Robot Framework script:
*** Settings ***
Library | Library_A | ${Argument_A}
Library | Library_B | ${Argument_A}
*** Variables ***
${Argument_A} | aValue
*** Test Cases ***
Test new library
Keyword_from_Library_A
Keyword_from_Library_B
With this the Keyword_from_Library_A works while Keyword_from_Library_B doesn’t anymore (“AttributeError: Class_A instance has no attribute ‘private_attribute_C’”). If I change the import order of the libraries, the Keyword_from_Library_A doesn’t work (“AttributeError: Class_A instance has no attribute ‘private_attribute_D’”), but Keyword_from_Library_B works now.
The long text leads to the question, how to get out from this vicious circle?
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at
http://groups.google.com/group/robotframework-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Dear all,
currently I’m writing a new library (module B) for Robot Framework in Python. This library uses keywords from a second library (module A). So I imported module A into module B. Maybe I have to mention that the constructor of the class A has a parameter. So my solution was to add a parameter to class B’s constructor too and load an instance of class A within the constructor of class B (check attached code snippet). So far so good. This works fine both in Python environment and in the Robot Framework when I use the library standalone (means I use just the new library and its keywords).
I want to extend the tests by using different keywords from library A. So I have to import the library A into Robot Framework as well to access those keywords. Here an excerpt from the Robot Framework script:
*** Settings ***
Library | Library_A | ${Argument_A}
Library | Library_B | ${Argument_A}
*** Variables ***
${Argument_A} | aValue
*** Test Cases ***
Test new library
Keyword_from_Library_A
Keyword_from_Library_B
With this the Keyword_from_Library_A works while Keyword_from_Library_B doesn’t anymore (“AttributeError: Class_A instance has no attribute ‘private_attribute_C’”). If I change the import order of the libraries, the Keyword_from_Library_A doesn’t work (“AttributeError: Class_A instance has no attribute ‘private_attribute_D’”), but Keyword_from_Library_B works now.
The long text leads to the question, how to get out from this vicious circle?