pyats.aetest.steps package

Submodules

class pyats.aetest.steps.implementation.Step(name, *, index, parent, source, continue_=None, description=None)

Bases: Steps

Step Class

The actual class representing each step taken. This class is not normally instantiated by the user: it is instantiated from Steps.start() api.

Step class instances are context containers: using the “with” statement, users can enter/exit new step contexts and breakdown their testcase sections into smaller steps.

This class performs minimal error & signal handling, so that steps may have its own results & etc.

Example

>>> steps = Steps()
# step are created from step containers
>>> with steps.start('new step') as step:
>>>     assert isinstance(step, Step)
>>>     step.passed()

built-in __init__

instantiates each step.

Parameters:
  • (str) (description) –

  • (int/str) (index) –

  • (Step) (parent) –

  • (bool) (continue) – steps if the current step failed

  • (str)

static aborted(reason=None, data=None, from_exception=None)

Step Aborted

API to call when the current step execution is aborted. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

static blocked(reason=None, data=None, from_exception=None)

Step Blocked

API to call when the current step execution is blocked. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

property details

Step.details property

Used to access current step and all children steps) detail information in a flat list. Same as Steps().details property, but also includes this step’s details.

Parameters:

None

Return type:

list [] of StepDetail

static errored(reason=None, data=None, from_exception=None)

Step Errored

API to call when the current step execution errored out. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

static failed(reason=None, data=None, from_exception=None)

Step Failed

API to call when the current step execution is failed. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

property index

Step.index property

Each step’s index is its own index number prefixed with its parent’s index number. This property recursively calculates this index based on parent-child relationship and returns it to the caller.

Parameters:

None

Return type:

index separated by . in string format.

static passed(reason=None, data=None, from_exception=None)

Step Passed

API to call when the current step execution is passed. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

static passx(reason=None, data=None, from_exception=None)

Step Passx

API to call when the current step execution result is passed with exception. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

static skipped(reason=None, data=None, from_exception=None)

Step Skipped

API to call when the current step execution should be skipped. Terminates current step.

Parameters:
  • (str) (reason) –

  • (any) (data) –

class pyats.aetest.steps.implementation.StepDetail(index, name, result)

Bases: tuple

Create new instance of StepDetail(index, name, result)

index

Alias for field number 0

name

Alias for field number 1

result

Alias for field number 2

class pyats.aetest.steps.implementation.StepSource(name, location)

Bases: tuple

Create new instance of StepSource(name, location)

location

Alias for field number 1

name

Alias for field number 0

class pyats.aetest.steps.implementation.Steps(parent=None)

Bases: TestResultContext

Container & base class for steps feature. Allows users to define test steps within smaller test units within test sections. This class is instantiated by default for each TestFunction class as “steps” attribute, and is visible to user when the special ‘steps’ funcargs is used. It is a container: allows Step to be created internally, tracks the overall results, and maintains a list of indexes.

Examples

>>> from pyats.aetest.steps import Steps
>>> steps = Steps()
>>> with steps.start('x'): pass

Note

this is the only class users will use/refer directly within testscripts.

built-in __init__

instantiates the Steps class by creating an internal list that houses number of steps currently taken.

Note

step index is the same as the list index of current step.

property details

Steps.details property

Used to access current steps (including all children steps) detail information in a flat list. This api recursively goes through all steps and child steps and returns a list in proper order of all steps taken so far.

Parameters:

None

Return type:

list [] of StepDetail

classmethod init(stepDebugFile, testable, pdb=False)

Verify the file exists, Loads it Validate it Store inside _stepsDebug

pdb = False
report()

Reports all steps (including all children steps) to logfile. This api logs all current step information/result to logger for visual reference.

Example:

+..........................................................+
:                       STEPS Report                       :
+..........................................................+
STEP 1 - step 1                                       Failed
............................................................
Parameters:

None

Return type:

None

start()

Creates a new Step instance and return it to the user scope. This is the main API called within the user realm to create and start new steps within the current scope.

Parameters:
  • args (all arguments to this api propagates directly to Step) –

  • kwargs (all arguments to this api propagates directly to Step) –

Return type:

new Step() instance.

class pyats.aetest.steps.loader.StepsDebugLoader(schema={Any  (str) *: Use  (function) <function validate>, Optional  (str) extends: Use  (function) <function str_or_list>}, enable_extensions=True)

Bases: Loader

load(file)
pyats.aetest.steps.schema.str_or_list(value)

check_file

translates str/list into list.

pyats.aetest.steps.schema.validate(value)