<s> """<STR_LIT>""" <EOL> from pytest import yield_fixture , raises <EOL> from . . widgets import HTMLWidget , Table <EOL> @ yield_fixture <EOL> def table ( qtbot ) : <EOL> table = Table ( ) <EOL> table . show ( ) <EOL> def count ( id ) : <EOL> return <NUM_LIT> - <NUM_LIT:10> * id <EOL> table . add_column ( count , show = True ) <EOL> def skip ( id ) : <EOL> return id == <NUM_LIT:4> <EOL> table . add_column ( skip ) <EOL> table . set_rows ( range ( <NUM_LIT:10> ) ) <EOL> yield table <EOL> table . close ( ) <EOL> def test_widget_empty ( qtbot ) : <EOL> widget = HTMLWidget ( ) <EOL> widget . show ( ) <EOL> def test_widget_html ( qtbot ) : <EOL> widget = HTMLWidget ( ) <EOL> widget . add_styles ( '<STR_LIT>' ) <EOL> widget . add_header ( '<STR_LIT>' ) <EOL> widget . set_body ( '<STR_LIT>' ) <EOL> widget . show ( ) <EOL> assert '<STR_LIT>' in widget . html ( ) <EOL> def test_widget_javascript_1 ( qtbot ) : <EOL> widget = HTMLWidget ( ) <EOL> widget . eval_js ( '<STR_LIT>' ) <EOL> widget . show ( ) <EOL> assert widget . eval_js ( '<STR_LIT>' ) == <NUM_LIT:1> <EOL> def test_widget_javascript_2 ( qtbot ) : <EOL> widget = HTMLWidget ( ) <EOL> widget . show ( ) <EOL> _out = [ ] <EOL> @ widget . connect_ <EOL> def on_test ( arg ) : <EOL> _out . append ( arg ) <EOL> widget . eval_js ( '<STR_LIT>' ) <EOL> assert _out == [ [ <NUM_LIT:1> , <NUM_LIT:2> ] ] <EOL> widget . unconnect_ ( on_test ) <EOL> def test_table_current_sort ( ) : <EOL> assert Table ( ) . current_sort == ( None , None ) <EOL> def test_table_default_sort ( qtbot ) : <EOL> table = Table ( ) <EOL> table . show ( ) <EOL> with raises ( ValueError ) : <EOL> table . add_column ( lambda _ : _ ) <EOL> def count ( id ) : <EOL> return <NUM_LIT> - <NUM_LIT:10> * id <EOL> table . add_column ( count ) <EOL> table . set_default_sort ( '<STR_LIT:count>' , '<STR_LIT>' ) <EOL> table . set_rows ( range ( <NUM_LIT:10> ) ) <EOL> assert table . default_sort == ( '<STR_LIT:count>' , '<STR_LIT>' ) <EOL> table . next ( ) <EOL> assert table . selected == [ <NUM_LIT:9> ] <EOL> table . sort_by ( '<STR_LIT:id>' , '<STR_LIT>' ) <EOL> table . set_rows ( range ( <NUM_LIT:11> ) ) <EOL> table . next ( ) <EOL> assert table . selected == [ <NUM_LIT:10> ] <EOL> table . close ( ) <EOL> def test_table_duplicates ( qtbot , table ) : <EOL> assert table . default_sort == ( None , None ) <EOL> table . select ( [ <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> assert table . selected == [ <NUM_LIT:1> ] <EOL> def test_table_nav_first ( qtbot , table ) : <EOL> table . next ( ) <EOL> assert table . selected == [ <NUM_LIT:0> ] <EOL> def test_table_nav_last ( qtbot , table ) : <EOL> table . previous ( ) <EOL> assert table . selected == [ <NUM_LIT:9> ] <EOL> def test_table_nav_edge_0 ( qtbot , table ) : <EOL> table . set_rows ( [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> table . next ( ) <EOL> assert table . selected == [ <NUM_LIT:5> ] <EOL> def test_table_nav_edge_1 ( qtbot , table ) : <EOL> table . set_rows ( [ <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> table . previous ( ) <EOL> assert table . selected == [ <NUM_LIT:3> ] <EOL> def test_table_nav_0 ( qtbot , table ) : <EOL> table . select ( [ <NUM_LIT:4> ] ) <EOL> table . next ( ) <EOL> assert table . selected == [ <NUM_LIT:5> ] <EOL> table . previous ( ) <EOL> assert table . selected == [ <NUM_LIT:3> ] <EOL> _sel = [ ] <EOL> @ table . connect_ <EOL> def on_select ( items ) : <EOL> _sel . append ( items ) <EOL> table . eval_js ( '<STR_LIT>' ) <EOL> assert _sel == [ [ <NUM_LIT:1> ] ] <EOL> assert table . selected == [ <NUM_LIT:1> ] <EOL> def test_table_sort ( qtbot , table ) : <EOL> table . select ( [ <NUM_LIT:1> ] ) <EOL> table . sort_by ( '<STR_LIT:count>' , '<STR_LIT>' ) <EOL> table . previous ( ) <EOL> assert table . selected == [ <NUM_LIT:0> ] <EOL> assert table . current_sort == ( '<STR_LIT:count>' , '<STR_LIT>' ) </s>
