etr  4.0-pre
Modules | Files | Classes | Functions
Main Project

Etr Test Runner. More...

Modules

 Robot Framework Libraries
 Robot Framework libraries provided by etr.
 

Files

file  __init__.py
 
file  command.py
 
file  context.py
 
file  exception.py
 
file  info.py
 
file  main.py
 
file  plugin.py
 etr plugin manager
 
file  jinja2.py
 
file  nomad.py
 
file  nose.py
 
file  pytest.py
 
file  resources.py
 
file  __init__.py
 Robot Framework plugin for etr.
 
file  result.py
 
file  runner.py
 
file  __init__.py
 
file  manager.py
 
file  console.py
 
file  logcapture.py
 
file  subprocess.py
 
file  tests.py
 
file  xunit.py
 
file  etr.py
 
file  wscript
 

Classes

class  etr.context.Command
 Application commands enumeration. More...
 
class  etr.context.Step
 Main execution steps for the test command. More...
 
class  etr.exception.UserError
 A user error should never result in a back trace but a user friendly message about the error. More...
 
class  etr.exception.DeferredException
 Exception indicating that test execution is aborted by user. More...
 
class  etr.exception.AbortException
 Exception indicating a transient error. More...
 
class  etr.exception.TransientException
 Exception indicating that an error occurred due to external circumstance with user provided data. More...
 
class  etr.info.InfoRegister
 Class holding general information about a test session. More...
 
class  etr.plugin.Plugin
 Plugin base class to simplify implementation. More...
 
class  etr.plugin.PluginMgr
 Plugin instance manager. More...
 
class  etr.plugin.PluginRegister
 Plugin register containing types but not instances of plugins. More...
 
class  etr.plugins.jinja2.Renderer
 Jinja renderer. More...
 
class  etr.plugins.jinja2.Plugin
 Jinja2 plugin. More...
 
class  etr.plugins.nomad.Plugin
 Nomad plugin that enables deployment of Nomad jobs. More...
 
class  etr.plugins.nose.Plugin
 Nose plugin for etr to allow execution of nose test suites. More...
 
class  etr.plugins.pytest.Plugin
 Pytest plugin for etr to allow execution of Pytest test suites. More...
 
class  etr.plugins.resources.Storage
 Provides the storage abstraction for Resources. More...
 
class  etr.plugins.resources.RemoteService
 Adapter for the remote resource manager service. More...
 
class  etr.plugins.resources.LocalResources
 Acquire/release local resources, as specified by config files. More...
 
class  etr.plugins.resources.ResourceManager
 Resource Manager that acquires and releases resources as well as keeping the record of acquired/released resources. More...
 
class  etr.plugins.resources.Plugin
 Resources plugin. More...
 
class  etr.plugins.robot.Plugin
 Robot Framework plugin for etr to allow execution of robot test suites. More...
 
class  etr.result.ExitCode
 Application exit codes Codes are ordered by severity such that the highest number is reported. More...
 
class  etr.result.TextTestResult
 Outputs test results as text on a stream. More...
 
class  etr.runner.Runner
 ESO Test Facility Runner. More...
 
class  etr.storage.manager.CommitContext
 Context manager that does automatic commits if no errors occur. More...
 
class  etr.storage.manager.StorageManager
 Provides the storage abstraction for etr. More...
 
class  etr.tools.logcapture.CaptureHandler
 Captures logs into a line-buffer (list). More...
 
class  etr.tools.logcapture.LogCapture
 Captures log messages into a memory buffer and allows on-demand writing captured messages to stderr. More...
 
class  etr.tools.subprocess.SignalContextManager
 Provides a context manager to be able to captue signals and forward them to a subprocess within a context manager scope. More...
 
class  etr.tools.subprocess.KillOrphansContextManager
 Use instead of popen to perform cleanup of orphan subprocesses. More...
 
class  etr.tools.xunit.TestCaseResult
 Result of a test case. More...
 

Functions

def etr.main.main ()
 etr entrypoint More...
 
def etr.plugin.plugin (name)
 Class decorator that registers the class as a plugin. More...
 
def etr.result.pretty_time_delta (seconds)
 Prints elapsed time in a pretty format. More...
 
def etr.runner.parse_steps (str val)
 Parse value and return a list with steps parsed with the following rules: More...
 
def etr.runner.parse_command (str scmd)
 Parses the command enum strings and returns a Command enum. More...
 
def etr.tools.console.to_console (msg, file=None)
 Print msg to both console and logger. More...
 
def etr.tools.subprocess.cmd_and_log (List[str] command, *Optional[bool] kill_orphans=None, Optional[Callable[[str], None]] line_handler=None, Optional[bool] script_file=None, **kwargs)
 Runs command and logs to line_handler. More...
 
def etr.tools.tests.make_basename (index, test_file_path)
 Helper that creates a unified basename out of the test index and the test file path. More...
 
def etr.tools.tests.make_tests (list tests, bool randomize, list test_filters)
 Helper that creates the list of tests execute. More...
 
