Skip to content

unused codes fixes #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/BasicExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from qtpandas.compat import QtGui
from qtpandas.models.DataFrameModel import DataFrameModel
from qtpandas.views.DataTableView import DataTableWidget
from qtpandas.views._ui import icons_rc
# from qtpandas.views._ui import icons_rc

sys.excepthook = excepthook

Expand Down
11 changes: 6 additions & 5 deletions examples/TestApp.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# -*- coding: utf-8 -*-
import sys
import pandas
# import numpy

from qtpandas.excepthook import excepthook
sys.excepthook = excepthook

from qtpandas.compat import QtCore, QtGui, Qt, Slot, Signal

import pandas
import numpy

from qtpandas.models.DataFrameModel import DataFrameModel
from qtpandas.models.DataSearch import DataSearch
from qtpandas.views.CSVDialogs import CSVImportDialog, CSVExportDialog
from qtpandas.views._ui import icons_rc
# from qtpandas.views._ui import icons_rc
from qtpandas.views.DataTableView import DataTableWidget
from qtpandas.views.CustomDelegates import DtypeComboDelegate
from qtpandas.models.mime import PandasCellMimeType, PandasCellPayload
from util import getCsvData, getRandomData

sys.excepthook = excepthook


class DropLineEdit(QtGui.QLineEdit):

def __init__(self, text, parent=None):
Expand Down
4 changes: 2 additions & 2 deletions qtpandas/excepthook.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def excepthook(excType, excValue, tracebackobj):
else:
excValueStr = str(excValue)

except UnicodeEncodeError as e:
except UnicodeEncodeError:
excValueStr = str(excValue)

errmsg = '{0}: \n{1}'.format(excType, excValueStr)
Expand All @@ -60,7 +60,7 @@ def excepthook(excType, excValue, tracebackobj):
try:
msg = '\n'.join(sections)

except TypeError as e:
except TypeError:
# Remove all things not string.
sections = [item for item in sections if type(item) == str]
msg = '\n'.join(sections)
Expand Down
4 changes: 2 additions & 2 deletions qtpandas/models/ColumnDtypeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def setData(self, index, value, role=DTYPE_CHANGE_ROLE):

if dtype is not None:
if dtype != currentDtype:
col = index.column()
#row = self._dataFrame.columns[index.column()]
# col = index.column()
# Row = self._dataFrame.columns[index.column()]
columnName = self._dataFrame.columns[index.row()]

try:
Expand Down
8 changes: 4 additions & 4 deletions qtpandas/models/DataFrameModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ def setData(self, index, value, role=Qt.DisplayRole):
value = pandas.Timestamp(value)
except Exception:
raise Exception("Can't convert '{0}' into a datetime".format(value))
return False
# return False
else:
raise TypeError("try to set unhandled data type")

self._dataFrame.set_value(row, col, value)

#print 'after change: ', value, self._dataFrame.iloc[row][col]
# print 'after change: ', value, self._dataFrame.iloc[row][col]
self.layoutChanged.emit()
return True
else:
Expand Down Expand Up @@ -607,7 +607,7 @@ def addDataFrameColumn(self, columnName, dtype=str, defaultValue=None):
self.beginInsertColumns(QtCore.QModelIndex(), columnPosition - 1, columnPosition - 1)
try:
self._dataFrame.insert(columnPosition, columnName, newColumn, allow_duplicates=False)
except ValueError as e:
except ValueError:
# columnName does already exist
return False

Expand Down Expand Up @@ -727,4 +727,4 @@ def removeDataFrameRows(self, rows):

self.endRemoveRows()
return True
return False
return False
48 changes: 32 additions & 16 deletions tests/test_CSVDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ def _teardown():


class TestValidator(object):

@pytest.fixture()
def test_input(self, qtbot):
@classmethod
def test_input(cls, qtbot):
widget = QtGui.QLineEdit()
widget.setValidator(DelimiterValidator())
qtbot.addWidget(widget)
Expand All @@ -50,7 +52,8 @@ def test_input(self, qtbot):

