mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 04:50:07 +01:00
Make the pubsub tests Py3 compatible
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@76021 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -285,7 +285,7 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
|
||||
self.pub.getDefaultTopicMgr().newTopic(tName, 'desc', required, **args)
|
||||
msg = 'Should have raised self.pub.MessageDataSpecError for %s, %s, %s'
|
||||
assert False, msg % (tName, required, args)
|
||||
except self.pub.MessageDataSpecError, exc:
|
||||
except self.pub.MessageDataSpecError as exc:
|
||||
#import traceback
|
||||
#traceback.print_exc()
|
||||
pass
|
||||
|
||||
@@ -10,7 +10,7 @@ import imp_unittest, unittest
|
||||
import wtc
|
||||
|
||||
from wx.lib.pubsub.utils import notification
|
||||
from StringIO import StringIO
|
||||
from wx.lib.six import StringIO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ class lib_pubsub_ArgsInfo(wtc.PubsubTestCase):
|
||||
self.assertRaises(ListenerMismatchError, getArgs, 1)
|
||||
try:
|
||||
getArgs(1)
|
||||
except ListenerMismatchError, exc:
|
||||
except ListenerMismatchError as exc:
|
||||
msg = 'Listener "int" (from module "__main__") inadequate: type "int" not supported'
|
||||
self.assertEqual(str(exc), msg)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import wtc
|
||||
|
||||
from difflib import ndiff, unified_diff, context_diff
|
||||
|
||||
import wx.lib.six as six
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -23,7 +22,7 @@ class lib_pubsub_Notify(wtc.PubsubTestCase):
|
||||
from wx.lib.pubsub.utils.notification import useNotifyByWriteFile
|
||||
|
||||
def captureStdout():
|
||||
from six import StringIO
|
||||
from wx.lib.six import StringIO
|
||||
capture = StringIO()
|
||||
useNotifyByWriteFile( fileObj = capture )
|
||||
return capture
|
||||
|
||||
@@ -89,7 +89,7 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
|
||||
pass
|
||||
"""
|
||||
|
||||
myTopicTree = file('myTopicTree.py', 'w')
|
||||
myTopicTree = open('myTopicTree.py', 'w')
|
||||
myTopicTree.write(dedent(provFile))
|
||||
myTopicTree.close()
|
||||
self.pub.addTopicDefnProvider('myTopicTree',
|
||||
@@ -236,8 +236,10 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
|
||||
self.pub.exportTopicTreeSpec(os.path.join(basepath,'lib_pubsub_provider_actual'),
|
||||
rootTopic='test_import_export_no_change2',
|
||||
moduleDoc=treeDoc)
|
||||
lines1 = open(os.path.join(basepath,'lib_pubsub_provider_actual.py'), 'r').readlines()
|
||||
lines2 = open(os.path.join(basepath,'lib_pubsub_provider_expect.py'), 'r').readlines()
|
||||
with open(os.path.join(basepath,'lib_pubsub_provider_actual.py'), 'r') as f:
|
||||
lines1 = f.readlines()
|
||||
with open(os.path.join(basepath,'lib_pubsub_provider_expect.py'), 'r') as f:
|
||||
lines2 = f.readlines()
|
||||
diffs = ndiff( lines1, lines2 )
|
||||
diffs = [d for d in diffs if not d.startswith(' ')]
|
||||
assert not list(diffs) or list(diffs) == ['- # - fileObj: TextIOWrapper\n', '+ # - fileObj: file\n']
|
||||
|
||||
@@ -305,7 +305,7 @@ class lib_pubsub_TopicMgr2_GetOrCreate_DefnProv(wtc.PubsubTestCase):
|
||||
topicName)
|
||||
try:
|
||||
assert topicMgr.getOrCreateTopic(topicName) is None
|
||||
except MessageDataSpecError, exc:
|
||||
except MessageDataSpecError as exc:
|
||||
# ok, did raise but is it correct message?
|
||||
try:
|
||||
str(exc).index(expectMsg)
|
||||
@@ -359,7 +359,7 @@ class lib_pubsub_TopicMgr3_TreeTraverser(wtc.PubsubTestCase):
|
||||
topicMgr.getOrCreateTopic('a2.b.a')
|
||||
topicMgr.getOrCreateTopic('a2.b.b')
|
||||
|
||||
from StringIO import StringIO
|
||||
from wx.lib.six import StringIO
|
||||
buffer = StringIO()
|
||||
printTreeDocs(rootTopic=root, width=70, fileObj=buffer)
|
||||
self.assertEqual( buffer.getvalue(), self.expectedOutput )
|
||||
|
||||
Reference in New Issue
Block a user