Files
Phoenix/unittests/test_cursor.py
Robin Dunn b41df0b779 Many, many (many!) changes needed to build and run the Phoenix extension modules with Python 3. Where possible changes were made such that the code works with both Python 2.7 and 3.2 without conditionals. In general the following types of changes were made:
* Changed imports to use either absolute or explicit relative imports.  Implicit relative imports are no longer allowed.

 * Changes to accomodate standard library classes or modues moving to other locations, or being removed entirely.

 * Changes related to print becoming a function, execfile being removed, u'' no longer allowed, and other syntax related issues.

 * Working around C APIs that have changed or simply vanished. (PyInt, PyString, PyBytes, etc.)

 * Dealing with text file objects using strings vs binary file objects using bytes, auto-encoding, and etc.

 * Replacing the use of PyCObject with PyCapsule and dealing with an apparent bug where PyCapsule objects can't be imported from submodules within a package.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71554 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-05-24 23:28:02 +00:00

110 lines
2.9 KiB
Python

import imp_unittest, unittest
import wtc
import wx
import os
pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png')
curFile = os.path.join(os.path.dirname(__file__), 'horse.cur')
#---------------------------------------------------------------------------
class CursorTests(wtc.WidgetTestCase):
def test_CursorCtors(self):
# stock
c = wx.Cursor(wx.CURSOR_HAND)
self.assertTrue(c.IsOk())
# from file
c = wx.Cursor(curFile, wx.BITMAP_TYPE_CUR)
self.assertTrue(c.IsOk())
# from image
img = wx.Image(pngFile)
img.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 1)
img.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 1)
c = wx.Cursor(img)
self.assertTrue(c.IsOk())
# copy
c2 = wx.Cursor(c)
self.assertTrue(c2.IsOk())
def test_CursorStockIDsExist(self):
wx.CURSOR_ARROW
wx.CURSOR_RIGHT_ARROW
wx.CURSOR_BULLSEYE
wx.CURSOR_CHAR
wx.CURSOR_CROSS
wx.CURSOR_HAND
wx.CURSOR_IBEAM
wx.CURSOR_LEFT_BUTTON
wx.CURSOR_MAGNIFIER
wx.CURSOR_MIDDLE_BUTTON
wx.CURSOR_NO_ENTRY
wx.CURSOR_PAINT_BRUSH
wx.CURSOR_PENCIL
wx.CURSOR_POINT_LEFT
wx.CURSOR_POINT_RIGHT
wx.CURSOR_QUESTION_ARROW
wx.CURSOR_RIGHT_BUTTON
wx.CURSOR_SIZENESW
wx.CURSOR_SIZENS
wx.CURSOR_SIZENWSE
wx.CURSOR_SIZEWE
wx.CURSOR_SIZING
wx.CURSOR_SPRAYCAN
wx.CURSOR_WAIT
wx.CURSOR_WATCH
wx.CURSOR_BLANK
wx.CURSOR_DEFAULT
wx.CURSOR_COPY_ARROW
wx.CURSOR_ARROWWAIT
def test_Cursor__nonzero__(self):
c1 = wx.Cursor()
self.assertTrue( not c1.IsOk() )
c2 = wx.Cursor(wx.CURSOR_ARROW)
self.assertTrue( c2.IsOk() )
if wtc.isPython3():
self.assertTrue( c2.__bool__() == c2.IsOk() )
else:
self.assertTrue( c2.__nonzero__() == c2.IsOk() )
# check that the __nonzero__ method can be used with if satements
nzcheck = False
if c2:
nzcheck = True
self.assertTrue(nzcheck)
nzcheck = False
if not c1:
nzcheck = True
self.assertTrue(nzcheck)
def test_NullCursor(self):
# just make sure this one exists
wx.NullCursor
self.assertTrue(not wx.NullCursor.IsOk())
def test_StockCursorsExist(self):
wx.STANDARD_CURSOR
wx.HOURGLASS_CURSOR
wx.CROSS_CURSOR
def test_StockCursorsInitialized(self):
self.assertTrue(wx.STANDARD_CURSOR.IsOk())
self.assertTrue(wx.HOURGLASS_CURSOR.IsOk())
self.assertTrue(wx.CROSS_CURSOR.IsOk())
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()