-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22b72fd
commit 1b2d64e
Showing
6 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
def get_data_format(value): | ||
def get_data_format_stylish(value): | ||
if isinstance(value, str): | ||
return value | ||
elif value is None: | ||
return 'null' | ||
return str(value).lower() | ||
|
||
|
||
def get_data_format_plain(value): | ||
if isinstance(value, dict): | ||
return '[complex value]' | ||
if isinstance(value, bool): | ||
elif isinstance(value, bool): | ||
return str(value).lower() | ||
if isinstance(value, str): | ||
return value | ||
if value is None: | ||
elif isinstance(value, str): | ||
return f"'{value}'" | ||
elif value is None: | ||
return 'null' | ||
return str(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/fixtures/comparison_results/plain_format_comparison.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Property 'common.follow' was added with value: false | ||
Property 'common.setting2' was removed | ||
Property 'common.setting3' was updated. From true to null | ||
Property 'common.setting4' was added with value: 'blah blah' | ||
Property 'common.setting5' was added with value: [complex value] | ||
Property 'common.setting6.doge.wow' was updated. From '' to 'so much' | ||
Property 'common.setting6.ops' was added with value: 'vops' | ||
Property 'group1.baz' was updated. From 'bas' to 'bars' | ||
Property 'group1.nest' was updated. From [complex value] to 'str' | ||
Property 'group2' was removed | ||
Property 'group3' was added with value: [complex value] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
from gendiff.formatters.format_determinant import get_data_format | ||
|
||
def test_get_data_format(): | ||
assert get_data_format(10) == "10" | ||
assert get_data_format(True) == "true" | ||
assert get_data_format("hello") == "hello" | ||
assert get_data_format(None) == "null" | ||
assert get_data_format({1: [2, 3]}) == "[complex value]" | ||
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]' | ||
|
||
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters