def test_json(): with open(os.path.join(place, 'test_json.json')) as result: test_file = json.load(result) assert json.loads( generate_diff(os.path.join(place, 'before_simple.json'), os.path.join(place, 'after_simple.json'), format.JSON)) == test_file assert json.loads( generate_diff(os.path.join(place, 'before_simple.yml'), os.path.join(place, 'after_simple.yml'), format.JSON)) == test_file
def main(): args = parse_args() print(generate_diff(args.first_file, args.second_file, args.format))
def test_wrong_format(self): assert generate_diff(None, JSON_1, JSON_2)\ == UNKNOWN_OUTPUT_FORMAT_ERROR
import pytest import os import json from gendiff.app import generate_diff from gendiff import format place = './tests/fixtures/' expected_complex_plain = open(os.path.join(place, 'answer_complex_plain.txt')).read() test_complex_plain_js = generate_diff( os.path.join(place, 'before_complex.json'), os.path.join(place, 'after_complex.json'), format.PLAIN) test_complex_plain_yml = generate_diff( os.path.join(place, 'before_complex.yml'), os.path.join(place, 'after_complex.yml'), format.PLAIN) expected_complex_default = open( os.path.join(place, 'answer_complex_default.txt')).read() test_complex_default_js = generate_diff( os.path.join(place, 'before_complex.json'), os.path.join(place, 'after_complex.json'), format.DEFAULT) test_complex_default_yml = generate_diff( os.path.join(place, 'before_complex.yml'), os.path.join(place, 'after_complex.yml'), format.DEFAULT) expected_simple_plain = open(os.path.join(place, 'answer_simple_plain.txt')).read() test_simple_plain_js = generate_diff(os.path.join(place, 'before_simple.json'), os.path.join(place, 'after_simple.json'), format.PLAIN) test_simple_plain_yml = generate_diff(os.path.join(place, 'before_simple.yml'), os.path.join(place, 'after_simple.yml'),
def test_yml_and_yaml(self): assert generate_diff(plain.render, YAML_1, YAML_2)\ == "Property 'timeout' was removed"
def test_wrong_format(self): assert generate_diff(plain.render, JSON_1, '1.txt')\ == UNKNOWN_FILE_FORMAT_ERROR
def test_json_and_yaml(self): assert generate_diff(plain.render, YAML_2, JSON_1)\ == "Property 'timeout' was added with value: '50'"
def test_abs_and_rel_path(self): assert generate_diff(plain.render, JSON_2, os.path.abspath(JSON_1))\ == "Property 'timeout' was added with value: '50'"
def test_abspath(self): assert generate_diff( plain.render, os.path.abspath(YAML_2), os.path.abspath(YAML_1))\ == "Property 'timeout' was added with value: '50'"
def test_relpath(self): assert generate_diff(plain.render, JSON_1, JSON_2)\ == "Property 'timeout' was removed"
def main(): args = parser.parse_args() result = generate_diff(args.format, args.first_file, args.second_file) print(result)