Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnitTestRunResults interface to be compatible with UnitTestRunDeltaResults #434

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/publish/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,18 +587,18 @@ def do_changes_require_comment(earlier_stats_is_different_to: Optional[Callable[

if self._settings.comment_mode == comment_mode_changes and \
do_changes_require_comment(earlier_stats.is_different if earlier_stats else None,
stats.has_changes):
stats.is_delta and stats.has_changes):
return True

if self._settings.comment_mode == comment_mode_changes_failures and \
do_changes_require_comment(earlier_stats.is_different_in_failures if earlier_stats else None,
stats.has_failure_changes,
stats.is_delta and stats.has_failure_changes,
'failures'):
return True

if self._settings.comment_mode in [comment_mode_changes_failures, comment_mode_changes_errors] and \
do_changes_require_comment(earlier_stats.is_different_in_errors if earlier_stats else None,
stats.has_error_changes,
stats.is_delta and stats.has_error_changes,
'errors'):
return True

Expand Down
18 changes: 11 additions & 7 deletions python/test/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,19 @@ def do_test_require_comment(self, comment_mode, test_expectation: Callable[["Com
) if not test.earlier_is_none else None
current = mock.MagicMock(
is_delta=test.current_has_changes is not None,
has_changes=test.current_has_changes,
has_failure_changes=test.current_has_failure_changes,
has_error_changes=test.current_has_error_changes,
has_failures=test.current_has_failures,
has_errors=test.current_has_errors)
if current.is_delta:
current.has_changes = test.current_has_changes
current.has_failure_changes = test.current_has_failure_changes
current.has_error_changes = test.current_has_error_changes
current.without_delta = mock.Mock(return_value=current)
required = Publisher.require_comment(publisher, current, earlier)
self.assertEqual(required, expected)
# do not access these prperties when current is not a delta stats
self.assertTrue(current.is_delta or 'has_changes' not in current._mock_children, 'has_changes')
self.assertTrue(current.is_delta or 'has_failure_changes' not in current._mock_children, 'has_failure_changes')
self.assertTrue(current.is_delta or 'has_error_changes' not in current._mock_children, 'has_error_changes')

comment_condition_tests = [CommentConditionTest(earlier_is_none,
earlier_is_different, earlier_is_different_in_failures, earlier_is_different_in_errors,
Expand All @@ -372,14 +376,14 @@ def do_test_require_comment(self, comment_mode, test_expectation: Callable[["Com
current_has_failures, current_has_errors)
for earlier_is_none in [False, True]
for earlier_is_different in [False, True]
for earlier_is_different_in_failures in ([False, True] if not earlier_is_different else [True])
for earlier_is_different_in_errors in ([False, True] if not earlier_is_different else [True])
for earlier_is_different_in_failures in ([False, True] if earlier_is_different else [False])
for earlier_is_different_in_errors in ([False, True] if earlier_is_different else [False])
for earlier_has_failures in [False, True]
for earlier_has_errors in [False, True]

for current_has_changes in [None, False, True]
for current_has_failure_changes in ([False, True] if not current_has_changes else [True])
for current_has_error_changes in ([False, True] if not current_has_changes else [True])
for current_has_failure_changes in ([False, True] if current_has_changes else [False])
for current_has_error_changes in ([False, True] if current_has_changes else [False])
for current_has_failures in [False, True]
for current_has_errors in [False, True]]

Expand Down