test.in_list_dict_chk implemented
This commit is contained in:
parent
a34ffe1201
commit
9bb490eb30
29
test.py
29
test.py
@ -26,6 +26,10 @@ def __report_expectation_equivalency__(expectation, description, data_filter=rep
|
||||
logger.debug('Expectation (%s): result = %s (%s)', description, __get_repr__(expectation, data_filter), repr(type(expectation)))
|
||||
|
||||
|
||||
def __report_expectation_inlist__(expectation, description, data_filter=repr):
|
||||
logger.debug('Expectation (%s): %s in result', description, __get_repr__(expectation, data_filter))
|
||||
|
||||
|
||||
def __report_expectation_range__(min_expectation, max_expectation, description):
|
||||
logger.debug('Expectation (%s): %s <= result <= %s', description, __get_repr__(min_expectation), __get_repr__(max_expectation))
|
||||
|
||||
@ -130,8 +134,6 @@ def equivalency_chk(result, expectation, tcl, description='Variable', report_com
|
||||
:type expectation: All types are supported
|
||||
:param description: A descrition of the result. It will be reported like "xxx is correct." Example: descrition="stringrepresentation created by modulename"
|
||||
:type description: str
|
||||
:param report_level_pass: The reporting level as defined in :class:`logging` (e.g.: logging.INFO)
|
||||
:param report_level_fail: The reporting level as defined in :class:`logging` (e.g.: logging.ERROR)
|
||||
:param report_comment_fail: Comment for a failed Testexecution. Will be added in brakets after the Result-Text.
|
||||
:type report_comment_fail: str
|
||||
"""
|
||||
@ -221,21 +223,24 @@ def range_chk(result, min_expectation, max_expectation, tcl, description='Value'
|
||||
return report_level
|
||||
|
||||
|
||||
def in_list_chk(result, expectation_list, tcl, description='Value', report_level_pass=logging.INFO, report_level_fail=logging.ERROR, report_comment_fail=None):
|
||||
def in_list_dict_chk(result_list, expectation_key, tcl, description='Value', report_comment_fail=None, data_filter=repr):
|
||||
"""
|
||||
Routine to check values to be in a range inside a test run and report to a testCaseLogger.
|
||||
|
||||
:param result: The result of a test execution of a module
|
||||
:type result: All types are supported
|
||||
:param expectation_list: The list of allowed values
|
||||
:type expectation_list: A list of all types is supported
|
||||
:param result_key: The result of a test execution of a module
|
||||
:type result_key: All types are supported
|
||||
:param expectation_list: The list or dict of allowed values
|
||||
:type expectation_list: A list of all types or a dict is supported
|
||||
:param description: A descrition of the result. It will be reported like "xxx is correct." Example: descrition="stringrepresentation created by modulename"
|
||||
:type description: str
|
||||
:param report_level_pass: The reporting level as defined in :class:`logging` (e.g.: logging.INFO)
|
||||
:param report_level_fail: The reporting level as defined in :class:`logging` (e.g.: logging.ERROR)
|
||||
:param report_comment_fail: Comment for a failed Testexecution. Will be added in brakets after the Result-Text.
|
||||
:type report_comment_fail: str
|
||||
"""
|
||||
__report_values__(result, expectation)
|
||||
tcl.log(REPORT_LEVEL_FAIL, 'in_list check not yet implemented')
|
||||
return REPORT_LEVEL_FAIL
|
||||
__report_result__(result_list, description)
|
||||
__report_expectation_inlist__(expectation_key, description, data_filter=data_filter)
|
||||
if expectation_key in result_list:
|
||||
tcl.log(REPORT_LEVEL_PASS, description + ' is correct (%s is in the list or dict).', data_filter(expectation_key))
|
||||
return REPORT_LEVEL_PASS
|
||||
else:
|
||||
tcl.log(REPORT_LEVEL_FAIL, description + ' is NOT correct (%s is NOT in the list or dict).', data_filter(expectation_key))
|
||||
return REPORT_LEVEL_FAIL
|
||||
|
Loading…
x
Reference in New Issue
Block a user