Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10)

Side by Side Diff: Lib/test/test_bigmem.py

Issue 20547: Use specific asserts in bigmem tests
Patch Set: Created 3 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Bigmem tests - tests for the 32-bit boundary in containers. 1 """Bigmem tests - tests for the 32-bit boundary in containers.
2 2
3 These tests try to exercise the 32-bit boundary that is sometimes, if 3 These tests try to exercise the 32-bit boundary that is sometimes, if
4 rarely, exceeded in practice, but almost never tested. They are really only 4 rarely, exceeded in practice, but almost never tested. They are really only
5 meaningful on 64-bit builds on machines with a *lot* of memory, but the 5 meaningful on 64-bit builds on machines with a *lot* of memory, but the
6 tests are always run, usually with very low memory limits to make sure the 6 tests are always run, usually with very low memory limits to make sure the
7 tests themselves don't suffer from bitrot. To run them for real, pass a 7 tests themselves don't suffer from bitrot. To run them for real, pass a
8 high memory limit to regrtest, with the -M option. 8 high memory limit to regrtest, with the -M option.
9 """ 9 """
10 10
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 self.assertTrue(5 in t) 858 self.assertTrue(5 in t)
859 self.assertFalse((1, 2, 3, 4, 5) in t) 859 self.assertFalse((1, 2, 3, 4, 5) in t)
860 self.assertFalse(0 in t) 860 self.assertFalse(0 in t)
861 861
862 @bigmemtest(size=_2G + 10, memuse=8) 862 @bigmemtest(size=_2G + 10, memuse=8)
863 def test_hash(self, size): 863 def test_hash(self, size):
864 t1 = (0,) * size 864 t1 = (0,) * size
865 h1 = hash(t1) 865 h1 = hash(t1)
866 del t1 866 del t1
867 t2 = (0,) * (size + 1) 867 t2 = (0,) * (size + 1)
868 self.assertFalse(h1 == hash(t2)) 868 self.assertNotEqual(h1, hash(t2))
869 869
870 @bigmemtest(size=_2G + 10, memuse=8) 870 @bigmemtest(size=_2G + 10, memuse=8)
871 def test_index_and_slice(self, size): 871 def test_index_and_slice(self, size):
872 t = (None,) * size 872 t = (None,) * size
873 self.assertEqual(len(t), size) 873 self.assertEqual(len(t), size)
874 self.assertEqual(t[-1], None) 874 self.assertEqual(t[-1], None)
875 self.assertEqual(t[5], None) 875 self.assertEqual(t[5], None)
876 self.assertEqual(t[size - 1], None) 876 self.assertEqual(t[size - 1], None)
877 self.assertRaises(IndexError, operator.getitem, t, size) 877 self.assertRaises(IndexError, operator.getitem, t, size)
878 self.assertEqual(t[:5], (None,) * 5) 878 self.assertEqual(t[:5], (None,) * 5)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 return self.basic_test_concat(size) 984 return self.basic_test_concat(size)
985 985
986 @bigmemtest(size=_2G + 2, memuse=24) 986 @bigmemtest(size=_2G + 2, memuse=24)
987 def test_concat_large(self, size): 987 def test_concat_large(self, size):
988 return self.basic_test_concat(size) 988 return self.basic_test_concat(size)
989 989
990 def basic_test_inplace_concat(self, size): 990 def basic_test_inplace_concat(self, size):
991 l = [sys.stdout] * size 991 l = [sys.stdout] * size
992 l += l 992 l += l
993 self.assertEqual(len(l), size * 2) 993 self.assertEqual(len(l), size * 2)
994 self.assertTrue(l[0] is l[-1]) 994 self.assertIs(l[0], l[-1])
995 self.assertTrue(l[size - 1] is l[size + 1]) 995 self.assertIs(l[size - 1], l[size + 1])
996 996
997 @bigmemtest(size=_2G // 2 + 2, memuse=24) 997 @bigmemtest(size=_2G // 2 + 2, memuse=24)
998 def test_inplace_concat_small(self, size): 998 def test_inplace_concat_small(self, size):
999 return self.basic_test_inplace_concat(size) 999 return self.basic_test_inplace_concat(size)
1000 1000
1001 @bigmemtest(size=_2G + 2, memuse=24) 1001 @bigmemtest(size=_2G + 2, memuse=24)
1002 def test_inplace_concat_large(self, size): 1002 def test_inplace_concat_large(self, size):
1003 return self.basic_test_inplace_concat(size) 1003 return self.basic_test_inplace_concat(size)
1004 1004
1005 @bigmemtest(size=_2G // 5 + 10, memuse=8 * 5) 1005 @bigmemtest(size=_2G // 5 + 10, memuse=8 * 5)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 return self.basic_test_repeat(size) 1084 return self.basic_test_repeat(size)
1085 1085
1086 @bigmemtest(size=_2G + 2, memuse=24) 1086 @bigmemtest(size=_2G + 2, memuse=24)
1087 def test_repeat_large(self, size): 1087 def test_repeat_large(self, size):
1088 return self.basic_test_repeat(size) 1088 return self.basic_test_repeat(size)
1089 1089
1090 def basic_test_inplace_repeat(self, size): 1090 def basic_test_inplace_repeat(self, size):
1091 l = [''] 1091 l = ['']
1092 l *= size 1092 l *= size
1093 self.assertEqual(len(l), size) 1093 self.assertEqual(len(l), size)
1094 self.assertTrue(l[0] is l[-1]) 1094 self.assertIs(l[0], l[-1])
1095 del l 1095 del l
1096 1096
1097 l = [''] * size 1097 l = [''] * size
1098 l *= 2 1098 l *= 2
1099 self.assertEqual(len(l), size * 2) 1099 self.assertEqual(len(l), size * 2)
1100 self.assertTrue(l[size - 1] is l[-1]) 1100 self.assertIs(l[size - 1], l[-1])
1101 1101
1102 @bigmemtest(size=_2G // 2 + 2, memuse=16) 1102 @bigmemtest(size=_2G // 2 + 2, memuse=16)
1103 def test_inplace_repeat_small(self, size): 1103 def test_inplace_repeat_small(self, size):
1104 return self.basic_test_inplace_repeat(size) 1104 return self.basic_test_inplace_repeat(size)
1105 1105
1106 @bigmemtest(size=_2G + 2, memuse=16) 1106 @bigmemtest(size=_2G + 2, memuse=16)
1107 def test_inplace_repeat_large(self, size): 1107 def test_inplace_repeat_large(self, size):
1108 return self.basic_test_inplace_repeat(size) 1108 return self.basic_test_inplace_repeat(size)
1109 1109
1110 def basic_test_repr(self, size): 1110 def basic_test_repr(self, size):
(...skipping 13 matching lines...) Expand all
1124 def test_repr_large(self, size): 1124 def test_repr_large(self, size):
1125 return self.basic_test_repr(size) 1125 return self.basic_test_repr(size)
1126 1126
1127 # list overallocates ~1/8th of the total size (on first expansion) so 1127 # list overallocates ~1/8th of the total size (on first expansion) so
1128 # the single list.append call puts memuse at 9 bytes per size. 1128 # the single list.append call puts memuse at 9 bytes per size.
1129 @bigmemtest(size=_2G, memuse=9) 1129 @bigmemtest(size=_2G, memuse=9)
1130 def test_append(self, size): 1130 def test_append(self, size):
1131 l = [object()] * size 1131 l = [object()] * size
1132 l.append(object()) 1132 l.append(object())
1133 self.assertEqual(len(l), size+1) 1133 self.assertEqual(len(l), size+1)
1134 self.assertTrue(l[-3] is l[-2]) 1134 self.assertIs(l[-3], l[-2])
1135 self.assertFalse(l[-2] is l[-1]) 1135 self.assertIsNot(l[-2], l[-1])
1136 1136
1137 @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5) 1137 @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
1138 def test_count(self, size): 1138 def test_count(self, size):
1139 l = [1, 2, 3, 4, 5] * size 1139 l = [1, 2, 3, 4, 5] * size
1140 self.assertEqual(l.count(1), size) 1140 self.assertEqual(l.count(1), size)
1141 self.assertEqual(l.count("1"), 0) 1141 self.assertEqual(l.count("1"), 0)
1142 1142
1143 def basic_test_extend(self, size): 1143 def basic_test_extend(self, size):
1144 l = [object] * size 1144 l = [object] * size
1145 l.extend(l) 1145 l.extend(l)
1146 self.assertEqual(len(l), size * 2) 1146 self.assertEqual(len(l), size * 2)
1147 self.assertTrue(l[0] is l[-1]) 1147 self.assertIs(l[0], l[-1])
1148 self.assertTrue(l[size - 1] is l[size + 1]) 1148 self.assertIs(l[size - 1], l[size + 1])
1149 1149
1150 @bigmemtest(size=_2G // 2 + 2, memuse=16) 1150 @bigmemtest(size=_2G // 2 + 2, memuse=16)
1151 def test_extend_small(self, size): 1151 def test_extend_small(self, size):
1152 return self.basic_test_extend(size) 1152 return self.basic_test_extend(size)
1153 1153
1154 @bigmemtest(size=_2G + 2, memuse=16) 1154 @bigmemtest(size=_2G + 2, memuse=16)
1155 def test_extend_large(self, size): 1155 def test_extend_large(self, size):
1156 return self.basic_test_extend(size) 1156 return self.basic_test_extend(size)
1157 1157
1158 @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5) 1158 @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 self.assertEqual(l[-10:], [5] * 10) 1247 self.assertEqual(l[-10:], [5] * 10)
1248 1248
1249 def test_main(): 1249 def test_main():
1250 support.run_unittest(StrTest, BytesTest, BytearrayTest, 1250 support.run_unittest(StrTest, BytesTest, BytearrayTest,
1251 TupleTest, ListTest) 1251 TupleTest, ListTest)
1252 1252
1253 if __name__ == '__main__': 1253 if __name__ == '__main__':
1254 if len(sys.argv) > 1: 1254 if len(sys.argv) > 1:
1255 support.set_memlimit(sys.argv[1]) 1255 support.set_memlimit(sys.argv[1])
1256 test_main() 1256 test_main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+