mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Change the PyUnit-based tests to use the test_main() approach. This
allows using the tests with unittest.py as a script. The tests will still run when run as a script themselves.
This commit is contained in:
@@ -42,4 +42,9 @@ class BinHexTestCase(unittest.TestCase):
|
||||
self.assertEqual(self.DATA, finish)
|
||||
|
||||
|
||||
test_support.run_unittest(BinHexTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(BinHexTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -320,4 +320,9 @@ self.assertEqual(Rat(1, 2) * 3.0, 1.5)
|
||||
self.assertEqual(eval('1/2'), 0.5)
|
||||
"""
|
||||
|
||||
test_support.run_unittest(RatTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(RatTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -122,4 +122,10 @@ class CFunctionCalls(unittest.TestCase):
|
||||
def test_oldargs1_2_kw(self):
|
||||
self.assertRaises(TypeError, {}.update, x=2, y=2)
|
||||
|
||||
run_unittest(CFunctionCalls)
|
||||
|
||||
def test_main():
|
||||
run_unittest(CFunctionCalls)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -22,4 +22,10 @@ class UTF16Test(unittest.TestCase):
|
||||
f = reader(s)
|
||||
self.assertEquals(f.read(), u"spamspam")
|
||||
|
||||
test_support.run_unittest(UTF16Test)
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(UTF16Test)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -87,4 +87,10 @@ class CodeopTests(unittest.TestCase):
|
||||
self.assertNotEquals(compile_command("a = 1\n", "abc").co_filename,
|
||||
compile("a = 1\n", "def", 'single').co_filename)
|
||||
|
||||
run_unittest(CodeopTests)
|
||||
|
||||
def test_main():
|
||||
run_unittest(CodeopTests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -42,4 +42,10 @@ class CommandTests(unittest.TestCase):
|
||||
|
||||
self.assert_(re.match(pat, getstatus("/bin/ls"), re.VERBOSE))
|
||||
|
||||
run_unittest(CommandTests)
|
||||
|
||||
def test_main():
|
||||
run_unittest(CommandTests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -22,4 +22,9 @@ class CopyRegTestCase(unittest.TestCase):
|
||||
type(1), int, "not a callable")
|
||||
|
||||
|
||||
test_support.run_unittest(CopyRegTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(CopyRegTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -65,4 +65,10 @@ class DircacheTests(unittest.TestCase):
|
||||
dircache.annotate(self.tempdir, lst)
|
||||
self.assertEquals(lst, ['A/', 'test2', 'test_nonexistent'])
|
||||
|
||||
run_unittest(DircacheTests)
|
||||
|
||||
def test_main():
|
||||
run_unittest(DircacheTests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -53,4 +53,9 @@ class DOSPathTestCase(unittest.TestCase):
|
||||
self.assertEquals(splitdrive("c:"), ('c:', ''))
|
||||
|
||||
|
||||
test_support.run_unittest(DOSPathTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(DOSPathTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -38,4 +38,9 @@ class FnmatchTestCase(unittest.TestCase):
|
||||
check('\\', r'[!\]', 0)
|
||||
|
||||
|
||||
test_support.run_unittest(FnmatchTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(FnmatchTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -66,4 +66,10 @@ class FpformatTest(unittest.TestCase):
|
||||
else:
|
||||
self.fail("No exception on non-numeric sci")
|
||||
|
||||
run_unittest(FpformatTest)
|
||||
|
||||
def test_main():
|
||||
run_unittest(FpformatTest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -106,4 +106,10 @@ class GlobTests(unittest.TestCase):
|
||||
eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'),
|
||||
os.path.join('aab', 'F')]))
|
||||
|
||||
run_unittest(GlobTests)
|
||||
|
||||
def test_main():
|
||||
run_unittest(GlobTests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -19,4 +19,9 @@ class GroupDatabaseTestCase(unittest.TestCase):
|
||||
entry = grp.getgrnam(self.groups[0][0])
|
||||
|
||||
|
||||
test_support.run_unittest(GroupDatabaseTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(GroupDatabaseTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -28,4 +28,9 @@ class HashEqualityTestCase(unittest.TestCase):
|
||||
self.same_hash(float(0.5), complex(0.5, 0.0))
|
||||
|
||||
|
||||
test_support.run_unittest(HashEqualityTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(HashEqualityTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -694,4 +694,10 @@ class TestCase(unittest.TestCase):
|
||||
(a, b), (c,) = IteratingSequenceClass(2), {42: 24}
|
||||
self.assertEqual((a, b, c), (0, 1, 42))
|
||||
|
||||
run_unittest(TestCase)
|
||||
|
||||
def test_main():
|
||||
run_unittest(TestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -96,4 +96,9 @@ class MaildirTestCase(unittest.TestCase):
|
||||
# XXX We still need more tests!
|
||||
|
||||
|
||||
test_support.run_unittest(MaildirTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(MaildirTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -331,4 +331,10 @@ class MhlibTests(unittest.TestCase):
|
||||
msg.fp.close()
|
||||
del msg
|
||||
|
||||
run_unittest(MhlibTests)
|
||||
|
||||
def test_main():
|
||||
run_unittest(MhlibTests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -39,4 +39,9 @@ class MimeTypesTestCase(unittest.TestCase):
|
||||
".pyunit")
|
||||
|
||||
|
||||
test_support.run_unittest(MimeTypesTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(MimeTypesTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -210,4 +210,9 @@ class OperatorTestCase(unittest.TestCase):
|
||||
self.failUnless(operator.xor(0xb, 0xc) == 0x7)
|
||||
|
||||
|
||||
test_support.run_unittest(OperatorTestCase)
|
||||
def test_main():
|
||||
test_support.run_unittest(OperatorTestCase)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
@@ -62,5 +62,9 @@ class TemporaryFileTests(unittest.TestCase):
|
||||
self.check_tempfile(os.tmpnam())
|
||||
|
||||
|
||||
def test_main():
|
||||
run_unittest(TemporaryFileTests)
|
||||
|
||||
run_unittest(TemporaryFileTests)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user