You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This attribute makes it easier to detect is a certain model object a suite, a test, a keyword or a control structure. One use case is implementing start_keyword in a visitor or a listener and wanting to know the type of kw.parent. A concrete use case is that JsonLogger implemented as part of #3423 needs to know is a parent of a teardown keyword a suite or a test.
Keywords and control structures already have a type attribute that's need also in JSON serialization, but using kw.parent.type currently fails if the parent happens to be a test or a suite. A workaround is importing appropriate classes and using something like isinstance(kw.parent, TestSuite), but in many usages using kw.parent == 'SUITE is more convenient. Another workaround is implementing also start_suite, start_test and start_body_item and keeping track of the parent type separately. That can be needed in some cases anyway, but in simple usages accessing the type attribute is a lot simpler.
The text was updated successfully, but these errors were encountered:
I believe good values for the type attribute are SUITE and TEST. Types used with keywords and control structures are defined as constants in the BodyItem class that is their common base class. I believe we should move constants to ModelObject that also TestSuite and TestCase share and add appropriate constants there as well.
This attribute makes it easier to detect is a certain model object a suite, a test, a keyword or a control structure. One use case is implementing
start_keyword
in a visitor or a listener and wanting to know the type ofkw.parent
. A concrete use case is thatJsonLogger
implemented as part of #3423 needs to know is a parent of a teardown keyword a suite or a test.Keywords and control structures already have a
type
attribute that's need also in JSON serialization, but usingkw.parent.type
currently fails if the parent happens to be a test or a suite. A workaround is importing appropriate classes and using something likeisinstance(kw.parent, TestSuite)
, but in many usages usingkw.parent == 'SUITE
is more convenient. Another workaround is implementing alsostart_suite
,start_test
andstart_body_item
and keeping track of the parent type separately. That can be needed in some cases anyway, but in simple usages accessing thetype
attribute is a lot simpler.The text was updated successfully, but these errors were encountered: