summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-02-17 14:51:41 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-02-17 14:51:41 (GMT)
commit996acf122dbf8d9aa694a16a32ced065f5805cd2 (patch)
treeed565bdce871aff987c7918e7ae1f405d995a468
parent9e5d87fa2018a48921d0452850a1d2f0b9fafb1e (diff)
downloadcpython-996acf122dbf8d9aa694a16a32ced065f5805cd2.zip
cpython-996acf122dbf8d9aa694a16a32ced065f5805cd2.tar.gz
cpython-996acf122dbf8d9aa694a16a32ced065f5805cd2.tar.bz2
Actually run these tests from regrtest.py.
There was no test_main() and the main body was protected by if __name__ == '__main__' so the test didn't happen on import either.
-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()