Skip to content

Commit

Permalink
Add regression test for issue spyder-ide#4139
Browse files Browse the repository at this point in the history
  • Loading branch information
jitseniesen committed Feb 13, 2017
1 parent 983029c commit 1dc188d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spyder/widgets/variableexplorer/tests/test_dataframeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pandas import DataFrame, date_range, read_csv
from qtpy.QtGui import QColor
from qtpy.QtCore import Qt
import numpy
import pytest

# Local imports
Expand Down Expand Up @@ -156,6 +157,19 @@ def test_dataframemodel_get_bgcolor_with_object():
a = dataframeeditor.BACKGROUND_MISC_ALPHA
assert colorclose(bgcolor(dfm, 0, 1), (h, s, v, a))

def test_dataframemodel_with_format_percent_d_and_nan():
"""
Test DataFrameModel with format `%d` and dataframe containing NaN
Regression test for issue 4139.
"""
np_array = numpy.zeros(2)
np_array[1] = numpy.nan
dataframe = DataFrame(np_array)
dfm = DataFrameModel(dataframe, format='%d')
assert data(dfm, 0, 1) == '0'
assert data(dfm, 1, 1) == 'nan'

def test_change_format_emits_signal(qtbot, monkeypatch):
mockQInputDialog = Mock()
mockQInputDialog.getText = lambda parent, title, label, mode, text: ('%10.3e', True)
Expand Down

0 comments on commit 1dc188d

Please sign in to comment.