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

## Delta Between Two Patch Sets: Lib/test/test_sys.py

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 7 years, 9 months ago
Right Patch Set: Created 7 years, 7 months ago
 Left: Base Patch Set 1: None Patch Set 2: None Patch Set 3: None Patch Set 4: None Patch Set 5: None Right: Patch Set 1: None Patch Set 2: None Patch Set 3: None Patch Set 4: None Patch Set 5: None
« no previous file with change/comment | « Lib/test/test_pep380.py ('k') | Misc/ACKS » ('j') | Modules/parsermodule.c » ('J')
LEFTRIGHT
1 import unittest, test.support 1 import unittest, test.support
2 import sys, io, os 2 import sys, io, os
3 import struct 3 import struct
4 import subprocess 4 import subprocess
5 import textwrap 5 import textwrap
6 import warnings 6 import warnings
7 import operator 7 import operator
8 import codecs 8 import codecs
9 9
10 # count the number of test runs, used to create unique 10 # count the number of test runs, used to create unique
(...skipping 652 matching lines...)
663 x = 42 663 x = 42
664 def inner(): 664 def inner():
665 return x 665 return x
666 return inner 666 return inner
667 check(get_cell().__closure__[0], size(h + 'P')) 667 check(get_cell().__closure__[0], size(h + 'P'))
668 # code 668 # code
669 check(get_cell().__code__, size(h + '5i9Pi3P')) 669 check(get_cell().__code__, size(h + '5i9Pi3P'))
670 # complex 670 # complex
671 check(complex(0,1), size(h + '2d')) 671 check(complex(0,1), size(h + '2d'))
672 # method_descriptor (descriptor object) 672 # method_descriptor (descriptor object)
673 check(str.lower, size(h + '2PP')) 673 check(str.lower, size(h + '3PP'))
674 # classmethod_descriptor (descriptor object) 674 # classmethod_descriptor (descriptor object)
675 # XXX 675 # XXX
676 # member_descriptor (descriptor object) 676 # member_descriptor (descriptor object)
677 import datetime 677 import datetime
678 check(datetime.timedelta.days, size(h + '2PP')) 678 check(datetime.timedelta.days, size(h + '3PP'))
679 # getset_descriptor (descriptor object) 679 # getset_descriptor (descriptor object)
680 import collections 680 import collections
681 check(collections.defaultdict.default_factory, size(h + '2PP')) 681 check(collections.defaultdict.default_factory, size(h + '3PP'))
682 # wrapper_descriptor (descriptor object) 682 # wrapper_descriptor (descriptor object)
684 # method-wrapper (descriptor object) 684 # method-wrapper (descriptor object)
685 check({}.__iter__, size(h + '2P')) 685 check({}.__iter__, size(h + '2P'))
686 # dict 686 # dict
687 check({}, size(h + '3P2P' + 8*'P2P')) 687 check({}, size(h + '3P2P' + 8*'P2P'))
688 longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8} 688 longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8}
689 check(longdict, size(h + '3P2P' + 8*'P2P') + 16*size('P2P')) 689 check(longdict, size(h + '3P2P' + 8*'P2P') + 16*size('P2P'))
690 # dictionary-keyiterator 690 # dictionary-keyiterator
691 check({}.keys(), size(h + 'P')) 691 check({}.keys(), size(h + 'P'))
692 # dictionary-valueiterator 692 # dictionary-valueiterator
693 check({}.values(), size(h + 'P')) 693 check({}.values(), size(h + 'P'))
(...skipping 29 matching lines...) Expand all
723 import inspect 723 import inspect
724 CO_MAXBLOCKS = 20 724 CO_MAXBLOCKS = 20
725 x = inspect.currentframe() 725 x = inspect.currentframe()
726 ncells = len(x.f_code.co_cellvars) 726 ncells = len(x.f_code.co_cellvars)
727 nfrees = len(x.f_code.co_freevars) 727 nfrees = len(x.f_code.co_freevars)
728 extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\ 728 extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\
729 ncells + nfrees - 1 729 ncells + nfrees - 1
730 check(x, size(vh + '13P3i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P')) 730 check(x, size(vh + '13P3i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P'))
731 # function 731 # function
732 def func(): pass 732 def func(): pass
733 check(func, size(h + '11P')) 733 check(func, size(h + '12P'))
734 class c(): 734 class c():
735 @staticmethod 735 @staticmethod
736 def foo(): 736 def foo():
737 pass 737 pass
738 @classmethod 738 @classmethod
739 def bar(cls): 739 def bar(cls):
740 pass 740 pass
741 # staticmethod 741 # staticmethod
742 check(foo, size(h + 'P')) 742 check(foo, size(h + 'P'))
743 # classmethod 743 # classmethod
(...skipping 19 matching lines...) Expand all
763 # listreverseiterator (list) 763 # listreverseiterator (list)
764 check(reversed([]), size(h + 'lP')) 764 check(reversed([]), size(h + 'lP'))
765 # long 765 # long
766 check(0, size(vh)) 766 check(0, size(vh))
767 check(1, size(vh) + self.longdigit) 767 check(1, size(vh) + self.longdigit)
768 check(-1, size(vh) + self.longdigit) 768 check(-1, size(vh) + self.longdigit)
769 PyLong_BASE = 2**sys.int_info.bits_per_digit 769 PyLong_BASE = 2**sys.int_info.bits_per_digit
770 check(int(PyLong_BASE), size(vh) + 2*self.longdigit) 770 check(int(PyLong_BASE), size(vh) + 2*self.longdigit)
771 check(int(PyLong_BASE**2-1), size(vh) + 2*self.longdigit) 771 check(int(PyLong_BASE**2-1), size(vh) + 2*self.longdigit)
772 check(int(PyLong_BASE**2), size(vh) + 3*self.longdigit) 772 check(int(PyLong_BASE**2), size(vh) + 3*self.longdigit)
773 # memory 773 # memory (Py_buffer + hash value)
774 check(memoryview(b''), size(h + 'PP2P2i7P')) 774 check(memoryview(b''), size(h + 'PP2P2i7P' + 'P'))
775 # module 775 # module
776 check(unittest, size(h + '3P')) 776 check(unittest, size(h + '3P'))
777 # None 777 # None
778 check(None, size(h + '')) 778 check(None, size(h + ''))
779 # NotImplementedType 779 # NotImplementedType
780 check(NotImplemented, size(h)) 780 check(NotImplemented, size(h))
781 # object 781 # object
782 check(object(), size(h + '')) 782 check(object(), size(h + ''))
783 # property (descriptor object) 783 # property (descriptor object)
784 class C(object): 784 class C(object):
(...skipping 36 matching lines...)
821 # slice 821 # slice
822 check(slice(0), size(h + '3P')) 822 check(slice(0), size(h + '3P'))
823 # super 823 # super
824 check(super(int), size(h + '3P')) 824 check(super(int), size(h + '3P'))
825 # tuple 825 # tuple
826 check((), size(vh)) 826 check((), size(vh))
827 check((1,2,3), size(vh) + 3*self.P) 827 check((1,2,3), size(vh) + 3*self.P)
828 # type 828 # type
829 # (PyTypeObject + PyNumberMethods + PyMappingMethods + 829 # (PyTypeObject + PyNumberMethods + PyMappingMethods +
830 # PySequenceMethods + PyBufferProcs) 830 # PySequenceMethods + PyBufferProcs)
831 s = size(vh + 'P2P15Pl4PP9PP11PI') + size('16Pi17P 3P 10P 2P 2P') 831 s = size(vh + 'P2P15Pl4PP9PP11PI') + size('16Pi17P 3P 10P 2P 3P')
832 check(int, s) 832 check(int, s)
833 # class 833 # class
834 class newstyleclass(object): pass 834 class newstyleclass(object): pass
835 check(newstyleclass, s) 835 check(newstyleclass, s)
836 # unicode 836 # unicode
837 # each tuple contains a string and its expected character size 837 # each tuple contains a string and its expected character size
838 # don't put any static strings here, as they may contain 838 # don't put any static strings here, as they may contain
839 # wchar_t or UTF-8 representations 839 # wchar_t or UTF-8 representations
840 samples = ['1'*100, '\xff'*50, 840 samples = ['1'*100, '\xff'*50,
841 '\u0100'*40, '\uffff'*100, 841 '\u0100'*40, '\uffff'*100,
(...skipping 52 matching lines...)
894 # XXX 894 # XXX
895 # sys.flags 895 # sys.flags
896 check(sys.flags, size(vh) + self.P * len(sys.flags)) 896 check(sys.flags, size(vh) + self.P * len(sys.flags))
897 897
898 898
899 def test_main(): 899 def test_main():
900 test.support.run_unittest(SysModuleTest, SizeofTest) 900 test.support.run_unittest(SysModuleTest, SizeofTest)
901 901
902 if __name__ == "__main__": 902 if __name__ == "__main__":
903 test_main() 903 test_main()
LEFTRIGHT

This is Rietveld 894c83f36cb7+