Fix the test control support for the pickle & cPickle tests so the tests run

under regrtest.
This commit is contained in:
Fred Drake 2001-12-19 16:42:15 +00:00
parent 1444f67fa0
commit 694ed091af
2 changed files with 22 additions and 8 deletions

View File

@ -1,7 +1,8 @@
import cPickle import cPickle
import test_support
import unittest
from cStringIO import StringIO from cStringIO import StringIO
from pickletester import AbstractPickleTests, AbstractPickleModuleTests from pickletester import AbstractPickleTests, AbstractPickleModuleTests
from test_support import run_unittest
class cPickleTests(AbstractPickleTests, AbstractPickleModuleTests): class cPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
@ -79,8 +80,14 @@ class cPickleFastPicklerTests(AbstractPickleTests):
AbstractPickleTests.test_recursive_multi, AbstractPickleTests.test_recursive_multi,
self) self)
def test_main():
loader = unittest.TestLoader()
suite = unittest.TestSuite()
suite.addTest(loader.loadTestsFromTestCase(cPickleTests))
suite.addTest(loader.loadTestsFromTestCase(cPicklePicklerTests))
suite.addTest(loader.loadTestsFromTestCase(cPickleListPicklerTests))
suite.addTest(loader.loadTestsFromTestCase(cPickleFastPicklerTests))
test_support.run_suite(suite)
if __name__ == "__main__": if __name__ == "__main__":
run_unittest(cPickleTests) test_main()
run_unittest(cPicklePicklerTests)
run_unittest(cPickleListPicklerTests)
run_unittest(cPickleFastPicklerTests)

View File

@ -1,7 +1,8 @@
import pickle import pickle
import test_support
import unittest
from cStringIO import StringIO from cStringIO import StringIO
from pickletester import AbstractPickleTests, AbstractPickleModuleTests from pickletester import AbstractPickleTests, AbstractPickleModuleTests
from test_support import run_unittest
class PickleTests(AbstractPickleTests, AbstractPickleModuleTests): class PickleTests(AbstractPickleTests, AbstractPickleModuleTests):
@ -28,6 +29,12 @@ class PicklerTests(AbstractPickleTests):
u = pickle.Unpickler(f) u = pickle.Unpickler(f)
return u.load() return u.load()
def test_main():
loader = unittest.TestLoader()
suite = unittest.TestSuite()
suite.addTest(loader.loadTestsFromTestCase(PickleTests))
suite.addTest(loader.loadTestsFromTestCase(PicklerTests))
test_support.run_suite(suite)
if __name__ == "__main__": if __name__ == "__main__":
run_unittest(PickleTests) test_main()
run_unittest(PicklerTests)