From 342459580d41286a426242e4e5f6b754f5416262 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 10 May 2012 22:39:24 +0000 Subject: [PATCH] Add a unit test for wx.Clipboard git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/clipbrd.py | 1 + unittests/test_clipbrd.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/etg/clipbrd.py b/etg/clipbrd.py index 984222bf..794eed31 100644 --- a/etg/clipbrd.py +++ b/etg/clipbrd.py @@ -41,6 +41,7 @@ def run(): c.addPyMethod('__enter__', '(self)', 'return self') c.addPyMethod('__exit__', '(self, exc_type, exc_val, exc_tb)', 'self.Close()') + # TODO: This init wrapper class may be useful elsewhere... module.addPyCode("""\ # Since wxTheClipoard is not really a global varaiable (it is a macro # that calls the Get static method) we can't declare it as a global diff --git a/unittests/test_clipbrd.py b/unittests/test_clipbrd.py index 13cdfe36..e631f12f 100644 --- a/unittests/test_clipbrd.py +++ b/unittests/test_clipbrd.py @@ -6,9 +6,20 @@ import wx class clipbrd_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. def test_clipbrd1(self): - self.fail("Unit tests for clipbrd not implemented yet.") + # copy + data1 = wx.TextDataObject('This is some data.') + if wx.TheClipboard.Open(): + wx.TheClipboard.SetData(data1) + wx.TheClipboard.Close() + + # paste + data2 = wx.TextDataObject() + if wx.TheClipboard.Open(): + wx.TheClipboard.GetData(data2) + wx.TheClipboard.Close() + + self.assertEqual(data2.GetText(), 'This is some data.') #---------------------------------------------------------------------------