TestResultContext(*args, uid, **kwargs)¶
Not intended to be used by itself.
TestResultContext class is a context container that its subclasses to have results, and enables the use of python ‘with’ statement, propagating results from one context to another.
This class gives its subclasses to carry a result. When a TestResultContext is given a result, its parent context’s result is also affected (rolled up).
Pseudo Code Example:
obj_a = TestResultContext() obj_b = TestResultContext(parent = obj_a) # roll up obj_b's result context into obj_a automatically. with obj_a: with obj_b: obj_b.result = Failed
uid (str) – Required UID for this test context
*args – arguments to propagate through
**kwargs – arguments to propagate through
name of the test section as it will show up in the report
returns the rest context parent
returns the context object result
returns the test item unique id.
>>> t = TestItem(uid = 'test', description = '') >>> t.uid
Subclass of base str class, enables section uids to have a ‘full’ uid attribute, returning the whole uid (including it’s parent’s uid), and a ‘list’ uid attribute which returns a list of all ancestor uids.
>>> tc.section.uid.full 'mytestcase.test_one' >>> tc.section.uid.list ['mytestcase', 'test_one']
built in __new__
Since str is immutable it doesn’t seem to have a __init__, only __new__, so we’ll rig this to return instance of each string with a new attribute called ‘full’, containing the full uid, and an attribute called ‘list’, containing a list of all parent uids
A standard dictionary keeping track of overall numbers of testcase results. By default, contains the following keys:
passed, passx, failed, aborted, skipped, blocked, errored
- and the following dynamically computed values:
items() → a set-like object providing a view on D’s items¶
keys() → a set-like object providing a view on D’s keys¶
update([E, ]**F) → None. Update D from mapping/iterable E and F.¶
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values() → an object providing a view on D’s values¶
TestResult(code, reason=None, data=None)¶
Test Result class
Class for handling ATS-style test results such as Passed, Failed, Aborted etc. Typically, ATS results assocate a code (integer) to a name (string), and a set of pre-defined roll-up rules. This class and its derived objects are designed to facilitate the above behavior. Also contains the reasoning and data associated with each test result
- Result Rollup:
result objects can be rolled up together by using the addition “+” operator. Eg:
Passed + Errored -> Errored
Legacy “setup_pass/setup_fail” and etc have been removed in pyATS and no longer used.
Inits optional internal variables
Returns a new result of the same type
from_str(string, reason=None, data=None)¶
Allows the creation of TestResult objects from strings names
string (str) – string name to convert to object