def test_sort_dataframe_with_category_dtypes(qtbot): # cf. issue 5361 df = DataFrame({'A': [1, 2, 3, 4], 'B': ['a', 'b', 'c', 'd']}) df = df.astype(dtype={'B': 'category'}) df_cols = df.dtypes editor = DataFrameEditor(None) editor.setup_and_check(df_cols) dfm = editor.dataModel QTimer.singleShot(1000, lambda: close_message_box(qtbot)) editor.dataModel.sort(1) assert data(dfm, 0, 1) == 'int64' assert data(dfm, 1, 1) == 'category'
def test_sort_dataframe_with_category_dtypes(qtbot): # cf. issue 5361 df = DataFrame({'A': [1, 2, 3, 4], 'B': ['a', 'b', 'c', 'd']}) df = df.astype(dtype={'B': 'category'}) df_cols = df.dtypes editor = DataFrameEditor(None) editor.setup_and_check(df_cols) dfm = editor.dataModel QTimer.singleShot(1000, lambda: close_message_box(qtbot)) editor.dataModel.sort(0) assert data(dfm, 0, 0) == 'int64' assert data(dfm, 1, 0) == 'category'
def environ_dialog(qtbot): "Setup the Environment variables Dialog taking into account the os." QTimer.singleShot(1000, lambda: close_message_box(qtbot)) if os.name == 'nt': from spyder.utils.environ import WinUserEnvDialog dialog = WinUserEnvDialog() else: from spyder.utils.environ import EnvDialog dialog = EnvDialog() qtbot.addWidget(dialog) return dialog
def environ_dialog(qtbot): "Setup the Environment variables Dialog taking into account the os." QTimer.singleShot(1000, lambda: close_message_box(qtbot)) if os.name == 'nt': from spyder.utils.environ import WinUserEnvDialog dialog = WinUserEnvDialog() else: from spyder.utils.environ import EnvDialog dialog = EnvDialog() qtbot.addWidget(dialog) return dialog
def test_sort_dataframe_with_duplicate_column(qtbot): df = DataFrame({'A': [1, 3, 2], 'B': [4, 6, 5]}) df = concat((df, df.A), axis=1) editor = DataFrameEditor(None) editor.setup_and_check(df) dfm = editor.dataModel QTimer.singleShot(1000, lambda: close_message_box(qtbot)) editor.dataModel.sort(0) assert [data(dfm, row, 0) for row in range(len(df))] == ['1', '3', '2'] assert [data(dfm, row, 1) for row in range(len(df))] == ['4', '6', '5'] editor.dataModel.sort(1) assert [data(dfm, row, 0) for row in range(len(df))] == ['1', '2', '3'] assert [data(dfm, row, 1) for row in range(len(df))] == ['4', '5', '6']
def test_sort_dataframe_with_duplicate_column(qtbot): df = DataFrame({'A': [1, 3, 2], 'B': [4, 6, 5]}) df = concat((df, df.A), axis=1) editor = DataFrameEditor(None) editor.setup_and_check(df) dfm = editor.dataModel QTimer.singleShot(1000, lambda: close_message_box(qtbot)) editor.dataModel.sort(1) assert [data(dfm, row, 1) for row in range(len(df))] == ['1', '3', '2'] assert [data(dfm, row, 2) for row in range(len(df))] == ['4', '6', '5'] editor.dataModel.sort(2) assert [data(dfm, row, 1) for row in range(len(df))] == ['1', '2', '3'] assert [data(dfm, row, 2) for row in range(len(df))] == ['4', '5', '6']
def test_restart_kernel(ipyconsole, qtbot): """ Test that kernel is restarted correctly """ shell = ipyconsole.get_current_shellwidget() client = ipyconsole.get_current_client() qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Do an assignment to verify that it's not there after restarting with qtbot.waitSignal(shell.executed): shell.execute('a = 10') # Restart kernel and wait until it's up again shell._prompt_html = None QTimer.singleShot(1000, lambda: close_message_box(qtbot)) client.restart_kernel() qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT) assert not shell.is_defined('a')
def test_restart_kernel(ipyconsole, qtbot): """ Test that kernel is restarted correctly """ shell = ipyconsole.get_current_shellwidget() client = ipyconsole.get_current_client() qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Do an assigment to verify that it's not there after restarting with qtbot.waitSignal(shell.executed): shell.execute('a = 10') # Restart kernel and wait until it's up again shell._prompt_html = None QTimer.singleShot(1000, lambda: close_message_box(qtbot)) client.restart_kernel() qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT) assert not shell.is_defined('a')
def test_environ(qtbot): """Test the environment variables dialog.""" QTimer.singleShot(1000, lambda: close_message_box(qtbot)) dialog = setup_environ(qtbot) dialog.show() assert dialog
def test_environ(qtbot): """Test the environment variables dialog.""" QTimer.singleShot(1000, lambda: close_message_box(qtbot)) dialog = setup_environ(qtbot) dialog.show() assert dialog