9
9
import warnings
10
10
import weakref
11
11
12
+ import doctest
12
13
import unittest
13
14
from test import support
14
15
from test .support import import_helper
31
32
has_c_implementation = False
32
33
33
34
34
- class PyPickleTests (AbstractPickleModuleTests ):
35
+ class PyPickleTests (AbstractPickleModuleTests , unittest . TestCase ):
35
36
dump = staticmethod (pickle ._dump )
36
37
dumps = staticmethod (pickle ._dumps )
37
38
load = staticmethod (pickle ._load )
@@ -40,7 +41,7 @@ class PyPickleTests(AbstractPickleModuleTests):
40
41
Unpickler = pickle ._Unpickler
41
42
42
43
43
- class PyUnpicklerTests (AbstractUnpickleTests ):
44
+ class PyUnpicklerTests (AbstractUnpickleTests , unittest . TestCase ):
44
45
45
46
unpickler = pickle ._Unpickler
46
47
bad_stack_errors = (IndexError ,)
@@ -54,7 +55,7 @@ def loads(self, buf, **kwds):
54
55
return u .load ()
55
56
56
57
57
- class PyPicklerTests (AbstractPickleTests ):
58
+ class PyPicklerTests (AbstractPickleTests , unittest . TestCase ):
58
59
59
60
pickler = pickle ._Pickler
60
61
unpickler = pickle ._Unpickler
@@ -73,7 +74,7 @@ def loads(self, buf, **kwds):
73
74
74
75
75
76
class InMemoryPickleTests (AbstractPickleTests , AbstractUnpickleTests ,
76
- BigmemPickleTests ):
77
+ BigmemPickleTests , unittest . TestCase ):
77
78
78
79
bad_stack_errors = (pickle .UnpicklingError , IndexError )
79
80
truncated_errors = (pickle .UnpicklingError , EOFError ,
@@ -110,14 +111,14 @@ def persistent_load(subself, obj):
110
111
111
112
112
113
class PyPersPicklerTests (AbstractPersistentPicklerTests ,
113
- PersistentPicklerUnpicklerMixin ):
114
+ PersistentPicklerUnpicklerMixin , unittest . TestCase ):
114
115
115
116
pickler = pickle ._Pickler
116
117
unpickler = pickle ._Unpickler
117
118
118
119
119
120
class PyIdPersPicklerTests (AbstractIdentityPersistentPicklerTests ,
120
- PersistentPicklerUnpicklerMixin ):
121
+ PersistentPicklerUnpicklerMixin , unittest . TestCase ):
121
122
122
123
pickler = pickle ._Pickler
123
124
unpickler = pickle ._Unpickler
@@ -183,37 +184,37 @@ def persistent_load(pid):
183
184
check (PersUnpickler )
184
185
185
186
186
- class PyPicklerUnpicklerObjectTests (AbstractPicklerUnpicklerObjectTests ):
187
+ class PyPicklerUnpicklerObjectTests (AbstractPicklerUnpicklerObjectTests , unittest . TestCase ):
187
188
188
189
pickler_class = pickle ._Pickler
189
190
unpickler_class = pickle ._Unpickler
190
191
191
192
192
- class PyDispatchTableTests (AbstractDispatchTableTests ):
193
+ class PyDispatchTableTests (AbstractDispatchTableTests , unittest . TestCase ):
193
194
194
195
pickler_class = pickle ._Pickler
195
196
196
197
def get_dispatch_table (self ):
197
198
return pickle .dispatch_table .copy ()
198
199
199
200
200
- class PyChainDispatchTableTests (AbstractDispatchTableTests ):
201
+ class PyChainDispatchTableTests (AbstractDispatchTableTests , unittest . TestCase ):
201
202
202
203
pickler_class = pickle ._Pickler
203
204
204
205
def get_dispatch_table (self ):
205
206
return collections .ChainMap ({}, pickle .dispatch_table )
206
207
207
208
208
- class PyPicklerHookTests (AbstractHookTests ):
209
+ class PyPicklerHookTests (AbstractHookTests , unittest . TestCase ):
209
210
class CustomPyPicklerClass (pickle ._Pickler ,
210
211
AbstractCustomPicklerClass ):
211
212
pass
212
213
pickler_class = CustomPyPicklerClass
213
214
214
215
215
216
if has_c_implementation :
216
- class CPickleTests (AbstractPickleModuleTests ):
217
+ class CPickleTests (AbstractPickleModuleTests , unittest . TestCase ):
217
218
from _pickle import dump , dumps , load , loads , Pickler , Unpickler
218
219
219
220
class CUnpicklerTests (PyUnpicklerTests ):
@@ -241,7 +242,7 @@ class DumpPickle_CLoadPickle(PyPicklerTests):
241
242
pickler = pickle ._Pickler
242
243
unpickler = _pickle .Unpickler
243
244
244
- class CPicklerUnpicklerObjectTests (AbstractPicklerUnpicklerObjectTests ):
245
+ class CPicklerUnpicklerObjectTests (AbstractPicklerUnpicklerObjectTests , unittest . TestCase ):
245
246
pickler_class = _pickle .Pickler
246
247
unpickler_class = _pickle .Unpickler
247
248
@@ -254,17 +255,17 @@ def test_issue18339(self):
254
255
unpickler .memo = {- 1 : None }
255
256
unpickler .memo = {1 : None }
256
257
257
- class CDispatchTableTests (AbstractDispatchTableTests ):
258
+ class CDispatchTableTests (AbstractDispatchTableTests , unittest . TestCase ):
258
259
pickler_class = pickle .Pickler
259
260
def get_dispatch_table (self ):
260
261
return pickle .dispatch_table .copy ()
261
262
262
- class CChainDispatchTableTests (AbstractDispatchTableTests ):
263
+ class CChainDispatchTableTests (AbstractDispatchTableTests , unittest . TestCase ):
263
264
pickler_class = pickle .Pickler
264
265
def get_dispatch_table (self ):
265
266
return collections .ChainMap ({}, pickle .dispatch_table )
266
267
267
- class CPicklerHookTests (AbstractHookTests ):
268
+ class CPicklerHookTests (AbstractHookTests , unittest . TestCase ):
268
269
class CustomCPicklerClass (_pickle .Pickler , AbstractCustomPicklerClass ):
269
270
pass
270
271
pickler_class = CustomCPicklerClass
@@ -514,22 +515,10 @@ def test_multiprocessing_exceptions(self):
514
515
('multiprocessing.context' , name ))
515
516
516
517
517
- def test_main ():
518
- tests = [PyPickleTests , PyUnpicklerTests , PyPicklerTests ,
519
- PyPersPicklerTests , PyIdPersPicklerTests ,
520
- PyDispatchTableTests , PyChainDispatchTableTests ,
521
- CompatPickleTests , PyPicklerHookTests ]
522
- if has_c_implementation :
523
- tests .extend ([CPickleTests , CUnpicklerTests , CPicklerTests ,
524
- CPersPicklerTests , CIdPersPicklerTests ,
525
- CDumpPickle_LoadPickle , DumpPickle_CLoadPickle ,
526
- PyPicklerUnpicklerObjectTests ,
527
- CPicklerUnpicklerObjectTests ,
528
- CDispatchTableTests , CChainDispatchTableTests ,
529
- CPicklerHookTests ,
530
- InMemoryPickleTests , SizeofTests ])
531
- support .run_unittest (* tests )
532
- support .run_doctest (pickle )
518
+ def load_tests (loader , tests , pattern ):
519
+ tests .addTest (doctest .DocTestSuite ())
520
+ return tests
521
+
533
522
534
523
if __name__ == "__main__" :
535
- test_main ()
524
+ unittest . main ()
0 commit comments