0001 import unittest 0002 from test import test_support, list_tests 0003 0004 class ListTest(list_tests.CommonTest): 0005 type2test = list 0006 0007 def test_truth(self): 0008 super(ListTest, self).test_truth() 0009 self.assert_(not []) 0010 self.assert_([42]) 0011 0012 def test_identity(self): 0013 self.assert_([] is not []) 0014 0015 def test_len(self): 0016 super(ListTest, self).test_len() 0017 self.assertEqual(len([]), 0) 0018 self.assertEqual(len([0]), 1) 0019 self.assertEqual(len([0, 1, 2]), 3) 0020 0021 def test_main(verbose=None): 0022 test_support.run_unittest(ListTest) 0023 0024 # verify reference counting 0025 import sys 0026 if verbose and hasattr(sys, "gettotalrefcount"): 0027 import gc 0028 counts = [None] * 5 0029 for i in xrange(len(counts)): 0030 test_support.run_unittest(ListTest) 0031 gc.collect() 0032 counts[i] = sys.gettotalrefcount() 0033 print counts 0034 0035 0036 if __name__ == "__main__": 0037 test_main(verbose=True) 0038
Generated by PyXR 0.9.4