TestSuiteResult etr.tools.xunit.parse_ts (elem)
 Parse <testsuite> element. More...
 
List[TestSuiteResultetr.tools.xunit.parse_root (root)
 Parse xunit root element. More...
 
List[TestSuiteResultetr.tools.xunit.parse (xunit_file)
 Parse xunit file, or file-like object. More...
 

Detailed Description

Etr Test Runner.

Function Documentation

◆ cmd_and_log()

def etr.tools.subprocess.cmd_and_log ( List[str]  command,
*Optional[bool]   kill_orphans = None,
Optional[Callable[[str], None]]   line_handler = None,
Optional[bool]   script_file = None,
**  kwargs 
)

Runs command and logs to line_handler.

It can also generate a script file that re-creates the execution environment which can be useful for debugging outside etr.

Parameters
commandCommand to execute.
kill_orphansWhether to kill orphaned processes or not. Default is True.
line_handlerCallback invoked for each line of output of command
script_fileWhether or not to generate a script file that reproduce the command invocation.
Returns
None

◆ main()

def etr.main.main ( )

etr entrypoint

◆ make_basename()

def etr.tools.tests.make_basename (   index,
  test_file_path 
)

Helper that creates a unified basename out of the test index and the test file path.

>>> make_basename(0, 'src/test.robot')
'00_test'
def make_basename(index, test_file_path)
Helper that creates a unified basename out of the test index and the test file path.
Definition: tests.py:27

◆ make_tests()

def etr.tools.tests.make_tests ( list  tests,
bool  randomize,
list  test_filters 
)

Helper that creates the list of tests execute.

Additionally, it implements standard features that should be valid across any test runner plugin. These are:

  • Test randomization
  • Test selection/filtering

Returns an ordered list (that may be shuffled) of tuples where each tuple contains the original sequence and the test filename, e.g.:

[(12, 'src/some_test.robot'), (1, 'src/other_test.robot'), ...]

◆ parse()

List[TestSuiteResult] etr.tools.xunit.parse (   xunit_file)

Parse xunit file, or file-like object.

◆ parse_command()

def etr.runner.parse_command ( str  scmd)

Parses the command enum strings and returns a Command enum.

>>> parse_command('test').name
'TEST'
>>> parse_command('clean').name
'CLEAN'
>>> parse_command('info').name
'INFO'
def parse_command(str scmd)
Parses the command enum strings and returns a Command enum.
Definition: runner.py:129

◆ parse_root()

List[TestSuiteResult] etr.tools.xunit.parse_root (   root)

Parse xunit root element.

Returns a list of TestSuiteResult instances

The xunit xml schema also contains aggregate information, but we skip that bit and process info from the parsed testcases.

◆ parse_steps()

def etr.runner.parse_steps ( str  val)

Parse value and return a list with steps parsed with the following rules:

Single step e.g. 'setup':

>>> [s.name for s in parse_steps('setup')]
['SETUP']
def parse_steps(str val)
Parse value and return a list with steps parsed with the following rules:
Definition: runner.py:75

Starting at a step and continuing to the end: 'start:'

>>> [s.name for s in parse_steps('setup:')]
['SETUP', 'RUN', 'TEARDOWN']

Starting from the beginning and run to specified step ':end':

>>> [s.name for s in parse_steps(':run')]
['SETUP', 'RUN']

Starting from specified and ending at a specified step:

>>> [s.name for s in parse_steps('run:teardown')]
['RUN', 'TEARDOWN']

Executing steps in reverse order is illegal:

>>> parse_steps('teardown:run') # doctest: +ELLIPSIS
Traceback (most recent call last):
...
etr.exception.UserError: Can only run the step sequence in order...
A user error should never result in a back trace but a user friendly message about the error.
Definition: exception.py:13

◆ parse_ts()

TestSuiteResult etr.tools.xunit.parse_ts (   elem)

Parse <testsuite> element.

◆ plugin()

def etr.plugin.plugin (   name)

Class decorator that registers the class as a plugin.

Although not it's not necessary that plugins inherit from Plugin, they need to implement the same methods.

@plugin('myplugin')
class MyPlugin(Plugin):

    @classmethod
    def add_options(cls, parser):
        '''Optional

        Used to add custom command line options.

        @note: Must be a static method.
        '''
        pass

    def setup(self, ctx:SetupContext):
        '''Optional

        Called during setup step
        '''
        pass

    def run(self, ctx:RunContext):
        '''Optional

        Called during run
        '''
        pass

    def teardown(self, ctx:TeardownContext):
        '''Optional

        Called during teardown
        '''
        pass

◆ pretty_time_delta()

def etr.result.pretty_time_delta (   seconds)

Prints elapsed time in a pretty format.

'7.1s'
>>> pretty_time_delta(30*60 + 1)
'30m 1s'
'1h 0m 1s'
def pretty_time_delta(seconds)
Prints elapsed time in a pretty format.
Definition: result.py:43

◆ to_console()

def etr.tools.console.to_console (   msg,
  file = None 
)

Print msg to both console and logger.