Skip to content

Commit

Permalink
refactoring diff_builder.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DmGorokhov committed Apr 8, 2023
1 parent a67924d commit 2156cc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gendiff/diff_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ def generate_diff(filepath_old, filepath_new, format='stylish'):
diff_report = get_plain(diff)
case 'json':
diff_report = get_json(diff)
case _:
raise Exception('Unknown or unsupported output format')
return diff_report
8 changes: 8 additions & 0 deletions tests/test_gendiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,11 @@ def test_generate_diff(file1, file2, format, result):
file_path_1 = get_fixture_path(file1)
file_path_2 = get_fixture_path(file2)
assert generate_diff(file_path_1, file_path_2, format) == result


def test_generate_diff_wrong_format():
file_path_1 = get_fixture_path('file1.json')
file_path_2 = get_fixture_path('file2.json')
with pytest.raises(Exception) as exeption:
generate_diff(file_path_1, file_path_2, 'another format')
assert str(exeption.value) == 'Unknown or unsupported output format'

0 comments on commit 2156cc6

Please sign in to comment.