Test utilities

Utilities for test functions

This code assumes that the namespace that python based tests are in is correctly assigned, otherwise global variables won’t be present and this will throw errors

class gsmodutils.test.utils.ModelLoader(project, model_id, conditions_id, design_id)[source]

Bases: object

load(log)[source]
class gsmodutils.test.utils.ModelTestSelector(models=None, conditions=None, designs=None)[source]

Bases: object

class gsmodutils.test.utils.ResultRecord(tid='', parent=None, param_child=False)[source]

Bases: object

Class for handling logging of errors in tester follows a hierarchical pattern as log records allow child records This is a bit of a weird data structure but the objective is to (in a future version) encapsulate all tests inside an instance of Test Record

add_error(msg, desc='')[source]

For errors loading tests, e.g. success cases can’t be reached because the model doesn’t load or can’t get a feasable solution

assertion(statement, success_msg, error_msg, desc='')[source]

Called within test functions to store errors and successes Results will be appended to the correct log reccords

create_child(new_id, param_child=False)[source]

Used within decorator helper functions to allow multiple tests with the same function but where other parameters change

is_success

The test function is considered a failure if there are one or more error logs

log_count

count total errors for self and children

to_dict(stk=None)[source]

converts log into dictionary form for portability stk stops cyclic behaviour

warning(statement, message, desc='')[source]

Called within test functions to capture warnings about the status of models. If statement is true, the warning message will be stored.

gsmodutils.test.utils.stdout_ctx(stdout=None)[source]

Context to capture standard output of python executed tests during run time This is displayed to the user for them to see after the tests are run