def parse(check_manager, dataset): """Test parse function If dataset has .info attribute and the check has parse function defined, test it, and return the result. Otherwise return None. If the .parsed attribute is present, it is compared to the result. """ print("parse: %r" % dataset.checkname) info = getattr(dataset, 'info', None) parsed_expected = getattr(dataset, 'parsed', None) if info is None: return None try: main_check = check_manager.get_check(dataset.checkname) parse_function = main_check.info.get("parse_function") except MissingCheckInfoError: # this could be ok - # it just implies we don't have a parse function parse_function = None if parsed_expected is not None: # we *must* have a parse function in this case! assert parse_function, "%s has no parse function!" \ % dataset.checkname elif not parse_function: # we may not have one: return None parsed = main_check.run_parse(info) if parsed_expected is not None: assertEqual(parsed, parsed_expected, ' parsed result ') return parsed
def test_zfsget_parse(info, expected_parse_result): assertEqual(Check("zfsget").run_parse(info), expected_parse_result)