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

Delta Between Two Patch Sets: Lib/test/test_bigmem.py

Issue 20547: Use specific asserts in bigmem tests
Left Patch Set: Created 6 years, 3 months ago
Right Patch Set: Created 3 years, 2 months 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 from test import support 11 from test import support
12 from test.support import bigmemtest, _1G, _2G, _4G 12 from test.support import bigmemtest, _1G, _2G, _4G
13 13
14 import unittest 14 import unittest
15 import operator 15 import operator
16 import sys 16 import sys
17 import functools
18 17
19 # These tests all use one of the bigmemtest decorators to indicate how much 18 # These tests all use one of the bigmemtest decorators to indicate how much
20 # memory they use and how much memory they need to be even meaningful. The 19 # memory they use and how much memory they need to be even meaningful. The
21 # decorators take two arguments: a 'memuse' indicator declaring 20 # decorators take two arguments: a 'memuse' indicator declaring
22 # (approximate) bytes per size-unit the test will use (at peak usage), and a 21 # (approximate) bytes per size-unit the test will use (at peak usage), and a
23 # 'minsize' indicator declaring a minimum *useful* size. A test that 22 # 'minsize' indicator declaring a minimum *useful* size. A test that
24 # allocates a bytestring to test various operations near the end will have a 23 # allocates a bytestring to test various operations near the end will have a
25 # minsize of at least 2Gb (or it wouldn't reach the 32-bit limit, so the 24 # minsize of at least 2Gb (or it wouldn't reach the 32-bit limit, so the
26 # test wouldn't be very useful) and a memuse of 1 (one byte per size-unit, 25 # test wouldn't be very useful) and a memuse of 1 (one byte per size-unit,
27 # if it allocates only one big string at a time.) 26 # if it allocates only one big string at a time.)
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 s = char * size 729 s = char * size
731 try: 730 try:
732 for f in (repr, ascii): 731 for f in (repr, ascii):
733 r = f(s) 732 r = f(s)
734 self.assertEqual(len(r), 2 + (len(f(char)) - 2) * size) 733 self.assertEqual(len(r), 2 + (len(f(char)) - 2) * size)
735 self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:]) 734 self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:])
736 r = None 735 r = None
737 finally: 736 finally:
738 r = s = None 737 r = s = None
739 738
740 # The original test_translate is overriden here, so as to get the 739 # The original test_translate is overridden here, so as to get the
741 # correct size estimate: str.translate() uses an intermediate Py_UCS4 740 # correct size estimate: str.translate() uses an intermediate Py_UCS4
742 # representation. 741 # representation.
743 742
744 @bigmemtest(size=_2G, memuse=ascii_char_size * 2 + ucs4_char_size) 743 @bigmemtest(size=_2G, memuse=ascii_char_size * 2 + ucs4_char_size)
745 def test_translate(self, size): 744 def test_translate(self, size):
746 _ = self.from_latin1 745 _ = self.from_latin1
747 SUBSTR = _('aZz.z.Aaz.') 746 SUBSTR = _('aZz.z.Aaz.')
748 trans = { 747 trans = {
749 ord(_('.')): _('-'), 748 ord(_('.')): _('-'),
750 ord(_('a')): _('!'), 749 ord(_('a')): _('!'),
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 self.assertEqual(l[-10:], [5] * 10) 1247 self.assertEqual(l[-10:], [5] * 10)
1249 1248
1250 def test_main(): 1249 def test_main():
1251 support.run_unittest(StrTest, BytesTest, BytearrayTest, 1250 support.run_unittest(StrTest, BytesTest, BytearrayTest,
1252 TupleTest, ListTest) 1251 TupleTest, ListTest)
1253 1252
1254 if __name__ == '__main__': 1253 if __name__ == '__main__':
1255 if len(sys.argv) > 1: 1254 if len(sys.argv) > 1:
1256 support.set_memlimit(sys.argv[1]) 1255 support.set_memlimit(sys.argv[1])
1257 test_main() 1256 test_main()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

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