示例#1
0
def test_complex_yaml_yaml(complex_yaml_old, complex_yaml_new, complex_result_yaml):
    format_diff = gendiff.formatters.yaml.format_diff
    old_map, new_map = parse_yaml(complex_yaml_old), parse_yaml(complex_yaml_new)
    test_diff = yaml.load(format_diff(generate_diff(old_map, new_map)), 
                          Loader=yaml.SafeLoader)
    ethalon_diff = yaml.load(complex_result_yaml, Loader=yaml.SafeLoader)
    assert test_diff == ethalon_diff
def main():
    parsed_args = get_args()
    with open(parsed_args.first_path, 'r') as first_file:
        with open(parsed_args.second_path, 'r') as second_file:
            first_parsed = get_parsed(first_file)
            second_parsed = get_parsed(second_file)
    diff_tree = generate_diff(first_parsed, second_parsed)
    print(parsed_args.format(diff_tree))
def test_complex_tree(complex_json_old, complex_json_new, complex_diff):
    old_map, new_map = parse_json(complex_json_old), parse_json(
        complex_json_new)
    test_diff = generate_diff(old_map, new_map)
    assert test_diff == complex_diff
示例#4
0
def test_plain_yaml(plain_yaml_old, plain_yaml_new, plain_result_plain):
    format_diff = gendiff.formatters.plain.format_diff
    old_map, new_map = parse_yaml(plain_yaml_old), parse_yaml(plain_yaml_new)
    test_diff = format_diff(generate_diff(old_map, new_map))
    ethalon_diff = plain_result_plain.read()
    assert test_diff == ethalon_diff
示例#5
0
def test_complex_yaml_tree(complex_yaml_old, complex_yaml_new, complex_result_tree):
    format_diff = gendiff.formatters.tree.format_diff
    old_map, new_map = parse_yaml(complex_yaml_old), parse_yaml(complex_yaml_new)
    test_diff = format_diff(generate_diff(old_map, new_map))
    ethalon_diff = complex_result_tree.read()
    assert test_diff == ethalon_diff
def test_complex_json_json(complex_json_old, complex_json_new, complex_result_json):
    format_diff =  gendiff.formatters.json.format_diff
    old_map, new_map = parse_json(complex_json_old), parse_json(complex_json_new)
    test_diff = json.loads(format_diff(generate_diff(old_map, new_map)))
    ethalon_diff = json.load(complex_result_json)
    assert test_diff == ethalon_diff
def test_complex_json_plain(complex_json_old, complex_json_new, complex_result_plain):
    format_diff = gendiff.formatters.plain.format_diff
    old_map, new_map = parse_json(complex_json_old), parse_json(complex_json_new)
    test_diff = format_diff(generate_diff(old_map, new_map))
    ethalon_diff = complex_result_plain.read()
    assert test_diff == ethalon_diff