class TestDelimiterBox(object):
@pytest.fixture()
def test_selections_and_signals(self, qtbot):
@classmethod
def test_selections_and_signals(cls, qtbot):
box = DelimiterSelectionWidget()
qtbot.addWidget(box)
box.show()
Expand All @@ -72,7 +75,8 @@ def test_selections_and_signals(self, qtbot):
assert char in delimiters

@pytest.fixture()
def test_reset(self, qtbot):
@classmethod
def test_reset(cls, qtbot):
box = DelimiterSelectionWidget()
qtbot.addWidget(box)
box.show()
Expand All @@ -93,16 +97,19 @@ def test_reset(self, qtbot):


class TestCSVImportWidget(object):

@pytest.fixture()
def test_init(self, qtbot):
@classmethod
def test_init(cls, qtbot):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
assert csvwidget.isModal()
assert csvwidget.windowTitle() == 'Import CSV'

@pytest.fixture()
def test_fileinput(self, qtbot, csv_file):
@classmethod
def test_fileinput(cls, qtbot, csv_file):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand All @@ -115,7 +122,8 @@ def test_fileinput(self, qtbot, csv_file):
assert csvwidget._header is None

@pytest.fixture()
def test_header(self, qtbot):
@classmethod
def test_header(cls, qtbot):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand All @@ -125,7 +133,8 @@ def test_header(self, qtbot):
checkboxes[0].toggle()
assert csvwidget._header == 0

def test_encoding(self, qtbot):
@classmethod
def test_encoding(cls, qtbot):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand All @@ -138,7 +147,8 @@ def test_encoding(self, qtbot):
assert csvwidget._encodingKey != 'iso_ir_6'

@pytest.fixture()
def test_delimiter(self, qtbot):
@classmethod
def test_delimiter(cls, qtbot):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand All @@ -157,7 +167,8 @@ def test_delimiter(self, qtbot):
assert csvwidget._delimiter == groupboxes[0].currentSelected()

@pytest.fixture()
def test_accept_reject(self, qtbot):
@classmethod
def test_accept_reject(cls, qtbot):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand All @@ -168,7 +179,8 @@ def test_accept_reject(self, qtbot):
if not csvwidget.isVisible():
csvwidget.show()

def test_preview(self, qtbot, csv_file):
@classmethod
def test_preview(cls, qtbot, csv_file):
csvwidget = CSVImportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand Down Expand Up @@ -199,14 +211,16 @@ def _assert(x, path):


class TestCSVExportWidget(object):

def test_init(self, qtbot):
csvwidget = CSVExportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
assert csvwidget.isModal()
assert csvwidget.windowTitle() == 'Export to CSV'

def test_fileoutput(self, qtbot, csv_file):
@classmethod
def test_fileoutput(cls, qtbot, csv_file):
csvwidget = CSVExportDialog()
qtbot.addWidget(csvwidget)
csvwidget.show()
Expand All @@ -231,7 +245,7 @@ def test_encoding(self, qtbot):
csvwidget.show()

comboboxes = csvwidget.findChildren(QtGui.QComboBox)
comboboxes[0]
# comboboxes[0]
assert comboboxes[0].itemText(comboboxes[0].currentIndex()) == 'UTF_8'

def test_delimiter(self, qtbot):
Expand Down Expand Up @@ -264,13 +278,15 @@ def test_accept_reject(self, qtbot):
for button in buttons:
qtbot.mouseClick(button, QtCore.Qt.LeftButton)
if button.text() == 'Export Data':
assert csvwidget.isVisible() == True
assert csvwidget.isVisible() is True
else:
assert csvwidget.isVisible() == False
assert csvwidget.isVisible() is False


class TestDateTimeConversion(object):

def test_read_write(self, qtbot, csv_file, tmp):
@classmethod
def test_read_write(cls, qtbot, csv_file, tmp):
importWidget = CSVImportDialog()

qtbot.addWidget(importWidget)
Expand Down Expand Up @@ -344,4 +360,4 @@ def test_read_write(self, qtbot, csv_file, tmp):
comparator = model_in.dataFrame() == model_out_in.dataFrame()
assert all(comparator)

df = model_out_in.dataFrame()
# df = model_out_in.dataFrame()
Loading