Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-mixas committed May 7, 2023
1 parent 7dee920 commit 44f770a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 0 additions & 3 deletions tests/data/formatters/HtmlFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@
'sublist_filled_noA': {
'result': '<div class="nDvD"></div>',
},
'text_diff_disabled': {
'result': '<div class="nDvD"><div>- <div class="nDvO">&#x27;A\\nB&#x27;</div></div><div>+ <div class="nDvN">&#x27;B\\nC&#x27;</div></div></div>',
},
'text_equal': {
'result': '<div class="nDvD"></div>',
},
Expand Down
3 changes: 0 additions & 3 deletions tests/data/formatters/TermFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@
'sublist_filled_noA': {
'result': '',
},
'text_diff_disabled': {
'result': "\x1b[31m- 'A\\nB'\x1b[0m\n\x1b[32m+ 'B\\nC'\x1b[0m\n",
},
'text_equal': {
'result': '',
},
Expand Down
3 changes: 0 additions & 3 deletions tests/data/formatters/TextFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@
'sublist_filled_noA': {
'result': '',
},
'text_diff_disabled': {
'result': "- 'A\\nB'\n+ 'B\\nC'\n",
},
'text_equal': {
'result': '',
},
Expand Down
10 changes: 10 additions & 0 deletions tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,13 @@ def test_text_diff_func_extra_handlers_opt():
got = diff(a, b, extra_handlers=[handlers.TextHandler(context=3)])

assert got == expected


def test_text_diff_func_text_diff_ctx_opt():
a = ['a']
b = ['a\nb']

expected = {'D': [{'D': [{'I': [0, 1, 0, 2]}, {'U': 'a'}, {'A': 'b'}], 'E': 5}]}
got = diff(a, b, text_diff_ctx=3)

assert got == expected
6 changes: 5 additions & 1 deletion tests/test_patch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from nested_diff import Differ, Patcher
from nested_diff import Differ, Patcher, patch

from tests.data import specific, standard

Expand Down Expand Up @@ -75,3 +75,7 @@ def test_unsupported_extension():
def test_unsupported_patch_type():
with pytest.raises(ValueError, match='unsupported patch type: module'):
Patcher().patch(None, {'D': pytest}) # module


def test_patch_func():
assert patch('a', {'N': 'b', 'O': 'a'}) == 'b'

0 comments on commit 44f770a

Please sign in to comment.