Skip to content

Commit

Permalink
[BEAM-11797] Fix wrong assertion usage (apache#14377)
Browse files Browse the repository at this point in the history
1. Replaced all assert_called_with with assert_any_call in the
   ProgressIndicatorTest.
2. assert_called_with only asserts the most recent call. However, there
   is an IPythonLogHandler we have customized to emit rich logging in
   notebooks that also calls display to render HTML and JavaScript. The
   emission of logs can happen any time during the test, causing the
   flakiness. Instead of unregistering the log handler during tests that
   could make the tests unnecessarily complicated, we could use
   assert_any_call within the patched context for simplicity.
  • Loading branch information
Ning Kang authored Mar 30, 2021
1 parent f93d61d commit 52c3b0b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sdks/python/apache_beam/runners/interactive/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ def test_progress_in_plain_text_when_not_in_notebook(self):

@utils.progress_indicated
def progress_indicated_dummy():
mocked_display.assert_called_with('Processing...')
mocked_display.assert_any_call('Processing...')

progress_indicated_dummy()
mocked_display.assert_called_with('Done.')
mocked_display.assert_any_call('Done.')

def test_progress_in_HTML_JS_when_in_notebook(self):
ie.current_env()._is_in_notebook = True
Expand All @@ -212,10 +212,10 @@ def test_progress_in_HTML_JS_when_in_notebook(self):

@utils.progress_indicated
def progress_indicated_dummy():
mocked_html.assert_called_with('enter')
mocked_html.assert_any_call('enter')

progress_indicated_dummy()
mocked_javascript.assert_called_with(
mocked_javascript.assert_any_call(
ie._JQUERY_WITH_DATATABLE_TEMPLATE.format(customized_script='exit'))


Expand Down

0 comments on commit 52c3b0b

Please sign in to comment.