def test_change_format_emits_signal(qtbot, monkeypatch): mockQInputDialog = Mock() mockQInputDialog.getText = lambda parent, title, label, mode, text: ('%10.3e', True) monkeypatch.setattr('spyder.plugins.variableexplorer.widgets.dataframeeditor.QInputDialog', mockQInputDialog) df = DataFrame([[0]]) editor = DataFrameEditor(None) editor.setup_and_check(df) with qtbot.waitSignal(editor.sig_option_changed) as blocker: editor.change_format() assert blocker.args == ['dataframe_format', '%10.3e']
def test_change_format_emits_signal(qtbot, monkeypatch): mockQInputDialog = Mock() mockQInputDialog.getText = lambda parent, title, label, mode, text: ('%10.3e', True) monkeypatch.setattr('spyder.plugins.variableexplorer.widgets.dataframeeditor.QInputDialog', mockQInputDialog) df = DataFrame([[0]]) editor = DataFrameEditor(None) editor.setup_and_check(df) with qtbot.waitSignal(editor.sig_option_changed) as blocker: editor.change_format() assert blocker.args == ['dataframe_format', '%10.3e']
def test_change_format_with_format_not_starting_with_percent(qtbot, monkeypatch): mockQInputDialog = Mock() mockQInputDialog.getText = lambda parent, title, label, mode, text: ('xxx%f', True) monkeypatch.setattr('spyder.plugins.variableexplorer.widgets.dataframeeditor' '.QInputDialog', mockQInputDialog) monkeypatch.setattr('spyder.plugins.variableexplorer.widgets.dataframeeditor' '.QMessageBox.critical', Mock()) df = DataFrame([[0]]) editor = DataFrameEditor(None) editor.setup_and_check(df) with qtbot.assertNotEmitted(editor.sig_option_changed): editor.change_format()
def test_change_format_with_format_not_starting_with_percent(qtbot, monkeypatch): mockQInputDialog = Mock() mockQInputDialog.getText = lambda parent, title, label, mode, text: ('xxx%f', True) monkeypatch.setattr('spyder.plugins.variableexplorer.widgets.dataframeeditor' '.QInputDialog', mockQInputDialog) monkeypatch.setattr('spyder.plugins.variableexplorer.widgets.dataframeeditor' '.QMessageBox.critical', Mock()) df = DataFrame([[0]]) editor = DataFrameEditor(None) editor.setup_and_check(df) with qtbot.assertNotEmitted(editor.sig_option_changed): editor.change_format()
def test_change_format(qtbot, monkeypatch): mockQInputDialog = Mock() mockQInputDialog.getText = lambda parent, title, label, mode, text: ( '%10.3e', True) monkeypatch.setattr( 'spyder.plugins.variableexplorer.widgets.dataframeeditor.QInputDialog', mockQInputDialog) df = DataFrame([[0]]) editor = DataFrameEditor(None) editor.setup_and_check(df) editor.change_format() assert editor.dataModel._format == '%10.3e' assert editor.get_conf('dataframe_format') == '10.3e' editor.set_conf('dataframe_format', '.6g')