Skip to content

Commit

Permalink
Merge branch 'pydiffx/release-1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidt committed Sep 3, 2021
2 parents 2c6a66b + fe417d4 commit 69f212c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/pydiffx/dom/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def generate_stats(self):
This should only be run once the change is complete. Normally,
callers will want to call :py:meth:`DiffX.generate_stats` instead.
"""
if self.diff is None or self.diff_type == DiffType.BINARY:
if not self.diff or self.diff_type == DiffType.BINARY:
return

if self.diff_line_endings:
Expand Down
17 changes: 16 additions & 1 deletion python/pydiffx/tests/test_dom_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run_invalid_option_value_test(self, option_name, value,
setattr(section, option_name, value)


class DiffXTests(BaseSectionTestCase):
class DiffXTests(kgb.SpyAgency, BaseSectionTestCase):
"""Unit tests for pydiffx.dom.objects.DiffX."""

section_cls = DiffX
Expand Down Expand Up @@ -959,6 +959,21 @@ def test_generate_stats_merges(self):
'special': 123,
})

def test_generate_stats_empty_diff(self):
"""Testing DiffX.generate_stats with an empty diff"""
self.spy_on(dom_objects_logger.error)

diffx = DiffX()
change_section = diffx.add_change()
change_section.add_file(diff=b'')
change_section.add_file()

diffx.generate_stats()

# Empty diffs used to cause errors to be logged. This should no longer
# be hit.
self.assertSpyNotCalled(dom_objects_logger.error)

def test_repr(self):
"""Testing DiffX.__repr__"""
diffx = DiffX(
Expand Down

0 comments on commit 69f212c

Please sign in to comment.