summaryrefslogtreecommitdiff
path: root/dev-python/pyro/files/4.20-0001-Use-unittest2-for-older-Python-version.patch
blob: 554ea01321a68d91674e4595713eff4476f3c1bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
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