Skip to content

Commit e2614a6

Browse files
committed
TST: add helper context overrideclipboard
Replace `wx.TheClipboard` with a dummy object to prevent clipboard modifications.
1 parent e609247 commit e2614a6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/diffpy/pdfgui/tests/testutils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ def GetPaths(self):
7272
return
7373

7474

75+
@contextmanager
76+
def overrideclipboard():
77+
"Temporarily replace wx.TheClipboard with a dummy object."
78+
save_theclipboard = wx.TheClipboard
79+
class _TTheClipboard(object):
80+
def IsSupported(self, fmt):
81+
return False
82+
pass
83+
wx.TheClipboard = _TTheClipboard()
84+
try:
85+
yield wx.TheClipboard
86+
finally:
87+
wx.TheClipboard = save_theclipboard
88+
return
89+
90+
7591
def tooltiptext(widget):
7692
tt = widget.GetToolTip()
7793
return tt.GetTip()

0 commit comments

Comments
 (0)