Skip to content

Commit

Permalink
linter error correction
Browse files Browse the repository at this point in the history
  • Loading branch information
DSungatulin committed Feb 23, 2024
1 parent 93b1610 commit fb3ffed
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package-reinstall:
python3 -m pip install --user dist/*.whl --force-reinstall

lint:
poetry run flake8 gendiff
poetry run flake8

test:
poetry run pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/expected_output_for_test_get_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
{'key': 'z', 'action': 'ADDED', 'old value': None, 'new value': 30}
]},
{'key': 'd', 'action': 'ADDED', 'old value': None, 'new value': 4}
]
]
2 changes: 1 addition & 1 deletion tests/fixtures/fixture_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def parse_fixture(file_path):
with open(file_path) as file:
return file.read().strip()
return file.read().strip()
9 changes: 7 additions & 2 deletions tests/test_format_determinant.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
from gendiff.formatters.format_determinant import get_data_format_plain


def test_get_data_format_plain_dict():
assert get_data_format_plain({"key": "value"}) == '[complex value]'
assert get_data_format_plain({"key": "value"}) == '[complex value]'


def test_get_data_format_plain_bool():
assert get_data_format_plain(True) == 'true'
assert get_data_format_plain(False) == 'false'


def test_get_data_format_plain_string():
assert get_data_format_plain("hello") == "'hello'"


def test_get_data_format_plain_none():
assert get_data_format_plain(None) == 'null'


def test_get_data_format_plain_other_types():
assert get_data_format_plain(123) == '123'
assert get_data_format_plain(12.3) == '12.3'
assert get_data_format_plain(12.3) == '12.3'
8 changes: 4 additions & 4 deletions tests/test_generate_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ def test_generate_diff():
'tests/fixtures/comparison_results/correct_flat_comparison.txt', 'r'
)
assert file_differences == correct_result.read()

first_file = 'tests/fixtures/flat_files/file1.yml'
second_file = 'tests/fixtures/flat_files/file2.yml'
file_differences = generate_diff(first_file, second_file)
correct_result = open(
'tests/fixtures/comparison_results/correct_flat_comparison.txt', 'r'
)
assert file_differences == correct_result.read()

first_file = 'tests/fixtures/nested_files/file1.json'
second_file = 'tests/fixtures/nested_files/file2.json'
file_differences = generate_diff(first_file, second_file)
correct_result = open(
'tests/fixtures/comparison_results/correct_nested_comparison.txt', 'r'
)
assert file_differences == correct_result.read()

first_file = 'tests/fixtures/nested_files/file1.yml'
second_file = 'tests/fixtures/nested_files/file2.yml'
file_differences = generate_diff(first_file, second_file)
correct_result = open(
'tests/fixtures/comparison_results/correct_nested_comparison.txt', 'r'
)
assert file_differences == correct_result.read()

first_file = 'tests/fixtures/nested_files/file1.yml'
second_file = 'tests/fixtures/nested_files/file2.yml'
file_differences = generate_diff(first_file, second_file, 'plain')
Expand Down
1 change: 1 addition & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def test_determine_file_format():
assert file1 == {'follow': False, 'host': 'hexlet.io', 'proxy': '123.234.53.22', 'timeout': 50}
assert file2 == {'host': 'hexlet.io', 'timeout': 20, 'verbose': True}


def test_determine_file_format_invalid():
with pytest.raises(TypeError) as excinfo:
determine_file_format('tests/fixtures/comparison_results/correct_flat_comparison.txt')
Expand Down
3 changes: 2 additions & 1 deletion tests/test_plain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def test_get_plain_view():
assert get_plain_view('path_to_property', 'REMOVED', 'old_value', None) == "Property 'path_to_property' was removed"
assert get_plain_view('path_to_property', 'CHANGED', 'old_value', 'new_value') == "Property 'path_to_property' was updated. From 'old_value' to 'new_value'"


def test_get_plained():
diff = [
{
Expand Down Expand Up @@ -35,4 +36,4 @@ def test_get_plained():
"Property 'another_property' was removed",
"Property 'yet_another_property' was updated. From 'old_value' to 'new_value'"
])
assert get_plained(diff) == expected_output
assert get_plained(diff) == expected_output
5 changes: 3 additions & 2 deletions tests/test_stylish.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@

from gendiff.formatters.stylish import get_stylish_view, form_string, get_stylished


def test_get_stylish_view():
assert get_stylish_view('key', 'value', '+ ', 1, ' ') == " + key: value"
assert get_stylish_view('key', {'nested_key': 'value'}, ' ', 1, ' ') == " key: {\n nested_key: value\n }"


def test_form_string():
assert form_string('key', 'ADDED', None, 'new_value', 1, ' ') == " + key: new_value"
assert form_string('key', 'REMOVED', 'old_value', None, 1, ' ') == " - key: old_value"
assert form_string('key', 'CHANGED', 'old_value', 'new_value', 1, ' ') == " - key: old_value\n + key: new_value"
assert form_string('key', 'UNCHANGED', 'old_value', 'old_value', 1, ' ') == " key: old_value"


def test_get_stylished():
diff = [
{
Expand Down Expand Up @@ -44,4 +45,4 @@ def test_get_stylished():
" + yet_another_property: new_value",
"}"
])
assert get_stylished(diff) == expected_output
assert get_stylished(diff) == expected_output

0 comments on commit fb3ffed

Please sign in to comment.