pyats.results package¶
Submodules¶
- class pyats.results.context.TestResultContext(*args, uid, **kwargs)¶
Bases:
object
TestResultContext class
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
built-in __init__
- Parameters
uid (str) – Required UID for this test context
*args – arguments to propagate through
**kwargs – arguments to propagate through
- property name¶
name
name of the test section as it will show up in the report
- Type
Property
- property parent¶
parent
returns the rest context parent
- Type
Property
- property result¶
result
returns the context object result
- Type
Property
- property uid¶
uid
returns the test item unique id.
Example
>>> t = TestItem(uid = 'test', description = '') >>> t.uid
- Type
Property
- class pyats.results.context.TestableId(string, parent=None)¶
Bases:
str
TestableId class
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.
Example
>>> 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
- class pyats.results.counter.ResultCounter(results=None, weight=1.0)¶
Bases:
collections.abc.MutableMapping
ResultCounter class
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:
total, success_rate
- copy()¶
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- property success_rate¶
- property total¶
- 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 ¶
- class pyats.results.result.TestResult(code, reason=None, data=None)¶
Bases:
object
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
Object
Code
String
Failed
0
‘failed’
Passed
1
‘passed’
Aborted
2
‘aborted’
Blocked
3
‘blocked’
Skipped
4
‘skipped’
Errored
5
‘errored’
Passx
8
‘passx’
- Result Rollup:
result objects can be rolled up together by using the addition “+” operator. Eg:
Passed + Errored -> Errored
Note
Legacy “setup_pass/setup_fail” and etc have been removed in pyATS and no longer used.
See also
- http://wwwin-ats.cisco.com/product5.3.0/5.3.0/AEtest/NetHelp/
Documents/testcaserollup.htm
built-in __init__
Inits optional internal variables
- Parameters
- clone(reason=None, data=None)¶
method clone
Returns a new result of the same type
- classmethod from_str(string, reason=None, data=None)¶
classmethod from_str
Allows the creation of TestResult objects from strings names
- Parameters
string (str) – string name to convert to object
- property name¶