summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_imp.py7
-rw-r--r--Lib/test/test_importhooks.py4
-rw-r--r--Lib/test/test_multifile.py4
-rw-r--r--Lib/test/test_netrc.py4
-rw-r--r--Lib/test/test_tarfile.py25
-rw-r--r--Lib/test/test_timeout.py4
6 files changed, 38 insertions, 10 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index ebecf82..cd26b0a 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -1,7 +1,7 @@
import imp
import unittest
-from test_support import TestFailed
+from test_support import TestFailed, run_unittest
class ImpLock(unittest.TestCase):
@@ -22,5 +22,8 @@ class ImpLock(unittest.TestCase):
raise TestFailed, \
"release_lock() without lock should raise RuntimeError"
+def test_main():
+ run_unittest(ImpLock)
+
if __name__ == "__main__":
- test_support.run_unittest(ImpLock)
+ test_main()
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index 070b578..4191a17 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -199,6 +199,8 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
m = __import__(mname, globals(), locals(), ["__dummy__"])
m.__loader__ # to make sure we actually handled the import
+def test_main():
+ test_support.run_unittest(ImportHooksTestCase)
if __name__ == "__main__":
- test_support.run_unittest(ImportHooksTestCase)
+ test_main()
diff --git a/Lib/test/test_multifile.py b/Lib/test/test_multifile.py
index 6cb946f..cd89e5e 100644
--- a/Lib/test/test_multifile.py
+++ b/Lib/test/test_multifile.py
@@ -56,11 +56,11 @@ def getMIMEMsg(mf):
lines = mf.readlines()
linecount += len(lines)
-def main():
+def test_main():
f = cStringIO.StringIO(msg)
getMIMEMsg(multifile.MultiFile(f))
assert boundaries == 2
assert linecount == 9
if __name__ == '__main__':
- main()
+ test_main()
diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py
index 15e7e68..8f4c825 100644
--- a/Lib/test/test_netrc.py
+++ b/Lib/test/test_netrc.py
@@ -38,6 +38,8 @@ class NetrcTestCase(unittest.TestCase):
self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2'))
+def test_main():
+ test_support.run_unittest(NetrcTestCase)
if __name__ == "__main__":
- test_support.run_unittest(NetrcTestCase)
+ test_main()
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 2dc06ea..4a8edb8 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -231,7 +231,7 @@ if not gzip:
del WriteTestGzip
del WriteStreamTestGzip
-if __name__ == "__main__":
+def test_main():
if gzip:
# create testtar.tar.gz
gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read())
@@ -240,7 +240,26 @@ if __name__ == "__main__":
bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read())
try:
- unittest.main()
+ suite = unittest.TestSuite()
+
+ suite.addTest(unittest.makeSuite(ReadTest))
+ suite.addTest(unittest.makeSuite(ReadStreamTest))
+ suite.addTest(unittest.makeSuite(WriteTest))
+ suite.addTest(unittest.makeSuite(WriteStreamTest))
+
+ if gzip:
+ suite.addTest(unittest.makeSuite(ReadTestGzip))
+ suite.addTest(unittest.makeSuite(ReadStreamTestGzip))
+ suite.addTest(unittest.makeSuite(WriteTestGzip))
+ suite.addTest(unittest.makeSuite(WriteStreamTestGzip))
+
+ if bz2:
+ suite.addTest(unittest.makeSuite(ReadTestBzip2))
+ suite.addTest(unittest.makeSuite(ReadStreamTestBzip2))
+ suite.addTest(unittest.makeSuite(WriteTestBzip2))
+ suite.addTest(unittest.makeSuite(WriteStreamTestBzip2))
+
+ test_support.run_suite(suite)
finally:
if gzip:
os.remove(tarname("gz"))
@@ -251,3 +270,5 @@ if __name__ == "__main__":
if os.path.exists(tempname):
os.remove(tempname)
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index 65470d7..6510ca9 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -175,11 +175,11 @@ class TimeoutTestCase(unittest.TestCase):
pass
-def main():
+def test_main():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(CreationTestCase))
suite.addTest(unittest.makeSuite(TimeoutTestCase))
test_support.run_suite(suite)
if __name__ == "__main__":
- main()
+ test_main()