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
@@ -549,6 +551,23 @@ def test_widget_row_count_reflects_actual_data_available(
549551 assert widget .page_size == 2 # Respects the display option
550552
551553
552- # TODO(shuowei): Add tests for custom index and multiindex
554+ def test_repr_html_anywidget_fallback (paginated_bf_df : bf .dataframe .DataFrame ):
555+ """
556+ Test that _repr_html_ falls back to deferred mode when anywidget is not available.
557+ """
558+ with bf .option_context ("display.repr_mode" , "anywidget" ):
559+ # Use a mock to simulate the absence of the 'anywidget' module.
560+ with mock .patch .dict (
561+ "sys.modules" , {"anywidget" : None , "IPython" : mock .MagicMock ()}
562+ ):
563+ # The warning is now expected inside the _ipython_display_ call, not _repr_html_
564+ # The test setup doesn't easily allow capturing warnings from ipython display hooks.
565+ # Instead we focus on the fallback behavior of _repr_html_
566+ html = paginated_bf_df ._repr_html_ ()
567+ assert "Computation deferred." in html
568+ assert "Computation will process" in html
569+
570+
571+ # TODO(b/332316283): Add tests for custom index and multiindex
553572# This may not be necessary for the SQL Cell use case but should be
554573# considered for completeness.
You can’t perform that action at this time.
0 commit comments