From d27de91579bd64397a9554b6c6a2257f098dbaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= <aidecoe@aidecoe.name> Date: Thu, 18 Jul 2013 20:19:03 +0200 Subject: [PATCH] Use unittest2 for older Python versions. --- tests/PyroTests/test_core.py | 6 +++++- tests/PyroTests/test_daemon.py | 7 ++++++- tests/PyroTests/test_echoserver.py | 7 ++++++- tests/PyroTests/test_flame.py | 7 ++++++- tests/PyroTests/test_ironpython.py | 6 +++++- tests/PyroTests/test_naming.py | 7 ++++++- tests/PyroTests/test_naming2.py | 6 +++++- tests/PyroTests/test_package.py | 7 ++++++- tests/PyroTests/test_serialize.py | 6 +++++- tests/PyroTests/test_server.py | 6 +++++- tests/PyroTests/test_server_timeout.py | 7 ++++++- tests/PyroTests/test_socket.py | 6 +++++- tests/PyroTests/test_tpjobqueue.py | 7 ++++++- tests/PyroTests/test_util.py | 7 +++++-- 14 files changed, 77 insertions(+), 15 deletions(-) diff --git a/tests/PyroTests/test_core.py b/tests/PyroTests/test_core.py index cbcbded..a0b801f 100644 --- a/tests/PyroTests/test_core.py +++ b/tests/PyroTests/test_core.py @@ -5,7 +5,6 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest import copy import logging import os, sys, time @@ -17,6 +16,11 @@ import Pyro4.constants import Pyro4.futures from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest if sys.version_info>=(3,0): import imp diff --git a/tests/PyroTests/test_daemon.py b/tests/PyroTests/test_daemon.py index cf7c06e..05472fd 100644 --- a/tests/PyroTests/test_daemon.py +++ b/tests/PyroTests/test_daemon.py @@ -5,14 +5,19 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement +import sys import os, time, socket -import unittest import Pyro4.core import Pyro4.constants import Pyro4.socketutil from Pyro4.errors import DaemonError,PyroError from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class MyObj(object): def __init__(self, arg): diff --git a/tests/PyroTests/test_echoserver.py b/tests/PyroTests/test_echoserver.py index abca795..5e58e24 100644 --- a/tests/PyroTests/test_echoserver.py +++ b/tests/PyroTests/test_echoserver.py @@ -4,13 +4,18 @@ Tests for the built-in test echo server. Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ -import unittest +import sys import time import Pyro4.test.echoserver as echoserver import Pyro4 from threading import Thread,Event from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class EchoServerThread(Thread): def __init__(self): diff --git a/tests/PyroTests/test_flame.py b/tests/PyroTests/test_flame.py index 2406bae..fdc611f 100644 --- a/tests/PyroTests/test_flame.py +++ b/tests/PyroTests/test_flame.py @@ -5,12 +5,17 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest import Pyro4.utils.flame import Pyro4.utils.flameserver import Pyro4.errors +import sys from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class FlameDisabledTests(unittest.TestCase): def testFlameDisabled(self): diff --git a/tests/PyroTests/test_ironpython.py b/tests/PyroTests/test_ironpython.py index 70dff4f..8343729 100644 --- a/tests/PyroTests/test_ironpython.py +++ b/tests/PyroTests/test_ironpython.py @@ -4,10 +4,14 @@ Tests for some Ironpython peculiarities. Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ -import unittest import sys import pickle +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest if sys.platform=="cli": diff --git a/tests/PyroTests/test_naming.py b/tests/PyroTests/test_naming.py index d61fa99..fb5b580 100644 --- a/tests/PyroTests/test_naming.py +++ b/tests/PyroTests/test_naming.py @@ -5,7 +5,7 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest +import sys import time import Pyro4.core import Pyro4.naming @@ -15,6 +15,11 @@ from Pyro4.errors import NamingError from Pyro4 import threadutil from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class NSLoopThread(threadutil.Thread): def __init__(self, nameserver): diff --git a/tests/PyroTests/test_naming2.py b/tests/PyroTests/test_naming2.py index afa0b22..ae398ac 100644 --- a/tests/PyroTests/test_naming2.py +++ b/tests/PyroTests/test_naming2.py @@ -5,7 +5,6 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest import sys, select, os import Pyro4.core import Pyro4.naming @@ -15,6 +14,11 @@ import Pyro4.socketutil from Pyro4.errors import NamingError,PyroError from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class OfflineNameServerTests(unittest.TestCase): def setUp(self): diff --git a/tests/PyroTests/test_package.py b/tests/PyroTests/test_package.py index 9ab3bba..052eebf 100644 --- a/tests/PyroTests/test_package.py +++ b/tests/PyroTests/test_package.py @@ -4,7 +4,6 @@ Tests for the package structure and import names. Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ -import unittest import Pyro4 import Pyro4.constants import Pyro4.core @@ -14,7 +13,13 @@ import Pyro4.nsc import Pyro4.socketutil import Pyro4.threadutil import Pyro4.util +import sys +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class TestPackage(unittest.TestCase): def testPyro4(self): diff --git a/tests/PyroTests/test_serialize.py b/tests/PyroTests/test_serialize.py index 4fea39c..f05c84a 100644 --- a/tests/PyroTests/test_serialize.py +++ b/tests/PyroTests/test_serialize.py @@ -5,7 +5,6 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest import sys import pprint import Pyro4.util @@ -13,6 +12,11 @@ import Pyro4.errors import Pyro4.core from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class SerializeTests_pickle(unittest.TestCase): SERIALIZER="pickle" diff --git a/tests/PyroTests/test_server.py b/tests/PyroTests/test_server.py index d1ebfcc..b2dd661 100644 --- a/tests/PyroTests/test_server.py +++ b/tests/PyroTests/test_server.py @@ -5,7 +5,6 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest import Pyro4.core import Pyro4.errors import Pyro4.util @@ -13,6 +12,11 @@ import time, os, sys, platform from Pyro4 import threadutil from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class MyThing(object): def __init__(self): diff --git a/tests/PyroTests/test_server_timeout.py b/tests/PyroTests/test_server_timeout.py index daa5a8d..dd5ee34 100644 --- a/tests/PyroTests/test_server_timeout.py +++ b/tests/PyroTests/test_server_timeout.py @@ -4,10 +4,15 @@ Tests for a running Pyro server, with timeouts. Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ -import unittest +import sys import os import test_server +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest class ServerTestsThreadTimeout(test_server.ServerTestsThreadNoTimeout): SERVERTYPE="thread" diff --git a/tests/PyroTests/test_socket.py b/tests/PyroTests/test_socket.py index 4d44139..b487686 100644 --- a/tests/PyroTests/test_socket.py +++ b/tests/PyroTests/test_socket.py @@ -4,7 +4,6 @@ Tests for the low level socket functions. Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ -import unittest import socket, os, sys import Pyro4.socketutil as SU from Pyro4 import threadutil @@ -13,6 +12,11 @@ from Pyro4.socketserver.threadpoolserver import SocketServer_Threadpool import Pyro4 from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest # determine ipv6 capability has_ipv6 = socket.has_ipv6 diff --git a/tests/PyroTests/test_tpjobqueue.py b/tests/PyroTests/test_tpjobqueue.py index 8ab7f7b..7cdc3bb 100644 --- a/tests/PyroTests/test_tpjobqueue.py +++ b/tests/PyroTests/test_tpjobqueue.py @@ -5,12 +5,17 @@ Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ from __future__ import with_statement -import unittest +import sys import time import random from Pyro4.tpjobqueue import ThreadPooledJobQueue, JobQueueError import Pyro4.threadutil +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest MIN_POOL_SIZE = 5 MAX_POOL_SIZE = 10 diff --git a/tests/PyroTests/test_util.py b/tests/PyroTests/test_util.py index ac1e639..497ec4a 100644 --- a/tests/PyroTests/test_util.py +++ b/tests/PyroTests/test_util.py @@ -4,12 +4,15 @@ Tests for the utility functions. Pyro - Python Remote Objects. Copyright by Irmen de Jong (irmen@razorvine.net). """ -import unittest - import sys, imp, os, platform import Pyro4.util from testsupport import * +if (sys.version_info >= (2, 7) and sys.version_info < (3, 0)) or \ + (sys.version_info >= (3, 1)): + import unittest +else: + import unittest2 as unittest if not hasattr(imp,"reload"): imp.reload=reload # python 2.5 doesn't have imp.reload -- 1.8.2.1