File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515
16+ import unittest .mock as mock
17+
1618import pandas as pd
1719import pytest
1820
@@ -684,6 +686,23 @@ def test_widget_with_unknown_row_count_empty_dataframe(
684686 assert widget .page == 0
685687
686688
687- # TODO(shuowei): Add tests for custom index and multiindex
689+ def test_repr_html_anywidget_fallback (paginated_bf_df : bf .dataframe .DataFrame ):
690+ """
691+ Test that _repr_html_ falls back to deferred mode when anywidget is not available.
692+ """
693+ with bf .option_context ("display.repr_mode" , "anywidget" ):
694+ # Use a mock to simulate the absence of the 'anywidget' module.
695+ with mock .patch .dict (
696+ "sys.modules" , {"anywidget" : None , "IPython" : mock .MagicMock ()}
697+ ):
698+ # The warning is now expected inside the _ipython_display_ call, not _repr_html_
699+ # The test setup doesn't easily allow capturing warnings from ipython display hooks.
700+ # Instead we focus on the fallback behavior of _repr_html_
701+ html = paginated_bf_df ._repr_html_ ()
702+ assert "Computation deferred." in html
703+ assert "Computation will process" in html
704+
705+
706+ # TODO(b/332316283): Add tests for custom index and multiindex
688707# This may not be necessary for the SQL Cell use case but should be
689708# considered for completeness.
You can’t perform that action at this time.
0 commit comments