mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 12:00:13 +01:00
Change the test function to have a leading underscore so it isn't quite as visible.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@70779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -77,10 +77,10 @@
|
||||
|
||||
// Used just for testing the MappedType code, it can be removed later
|
||||
%ModuleCode
|
||||
wxString testStringTypemap(const wxString& str)
|
||||
wxString _testStringTypemap(const wxString& str)
|
||||
{
|
||||
wxString local = str;
|
||||
return local;
|
||||
}
|
||||
%End
|
||||
wxString testStringTypemap(const wxString& str);
|
||||
wxString _testStringTypemap(const wxString& str);
|
||||
|
||||
@@ -6,53 +6,53 @@ import wx
|
||||
|
||||
class String(unittest.TestCase):
|
||||
|
||||
if hasattr(wx, 'testStringTypemap'):
|
||||
if hasattr(wx, '_testStringTypemap'):
|
||||
def test_StringTypemaps(self):
|
||||
utf = '\xc3\xa9l\xc3\xa9phant' # utf-8 string
|
||||
uni = utf.decode('utf-8') # convert to unicode
|
||||
iso = uni.encode('iso-8859-1') # make a string with a different encoding
|
||||
|
||||
|
||||
# wx.testStringTypemap() will accept a parameter that is a Unicode object
|
||||
# wx._testStringTypemap() will accept a parameter that is a Unicode object
|
||||
# or an 'ascii' or 'utf-8' string object, which will then be converted to
|
||||
# a wxString. The return value is a Unicode object that has been
|
||||
# converted from a wxString that is a copy of the wxString created for
|
||||
# the parameter.
|
||||
|
||||
# ascii
|
||||
result = wx.testStringTypemap('hello')
|
||||
result = wx._testStringTypemap('hello')
|
||||
self.assertTrue(type(result) == unicode)
|
||||
self.assertTrue(result == u'hello')
|
||||
|
||||
# unicode should pass through unmodified
|
||||
result = wx.testStringTypemap(uni)
|
||||
result = wx._testStringTypemap(uni)
|
||||
self.assertTrue(result == uni)
|
||||
|
||||
# utf-8 is converted
|
||||
result = wx.testStringTypemap(utf)
|
||||
result = wx._testStringTypemap(utf)
|
||||
self.assertTrue(result == uni)
|
||||
|
||||
# can't auto-convert this
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
result = wx.testStringTypemap(iso)
|
||||
result = wx._testStringTypemap(iso)
|
||||
|
||||
# utf-16-be
|
||||
val = "\x00\xe9\x00l\x00\xe9\x00p\x00h\x00a\x00n\x00t"
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
result = wx.testStringTypemap(val)
|
||||
result = wx.testStringTypemap( val.decode('utf-16-be'))
|
||||
result = wx._testStringTypemap(val)
|
||||
result = wx._testStringTypemap( val.decode('utf-16-be'))
|
||||
self.assertTrue(result == uni)
|
||||
|
||||
# utf-32-be
|
||||
val = "\x00\x00\x00\xe9\x00\x00\x00l\x00\x00\x00\xe9\x00\x00\x00p\x00\x00\x00h\x00\x00\x00a\x00\x00\x00n\x00\x00\x00t"
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
result = wx.testStringTypemap(val)
|
||||
result = wx.testStringTypemap(val.decode('utf-32-be'))
|
||||
result = wx._testStringTypemap(val)
|
||||
result = wx._testStringTypemap(val.decode('utf-32-be'))
|
||||
self.assertTrue(result == uni)
|
||||
|
||||
# utf-8 with BOM
|
||||
val = "\xef\xbb\xbfHello"
|
||||
result = wx.testStringTypemap(val)
|
||||
result = wx._testStringTypemap(val)
|
||||
self.assertTrue(result == u'\ufeffHello')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user