Skip to content
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

Emit modelReset after sorting test results #110

Merged
merged 1 commit into from
Feb 16, 2018
Merged
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
4 changes: 2 additions & 2 deletions spyder_unittest/widgets/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def sort(self, column, order):
def key_time(result):
return result.time or -1

self.beginResetModel()
reverse = order == Qt.DescendingOrder
if column == STATUS_COLUMN:
self.testresults.sort(key=attrgetter('category', 'status'),
Expand All @@ -377,8 +378,7 @@ def key_time(result):
self.testresults.sort(key=attrgetter('message'), reverse=reverse)
elif column == TIME_COLUMN:
self.testresults.sort(key=key_time, reverse=reverse)
self.dataChanged.emit(self.index(0, 0),
self.index(len(self.testresults), len(HEADERS)))
self.endResetModel()

def summary(self):
"""Return summary for current results."""
Expand Down
2 changes: 1 addition & 1 deletion spyder_unittest/widgets/tests/test_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def check_args(topLeft, bottomRight, *args):
def test_testdatamodel_sort_by_status_ascending(qtbot):
model = TestDataModel()
model.testresults = STANDARD_TESTRESULTS[:]
with qtbot.waitSignal(model.dataChanged):
with qtbot.waitSignal(model.modelReset):
model.sort(0, Qt.AscendingOrder)
expected = [STANDARD_TESTRESULTS[k] for k in [2, 1, 0]]
assert model.testresults == expected
Expand Down