From 3c81c73b9e5058c62ff3d8e9e33fdd570fa92a00 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 2 Aug 2012 05:39:36 +0000 Subject: [PATCH] Adapt tests to GetHandle changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- unittests/test_dc.py | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/unittests/test_dc.py b/unittests/test_dc.py index 3331400b..09434875 100644 --- a/unittests/test_dc.py +++ b/unittests/test_dc.py @@ -2,7 +2,7 @@ import imp_unittest, unittest import wtc import wx import os - +import warnings pngFile = os.path.join(os.path.dirname(__file__), 'toucan.png') @@ -92,34 +92,45 @@ class dc_Tests(wtc.WidgetTestCase): c = wx.DCFontChanger(dc, font) del c + + def test_NativeHandle(self): + dc = wx.MemoryDC(wx.Bitmap(10,10)) + h = dc.GetHandle() + self.assertTrue(h is not None) + self.assertNotEqual(int(h), 0) + def test_NativeWinHandle(self): dc = wx.ClientDC(self.frame) - if 'wxMSW' in wx.PlatformInfo: - h = dc.GetHDC() - self.assertNotEqual(h, 0) - else: - with self.assertRaises(NotImplementedError): - h = dc.GetHDC() + with warnings.catch_warnings(): + warnings.simplefilter("error") + with self.assertRaises(wx.wxPyDeprecationWarning): + try: + h = dc.GetHDC() + except NotImplementedError: + pass + def test_NativeGTKHandle(self): dc = wx.ClientDC(self.frame) - if 'wxGTK' in wx.PlatformInfo: - h = dc.GetGdkDrawable() - self.assertNotEqual(h, 0) - else: - with self.assertRaises(NotImplementedError): - h = dc.GetGdkDrawable() + with warnings.catch_warnings(): + warnings.simplefilter("error") + with self.assertRaises(wx.wxPyDeprecationWarning): + try: + h = dc.GetGdkDrawable() + except NotImplementedError: + pass def test_NativeMacHandle(self): dc = wx.MemoryDC(wx.Bitmap(10,10)) - if 'wxMac' in wx.PlatformInfo: - h = dc.GetCGContext() - self.assertTrue(h is not None) - self.assertNotEqual(int(h), 0) - else: - with self.assertRaises(NotImplementedError): - h = dc.GetCGContext() + with warnings.catch_warnings(): + warnings.simplefilter("error") + with self.assertRaises(wx.wxPyDeprecationWarning): + try: + h = dc.GetCGContext() + except NotImplementedError: + pass + def test_trickyStuff(self): # execute some tricky tweaks to make sure they work are as they are supposed to. @@ -131,9 +142,9 @@ class dc_Tests(wtc.WidgetTestCase): self.assertTrue(type(values) == list) self.assertTrue(len(values) == 5) + def test_dcPointLists(self): dc = wx.ClientDC(self.frame) - dc.DrawLines([wx.Point(5,5), wx.Point(25,5), wx.Point(25,25), wx.Point(25,5), wx.Point(5,5)]) dc.DrawLines([(15,15), (35,15), (35,35), (35,15), (15,15)])