diff --git a/unittests/test_lib_pubsub_api3.py b/unittests/test_lib_pubsub_api3.py index eb28f311..5837053d 100644 --- a/unittests/test_lib_pubsub_api3.py +++ b/unittests/test_lib_pubsub_api3.py @@ -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 diff --git a/unittests/test_lib_pubsub_defaultlog.py b/unittests/test_lib_pubsub_defaultlog.py index c7a59c12..9543bfdb 100644 --- a/unittests/test_lib_pubsub_defaultlog.py +++ b/unittests/test_lib_pubsub_defaultlog.py @@ -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 #--------------------------------------------------------------------------- diff --git a/unittests/test_lib_pubsub_listener.py b/unittests/test_lib_pubsub_listener.py index d02dd127..72d8e846 100644 --- a/unittests/test_lib_pubsub_listener.py +++ b/unittests/test_lib_pubsub_listener.py @@ -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) diff --git a/unittests/test_lib_pubsub_notify.py b/unittests/test_lib_pubsub_notify.py index 0479ab50..8adf9d50 100644 --- a/unittests/test_lib_pubsub_notify.py +++ b/unittests/test_lib_pubsub_notify.py @@ -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 diff --git a/unittests/test_lib_pubsub_provider.py b/unittests/test_lib_pubsub_provider.py index db081d86..bf0a94c4 100644 --- a/unittests/test_lib_pubsub_provider.py +++ b/unittests/test_lib_pubsub_provider.py @@ -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'] diff --git a/unittests/test_lib_pubsub_topicmgr.py b/unittests/test_lib_pubsub_topicmgr.py index feb6e294..c7416e46 100644 --- a/unittests/test_lib_pubsub_topicmgr.py +++ b/unittests/test_lib_pubsub_topicmgr.py @@ -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 )