From 492dcbab841ca24604d734761191d2c1dda780b6 Mon Sep 17 00:00:00 2001 From: KevinGG Date: Tue, 30 Mar 2021 12:13:41 -0700 Subject: [PATCH] [BEAM-11797] Fix wrong assertion usage 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. --- sdks/python/apache_beam/runners/interactive/utils_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdks/python/apache_beam/runners/interactive/utils_test.py b/sdks/python/apache_beam/runners/interactive/utils_test.py index 4bb94903ff51..ec0f11d4f251 100644 --- a/sdks/python/apache_beam/runners/interactive/utils_test.py +++ b/sdks/python/apache_beam/runners/interactive/utils_test.py @@ -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 @@ -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'))