Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Apr 4, 2021
1 parent 6d4b1fb commit e2d2cb9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions magicgui/backends/_qtpy/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,10 @@ def _mgui_bind_change_callback(self, callback):
"""Bind callback to event of changing any cell."""

def _item_callback(item, callback=callback):
col_head = item.tableWidget().horizontalHeaderItem(item.column()).text()
row_head = item.tableWidget().verticalHeaderItem(item.row()).text()
col_head = item.tableWidget().horizontalHeaderItem(item.column())
col_head = col_head.text() if col_head is not None else ""
row_head = item.tableWidget().verticalHeaderItem(item.row())
row_head = row_head.text() if row_head is not None else ""
data = {
"data": item.data(self._DATA_ROLE),
"row": item.row(),
Expand Down
7 changes: 5 additions & 2 deletions magicgui/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,11 @@ def __call__(self, *args, **kwargs) -> Event:
self.disconnect(cb)
finally:
self._emitting = False
if event._pop_source() != self.source:
raise RuntimeError("Event source-stack mismatch.")
evsource = event._pop_source()
if evsource is not self.source:
raise RuntimeError(
f"Event source-stack mismatch. ({evsource} is not {self.source}"
)

return event

Expand Down
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest


# for now, the only backend is qt, and pytest-qt's qapp provides some nice pre-post
# test cleanup that prevents some segfaults. Once we start testing multiple backends
# this will need to change.
@pytest.fixture(autouse=True, scope="session")
def always_qapp(qapp):
return qapp

0 comments on commit e2d2cb9

Please sign in to comment.