path
stringlengths
14
112
content
stringlengths
0
6.32M
size
int64
0
6.32M
max_lines
int64
1
100k
repo_name
stringclasses
2 values
autogenerated
bool
1 class
cosmopolitan/third_party/python/Lib/test/test_keywordonlyarg.py
"""Unit tests for the keyword only argument specified in PEP 3102.""" __author__ = "Jiwon Seo" __email__ = "seojiwon at gmail dot com" import unittest def posonly_sum(pos_arg1, *arg, **kwarg): return pos_arg1 + sum(arg) + sum(kwarg.values()) def keywordonly_sum(*, k1=0, k2): return k1 + k2 def keywordonly_nodefaults_sum(*, k1, k2): return k1 + k2 def keywordonly_and_kwarg_sum(*, k1, k2, **kwarg): return k1 + k2 + sum(kwarg.values()) def mixedargs_sum(a, b=0, *arg, k1, k2=0): return a + b + k1 + k2 + sum(arg) def mixedargs_sum2(a, b=0, *arg, k1, k2=0, **kwargs): return a + b + k1 + k2 + sum(arg) + sum(kwargs.values()) def sortnum(*nums, reverse=False): return sorted(list(nums), reverse=reverse) def sortwords(*words, reverse=False, **kwargs): return sorted(list(words), reverse=reverse) class Foo: def __init__(self, *, k1, k2=0): self.k1 = k1 self.k2 = k2 def set(self, p1, *, k1, k2): self.k1 = k1 self.k2 = k2 def sum(self): return self.k1 + self.k2 class KeywordOnlyArgTestCase(unittest.TestCase): def assertRaisesSyntaxError(self, codestr): def shouldRaiseSyntaxError(s): compile(s, "<test>", "single") self.assertRaises(SyntaxError, shouldRaiseSyntaxError, codestr) def testSyntaxErrorForFunctionDefinition(self): self.assertRaisesSyntaxError("def f(p, *):\n pass\n") self.assertRaisesSyntaxError("def f(p1, *, p1=100):\n pass\n") self.assertRaisesSyntaxError("def f(p1, *k1, k1=100):\n pass\n") self.assertRaisesSyntaxError("def f(p1, *, k1, k1=100):\n pass\n") self.assertRaisesSyntaxError("def f(p1, *, **k1):\n pass\n") self.assertRaisesSyntaxError("def f(p1, *, k1, **k1):\n pass\n") self.assertRaisesSyntaxError("def f(p1, *, None, **k1):\n pass\n") self.assertRaisesSyntaxError("def f(p, *, (k1, k2), **kw):\n pass\n") def testSyntaxForManyArguments(self): fundef = "def f(" for i in range(255): fundef += "i%d, "%i fundef += "*, key=100):\n pass\n" self.assertRaisesSyntaxError(fundef) fundef2 = "def foo(i,*," for i in range(255): fundef2 += "i%d, "%i fundef2 += "lastarg):\n pass\n" self.assertRaisesSyntaxError(fundef2) # exactly 255 arguments, should compile ok fundef3 = "def f(i,*," for i in range(253): fundef3 += "i%d, "%i fundef3 += "lastarg):\n pass\n" compile(fundef3, "<test>", "single") def testTooManyPositionalErrorMessage(self): def f(a, b=None, *, c=None): pass with self.assertRaises(TypeError) as exc: f(1, 2, 3) expected = "f() takes from 1 to 2 positional arguments but 3 were given" self.assertEqual(str(exc.exception), expected) def testSyntaxErrorForFunctionCall(self): self.assertRaisesSyntaxError("f(p, k=1, p2)") self.assertRaisesSyntaxError("f(p, k1=50, *(1,2), k1=100)") def testRaiseErrorFuncallWithUnexpectedKeywordArgument(self): self.assertRaises(TypeError, keywordonly_sum, ()) self.assertRaises(TypeError, keywordonly_nodefaults_sum, ()) self.assertRaises(TypeError, Foo, ()) try: keywordonly_sum(k2=100, non_existing_arg=200) self.fail("should raise TypeError") except TypeError: pass try: keywordonly_nodefaults_sum(k2=2) self.fail("should raise TypeError") except TypeError: pass def testFunctionCall(self): self.assertEqual(1, posonly_sum(1)) self.assertEqual(1+2, posonly_sum(1,**{"2":2})) self.assertEqual(1+2+3, posonly_sum(1,*(2,3))) self.assertEqual(1+2+3+4, posonly_sum(1,*(2,3),**{"4":4})) self.assertEqual(1, keywordonly_sum(k2=1)) self.assertEqual(1+2, keywordonly_sum(k1=1, k2=2)) self.assertEqual(1+2, keywordonly_and_kwarg_sum(k1=1, k2=2)) self.assertEqual(1+2+3, keywordonly_and_kwarg_sum(k1=1, k2=2, k3=3)) self.assertEqual(1+2+3+4, keywordonly_and_kwarg_sum(k1=1, k2=2, **{"a":3,"b":4})) self.assertEqual(1+2, mixedargs_sum(1, k1=2)) self.assertEqual(1+2+3, mixedargs_sum(1, 2, k1=3)) self.assertEqual(1+2+3+4, mixedargs_sum(1, 2, k1=3, k2=4)) self.assertEqual(1+2+3+4+5, mixedargs_sum(1, 2, 3, k1=4, k2=5)) self.assertEqual(1+2, mixedargs_sum2(1, k1=2)) self.assertEqual(1+2+3, mixedargs_sum2(1, 2, k1=3)) self.assertEqual(1+2+3+4, mixedargs_sum2(1, 2, k1=3, k2=4)) self.assertEqual(1+2+3+4+5, mixedargs_sum2(1, 2, 3, k1=4, k2=5)) self.assertEqual(1+2+3+4+5+6, mixedargs_sum2(1, 2, 3, k1=4, k2=5, k3=6)) self.assertEqual(1+2+3+4+5+6, mixedargs_sum2(1, 2, 3, k1=4, **{'k2':5, 'k3':6})) self.assertEqual(1, Foo(k1=1).sum()) self.assertEqual(1+2, Foo(k1=1,k2=2).sum()) self.assertEqual([1,2,3], sortnum(3,2,1)) self.assertEqual([3,2,1], sortnum(1,2,3, reverse=True)) self.assertEqual(['a','b','c'], sortwords('a','c','b')) self.assertEqual(['c','b','a'], sortwords('a','c','b', reverse=True)) self.assertEqual(['c','b','a'], sortwords('a','c','b', reverse=True, ignore='ignore')) def testKwDefaults(self): def foo(p1,p2=0, *, k1, k2=0): return p1 + p2 + k1 + k2 self.assertEqual(2, foo.__code__.co_kwonlyargcount) self.assertEqual({"k2":0}, foo.__kwdefaults__) foo.__kwdefaults__ = {"k1":0} try: foo(1,k1=10) self.fail("__kwdefaults__ is not properly changed") except TypeError: pass def test_kwonly_methods(self): class Example: def f(self, *, k1=1, k2=2): return k1, k2 self.assertEqual(Example().f(k1=1, k2=2), (1, 2)) self.assertEqual(Example.f(Example(), k1=1, k2=2), (1, 2)) self.assertRaises(TypeError, Example.f, k1=1, k2=2) def test_issue13343(self): # The Python compiler must scan all symbols of a function to # determine their scope: global, local, cell... # This was not done for the default values of keyword # arguments in a lambda definition, and the following line # used to fail with a SystemError. lambda *, k1=unittest: None def test_mangling(self): class X: def f(self, *, __a=42): return __a self.assertEqual(X().f(), 42) def test_default_evaluation_order(self): # See issue 16967 a = 42 with self.assertRaises(NameError) as err: def f(v=a, x=b, *, y=c, z=d): pass self.assertEqual(str(err.exception), "name 'b' is not defined") with self.assertRaises(NameError) as err: f = lambda v=a, x=b, *, y=c, z=d: None self.assertEqual(str(err.exception), "name 'b' is not defined") if __name__ == "__main__": unittest.main()
7,218
190
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_format.py
from test.support import verbose, TestFailed import locale import sys import test.support as support import unittest maxsize = support.MAX_Py_ssize_t # test string formatting operator (I am not sure if this is being tested # elsewhere but, surely, some of the given cases are *not* tested because # they crash python) # test on bytes object as well def testformat(formatstr, args, output=None, limit=None, overflowok=False): if verbose: if output: print("{!a} % {!a} =? {!a} ...".format(formatstr, args, output), end=' ') else: print("{!a} % {!a} works? ...".format(formatstr, args), end=' ') try: result = formatstr % args except OverflowError: if not overflowok: raise if verbose: print('overflow (this is fine)') else: if output and limit is None and result != output: if verbose: print('no') raise AssertionError("%r %% %r == %r != %r" % (formatstr, args, result, output)) # when 'limit' is specified, it determines how many characters # must match exactly; lengths must always match. # ex: limit=5, '12345678' matches '12345___' # (mainly for floating point format tests for which an exact match # can't be guaranteed due to rounding and representation errors) elif output and limit is not None and ( len(result)!=len(output) or result[:limit]!=output[:limit]): if verbose: print('no') print("%s %% %s == %s != %s" % \ (repr(formatstr), repr(args), repr(result), repr(output))) else: if verbose: print('yes') def testcommon(formatstr, args, output=None, limit=None, overflowok=False): # if formatstr is a str, test str, bytes, and bytearray; # otherwise, test bytes and bytearry if isinstance(formatstr, str): testformat(formatstr, args, output, limit, overflowok) b_format = formatstr.encode('ascii') else: b_format = formatstr ba_format = bytearray(b_format) b_args = [] if not isinstance(args, tuple): args = (args, ) b_args = tuple(args) if output is None: b_output = ba_output = None else: if isinstance(output, str): b_output = output.encode('ascii') else: b_output = output ba_output = bytearray(b_output) testformat(b_format, b_args, b_output, limit, overflowok) testformat(ba_format, b_args, ba_output, limit, overflowok) class FormatTest(unittest.TestCase): def test_common_format(self): # test the format identifiers that work the same across # str, bytes, and bytearrays (integer, float, oct, hex) testcommon("%.1d", (1,), "1") testcommon("%.*d", (sys.maxsize,1), overflowok=True) # expect overflow testcommon("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok=True) testcommon("%#.117x", (1,), '0x00000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '0000000000000000000000000001', overflowok=True) testcommon("%#.118x", (1,), '0x00000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000000000000000000000000001', overflowok=True) testcommon("%f", (1.0,), "1.000000") # these are trying to test the limits of the internal magic-number-length # formatting buffer, if that number changes then these tests are less # effective testcommon("%#.*g", (109, -1.e+49/3.)) testcommon("%#.*g", (110, -1.e+49/3.)) testcommon("%#.*g", (110, -1.e+100/3.)) # test some ridiculously large precision, expect overflow testcommon('%12.*f', (123456, 1.0)) # check for internal overflow validation on length of precision # these tests should no longer cause overflow in Python # 2.7/3.1 and later. testcommon("%#.*g", (110, -1.e+100/3.)) testcommon("%#.*G", (110, -1.e+100/3.)) testcommon("%#.*f", (110, -1.e+100/3.)) testcommon("%#.*F", (110, -1.e+100/3.)) # Formatting of integers. Overflow is not ok testcommon("%x", 10, "a") testcommon("%x", 100000000000, "174876e800") testcommon("%o", 10, "12") testcommon("%o", 100000000000, "1351035564000") testcommon("%d", 10, "10") testcommon("%d", 100000000000, "100000000000") big = 123456789012345678901234567890 testcommon("%d", big, "123456789012345678901234567890") testcommon("%d", -big, "-123456789012345678901234567890") testcommon("%5d", -big, "-123456789012345678901234567890") testcommon("%31d", -big, "-123456789012345678901234567890") testcommon("%32d", -big, " -123456789012345678901234567890") testcommon("%-32d", -big, "-123456789012345678901234567890 ") testcommon("%032d", -big, "-0123456789012345678901234567890") testcommon("%-032d", -big, "-123456789012345678901234567890 ") testcommon("%034d", -big, "-000123456789012345678901234567890") testcommon("%034d", big, "0000123456789012345678901234567890") testcommon("%0+34d", big, "+000123456789012345678901234567890") testcommon("%+34d", big, " +123456789012345678901234567890") testcommon("%34d", big, " 123456789012345678901234567890") testcommon("%.2d", big, "123456789012345678901234567890") testcommon("%.30d", big, "123456789012345678901234567890") testcommon("%.31d", big, "0123456789012345678901234567890") testcommon("%32.31d", big, " 0123456789012345678901234567890") testcommon("%d", float(big), "123456________________________", 6) big = 0x1234567890abcdef12345 # 21 hex digits testcommon("%x", big, "1234567890abcdef12345") testcommon("%x", -big, "-1234567890abcdef12345") testcommon("%5x", -big, "-1234567890abcdef12345") testcommon("%22x", -big, "-1234567890abcdef12345") testcommon("%23x", -big, " -1234567890abcdef12345") testcommon("%-23x", -big, "-1234567890abcdef12345 ") testcommon("%023x", -big, "-01234567890abcdef12345") testcommon("%-023x", -big, "-1234567890abcdef12345 ") testcommon("%025x", -big, "-0001234567890abcdef12345") testcommon("%025x", big, "00001234567890abcdef12345") testcommon("%0+25x", big, "+0001234567890abcdef12345") testcommon("%+25x", big, " +1234567890abcdef12345") testcommon("%25x", big, " 1234567890abcdef12345") testcommon("%.2x", big, "1234567890abcdef12345") testcommon("%.21x", big, "1234567890abcdef12345") testcommon("%.22x", big, "01234567890abcdef12345") testcommon("%23.22x", big, " 01234567890abcdef12345") testcommon("%-23.22x", big, "01234567890abcdef12345 ") testcommon("%X", big, "1234567890ABCDEF12345") testcommon("%#X", big, "0X1234567890ABCDEF12345") testcommon("%#x", big, "0x1234567890abcdef12345") testcommon("%#x", -big, "-0x1234567890abcdef12345") testcommon("%#27x", big, " 0x1234567890abcdef12345") testcommon("%#-27x", big, "0x1234567890abcdef12345 ") testcommon("%#027x", big, "0x00001234567890abcdef12345") testcommon("%#.23x", big, "0x001234567890abcdef12345") testcommon("%#.23x", -big, "-0x001234567890abcdef12345") testcommon("%#27.23x", big, " 0x001234567890abcdef12345") testcommon("%#-27.23x", big, "0x001234567890abcdef12345 ") testcommon("%#027.23x", big, "0x00001234567890abcdef12345") testcommon("%#+.23x", big, "+0x001234567890abcdef12345") testcommon("%# .23x", big, " 0x001234567890abcdef12345") testcommon("%#+.23X", big, "+0X001234567890ABCDEF12345") # next one gets two leading zeroes from precision, and another from the # 0 flag and the width testcommon("%#+027.23X", big, "+0X0001234567890ABCDEF12345") testcommon("%# 027.23X", big, " 0X0001234567890ABCDEF12345") # same, except no 0 flag testcommon("%#+27.23X", big, " +0X001234567890ABCDEF12345") testcommon("%#-+27.23x", big, "+0x001234567890abcdef12345 ") testcommon("%#- 27.23x", big, " 0x001234567890abcdef12345 ") big = 0o12345670123456701234567012345670 # 32 octal digits testcommon("%o", big, "12345670123456701234567012345670") testcommon("%o", -big, "-12345670123456701234567012345670") testcommon("%5o", -big, "-12345670123456701234567012345670") testcommon("%33o", -big, "-12345670123456701234567012345670") testcommon("%34o", -big, " -12345670123456701234567012345670") testcommon("%-34o", -big, "-12345670123456701234567012345670 ") testcommon("%034o", -big, "-012345670123456701234567012345670") testcommon("%-034o", -big, "-12345670123456701234567012345670 ") testcommon("%036o", -big, "-00012345670123456701234567012345670") testcommon("%036o", big, "000012345670123456701234567012345670") testcommon("%0+36o", big, "+00012345670123456701234567012345670") testcommon("%+36o", big, " +12345670123456701234567012345670") testcommon("%36o", big, " 12345670123456701234567012345670") testcommon("%.2o", big, "12345670123456701234567012345670") testcommon("%.32o", big, "12345670123456701234567012345670") testcommon("%.33o", big, "012345670123456701234567012345670") testcommon("%34.33o", big, " 012345670123456701234567012345670") testcommon("%-34.33o", big, "012345670123456701234567012345670 ") testcommon("%o", big, "12345670123456701234567012345670") testcommon("%#o", big, "0o12345670123456701234567012345670") testcommon("%#o", -big, "-0o12345670123456701234567012345670") testcommon("%#38o", big, " 0o12345670123456701234567012345670") testcommon("%#-38o", big, "0o12345670123456701234567012345670 ") testcommon("%#038o", big, "0o000012345670123456701234567012345670") testcommon("%#.34o", big, "0o0012345670123456701234567012345670") testcommon("%#.34o", -big, "-0o0012345670123456701234567012345670") testcommon("%#38.34o", big, " 0o0012345670123456701234567012345670") testcommon("%#-38.34o", big, "0o0012345670123456701234567012345670 ") testcommon("%#038.34o", big, "0o000012345670123456701234567012345670") testcommon("%#+.34o", big, "+0o0012345670123456701234567012345670") testcommon("%# .34o", big, " 0o0012345670123456701234567012345670") testcommon("%#+38.34o", big, " +0o0012345670123456701234567012345670") testcommon("%#-+38.34o", big, "+0o0012345670123456701234567012345670 ") testcommon("%#- 38.34o", big, " 0o0012345670123456701234567012345670 ") testcommon("%#+038.34o", big, "+0o00012345670123456701234567012345670") testcommon("%# 038.34o", big, " 0o00012345670123456701234567012345670") # next one gets one leading zero from precision testcommon("%.33o", big, "012345670123456701234567012345670") # base marker added in spite of leading zero (different to Python 2) testcommon("%#.33o", big, "0o012345670123456701234567012345670") # reduce precision, and base marker is always added testcommon("%#.32o", big, "0o12345670123456701234567012345670") # one leading zero from precision, plus two from "0" flag & width testcommon("%035.33o", big, "00012345670123456701234567012345670") # base marker shouldn't change the size testcommon("%0#35.33o", big, "0o012345670123456701234567012345670") # Some small ints, in both Python int and flavors). testcommon("%d", 42, "42") testcommon("%d", -42, "-42") testcommon("%d", 42.0, "42") testcommon("%#x", 1, "0x1") testcommon("%#X", 1, "0X1") testcommon("%#o", 1, "0o1") testcommon("%#o", 0, "0o0") testcommon("%o", 0, "0") testcommon("%d", 0, "0") testcommon("%#x", 0, "0x0") testcommon("%#X", 0, "0X0") testcommon("%x", 0x42, "42") testcommon("%x", -0x42, "-42") testcommon("%o", 0o42, "42") testcommon("%o", -0o42, "-42") # alternate float formatting testcommon('%g', 1.1, '1.1') testcommon('%#g', 1.1, '1.10000') def test_str_format(self): testformat("%r", "\u0378", "'\\u0378'") # non printable testformat("%a", "\u0378", "'\\u0378'") # non printable testformat("%r", "\u0374", "'\u0374'") # printable testformat("%a", "\u0374", "'\\u0374'") # printable # Test exception for unknown format characters, etc. if verbose: print('Testing exceptions') def test_exc(formatstr, args, exception, excmsg): try: testformat(formatstr, args) except exception as exc: if str(exc) == excmsg: if verbose: print("yes") else: if verbose: print('no') print('Unexpected ', exception, ':', repr(str(exc))) except: if verbose: print('no') print('Unexpected exception') raise else: raise TestFailed('did not get expected exception: %s' % excmsg) test_exc('abc %b', 1, ValueError, "unsupported format character 'b' (0x62) at index 5") #test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError, # "unsupported format character '?' (0x3000) at index 5") test_exc('%d', '1', TypeError, "%d format: a number is required, not str") test_exc('%x', '1', TypeError, "%x format: an integer is required, not str") test_exc('%x', 3.14, TypeError, "%x format: an integer is required, not float") test_exc('%g', '1', TypeError, "must be real number, not str") test_exc('no format', '1', TypeError, "not all arguments converted during string formatting") test_exc('%c', -1, OverflowError, "%c arg not in range(0x110000)") test_exc('%c', sys.maxunicode+1, OverflowError, "%c arg not in range(0x110000)") #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)") test_exc('%c', 3.14, TypeError, "%c requires int or char") test_exc('%c', 'ab', TypeError, "%c requires int or char") test_exc('%c', b'x', TypeError, "%c requires int or char") if maxsize == 2**31-1: # crashes 2.2.1 and earlier: try: "%*d"%(maxsize, -127) except MemoryError: pass else: raise TestFailed('"%*d"%(maxsize, -127) should fail') def test_bytes_and_bytearray_format(self): # %c will insert a single byte, either from an int in range(256), or # from a bytes argument of length 1, not from a str. testcommon(b"%c", 7, b"\x07") testcommon(b"%c", b"Z", b"Z") testcommon(b"%c", bytearray(b"Z"), b"Z") testcommon(b"%5c", 65, b" A") testcommon(b"%-5c", 65, b"A ") # %b will insert a series of bytes, either from a type that supports # the Py_buffer protocol, or something that has a __bytes__ method class FakeBytes(object): def __bytes__(self): return b'123' fb = FakeBytes() testcommon(b"%b", b"abc", b"abc") testcommon(b"%b", bytearray(b"def"), b"def") testcommon(b"%b", fb, b"123") testcommon(b"%b", memoryview(b"abc"), b"abc") # # %s is an alias for %b -- should only be used for Py2/3 code testcommon(b"%s", b"abc", b"abc") testcommon(b"%s", bytearray(b"def"), b"def") testcommon(b"%s", fb, b"123") testcommon(b"%s", memoryview(b"abc"), b"abc") # %a will give the equivalent of # repr(some_obj).encode('ascii', 'backslashreplace') testcommon(b"%a", 3.14, b"3.14") testcommon(b"%a", b"ghi", b"b'ghi'") testcommon(b"%a", "jkl", b"'jkl'") testcommon(b"%a", "\u0544", b"'\\u0544'") # %r is an alias for %a testcommon(b"%r", 3.14, b"3.14") testcommon(b"%r", b"ghi", b"b'ghi'") testcommon(b"%r", "jkl", b"'jkl'") testcommon(b"%r", "\u0544", b"'\\u0544'") # Test exception for unknown format characters, etc. if verbose: print('Testing exceptions') def test_exc(formatstr, args, exception, excmsg): try: testformat(formatstr, args) except exception as exc: if str(exc) == excmsg: if verbose: print("yes") else: if verbose: print('no') print('Unexpected ', exception, ':', repr(str(exc))) except: if verbose: print('no') print('Unexpected exception') raise else: raise TestFailed('did not get expected exception: %s' % excmsg) test_exc(b'%d', '1', TypeError, "%d format: a number is required, not str") test_exc(b'%d', b'1', TypeError, "%d format: a number is required, not bytes") test_exc(b'%x', 3.14, TypeError, "%x format: an integer is required, not float") test_exc(b'%g', '1', TypeError, "float argument required, not str") test_exc(b'%g', b'1', TypeError, "float argument required, not bytes") test_exc(b'no format', 7, TypeError, "not all arguments converted during bytes formatting") test_exc(b'no format', b'1', TypeError, "not all arguments converted during bytes formatting") test_exc(b'no format', bytearray(b'1'), TypeError, "not all arguments converted during bytes formatting") test_exc(b"%c", -1, OverflowError, "%c arg not in range(256)") test_exc(b"%c", 256, OverflowError, "%c arg not in range(256)") test_exc(b"%c", 2**128, OverflowError, "%c arg not in range(256)") test_exc(b"%c", b"Za", TypeError, "%c requires an integer in range(256) or a single byte") test_exc(b"%c", "Y", TypeError, "%c requires an integer in range(256) or a single byte") test_exc(b"%c", 3.14, TypeError, "%c requires an integer in range(256) or a single byte") test_exc(b"%b", "Xc", TypeError, "%b requires a bytes-like object, " "or an object that implements __bytes__, not 'str'") test_exc(b"%s", "Wd", TypeError, "%b requires a bytes-like object, " "or an object that implements __bytes__, not 'str'") if maxsize == 2**31-1: # crashes 2.2.1 and earlier: try: "%*d"%(maxsize, -127) except MemoryError: pass else: raise TestFailed('"%*d"%(maxsize, -127) should fail') def test_nul(self): # test the null character testcommon("a\0b", (), 'a\0b') testcommon("a%cb", (0,), 'a\0b') testformat("a%sb", ('c\0d',), 'ac\0db') testcommon(b"a%sb", (b'c\0d',), b'ac\0db') def test_non_ascii(self): testformat("\u20ac=%f", (1.0,), "\u20ac=1.000000") self.assertEqual(format("abc", "\u2007<5"), "abc\u2007\u2007") self.assertEqual(format(123, "\u2007<5"), "123\u2007\u2007") self.assertEqual(format(12.3, "\u2007<6"), "12.3\u2007\u2007") self.assertEqual(format(0j, "\u2007<4"), "0j\u2007\u2007") self.assertEqual(format(1+2j, "\u2007<8"), "(1+2j)\u2007\u2007") self.assertEqual(format("abc", "\u2007>5"), "\u2007\u2007abc") self.assertEqual(format(123, "\u2007>5"), "\u2007\u2007123") self.assertEqual(format(12.3, "\u2007>6"), "\u2007\u200712.3") self.assertEqual(format(1+2j, "\u2007>8"), "\u2007\u2007(1+2j)") self.assertEqual(format(0j, "\u2007>4"), "\u2007\u20070j") self.assertEqual(format("abc", "\u2007^5"), "\u2007abc\u2007") self.assertEqual(format(123, "\u2007^5"), "\u2007123\u2007") self.assertEqual(format(12.3, "\u2007^6"), "\u200712.3\u2007") self.assertEqual(format(1+2j, "\u2007^8"), "\u2007(1+2j)\u2007") self.assertEqual(format(0j, "\u2007^4"), "\u20070j\u2007") def test_locale(self): try: oldloc = locale.setlocale(locale.LC_ALL) locale.setlocale(locale.LC_ALL, '') except locale.Error as err: self.skipTest("Cannot set locale: {}".format(err)) try: localeconv = locale.localeconv() sep = localeconv['thousands_sep'] point = localeconv['decimal_point'] text = format(123456789, "n") self.assertIn(sep, text) self.assertEqual(text.replace(sep, ''), '123456789') text = format(1234.5, "n") self.assertIn(sep, text) self.assertIn(point, text) self.assertEqual(text.replace(sep, ''), '1234' + point + '5') finally: locale.setlocale(locale.LC_ALL, oldloc) @support.cpython_only def test_optimisations(self): text = "abcde" # 5 characters self.assertIs("%s" % text, text) self.assertIs("%.5s" % text, text) self.assertIs("%.10s" % text, text) self.assertIs("%1s" % text, text) self.assertIs("%5s" % text, text) self.assertIs("{0}".format(text), text) self.assertIs("{0:s}".format(text), text) self.assertIs("{0:.5s}".format(text), text) self.assertIs("{0:.10s}".format(text), text) self.assertIs("{0:1s}".format(text), text) self.assertIs("{0:5s}".format(text), text) self.assertIs(text % (), text) self.assertIs(text.format(), text) def test_precision(self): f = 1.2 self.assertEqual(format(f, ".0f"), "1") self.assertEqual(format(f, ".3f"), "1.200") with self.assertRaises(ValueError) as cm: format(f, ".%sf" % (sys.maxsize + 1)) c = complex(f) self.assertEqual(format(c, ".0f"), "1+0j") self.assertEqual(format(c, ".3f"), "1.200+0.000j") with self.assertRaises(ValueError) as cm: format(c, ".%sf" % (sys.maxsize + 1)) @support.cpython_only def test_precision_c_limits(self): from _testcapi import INT_MAX f = 1.2 with self.assertRaises(ValueError) as cm: format(f, ".%sf" % (INT_MAX + 1)) c = complex(f) with self.assertRaises(ValueError) as cm: format(c, ".%sf" % (INT_MAX + 1)) if __name__ == "__main__": unittest.main()
23,384
495
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/pstats.pck
{(u'/home/gbr/devel/python/Lib/sre_parse.pyiƒu __getitem__(i5i5g‹à+Ù±Q?g˶Óֈ`\?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(iigðh㈵øÔ>gíµ ÷Æà>(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i†i†gà iTàd;?g›6ã4DE?(u)/home/gbr/devel/python/Lib/sre_compile.pyicu_simple(irirg?«Ì”Öß?ghUMu?(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(iÛiÛgSb.äA?g§"Æ‚L?(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(i\i\g„¹ÝË}r?gŸqá@H?0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyipu_check_alias_dict(iigðh㈵øÔ>gðh㈵øÔ>{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiuset_negative_aliases(iigTäqs*É>gTäqs*É>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyizu set_aliases(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiDu__init__(iig,Cëâ6ú>g,Cëâ6ú>{(u'/home/gbr/devel/python/Lib/sre_parse.pyiªuparse(iig,Cëâ6ú>g,Cëâ6ú>0(u&/home/gbr/devel/python/Lib/tokenize.pyi—uStopTokenizing(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u&/home/gbr/devel/python/Lib/tokenize.pyi7uany(iigíµ ÷ư>gTäqs*É>{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigíµ ÷ư>gTäqs*É>0(u~iu!<method 'split' of 'str' objects>(iig?«Ì”Ößâ>g?«Ì”Ößâ>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u'/home/gbr/devel/python/Lib/posixpath.pyiJunormpath(iigTäqs*É>gTäqs*É>(usetup.pyiumain(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u+/home/gbr/devel/python/Lib/distutils/log.pyiuLog(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u*/home/gbr/devel/python/Lib/configparser.pyióu NoOptionError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiMuDistutilsByteCompileError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u'/home/gbr/devel/python/Lib/sysconfig.pyi>uget_config_var(iigTäqs*É>gíµ ÷Æà>{(usetup.pyiÇuPyBuildInstallLib(iigTäqs*É>gíµ ÷Æà>0(u$/home/gbr/devel/python/Lib/getopt.pyiu<module>(iig·_>Y1\Ý>gfLÁgÓ?{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi u<module>(iig·_>Y1\Ý>gfLÁgÓ?0(u'/home/gbr/devel/python/Lib/posixpath.pyiJunormpath(iig¢&ú|”÷>gùœ»]/M?{(u'/home/gbr/devel/python/Lib/posixpath.pyiouabspath(iigðh㈵øÔ>gíµ ÷Æà>(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi u<module>(iigfLÁgÓñ>g,Cëâ6ú>0(u*/home/gbr/devel/python/Lib/configparser.pyiquRawConfigParser(iigðh㈵øô>góuþÓ t?{(u~iu!<built-in method __build_class__>(iigðh㈵øô>góuþÓ t?0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi¯utranslate_longopt(iig·_>Y1\í>gðh㈵ø?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyipu <listcomp>(iig·_>Y1\í>gðh㈵ø?0(u /home/gbr/devel/python/Lib/os.pyiêuencode(iig?«Ì”Ößò>g·_>Y1\ý>{(u /home/gbr/devel/python/Lib/os.pyi©u __getitem__(iig·_>Y1\í>g{…÷ø>(u /home/gbr/devel/python/Lib/os.pyi­u __setitem__(iigíµ ÷ÆÐ>gðh㈵øÔ>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyizu set_aliases(iigíµ ÷ư>gTäqs*É>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigíµ ÷ư>gTäqs*É>0(u;/home/gbr/devel/python/Lib/distutils/command/install_lib.pyiu<module>(iigTäqs*é>g]éEí~?{(usetup.pyiu<module>(iigTäqs*é>g]éEí~?0(u./home/gbr/devel/python/Lib/distutils/errors.pyi^u LinkError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u./home/gbr/devel/python/Lib/distutils/errors.pyiQuCCompilerError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u'/home/gbr/devel/python/Lib/posixpath.pyi&u_get_sep(i i g·_>Y1\Ý>g¢'eRCë>{(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iiggíµ ÷ư>(u'/home/gbr/devel/python/Lib/posixpath.pyiGujoin(iigíµ ÷ÆÀ>gíµ ÷ÆÐ>(u'/home/gbr/devel/python/Lib/posixpath.pyi=uisabs(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u'/home/gbr/devel/python/Lib/posixpath.pyiubasename(iigíµ ÷ư>gTäqs*É>(u'/home/gbr/devel/python/Lib/posixpath.pyiŠudirname(iigíµ ÷ÆÀ>gTäqs*É>0(u&/home/gbr/devel/python/Lib/tokenize.pyišu Untokenizer(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiuDistutilsClassError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiÐuget(i‘i‘g;ßO—nR?g_"Þ:ÿvy?{(u'/home/gbr/devel/python/Lib/sre_parse.pyiªuparse(iigíµ ÷Æð>gfLÁgÓ?(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i|i|g…Í®{+R?gǟ¨lXSy?0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiSu _build_index(iig¢&ú|”ç>gTäqs*é>{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi+u__init__(iig¢&ú|”ç>gTäqs*é>0(u1/home/gbr/devel/python/Lib/distutils/extension.pyimu <genexpr>(iigíµ ÷ư>gíµ ÷ư>{(u~iu<built-in method all>(iigíµ ÷ư>gíµ ÷ư>0(u~iu!<method 'rfind' of 'str' objects>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u'/home/gbr/devel/python/Lib/posixpath.pyiŠudirname(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u'/home/gbr/devel/python/Lib/posixpath.pyiubasename(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u,/home/gbr/devel/python/Lib/distutils/core.pyi"u gen_usage(iigTäqs*Ù>gTäqs*é>{(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iigTäqs*Ù>gTäqs*é>0(u~iu"<method 'format' of 'str' objects>(iigðh㈵øä>gðh㈵øä>{(u*/home/gbr/devel/python/Lib/configparser.pyiquRawConfigParser(iigðh㈵øä>gðh㈵øä>0(usetup.pyiumain(iigðh㈵øô>gáy©Ø˜×Q?{(usetup.pyiu<module>(iigðh㈵øô>gáy©Ø˜×Q?0(u)/home/gbr/devel/python/Lib/_weakrefset.pyiDu __contains__(iigíµ ÷Æà>gíµ ÷Æà>{(u!/home/gbr/devel/python/Lib/abc.pyižu__instancecheck__(iigíµ ÷Æà>gíµ ÷Æà>0(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(iiWgÐîb€DC?g¯Z™ðKýŒ?{(u'/home/gbr/devel/python/Lib/sre_parse.pyiªuparse(iig×3Âۃ?g¯Z™ðKýŒ?(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(iBigŒJê4A?gñՎâu„?0(u'/home/gbr/devel/python/Lib/sre_parse.pyièu _class_escape(i%i%g!>°ã¿@?g{…÷?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i%i%g!>°ã¿@?g{…÷?0(u./home/gbr/devel/python/Lib/distutils/errors.pyiuDistutilsModuleError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u,/home/gbr/devel/python/Lib/distutils/dist.pyi0ufind_config_files(iig¢'eRCë>g©MœÜïP$?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyiYuparse_config_files(iig¢'eRCë>g©MœÜïP$?0(u-/home/gbr/devel/python/Lib/distutils/spawn.pyiu<module>(iigd?‹¥H¾"?gd?‹¥H¾"?{(u,/home/gbr/devel/python/Lib/distutils/util.pyiu<module>(iigd?‹¥H¾"?gd?‹¥H¾"?0(u~iu.<method 'match' of '_sre.SRE_Pattern' objects>(iigÒûÆ×žY?gÒûÆ×žY?{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(iigÒûÆ×žY?gÒûÆ×žY?0(u'/home/gbr/devel/python/Lib/sre_parse.pyiÙuisident(i i gðh㈵øÔ>gðh㈵øÔ>{(u'/home/gbr/devel/python/Lib/sre_parse.pyißuisname(i i gðh㈵øÔ>gðh㈵øÔ>0(u%/home/gbr/devel/python/Lib/_abcoll.pyiìuupdate(iig ØFìó>gÕÌZ Hû?{(u)/home/gbr/devel/python/Lib/collections.pyi(u__init__(iig ØFìó>gÕÌZ Hû?0(u~iu#<method 'extend' of 'list' objects>(i&i&gðh㈵øä>gðh㈵øä>{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigíµ ÷ư>gíµ ÷ư>(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u)/home/gbr/devel/python/Lib/sre_compile.pyi²u_compile_charset(iig·_>Y1\Ý>g·_>Y1\Ý>0(u~iu<built-in method repr>(iigðh㈵øÔ>gðh㈵øÔ>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigðh㈵øÔ>gðh㈵øÔ>0(usetup.pyiu <listcomp>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(usetup.pyiumain(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u~iu<built-in method dir>(iig ØFìó>g ØFìó>{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iig ØFìó>g ØFìó>0(usetup.pyiÇuPyBuildInstallLib(iigíµ ÷ÆÐ>gTäqs*é>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÐ>gTäqs*é>0(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(ii7gÀÍâÅÂ`?gçqÌ_!ƒ?{(u)/home/gbr/devel/python/Lib/sre_compile.pyi×u_code(iig Ž’Wç(?gçqÌ_!ƒ?(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(i"i"g¾IÓ h^?gMc{-轁?0(u~iu<built-in method setattr>(i=i=gùœ»]/M?gùœ»]/M?{(u'/home/gbr/devel/python/Lib/functools.pyiuupdate_wrapper(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(i9i9g¾IÓ hþ>g¾IÓ hþ>0(u)/home/gbr/devel/python/Lib/sre_compile.pyiu_identityfunction(iig™ò!¨½?g™ò!¨½?{(u)/home/gbr/devel/python/Lib/sre_compile.pyi²u_compile_charset(i¼i¼gíµ ÷Æ?gíµ ÷Æ?(u)/home/gbr/devel/python/Lib/sre_compile.pyiÏu_optimize_charset(iTiTgÒûÆ×žY?gÒûÆ×žY?0(u~iu<built-in method issubclass>(iigíµ ÷ư>gíµ ÷ư>{(u&/home/gbr/devel/python/Lib/warnings.pyiufilterwarnings(iigíµ ÷ư>gíµ ÷ư>0(usetup.pyi’u PyBuildExt(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u)/home/gbr/devel/python/Lib/genericpath.pyiuisfile(iig·_>Y1\í>gTäqs* ?{(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi-u _python_build(iigðh㈵øÔ>g ØFìó>(u,/home/gbr/devel/python/Lib/distutils/dist.pyi0ufind_config_files(iig?«Ì”Ößâ>g¾IÓ hþ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyi!uDistutilsArgError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u*/home/gbr/devel/python/Lib/configparser.pyiØuDuplicateOptionError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u)/home/gbr/devel/python/Lib/collections.pyiu <genexpr>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u~iu <method 'join' of 'str' objects>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyi&uDistutilsFileError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u0/home/gbr/devel/python/Lib/distutils/dir_util.pyiu<module>(iig¢&ú|”ç>g¢&ú|”ç>{(u+/home/gbr/devel/python/Lib/distutils/cmd.pyiu<module>(iig¢&ú|”ç>g¢&ú|”ç>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyiàu__init__(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyipu <listcomp>(iig?«Ì”Ößâ>gÀ“.«° ?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu Distribution(iig?«Ì”Ößâ>gÀ“.«° ?0(u~iu"<method 'clear' of 'dict' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(iigíµ ÷ư>gíµ ÷ư>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiSu _build_index(iigíµ ÷ư>gíµ ÷ư>0(u~iu<built-in method ord>(i¡i¡gJ°8œùÕ ?gJ°8œùÕ ?{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiwu <dictcomp>(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i€i€g™ò!¨½ ?g™ò!¨½ ?(u'/home/gbr/devel/python/Lib/sre_parse.pyiu_escape(iigTäqs*É>gTäqs*É>(u'/home/gbr/devel/python/Lib/sre_parse.pyièu _class_escape(iigg0(u~iu<built-in method max>(i^i^g¢&ú|”÷>g¢&ú|”÷>{(u'/home/gbr/devel/python/Lib/sre_parse.pyiugetwidth(i^i^g¢&ú|”÷>g¢&ú|”÷>0(u+/home/gbr/devel/python/Lib/distutils/cmd.pyi›u install_misc(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u /home/gbr/devel/python/Lib/os.pyi­u __setitem__(iigíµ ÷ÆÐ>gTäqs*ù>{(u,/home/gbr/devel/python/Lib/distutils/util.pyiúu check_environ(iigíµ ÷ÆÐ>gTäqs*ù>0(u$/home/gbr/devel/python/Lib/getopt.pyi&u GetoptError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u%/home/gbr/devel/python/Lib/_abcoll.pyiju __contains__(iig·_>Y1\Ý>gfLÁgÓ?{(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigíµ ÷ÆÀ>g?«Ì”Ößâ>(u,/home/gbr/devel/python/Lib/distutils/util.pyiúu check_environ(iigðh㈵øÔ>g,Cëâ6ú>0(u~iu<built-in method _getframe>(iigíµ ÷ư>gíµ ÷ư>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ư>gíµ ÷ư>0(u~iu!<method 'strip' of 'str' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(usetup.pyiumain(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu Distribution(iighUMuï>gíµ ÷Æ?{(u~iu!<built-in method __build_class__>(iighUMuï>gíµ ÷Æ?0(u<string>iu<module>(iigTäqs*É>gç4 ´;¤?{(u~iu<built-in method exec>(iigTäqs*É>gç4 ´;¤?0(u&/home/gbr/devel/python/Lib/tokenize.pyiqu_compile(iigTäqs*Ù>g¾¢[¯é‘?{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigTäqs*Ù>g¾¢[¯é‘?0(u~iu#<method 'replace' of 'str' objects>(iig·_>Y1\Ý>g·_>Y1\Ý>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigTäqs*É>gTäqs*É>(u,/home/gbr/devel/python/Lib/distutils/util.pyiu get_platform(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyi uDistutilsError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiuDistutilsGetoptError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u$/home/gbr/devel/python/Lib/getopt.pyi3ugetopt(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiÔugetopt(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(ii–g¶Ov3£o?gTUh –ÍŒ?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(i–ig¶Ov3£o?gTUh –ÍŒ?0(u0/home/gbr/devel/python/Lib/distutils/dep_util.pyiu<module>(iig·_>Y1\Ý>g·_>Y1\Ý>{(u,/home/gbr/devel/python/Lib/distutils/util.pyiu<module>(iig·_>Y1\Ý>g·_>Y1\Ý>0(u&/home/gbr/devel/python/Lib/tokenize.pyi#u <listcomp>(iig¢&ú|”÷>g?«Ì”Öß?{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iig¢&ú|”÷>g?«Ì”Öß?0(u,/home/gbr/devel/python/Lib/distutils/dist.pyipuhandle_display_options(iig¢&ú|”ç>g¢&ú|”ç>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iig¢&ú|”ç>g¢&ú|”ç>0(u+/home/gbr/devel/python/Lib/distutils/log.pyiEu set_verbosity(iigVñFæ‘?(?g ÉÉÄ­‚(?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigVñFæ‘?(?g ÉÉÄ­‚(?0(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi-u _python_build(iigðh㈵øÔ>gíµ ÷Æ?{(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi u<module>(iigðh㈵øÔ>gíµ ÷Æ?0(u'/home/gbr/devel/python/Lib/sre_parse.pyiªuparse(iigCÅ8 !?g¢Busñ·?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiæucompile(iigCÅ8 !?g¢Busñ·?0(u+/home/gbr/devel/python/Lib/distutils/cmd.pyiu<module>(iig÷q4GV~9?g3ˆìø/@?{(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iig÷q4GV~9?g3ˆìø/@?0(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu<module>(iig1zn¡+A?gÍv…>XƖ?{(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iig1zn¡+A?gÍv…>XƖ?0(u~iu#<method 'isalnum' of 'str' objects>(iigðh㈵øÔ>gðh㈵øÔ>{(u)/home/gbr/devel/python/Lib/collections.pyiu <genexpr>(iigðh㈵øÔ>gðh㈵øÔ>0(u~iu$<method 'decode' of 'bytes' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u /home/gbr/devel/python/Lib/os.pyiîudecode(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiJuDistutilsTemplateError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u /home/gbr/devel/python/Lib/re.pyiu_compile_typed(iig Ž’Wç(?gA 3mÿʚ?{(u'/home/gbr/devel/python/Lib/functools.pyi†uwrapper(iig Ž’Wç(?gA 3mÿʚ?0(u./home/gbr/devel/python/Lib/distutils/config.pyiu<module>(iig·}úëF?g'H0ÕÌz?{(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iig·}úëF?g'H0ÕÌz?0(u'/home/gbr/devel/python/Lib/sre_parse.pyi‡u __setitem__(i‚i‚gç4 ´;¤?gç4 ´;¤?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i‚i‚gç4 ´;¤?gç4 ´;¤?0(u)/home/gbr/devel/python/Lib/sre_compile.pyiu _mk_bitmap(iig*T7ÛS?gšÏ¹ÛõÒT?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiÏu_optimize_charset(iig*T7ÛS?gšÏ¹ÛõÒT?0(u*/home/gbr/devel/python/Lib/configparser.pyi|u<module>(iig!>°ã¿@?gυ‘^Ôîw?{(u./home/gbr/devel/python/Lib/distutils/config.pyiu<module>(iig!>°ã¿@?gυ‘^Ôîw?0(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(iig©MœÜïP$?gÉ©ajK]?{(u)/home/gbr/devel/python/Lib/sre_compile.pyi×u_code(iig©MœÜïP$?gÉ©ajK]?0(u1/home/gbr/devel/python/Lib/distutils/extension.pyiu Extension(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u1/home/gbr/devel/python/Lib/distutils/extension.pyiYu__init__(iig?«Ì”Ößâ>g·_>Y1\í>{(usetup.pyiumain(iig?«Ì”Ößâ>g·_>Y1\í>0(u'/home/gbr/devel/python/Lib/posixpath.pyiouabspath(iigTäqs*É>ghUMuï>{(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi u<module>(iigTäqs*É>ghUMuï>0(u#/home/gbr/devel/python/Lib/token.pyiu<module>(iigÞ3ßÁO ?gJ°8œùÕ ?{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigÞ3ßÁO ?gJ°8œùÕ ?0(u~iu<built-in method stat>(iighUMuÿ>ghUMuÿ>{(u)/home/gbr/devel/python/Lib/genericpath.pyiuisfile(iighUMuÿ>ghUMuÿ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiZuLibError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u)/home/gbr/devel/python/Lib/sre_compile.pyiæucompile(iig?«Ì”Öß"?gӆÃÒÀš?{(u /home/gbr/devel/python/Lib/re.pyiu_compile_typed(iig?«Ì”Öß"?gӆÃÒÀš?0(usetup.pyi¿uPyBuildInstall(iigg{(u~iu!<built-in method __build_class__>(iigg0(u'/home/gbr/devel/python/Lib/sre_parse.pyi‹uappend(iƒiƒg²t±i¥0?gî[­—ã5?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i`i`g´RäG.?g ØFì3?(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(i#i#g{…÷ø>ghUMuÿ>0(u~iu<built-in method putenv>(iighUMuï>ghUMuï>{(u /home/gbr/devel/python/Lib/os.pyi­u __setitem__(iighUMuï>ghUMuï>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiTuPreprocessError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u~iu<built-in method isinstance>(i£i£gí ¾0™*X?gðÙ:8؛X?{(u'/home/gbr/devel/python/Lib/sre_parse.pyižu fix_flags(iigTäqs*É>gTäqs*É>(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigíµ ÷ư>gíµ ÷ư>(u&/home/gbr/devel/python/Lib/warnings.pyiufilterwarnings(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/sre_parse.pyiƒu __getitem__(i5i5guæB?guæB?(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyipu_check_alias_dict(iigg(u /home/gbr/devel/python/Lib/os.pyiêuencode(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u1/home/gbr/devel/python/Lib/distutils/extension.pyiYu__init__(iigíµ ÷ư>gíµ ÷ư>(u%/home/gbr/devel/python/Lib/_abcoll.pyiìuupdate(iig?«Ì”Ößâ>g?«Ì”Öß?(u'/home/gbr/devel/python/Lib/posixpath.pyi&u_get_sep(i i gTäqs*Ù>gTäqs*Ù>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(iig·_>Y1\Ý>g·_>Y1\Ý>(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigg(u1/home/gbr/devel/python/Lib/distutils/extension.pyimu <genexpr>(iigg(u)/home/gbr/devel/python/Lib/sre_compile.pyiÔuisstring(i*i*g¢&ú|”ç>g¢&ú|”ç>(u'/home/gbr/devel/python/Lib/sre_parse.pyi·u__next(iØiØgÕ[[%XL?gÕ[[%XL?(u,/home/gbr/devel/python/Lib/distutils/dist.pyi1ufinalize_options(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/posixpath.pyiJunormpath(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u /home/gbr/devel/python/Lib/re.pyiu_compile_typed(iig¢'eRCë>g¢'eRCë>0(u7/home/gbr/devel/python/Lib/distutils/command/install.pyiu<module>(iig{…÷?g ¼“Om?{(usetup.pyiu<module>(iig{…÷?g ¼“Om?0(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iig•µMñ¸¨V?g9 {ÚáŸ?{(usetup.pyiu<module>(iig•µMñ¸¨V?g9 {ÚáŸ?0(u~iu"<method 'items' of 'dict' objects>(iigTäqs*É>gTäqs*É>{(u)/home/gbr/devel/python/Lib/sre_compile.pyiæucompile(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(iigg(u#/home/gbr/devel/python/Lib/token.pyiu<module>(iigg(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyipu_check_alias_dict(iigg(u%/home/gbr/devel/python/Lib/_abcoll.pyiìuupdate(iigíµ ÷ư>gíµ ÷ư>0(u,/home/gbr/devel/python/Lib/distutils/util.pyiu get_platform(iigfLÁgÓñ>gÒûÆ×žY?{(u,/home/gbr/devel/python/Lib/distutils/util.pyiúu check_environ(iigTäqs*Ù>gTäqs*é>(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyi)u build_ext(iig¢&ú|”ç>g{…÷ø>0(u~iu<built-in method exec>(iigîêUdt@B?góÿª#G:£?{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iiguæB?ga2U0*©C?0(u"/home/gbr/devel/python/Lib/stat.pyi1uS_ISREG(iigíµ ÷ÆÀ>gíµ ÷ÆÐ>{(u)/home/gbr/devel/python/Lib/genericpath.pyiuisfile(iigíµ ÷ÆÀ>gíµ ÷ÆÐ>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiju get_attr_name(iigfLÁgÓñ>gJ°8œùÕ ?{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(iigfLÁgÓñ>gJ°8œùÕ ?0(u~iu<built-in method len>(iÓigfLÁgÓQ?g,amŒðR?{(u'/home/gbr/devel/python/Lib/functools.pyi†uwrapper(iigTäqs*É>gTäqs*É>(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(i~i~gËÔ$xC%?gËÔ$xC%?(u'/home/gbr/devel/python/Lib/sre_parse.pyiu_escape(iigðh㈵øÔ>gðh㈵øÔ>(u'/home/gbr/devel/python/Lib/sre_parse.pyiu__len__(iýiýgˆÓI¶ºœ?gˆÓI¶ºœ?(u1/home/gbr/devel/python/Lib/distutils/extension.pyiYu__init__(iigg(u%/home/gbr/devel/python/Lib/_abcoll.pyiìuupdate(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigg(u'/home/gbr/devel/python/Lib/posixpath.pyiŠudirname(iigg(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(i:i:gTäqs*é>gTäqs*é>(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/sre_parse.pyièu _class_escape(iigg(u)/home/gbr/devel/python/Lib/sre_compile.pyiÏu_optimize_charset(i*i*g¢&ú|”?g¢&ú|”?(u'/home/gbr/devel/python/Lib/sre_parse.pyi·u__next(i3i3g ¨lXSYD?g ¨lXSYD?(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(irirg”ص½Ý’?g{…÷(?(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(i?i?gTäqs*é>g·_>Y1\í>(u)/home/gbr/devel/python/Lib/collections.pyi(u__init__(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(i~i~gç4 ´;¤?gíµ ÷Æ?0(u'/home/gbr/devel/python/Lib/posixpath.pyiŠudirname(iig¢&ú|”ç>g?«Ì”Ößò>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi0ufind_config_files(iigíµ ÷ÆÐ>g·_>Y1\Ý>(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi u<module>(iig·_>Y1\Ý>g¢&ú|”ç>0(u~iu <maketrans>(iigíµ ÷ư>gíµ ÷ư>{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi u<module>(iigíµ ÷ư>gíµ ÷ư>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi u<module>(iig5wô¿\‹&?g4)Ý^ÒX?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu<module>(iig5wô¿\‹&?g4)Ý^ÒX?0(u~iu#<method 'isdigit' of 'str' objects>(iigg{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigg0(u8/home/gbr/devel/python/Lib/distutils/command/__init__.pyiu<module>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(usetup.pyiu<module>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u&/home/gbr/devel/python/Lib/tokenize.pyi•u TokenError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u*/home/gbr/devel/python/Lib/configparser.pyi]u ConfigParser(iigíµ ÷ÆÐ>gâ8ðj¹33?{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÐ>gâ8ðj¹33?0(u'/home/gbr/devel/python/Lib/posixpath.pyi=uisabs(iigíµ ÷ư>gíµ ÷ÆÐ>{(u'/home/gbr/devel/python/Lib/posixpath.pyiouabspath(iigíµ ÷ư>gíµ ÷ÆÐ>0(u~iu<built-in method allocate_lock>(iigíµ ÷ư>gíµ ÷ư>{(u'/home/gbr/devel/python/Lib/functools.pyi~udecorating_function(iigíµ ÷ư>gíµ ÷ư>0(u~iu!<built-in method __build_class__>(i;i;goӟýHY?gӁ¬§V_}?{(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyiu<module>(iig¾IÓ hþ>gíµ ÷Æ?(u*/home/gbr/devel/python/Lib/configparser.pyi|u<module>(iig1]ˆÕa8?gR%ÊÞRÎw?(u+/home/gbr/devel/python/Lib/distutils/cmd.pyiu<module>(iigJ°8œùÕ ?gCÅ8 ?(u;/home/gbr/devel/python/Lib/distutils/command/install_lib.pyiu<module>(iig¢'eRCû>g¾IÓ hþ>(u1/home/gbr/devel/python/Lib/distutils/extension.pyiu<module>(iig«ZÒQf?g ØFì?(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu<module>(iigrQ-"ŠÉ ?g×3Âۃ ?(u./home/gbr/devel/python/Lib/distutils/errors.pyi u<module>(iigî=\rÜ)=?gH£'ÛÀ=?(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iig”ص½Ý’?gm7Á7MŸ?(u<string>iu<module>(iighUMuÿ>g¢&ú|”?(u1/home/gbr/devel/python/Lib/distutils/text_file.pyiu<module>(iig ØFì?g¢&ú|”?(u&/home/gbr/devel/python/Lib/warnings.pyiu<module>(iig$Dù‚?g?«Ì”Öß?(u,/home/gbr/devel/python/Lib/distutils/util.pyiu<module>(iigÞ3ßÁOü>g¾IÓ hþ>(u+/home/gbr/devel/python/Lib/distutils/log.pyiu<module>(iigfLÁgÓ?g?«Ì”Öß?(u7/home/gbr/devel/python/Lib/distutils/command/install.pyiu<module>(iig ØFì?g™ò!¨½ ?(u$/home/gbr/devel/python/Lib/getopt.pyiu<module>(iig¢'eRCû>gÞ3ßÁOü>(u./home/gbr/devel/python/Lib/distutils/config.pyiu<module>(iig¢&ú|”÷>g¢'eRCû>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi u<module>(iigTäqs* ?grQ-"ŠÉ ?(usetup.pyiu<module>(iig?«Ì”Öß?g¢&ú|”?0(u*/home/gbr/devel/python/Lib/configparser.pyi uInterpolationDepthError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u~iu <method 'get' of 'dict' objects>(iÚiÚgümOØî?gümOØî?{(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(i i gíµ ÷ÆÀ>gíµ ÷ÆÀ>(u'/home/gbr/devel/python/Lib/sre_parse.pyiu_escape(ijijg·_>Y1\ý>g·_>Y1\ý>(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iigíµ ÷ư>gíµ ÷ư>(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(iigg(u'/home/gbr/devel/python/Lib/sre_parse.pyiIu opengroup(iigíµ ÷ư>gíµ ÷ư>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(i3i3g¢&ú|”ç>g¢&ú|”ç>(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigg(u'/home/gbr/devel/python/Lib/sre_parse.pyièu _class_escape(i(i(ghUMuï>ghUMuï>(u'/home/gbr/devel/python/Lib/sysconfig.pyi>uget_config_var(iigíµ ÷ư>gíµ ÷ư>0(u+/home/gbr/devel/python/Lib/distutils/log.pyi?u set_threshold(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u+/home/gbr/devel/python/Lib/distutils/log.pyiEu set_verbosity(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyiWu CompileError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u~iu<built-in method getattr>(iigðh㈵øô>gðh㈵øô>{(u'/home/gbr/devel/python/Lib/functools.pyiuupdate_wrapper(iigTäqs*Ù>gTäqs*Ù>(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(iigTäqs*é>gTäqs*é>(u,/home/gbr/devel/python/Lib/distutils/dist.pyi1ufinalize_options(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u1/home/gbr/devel/python/Lib/distutils/extension.pyiu<module>(iigTäqs*Ù>g¢&ú|”?{(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iigTäqs*Ù>g¢&ú|”?0(u'/home/gbr/devel/python/Lib/sre_parse.pyi·u__next(i¹i¹g±OÅÈr?gdȱõ áx?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi³u__init__(iiga2U0*©?g Ž’Wç?(u'/home/gbr/devel/python/Lib/sre_parse.pyiÐuget(i‘i‘g ßû´Wo?g‘*ŠWYÛt?(u'/home/gbr/devel/python/Lib/sre_parse.pyiÊumatch(iigQfƒL2rF?g -ëþ±M?0(u,/home/gbr/devel/python/Lib/distutils/dist.pyiÊu_get_toplevel_options(iigíµ ÷ư>gíµ ÷ư>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigíµ ÷ư>gíµ ÷ư>0(u~iu#<method 'remove' of 'list' objects>(i0i0gTäqs*ù>gTäqs*ù>{(u'/home/gbr/devel/python/Lib/sre_parse.pyiTu closegroup(i0i0gTäqs*ù>gTäqs*ù>0(u /home/gbr/devel/python/Lib/re.pyiÌucompile(iigíµ ÷Æð>g¦–­õEB›?{(u&/home/gbr/devel/python/Lib/warnings.pyiufilterwarnings(iigíµ ÷ÆÀ>g†ÆAœ‡#?(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyiu<module>(iigíµ ÷ÆÀ>gÕ[[%XL?(u*/home/gbr/devel/python/Lib/configparser.pyiÜuSafeConfigParser(iigíµ ÷ư>gþz…÷.?(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu<module>(iigíµ ÷ư>gOʤ†6;?(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigíµ ÷ư>gXà+ºõš>?(u"/home/gbr/devel/python/Lib/glob.pyiu<module>(iigíµ ÷ư>g„dC?(u&/home/gbr/devel/python/Lib/tokenize.pyiqu_compile(iigíµ ÷ÆÐ>g÷¬k´è‘?(u*/home/gbr/devel/python/Lib/configparser.pyi]u ConfigParser(iigíµ ÷ư>g,amŒð2?(u*/home/gbr/devel/python/Lib/configparser.pyiquRawConfigParser(iigíµ ÷ÆÀ>gÕ Ìí^îs?(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi u<module>(iigíµ ÷ư>g{®GázT?(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi u<module>(iigg¢'eRCû>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiTu closegroup(i0i0g ØFì?g!>°ã¿@?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i0i0g ØFì?g!>°ã¿@?0(u./home/gbr/devel/python/Lib/distutils/errors.pyiEuDistutilsInternalError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u~iu#<method 'insert' of 'list' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u&/home/gbr/devel/python/Lib/warnings.pyiufilterwarnings(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u)/home/gbr/devel/python/Lib/collections.pyi(u__init__(iigðh㈵ø?g¢'eRC?{(u*/home/gbr/devel/python/Lib/configparser.pyi™u__init__(iigíµ ÷Æð>g{…÷?(u'/home/gbr/devel/python/Lib/functools.pyi~udecorating_function(iigTäqs*ù>g¾IÓ h?0(u'/home/gbr/devel/python/Lib/sre_parse.pyiugetwidth(i—i·g Xr‹ßT?gÏdÿ< X?{(u)/home/gbr/devel/python/Lib/sre_compile.pyicu_simple(i‚i‚gÀ“.«° ?gÀ“.«° ?(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(iig<ž–¸Ê#?gïô¥·?W?(u'/home/gbr/devel/python/Lib/sre_parse.pyiugetwidth(i i"g¦Ï¸®˜Q?gíœfv‡T?0(u&/home/gbr/devel/python/Lib/tokenize.pyi8umaybe(iigíµ ÷ư>gTäqs*É>{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigíµ ÷ư>gTäqs*É>0(u&/home/gbr/devel/python/Lib/warnings.pyiXu_processoptions(iigíµ ÷ư>gíµ ÷ư>{(u&/home/gbr/devel/python/Lib/warnings.pyiu<module>(iigíµ ÷ư>gíµ ÷ư>0(u&/home/gbr/devel/python/Lib/warnings.pyiufilterwarnings(iig¢'eRCë>gðk$ Â%?{(usetup.pyiumain(iig¢'eRCë>gðk$ Â%?0(u*/home/gbr/devel/python/Lib/configparser.pyiµuNoSectionError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u'/home/gbr/devel/python/Lib/posixpath.pyiubasename(iigðh㈵øÔ>gðh㈵øä>{(u,/home/gbr/devel/python/Lib/distutils/core.pyi"u gen_usage(iigTäqs*É>gðh㈵øÔ>(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iigíµ ÷ÆÀ>gðh㈵øÔ>0(u*/home/gbr/devel/python/Lib/configparser.pyi—uError(iigðh㈵øÔ>gðh㈵øÔ>{(u~iu!<built-in method __build_class__>(iigðh㈵øÔ>gðh㈵øÔ>0(u*/home/gbr/devel/python/Lib/configparser.pyi¾uDuplicateSectionError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyiÑuDistributionMetadata(iig?«Ì”Ößâ>g?«Ì”Ößâ>{(u~iu!<built-in method __build_class__>(iig?«Ì”Ößâ>g?«Ì”Ößâ>0(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyi)u build_ext(iig¢&ú|”ç>gÒûÆ×žY?{(u~iu!<built-in method __build_class__>(iig¢&ú|”ç>gÒûÆ×žY?0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiÔugetopt(iigTäqs*Ù>gÄËÓ¹¢”0?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigTäqs*Ù>gÄËÓ¹¢”0?0(u./home/gbr/devel/python/Lib/distutils/errors.pyi:uDistutilsPlatformError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u'/home/gbr/devel/python/Lib/sysconfig.pyiÀuget_config_vars(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u'/home/gbr/devel/python/Lib/sysconfig.pyi>uget_config_var(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iig¦@fgÑ;?gMLbõGH?{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iig¦@fgÑ;?gMLbõGH?0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiu FancyGetopt(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u~iu<built-in method vars>(iigíµ ÷ư>gíµ ÷ư>{(u,/home/gbr/devel/python/Lib/distutils/core.pyi"u gen_usage(iigíµ ÷ư>gíµ ÷ư>0(u0/home/gbr/devel/python/Lib/distutils/__init__.pyi u<module>(iigg{(usetup.pyiu<module>(iigg0(u7/home/gbr/devel/python/Lib/distutils/command/install.pyixuinstall(iig¢'eRCë>g¢'eRCë>{(u~iu!<built-in method __build_class__>(iig¢'eRCë>g¢'eRCë>0(u"/home/gbr/devel/python/Lib/stat.pyiuS_IFMT(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u"/home/gbr/devel/python/Lib/stat.pyi1uS_ISREG(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u~iu#<method 'update' of 'dict' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u'/home/gbr/devel/python/Lib/functools.pyiuupdate_wrapper(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u'/home/gbr/devel/python/Lib/linecache.pyiu<module>(iigÕýL½n1?geN—ÅÄæ“?{(u&/home/gbr/devel/python/Lib/warnings.pyiu<module>(iigÕýL½n1?geN—ÅÄæ“?0(u~iu <method 'find' of 'str' objects>(iigíµ ÷ư>gíµ ÷ư>{(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigíµ ÷ư>gíµ ÷ư>0(u1/home/gbr/devel/python/Lib/distutils/text_file.pyi uTextFile(iigTäqs*Ù>gTäqs*Ù>{(u~iu!<built-in method __build_class__>(iigTäqs*Ù>gTäqs*Ù>0(u~iu<built-in method locals>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyi5uDistutilsSetupError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u~iu<method 'add' of 'set' objects>(iigíµ ÷ư>gíµ ÷ư>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ư>gíµ ÷ư>0(u./home/gbr/devel/python/Lib/distutils/errors.pyibuUnknownFileError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(iigÙæÆô„%?gXÎüj0?{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiÔugetopt(iigÙæÆô„%?gXÎüj0?0(u~iu.<method '__contains__' of 'frozenset' objects>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u)/home/gbr/devel/python/Lib/sre_compile.pyiÏu_optimize_charset(i‚i‚gxB¯?‰Ïm?gu;ûʃôt?{(u)/home/gbr/devel/python/Lib/sre_compile.pyi²u_compile_charset(i‚i‚gxB¯?‰Ïm?gu;ûʃôt?0(u*/home/gbr/devel/python/Lib/configparser.pyiXuMissingSectionHeaderError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u*/home/gbr/devel/python/Lib/configparser.pyiuInterpolationSyntaxError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u&/home/gbr/devel/python/Lib/warnings.pyi uWarningMessage(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u~iu#<method 'append' of 'list' objects>(iigǺ¸ðF?gǺ¸ðF?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiu _mk_bitmap(iðiðgümOØî?gümOØî?(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(i7i7gõ×+,¸/?gõ×+,¸/?(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(išišgÒûÆ×žY?gÒûÆ×žY?(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyi)u build_ext(iigíµ ÷ư>gíµ ÷ư>(u)/home/gbr/devel/python/Lib/sre_compile.pyi×u_code(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>(u'/home/gbr/devel/python/Lib/posixpath.pyiJunormpath(i i gíµ ÷ÆÀ>gíµ ÷ÆÀ>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi‡u_grok_option_table(iig?«Ì”Ößâ>g?«Ì”Ößâ>(u'/home/gbr/devel/python/Lib/sre_parse.pyiIu opengroup(i0i0g·_>Y1\Ý>g·_>Y1\Ý>(u'/home/gbr/devel/python/Lib/sre_parse.pyi‹uappend(iƒiƒgðh㈵ø?gðh㈵ø?(u)/home/gbr/devel/python/Lib/sre_compile.pyiÏu_optimize_charset(iÂiÂg{…÷?g{…÷?(u7/home/gbr/devel/python/Lib/distutils/command/install.pyixuinstall(iigg(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i i g«ZÒQf?g«ZÒQf?(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(ijijg,Cëâ6ú>g,Cëâ6ú>(u)/home/gbr/devel/python/Lib/sre_compile.pyi²u_compile_charset(iigÒûÆ×žY?gÒûÆ×žY?0(u~iu<built-in method uname>(iig¢&ú|”ç>g¢&ú|”ç>{(u,/home/gbr/devel/python/Lib/distutils/util.pyiu get_platform(iig¢&ú|”ç>g¢&ú|”ç>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiu__len__(iýiýghUMu/?g–=Ô¶a4?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(iig‹à+Ù±!?gã5¯ê¬&?(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(iigTäqs*É>gTäqs*É>(u~iu<built-in method len>(i¬i¬gfLÁgÓ?gç4 ´;¤?(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(iJiJgfLÁgÓ?g]éEí~?0(u~iu'<built-in method getfilesystemencoding>(i i gTäqs*É>gTäqs*É>{(u /home/gbr/devel/python/Lib/os.pyiîudecode(iigg(u /home/gbr/devel/python/Lib/os.pyiêuencode(iigTäqs*É>gTäqs*É>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi+u__init__(iigðh㈵øÔ>gfLÁgÓñ>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigðh㈵øÔ>gfLÁgÓñ>0(u~iu<built-in method min>(iÈiÈg5wô¿\‹&?g5wô¿\‹&?{(u'/home/gbr/devel/python/Lib/sre_parse.pyiugetwidth(iÈiÈg5wô¿\‹&?g5wô¿\‹&?0(u~iu<built-in method chr>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u'/home/gbr/devel/python/Lib/sre_parse.pyi·u__next(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u'/home/gbr/devel/python/Lib/functools.pyiuu lru_cache(iigTäqs*É>gTäqs*É>{(u%/home/gbr/devel/python/Lib/fnmatch.pyi u<module>(iigTäqs*É>gTäqs*É>0(u,/home/gbr/devel/python/Lib/distutils/util.pyiúu check_environ(iig?«Ì”Ößâ>gÒûÆ×žY?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi0ufind_config_files(iig?«Ì”Ößâ>gÒûÆ×žY?0(u&/home/gbr/devel/python/Lib/warnings.pyiu<module>(iig„¹ÝË}r$?g[Y¢³Ì"”?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyiu<module>(iig„¹ÝË}r$?g[Y¢³Ì"”?0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiwu <dictcomp>(iigíµ ÷ÆÐ>gðh㈵øÔ>{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi u<module>(iigíµ ÷ÆÐ>gðh㈵øÔ>0(u./home/gbr/devel/python/Lib/distutils/errors.pyi@uDistutilsExecError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u)/home/gbr/devel/python/Lib/sre_compile.pyicu_simple(i‚i‚g1zn¡+1?gðJ’çú><?{(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(i‚i‚g1zn¡+1?gðJ’çú><?0(u~iu<built-in method hasattr>(i)i)gTäqs*ù>gTäqs*ù>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(i#i#gfLÁgÓñ>gfLÁgÓñ>(u%/home/gbr/devel/python/Lib/_abcoll.pyiìuupdate(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>(u,/home/gbr/devel/python/Lib/distutils/util.pyiu get_platform(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(usetup.pyiu<module>(iigíµ ÷ư>gíµ ÷ư>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiÊumatch(i•i•góWÈ\9?g Xr‹ßT?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i½i½gv‰ê­­2?gVÓõDׅO?(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(iØiØg™ò!¨½?g„¹ÝË}r4?0(u~iu<built-in method compile>(iiga2U0*©?ga2U0*©?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiæucompile(iiga2U0*©?ga2U0*©?0(u'/home/gbr/devel/python/Lib/sre_parse.pyi[u__init__(i;i;gçR\Uö]1?gçR\Uö]1?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i–i–g°t><K!?g°t><K!?(u'/home/gbr/devel/python/Lib/sre_parse.pyiƒu __getitem__(i‚i‚gvk™ Çó?gvk™ Çó?(u'/home/gbr/devel/python/Lib/sre_parse.pyi4u _parse_sub(i#i#gíµ ÷Æ?gíµ ÷Æ?0(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigðh㈵øä>g·_>Y1\ý>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi0ufind_config_files(iigðh㈵øä>g·_>Y1\ý>0(u./home/gbr/devel/python/Lib/distutils/config.pyiu PyPIRCCommand(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÐ>gíµ ÷ÆÐ>0(u*/home/gbr/devel/python/Lib/configparser.pyiÜuSafeConfigParser(iigTäqs*É>g¾IÓ h.?{(u~iu!<built-in method __build_class__>(iigTäqs*É>g¾IÓ h.?0(u&/home/gbr/devel/python/Lib/tokenize.pyi6ugroup(iigÉÇî%ö>gTäqs*ù>{(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iigfLÁgÓñ>gðh㈵øô>(u&/home/gbr/devel/python/Lib/tokenize.pyi7uany(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u&/home/gbr/devel/python/Lib/tokenize.pyi8umaybe(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u)/home/gbr/devel/python/Lib/sre_compile.pyiÔuisstring(i*i*g¾IÓ hþ>gðh㈵ø?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiæucompile(iig¢&ú|”ç>gfLÁgÓñ>(u /home/gbr/devel/python/Lib/re.pyiu_compile_typed(iig?«Ì”Ößò>g{…÷ø>0(u~iu%<method 'translate' of 'str' objects>(i/i/gíµ ÷Æ?gíµ ÷Æ?{(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi¯utranslate_longopt(iig¢'eRCû>g¢'eRCû>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiju get_attr_name(iig ØFì?g ØFì?0(u~iu!<method 'lower' of 'str' objects>(iigíµ ÷ư>gíµ ÷ư>{(u,/home/gbr/devel/python/Lib/distutils/util.pyiu get_platform(iigíµ ÷ư>gíµ ÷ư>0(u&/home/gbr/devel/python/Lib/tokenize.pyi0u TokenInfo(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiuget_option_order(iigíµ ÷ư>gíµ ÷ư>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigíµ ÷ư>gíµ ÷ư>0(u,/home/gbr/devel/python/Lib/distutils/util.pyiu<module>(iigÜóüi£:-?g¯]ÚpX:?{(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iigÜóüi£:-?g¯]ÚpX:?0(u~iu'<method 'setter' of 'property' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u*/home/gbr/devel/python/Lib/configparser.pyi-u ParsingError(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iig?«Ì”Ößò>g!>°ã¿@@?{(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iig?«Ì”Ößò>g!>°ã¿@@?0(u*/home/gbr/devel/python/Lib/configparser.pyi-u ParsingError(iigTäqs*Ù>gíµ ÷Æà>{(u~iu!<built-in method __build_class__>(iigTäqs*Ù>gíµ ÷Æà>0(u'/home/gbr/devel/python/Lib/sre_parse.pyižu fix_flags(iig!>°ã¿@?gfLÁgÓ?{(u'/home/gbr/devel/python/Lib/sre_parse.pyiªuparse(iig!>°ã¿@?gfLÁgÓ?0(u./home/gbr/devel/python/Lib/distutils/errors.pyi u<module>(iighUMuÿ>gõ×+,¸??{(usetup.pyiu<module>(iighUMuÿ>gõ×+,¸??0(u~iu"<method 'encode' of 'str' objects>(iigðh㈵øÔ>gðh㈵øÔ>{(u /home/gbr/devel/python/Lib/os.pyiêuencode(iigðh㈵øÔ>gðh㈵øÔ>0(u,/home/gbr/devel/python/Lib/distutils/util.pyi{u Mixin2to3(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u'/home/gbr/devel/python/Lib/sre_parse.pyi³u__init__(iig ØFì?gÕýL½n!?{(u'/home/gbr/devel/python/Lib/sre_parse.pyiªuparse(iig ØFì?gÕýL½n!?0(u~iu"<method 'rstrip' of 'str' objects>(iigTäqs*É>gTäqs*É>{(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/posixpath.pyiŠudirname(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u~iu <method 'join' of 'str' objects>(iig?«Ì”Ößâ>g¢'eRCë>{(u&/home/gbr/devel/python/Lib/tokenize.pyi6ugroup(iigTäqs*É>gTäqs*É>(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigðh㈵øÔ>g?«Ì”Ößâ>(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiÔugetopt(iigg(u'/home/gbr/devel/python/Lib/posixpath.pyiJunormpath(iigíµ ÷ư>gíµ ÷ư>0(u+/home/gbr/devel/python/Lib/distutils/log.pyiu__init__(iigg{(u+/home/gbr/devel/python/Lib/distutils/log.pyiu<module>(iigg0(u&/home/gbr/devel/python/Lib/warnings.pyi!ucatch_warnings(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u~iu!<built-in method __build_class__>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiIu opengroup(i0i0ghUMu?gfLÁgÓ?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i0i0ghUMu?gfLÁgÓ?0(u)/home/gbr/devel/python/Lib/sre_compile.pyi×u_code(iig#Diâ ?gíV`Èê†?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiæucompile(iig#Diâ ?gíV`Èê†?0(u%/home/gbr/devel/python/Lib/_abcoll.pyiduget(iigTäqs*Ù>gÉÇî%ö>{(u-/home/gbr/devel/python/Lib/distutils/debug.pyiu<module>(iigTäqs*Ù>gÉÇî%ö>0(u~iu<built-in method globals>(iigíµ ÷ư>gíµ ÷ư>{(u#/home/gbr/devel/python/Lib/token.pyiu<module>(iigíµ ÷ư>gíµ ÷ư>0(u~iu$<method 'endswith' of 'str' objects>(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>{(u'/home/gbr/devel/python/Lib/posixpath.pyiGujoin(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u)/home/gbr/devel/python/Lib/collections.pyi9u __setitem__(iigÙæÆô„%?gEÒnô1 ?{(u'/home/gbr/devel/python/Lib/functools.pyi†uwrapper(iigÙæÆô„%?gEÒnô1 ?0(usetup.pyiu<module>(iigÍ®{+c?gDúíëÀ9£?{(u~iu<built-in method exec>(iigÍ®{+c?gDúíëÀ9£?0(u /home/gbr/devel/python/Lib/os.pyiîudecode(iig·_>Y1\Ý>g?«Ì”Ößâ>{(u /home/gbr/devel/python/Lib/os.pyi©u __getitem__(iig·_>Y1\Ý>g?«Ì”Ößâ>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyi¶u OptionDummy(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u+/home/gbr/devel/python/Lib/distutils/log.pyiu<module>(iig·_>Y1\í>g,Cëâ6 ?{(usetup.pyiu<module>(iig·_>Y1\í>g,Cëâ6 ?0(u./home/gbr/devel/python/Lib/distutils/errors.pyi,uDistutilsOptionError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u;/home/gbr/devel/python/Lib/distutils/command/install_lib.pyiu install_lib(iigTäqs*É>gTäqs*É>{(u~iu!<built-in method __build_class__>(iigTäqs*É>gTäqs*É>0(u<string>iu TokenInfo(iig·_>Y1\í>g·_>Y1\í>{(u~iu!<built-in method __build_class__>(iig·_>Y1\í>g·_>Y1\í>0(u%/home/gbr/devel/python/Lib/fnmatch.pyi u<module>(iighUMuï>gm7Á7MŸ?{(u"/home/gbr/devel/python/Lib/glob.pyiu<module>(iighUMuï>gm7Á7MŸ?0(u*/home/gbr/devel/python/Lib/configparser.pyi™u__init__(iig¢&ú|”ç>g#Diâ ?{(u,/home/gbr/devel/python/Lib/distutils/dist.pyiYuparse_config_files(iig¢&ú|”ç>g#Diâ ?0(u'/home/gbr/devel/python/Lib/functools.pyiuupdate_wrapper(iigTäqs*Ù>g?«Ì”Ößò>{(u'/home/gbr/devel/python/Lib/functools.pyi~udecorating_function(iigTäqs*Ù>g?«Ì”Ößò>0(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyiu<module>(iig™sIÕv3?gQfƒL2rV?{(usetup.pyiu<module>(iig™sIÕv3?gQfƒL2rV?0(u!/home/gbr/devel/python/Lib/abc.pyižu__instancecheck__(iig ØFìó>gÞ3ßÁOü>{(u~iu<built-in method isinstance>(iig ØFìó>gÞ3ßÁOü>0(u'/home/gbr/devel/python/Lib/functools.pyi6uwraps(iigTäqs*É>gTäqs*É>{(u'/home/gbr/devel/python/Lib/functools.pyi~udecorating_function(iigTäqs*É>gTäqs*É>0(u"/home/gbr/devel/python/Lib/glob.pyiu<module>(iigõ×+,¸?g«<°S¬J?{(usetup.pyiu<module>(iigõ×+,¸?g«<°S¬J?0(u~iu<built-in method all>(iig¢'eRCë>gùœ»]/M?{(u1/home/gbr/devel/python/Lib/distutils/extension.pyiYu__init__(iigTäqs*É>gíµ ÷ÆÐ>(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigðh㈵øä>g¾IÓ hþ>0(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iigÉÇî%ö>gA ]ÞL?{(usetup.pyiumain(iigÉÇî%ö>gA ]ÞL?0(u~iu<built-in method proxy>(iigðh㈵øä>gðh㈵øä>{(u)/home/gbr/devel/python/Lib/collections.pyi9u __setitem__(iigíµ ÷Æà>gíµ ÷Æà>(u)/home/gbr/devel/python/Lib/collections.pyi(u__init__(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>0(u4/home/gbr/devel/python/Lib/distutils/fancy_getopt.pyiuset_negative_aliases(iigíµ ÷ÆÀ>gðh㈵øÔ>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyi‡uparse_command_line(iigíµ ÷ÆÀ>gðh㈵øÔ>0(u'/home/gbr/devel/python/Lib/posixpath.pyiGujoin(iigíµ ÷Æà>gíµ ÷Æð>{(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi-u _python_build(iigíµ ÷ÆÐ>gíµ ÷Æà>(u,/home/gbr/devel/python/Lib/distutils/dist.pyi0ufind_config_files(iigíµ ÷ÆÐ>gíµ ÷Æà>0(u-/home/gbr/devel/python/Lib/distutils/debug.pyiu<module>(iig·_>Y1\Ý>g·_>Y1\ý>{(u,/home/gbr/devel/python/Lib/distutils/core.pyiu<module>(iig·_>Y1\Ý>g·_>Y1\ý>0(u'/home/gbr/devel/python/Lib/functools.pyi†uwrapper(iigCÅ8 1?g@i¨QH2›?{(u /home/gbr/devel/python/Lib/re.pyiÿu_compile(iigCÅ8 1?g@i¨QH2›?0(u)/home/gbr/devel/python/Lib/collections.pyiu <genexpr>(i%i%g·_>Y1\í>g ØFìó>{(u~iu<built-in method all>(i%i%g·_>Y1\í>g ØFìó>0(u'/home/gbr/devel/python/Lib/functools.pyi~udecorating_function(iighUMuï>g Ž’Wç?{(u%/home/gbr/devel/python/Lib/fnmatch.pyi u<module>(iighUMuï>g Ž’Wç?0(u4/home/gbr/devel/python/Lib/distutils/archive_util.pyiu<module>(iig ØFìó>g ØFìó>{(u+/home/gbr/devel/python/Lib/distutils/cmd.pyiu<module>(iig ØFìó>g ØFìó>0(u'/home/gbr/devel/python/Lib/sre_parse.pyiu_escape(i9i9g()°¦ ?gd?‹¥H¾"?{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(i9i9g()°¦ ?gd?‹¥H¾"?0(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(iig#Diâ ?g!>°ã¿@ ?{(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iig#Diâ ?g!>°ã¿@ ?0(u*/home/gbr/devel/python/Lib/configparser.pyiuInterpolationMissingOptionError(iigíµ ÷ư>gíµ ÷ư>{(u~iu!<built-in method __build_class__>(iigíµ ÷ư>gíµ ÷ư>0(u1/home/gbr/devel/python/Lib/distutils/text_file.pyiu<module>(iig·_>Y1\Ý>g™ò!¨½ ?{(usetup.pyiu<module>(iig·_>Y1\Ý>g™ò!¨½ ?0(u*/home/gbr/devel/python/Lib/configparser.pyiþuInterpolationError(iigg{(u~iu!<built-in method __build_class__>(iigg0(u+/home/gbr/devel/python/Lib/distutils/cmd.pyiuCommand(iigíµ ÷Æà>gíµ ÷Æà>{(u~iu!<built-in method __build_class__>(iigíµ ÷Æà>gíµ ÷Æà>0(u)/home/gbr/devel/python/Lib/sre_compile.pyi²u_compile_charset(i‚i‚g çfh<A?g¹oµN\Žw?{(u)/home/gbr/devel/python/Lib/sre_compile.pyiju _compile_info(iigíµ ÷Æð>g¦@fgÑ;%?(u)/home/gbr/devel/python/Lib/sre_compile.pyi u_compile(iigŸ7©0¶@?g³=zÃ}äv?0(u'/home/gbr/devel/python/Lib/sre_parse.pyißuisname(iigÉÇî%ö>g¢'eRCû>{(u'/home/gbr/devel/python/Lib/sre_parse.pyi‚u_parse(iigÉÇî%ö>g¢'eRCû>0(u /home/gbr/devel/python/Lib/re.pyiÿu_compile(iigÖÿ9̗?g+iÅ7>›?{(u /home/gbr/devel/python/Lib/re.pyiÌucompile(iigÖÿ9̗?g+iÅ7>›?0(u&/home/gbr/devel/python/Lib/tokenize.pyiu<module>(iig”ص½Ý’,?gBZcÐ ¡“?{(u'/home/gbr/devel/python/Lib/linecache.pyiu<module>(iig”ص½Ý’,?gBZcÐ ¡“?0(u1/home/gbr/devel/python/Lib/distutils/file_util.pyiu<module>(iigðh㈵øä>gðh㈵øä>{(u+/home/gbr/devel/python/Lib/distutils/cmd.pyiu<module>(iigðh㈵øä>gðh㈵øä>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyiYuparse_config_files(iigðh㈵øä>gˆ»z-?{(u,/home/gbr/devel/python/Lib/distutils/core.pyi;usetup(iigðh㈵øä>gˆ»z-?0(u /home/gbr/devel/python/Lib/os.pyi©u __getitem__(iighUMuï>gç4 ´;¤?{(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iiggðh㈵øÔ>(u%/home/gbr/devel/python/Lib/_abcoll.pyiduget(iigðh㈵øÔ>ghUMuï>(u%/home/gbr/devel/python/Lib/_abcoll.pyiju __contains__(iigðh㈵øä>gÞ3ßÁOü>0(u,/home/gbr/devel/python/Lib/distutils/dist.pyi1ufinalize_options(iigíµ ÷ÆÀ>gðh㈵øÔ>{(u,/home/gbr/devel/python/Lib/distutils/dist.pyixu__init__(iigíµ ÷ÆÀ>gðh㈵øÔ>0(u~iu0<method 'disable' of '_lsprof.Profiler' objects>(iigíµ ÷ư>gíµ ÷ư>{0(u1/home/gbr/devel/python/Lib/distutils/sysconfig.pyi u<module>(iigÒûÆ×žY?g?«Ì”Öß"?{(u9/home/gbr/devel/python/Lib/distutils/command/build_ext.pyiu<module>(iigÒûÆ×žY?g?«Ì”Öß"?0(u~iu&<method 'startswith' of 'str' objects>(iTiTgÉÇî%ö>gÉÇî%ö>{(u'/home/gbr/devel/python/Lib/posixpath.pyiGujoin(iigíµ ÷ÆÀ>gíµ ÷ÆÀ>(u&/home/gbr/devel/python/Lib/tokenize.pyi#u <listcomp>(iCiCg·_>Y1\í>g·_>Y1\í>(u'/home/gbr/devel/python/Lib/posixpath.pyiëu expanduser(iigg(u)/home/gbr/devel/python/Lib/collections.pyiÛu namedtuple(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/posixpath.pyi=uisabs(iigíµ ÷ư>gíµ ÷ư>(u'/home/gbr/devel/python/Lib/posixpath.pyiJunormpath(iigTäqs*É>gTäqs*É>0(u)/home/gbr/devel/python/Lib/collections.pyi‚u move_to_end(iigíµ ÷Æà>gíµ ÷Æà>{(u'/home/gbr/devel/python/Lib/functools.pyi†uwrapper(iigíµ ÷Æà>gíµ ÷Æà>0(u&/home/gbr/devel/python/Lib/warnings.pyiSu _OptionError(iigg{(u~iu!<built-in method __build_class__>(iigg00
66,607
139
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/EUC-CN.TXT
00 0000 01 0001 02 0002 03 0003 04 0004 05 0005 06 0006 07 0007 08 0008 09 0009 0A 000A 0B 000B 0C 000C 0D 000D 0E 000E 0F 000F 10 0010 11 0011 12 0012 13 0013 14 0014 15 0015 16 0016 17 0017 18 0018 19 0019 1A 001A 1B 001B 1C 001C 1D 001D 1E 001E 1F 001F 20 0020 21 0021 22 0022 23 0023 24 0024 25 0025 26 0026 27 0027 28 0028 29 0029 2A 002A 2B 002B 2C 002C 2D 002D 2E 002E 2F 002F 30 0030 31 0031 32 0032 33 0033 34 0034 35 0035 36 0036 37 0037 38 0038 39 0039 3A 003A 3B 003B 3C 003C 3D 003D 3E 003E 3F 003F 40 0040 41 0041 42 0042 43 0043 44 0044 45 0045 46 0046 47 0047 48 0048 49 0049 4A 004A 4B 004B 4C 004C 4D 004D 4E 004E 4F 004F 50 0050 51 0051 52 0052 53 0053 54 0054 55 0055 56 0056 57 0057 58 0058 59 0059 5A 005A 5B 005B 5C 005C 5D 005D 5E 005E 5F 005F 60 0060 61 0061 62 0062 63 0063 64 0064 65 0065 66 0066 67 0067 68 0068 69 0069 6A 006A 6B 006B 6C 006C 6D 006D 6E 006E 6F 006F 70 0070 71 0071 72 0072 73 0073 74 0074 75 0075 76 0076 77 0077 78 0078 79 0079 7A 007A 7B 007B 7C 007C 7D 007D 7E 007E 7F 007F A1A1 3000 A1A2 3001 A1A3 3002 A1A4 30FB A1A5 02C9 A1A6 02C7 A1A7 00A8 A1A8 3003 A1A9 3005 A1AA 2015 A1AB FF5E A1AC 2016 A1AD 2026 A1AE 2018 A1AF 2019 A1B0 201C A1B1 201D A1B2 3014 A1B3 3015 A1B4 3008 A1B5 3009 A1B6 300A A1B7 300B A1B8 300C A1B9 300D A1BA 300E A1BB 300F A1BC 3016 A1BD 3017 A1BE 3010 A1BF 3011 A1C0 00B1 A1C1 00D7 A1C2 00F7 A1C3 2236 A1C4 2227 A1C5 2228 A1C6 2211 A1C7 220F A1C8 222A A1C9 2229 A1CA 2208 A1CB 2237 A1CC 221A A1CD 22A5 A1CE 2225 A1CF 2220 A1D0 2312 A1D1 2299 A1D2 222B A1D3 222E A1D4 2261 A1D5 224C A1D6 2248 A1D7 223D A1D8 221D A1D9 2260 A1DA 226E A1DB 226F A1DC 2264 A1DD 2265 A1DE 221E A1DF 2235 A1E0 2234 A1E1 2642 A1E2 2640 A1E3 00B0 A1E4 2032 A1E5 2033 A1E6 2103 A1E7 FF04 A1E8 00A4 A1E9 FFE0 A1EA FFE1 A1EB 2030 A1EC 00A7 A1ED 2116 A1EE 2606 A1EF 2605 A1F0 25CB A1F1 25CF A1F2 25CE A1F3 25C7 A1F4 25C6 A1F5 25A1 A1F6 25A0 A1F7 25B3 A1F8 25B2 A1F9 203B A1FA 2192 A1FB 2190 A1FC 2191 A1FD 2193 A1FE 3013 A2B1 2488 A2B2 2489 A2B3 248A A2B4 248B A2B5 248C A2B6 248D A2B7 248E A2B8 248F A2B9 2490 A2BA 2491 A2BB 2492 A2BC 2493 A2BD 2494 A2BE 2495 A2BF 2496 A2C0 2497 A2C1 2498 A2C2 2499 A2C3 249A A2C4 249B A2C5 2474 A2C6 2475 A2C7 2476 A2C8 2477 A2C9 2478 A2CA 2479 A2CB 247A A2CC 247B A2CD 247C A2CE 247D A2CF 247E A2D0 247F A2D1 2480 A2D2 2481 A2D3 2482 A2D4 2483 A2D5 2484 A2D6 2485 A2D7 2486 A2D8 2487 A2D9 2460 A2DA 2461 A2DB 2462 A2DC 2463 A2DD 2464 A2DE 2465 A2DF 2466 A2E0 2467 A2E1 2468 A2E2 2469 A2E5 3220 A2E6 3221 A2E7 3222 A2E8 3223 A2E9 3224 A2EA 3225 A2EB 3226 A2EC 3227 A2ED 3228 A2EE 3229 A2F1 2160 A2F2 2161 A2F3 2162 A2F4 2163 A2F5 2164 A2F6 2165 A2F7 2166 A2F8 2167 A2F9 2168 A2FA 2169 A2FB 216A A2FC 216B A3A1 FF01 A3A2 FF02 A3A3 FF03 A3A4 FFE5 A3A5 FF05 A3A6 FF06 A3A7 FF07 A3A8 FF08 A3A9 FF09 A3AA FF0A A3AB FF0B A3AC FF0C A3AD FF0D A3AE FF0E A3AF FF0F A3B0 FF10 A3B1 FF11 A3B2 FF12 A3B3 FF13 A3B4 FF14 A3B5 FF15 A3B6 FF16 A3B7 FF17 A3B8 FF18 A3B9 FF19 A3BA FF1A A3BB FF1B A3BC FF1C A3BD FF1D A3BE FF1E A3BF FF1F A3C0 FF20 A3C1 FF21 A3C2 FF22 A3C3 FF23 A3C4 FF24 A3C5 FF25 A3C6 FF26 A3C7 FF27 A3C8 FF28 A3C9 FF29 A3CA FF2A A3CB FF2B A3CC FF2C A3CD FF2D A3CE FF2E A3CF FF2F A3D0 FF30 A3D1 FF31 A3D2 FF32 A3D3 FF33 A3D4 FF34 A3D5 FF35 A3D6 FF36 A3D7 FF37 A3D8 FF38 A3D9 FF39 A3DA FF3A A3DB FF3B A3DC FF3C A3DD FF3D A3DE FF3E A3DF FF3F A3E0 FF40 A3E1 FF41 A3E2 FF42 A3E3 FF43 A3E4 FF44 A3E5 FF45 A3E6 FF46 A3E7 FF47 A3E8 FF48 A3E9 FF49 A3EA FF4A A3EB FF4B A3EC FF4C A3ED FF4D A3EE FF4E A3EF FF4F A3F0 FF50 A3F1 FF51 A3F2 FF52 A3F3 FF53 A3F4 FF54 A3F5 FF55 A3F6 FF56 A3F7 FF57 A3F8 FF58 A3F9 FF59 A3FA FF5A A3FB FF5B A3FC FF5C A3FD FF5D A3FE FFE3 A4A1 3041 A4A2 3042 A4A3 3043 A4A4 3044 A4A5 3045 A4A6 3046 A4A7 3047 A4A8 3048 A4A9 3049 A4AA 304A A4AB 304B A4AC 304C A4AD 304D A4AE 304E A4AF 304F A4B0 3050 A4B1 3051 A4B2 3052 A4B3 3053 A4B4 3054 A4B5 3055 A4B6 3056 A4B7 3057 A4B8 3058 A4B9 3059 A4BA 305A A4BB 305B A4BC 305C A4BD 305D A4BE 305E A4BF 305F A4C0 3060 A4C1 3061 A4C2 3062 A4C3 3063 A4C4 3064 A4C5 3065 A4C6 3066 A4C7 3067 A4C8 3068 A4C9 3069 A4CA 306A A4CB 306B A4CC 306C A4CD 306D A4CE 306E A4CF 306F A4D0 3070 A4D1 3071 A4D2 3072 A4D3 3073 A4D4 3074 A4D5 3075 A4D6 3076 A4D7 3077 A4D8 3078 A4D9 3079 A4DA 307A A4DB 307B A4DC 307C A4DD 307D A4DE 307E A4DF 307F A4E0 3080 A4E1 3081 A4E2 3082 A4E3 3083 A4E4 3084 A4E5 3085 A4E6 3086 A4E7 3087 A4E8 3088 A4E9 3089 A4EA 308A A4EB 308B A4EC 308C A4ED 308D A4EE 308E A4EF 308F A4F0 3090 A4F1 3091 A4F2 3092 A4F3 3093 A5A1 30A1 A5A2 30A2 A5A3 30A3 A5A4 30A4 A5A5 30A5 A5A6 30A6 A5A7 30A7 A5A8 30A8 A5A9 30A9 A5AA 30AA A5AB 30AB A5AC 30AC A5AD 30AD A5AE 30AE A5AF 30AF A5B0 30B0 A5B1 30B1 A5B2 30B2 A5B3 30B3 A5B4 30B4 A5B5 30B5 A5B6 30B6 A5B7 30B7 A5B8 30B8 A5B9 30B9 A5BA 30BA A5BB 30BB A5BC 30BC A5BD 30BD A5BE 30BE A5BF 30BF A5C0 30C0 A5C1 30C1 A5C2 30C2 A5C3 30C3 A5C4 30C4 A5C5 30C5 A5C6 30C6 A5C7 30C7 A5C8 30C8 A5C9 30C9 A5CA 30CA A5CB 30CB A5CC 30CC A5CD 30CD A5CE 30CE A5CF 30CF A5D0 30D0 A5D1 30D1 A5D2 30D2 A5D3 30D3 A5D4 30D4 A5D5 30D5 A5D6 30D6 A5D7 30D7 A5D8 30D8 A5D9 30D9 A5DA 30DA A5DB 30DB A5DC 30DC A5DD 30DD A5DE 30DE A5DF 30DF A5E0 30E0 A5E1 30E1 A5E2 30E2 A5E3 30E3 A5E4 30E4 A5E5 30E5 A5E6 30E6 A5E7 30E7 A5E8 30E8 A5E9 30E9 A5EA 30EA A5EB 30EB A5EC 30EC A5ED 30ED A5EE 30EE A5EF 30EF A5F0 30F0 A5F1 30F1 A5F2 30F2 A5F3 30F3 A5F4 30F4 A5F5 30F5 A5F6 30F6 A6A1 0391 A6A2 0392 A6A3 0393 A6A4 0394 A6A5 0395 A6A6 0396 A6A7 0397 A6A8 0398 A6A9 0399 A6AA 039A A6AB 039B A6AC 039C A6AD 039D A6AE 039E A6AF 039F A6B0 03A0 A6B1 03A1 A6B2 03A3 A6B3 03A4 A6B4 03A5 A6B5 03A6 A6B6 03A7 A6B7 03A8 A6B8 03A9 A6C1 03B1 A6C2 03B2 A6C3 03B3 A6C4 03B4 A6C5 03B5 A6C6 03B6 A6C7 03B7 A6C8 03B8 A6C9 03B9 A6CA 03BA A6CB 03BB A6CC 03BC A6CD 03BD A6CE 03BE A6CF 03BF A6D0 03C0 A6D1 03C1 A6D2 03C3 A6D3 03C4 A6D4 03C5 A6D5 03C6 A6D6 03C7 A6D7 03C8 A6D8 03C9 A7A1 0410 A7A2 0411 A7A3 0412 A7A4 0413 A7A5 0414 A7A6 0415 A7A7 0401 A7A8 0416 A7A9 0417 A7AA 0418 A7AB 0419 A7AC 041A A7AD 041B A7AE 041C A7AF 041D A7B0 041E A7B1 041F A7B2 0420 A7B3 0421 A7B4 0422 A7B5 0423 A7B6 0424 A7B7 0425 A7B8 0426 A7B9 0427 A7BA 0428 A7BB 0429 A7BC 042A A7BD 042B A7BE 042C A7BF 042D A7C0 042E A7C1 042F A7D1 0430 A7D2 0431 A7D3 0432 A7D4 0433 A7D5 0434 A7D6 0435 A7D7 0451 A7D8 0436 A7D9 0437 A7DA 0438 A7DB 0439 A7DC 043A A7DD 043B A7DE 043C A7DF 043D A7E0 043E A7E1 043F A7E2 0440 A7E3 0441 A7E4 0442 A7E5 0443 A7E6 0444 A7E7 0445 A7E8 0446 A7E9 0447 A7EA 0448 A7EB 0449 A7EC 044A A7ED 044B A7EE 044C A7EF 044D A7F0 044E A7F1 044F A8A1 0101 A8A2 00E1 A8A3 01CE A8A4 00E0 A8A5 0113 A8A6 00E9 A8A7 011B A8A8 00E8 A8A9 012B A8AA 00ED A8AB 01D0 A8AC 00EC A8AD 014D A8AE 00F3 A8AF 01D2 A8B0 00F2 A8B1 016B A8B2 00FA A8B3 01D4 A8B4 00F9 A8B5 01D6 A8B6 01D8 A8B7 01DA A8B8 01DC A8B9 00FC A8BA 00EA A8C5 3105 A8C6 3106 A8C7 3107 A8C8 3108 A8C9 3109 A8CA 310A A8CB 310B A8CC 310C A8CD 310D A8CE 310E A8CF 310F A8D0 3110 A8D1 3111 A8D2 3112 A8D3 3113 A8D4 3114 A8D5 3115 A8D6 3116 A8D7 3117 A8D8 3118 A8D9 3119 A8DA 311A A8DB 311B A8DC 311C A8DD 311D A8DE 311E A8DF 311F A8E0 3120 A8E1 3121 A8E2 3122 A8E3 3123 A8E4 3124 A8E5 3125 A8E6 3126 A8E7 3127 A8E8 3128 A8E9 3129 A9A4 2500 A9A5 2501 A9A6 2502 A9A7 2503 A9A8 2504 A9A9 2505 A9AA 2506 A9AB 2507 A9AC 2508 A9AD 2509 A9AE 250A A9AF 250B A9B0 250C A9B1 250D A9B2 250E A9B3 250F A9B4 2510 A9B5 2511 A9B6 2512 A9B7 2513 A9B8 2514 A9B9 2515 A9BA 2516 A9BB 2517 A9BC 2518 A9BD 2519 A9BE 251A A9BF 251B A9C0 251C A9C1 251D A9C2 251E A9C3 251F A9C4 2520 A9C5 2521 A9C6 2522 A9C7 2523 A9C8 2524 A9C9 2525 A9CA 2526 A9CB 2527 A9CC 2528 A9CD 2529 A9CE 252A A9CF 252B A9D0 252C A9D1 252D A9D2 252E A9D3 252F A9D4 2530 A9D5 2531 A9D6 2532 A9D7 2533 A9D8 2534 A9D9 2535 A9DA 2536 A9DB 2537 A9DC 2538 A9DD 2539 A9DE 253A A9DF 253B A9E0 253C A9E1 253D A9E2 253E A9E3 253F A9E4 2540 A9E5 2541 A9E6 2542 A9E7 2543 A9E8 2544 A9E9 2545 A9EA 2546 A9EB 2547 A9EC 2548 A9ED 2549 A9EE 254A A9EF 254B B0A1 554A B0A2 963F B0A3 57C3 B0A4 6328 B0A5 54CE B0A6 5509 B0A7 54C0 B0A8 7691 B0A9 764C B0AA 853C B0AB 77EE B0AC 827E B0AD 788D B0AE 7231 B0AF 9698 B0B0 978D B0B1 6C28 B0B2 5B89 B0B3 4FFA B0B4 6309 B0B5 6697 B0B6 5CB8 B0B7 80FA B0B8 6848 B0B9 80AE B0BA 6602 B0BB 76CE B0BC 51F9 B0BD 6556 B0BE 71AC B0BF 7FF1 B0C0 8884 B0C1 50B2 B0C2 5965 B0C3 61CA B0C4 6FB3 B0C5 82AD B0C6 634C B0C7 6252 B0C8 53ED B0C9 5427 B0CA 7B06 B0CB 516B B0CC 75A4 B0CD 5DF4 B0CE 62D4 B0CF 8DCB B0D0 9776 B0D1 628A B0D2 8019 B0D3 575D B0D4 9738 B0D5 7F62 B0D6 7238 B0D7 767D B0D8 67CF B0D9 767E B0DA 6446 B0DB 4F70 B0DC 8D25 B0DD 62DC B0DE 7A17 B0DF 6591 B0E0 73ED B0E1 642C B0E2 6273 B0E3 822C B0E4 9881 B0E5 677F B0E6 7248 B0E7 626E B0E8 62CC B0E9 4F34 B0EA 74E3 B0EB 534A B0EC 529E B0ED 7ECA B0EE 90A6 B0EF 5E2E B0F0 6886 B0F1 699C B0F2 8180 B0F3 7ED1 B0F4 68D2 B0F5 78C5 B0F6 868C B0F7 9551 B0F8 508D B0F9 8C24 B0FA 82DE B0FB 80DE B0FC 5305 B0FD 8912 B0FE 5265 B1A1 8584 B1A2 96F9 B1A3 4FDD B1A4 5821 B1A5 9971 B1A6 5B9D B1A7 62B1 B1A8 62A5 B1A9 66B4 B1AA 8C79 B1AB 9C8D B1AC 7206 B1AD 676F B1AE 7891 B1AF 60B2 B1B0 5351 B1B1 5317 B1B2 8F88 B1B3 80CC B1B4 8D1D B1B5 94A1 B1B6 500D B1B7 72C8 B1B8 5907 B1B9 60EB B1BA 7119 B1BB 88AB B1BC 5954 B1BD 82EF B1BE 672C B1BF 7B28 B1C0 5D29 B1C1 7EF7 B1C2 752D B1C3 6CF5 B1C4 8E66 B1C5 8FF8 B1C6 903C B1C7 9F3B B1C8 6BD4 B1C9 9119 B1CA 7B14 B1CB 5F7C B1CC 78A7 B1CD 84D6 B1CE 853D B1CF 6BD5 B1D0 6BD9 B1D1 6BD6 B1D2 5E01 B1D3 5E87 B1D4 75F9 B1D5 95ED B1D6 655D B1D7 5F0A B1D8 5FC5 B1D9 8F9F B1DA 58C1 B1DB 81C2 B1DC 907F B1DD 965B B1DE 97AD B1DF 8FB9 B1E0 7F16 B1E1 8D2C B1E2 6241 B1E3 4FBF B1E4 53D8 B1E5 535E B1E6 8FA8 B1E7 8FA9 B1E8 8FAB B1E9 904D B1EA 6807 B1EB 5F6A B1EC 8198 B1ED 8868 B1EE 9CD6 B1EF 618B B1F0 522B B1F1 762A B1F2 5F6C B1F3 658C B1F4 6FD2 B1F5 6EE8 B1F6 5BBE B1F7 6448 B1F8 5175 B1F9 51B0 B1FA 67C4 B1FB 4E19 B1FC 79C9 B1FD 997C B1FE 70B3 B2A1 75C5 B2A2 5E76 B2A3 73BB B2A4 83E0 B2A5 64AD B2A6 62E8 B2A7 94B5 B2A8 6CE2 B2A9 535A B2AA 52C3 B2AB 640F B2AC 94C2 B2AD 7B94 B2AE 4F2F B2AF 5E1B B2B0 8236 B2B1 8116 B2B2 818A B2B3 6E24 B2B4 6CCA B2B5 9A73 B2B6 6355 B2B7 535C B2B8 54FA B2B9 8865 B2BA 57E0 B2BB 4E0D B2BC 5E03 B2BD 6B65 B2BE 7C3F B2BF 90E8 B2C0 6016 B2C1 64E6 B2C2 731C B2C3 88C1 B2C4 6750 B2C5 624D B2C6 8D22 B2C7 776C B2C8 8E29 B2C9 91C7 B2CA 5F69 B2CB 83DC B2CC 8521 B2CD 9910 B2CE 53C2 B2CF 8695 B2D0 6B8B B2D1 60ED B2D2 60E8 B2D3 707F B2D4 82CD B2D5 8231 B2D6 4ED3 B2D7 6CA7 B2D8 85CF B2D9 64CD B2DA 7CD9 B2DB 69FD B2DC 66F9 B2DD 8349 B2DE 5395 B2DF 7B56 B2E0 4FA7 B2E1 518C B2E2 6D4B B2E3 5C42 B2E4 8E6D B2E5 63D2 B2E6 53C9 B2E7 832C B2E8 8336 B2E9 67E5 B2EA 78B4 B2EB 643D B2EC 5BDF B2ED 5C94 B2EE 5DEE B2EF 8BE7 B2F0 62C6 B2F1 67F4 B2F2 8C7A B2F3 6400 B2F4 63BA B2F5 8749 B2F6 998B B2F7 8C17 B2F8 7F20 B2F9 94F2 B2FA 4EA7 B2FB 9610 B2FC 98A4 B2FD 660C B2FE 7316 B3A1 573A B3A2 5C1D B3A3 5E38 B3A4 957F B3A5 507F B3A6 80A0 B3A7 5382 B3A8 655E B3A9 7545 B3AA 5531 B3AB 5021 B3AC 8D85 B3AD 6284 B3AE 949E B3AF 671D B3B0 5632 B3B1 6F6E B3B2 5DE2 B3B3 5435 B3B4 7092 B3B5 8F66 B3B6 626F B3B7 64A4 B3B8 63A3 B3B9 5F7B B3BA 6F88 B3BB 90F4 B3BC 81E3 B3BD 8FB0 B3BE 5C18 B3BF 6668 B3C0 5FF1 B3C1 6C89 B3C2 9648 B3C3 8D81 B3C4 886C B3C5 6491 B3C6 79F0 B3C7 57CE B3C8 6A59 B3C9 6210 B3CA 5448 B3CB 4E58 B3CC 7A0B B3CD 60E9 B3CE 6F84 B3CF 8BDA B3D0 627F B3D1 901E B3D2 9A8B B3D3 79E4 B3D4 5403 B3D5 75F4 B3D6 6301 B3D7 5319 B3D8 6C60 B3D9 8FDF B3DA 5F1B B3DB 9A70 B3DC 803B B3DD 9F7F B3DE 4F88 B3DF 5C3A B3E0 8D64 B3E1 7FC5 B3E2 65A5 B3E3 70BD B3E4 5145 B3E5 51B2 B3E6 866B B3E7 5D07 B3E8 5BA0 B3E9 62BD B3EA 916C B3EB 7574 B3EC 8E0C B3ED 7A20 B3EE 6101 B3EF 7B79 B3F0 4EC7 B3F1 7EF8 B3F2 7785 B3F3 4E11 B3F4 81ED B3F5 521D B3F6 51FA B3F7 6A71 B3F8 53A8 B3F9 8E87 B3FA 9504 B3FB 96CF B3FC 6EC1 B3FD 9664 B3FE 695A B4A1 7840 B4A2 50A8 B4A3 77D7 B4A4 6410 B4A5 89E6 B4A6 5904 B4A7 63E3 B4A8 5DDD B4A9 7A7F B4AA 693D B4AB 4F20 B4AC 8239 B4AD 5598 B4AE 4E32 B4AF 75AE B4B0 7A97 B4B1 5E62 B4B2 5E8A B4B3 95EF B4B4 521B B4B5 5439 B4B6 708A B4B7 6376 B4B8 9524 B4B9 5782 B4BA 6625 B4BB 693F B4BC 9187 B4BD 5507 B4BE 6DF3 B4BF 7EAF B4C0 8822 B4C1 6233 B4C2 7EF0 B4C3 75B5 B4C4 8328 B4C5 78C1 B4C6 96CC B4C7 8F9E B4C8 6148 B4C9 74F7 B4CA 8BCD B4CB 6B64 B4CC 523A B4CD 8D50 B4CE 6B21 B4CF 806A B4D0 8471 B4D1 56F1 B4D2 5306 B4D3 4ECE B4D4 4E1B B4D5 51D1 B4D6 7C97 B4D7 918B B4D8 7C07 B4D9 4FC3 B4DA 8E7F B4DB 7BE1 B4DC 7A9C B4DD 6467 B4DE 5D14 B4DF 50AC B4E0 8106 B4E1 7601 B4E2 7CB9 B4E3 6DEC B4E4 7FE0 B4E5 6751 B4E6 5B58 B4E7 5BF8 B4E8 78CB B4E9 64AE B4EA 6413 B4EB 63AA B4EC 632B B4ED 9519 B4EE 642D B4EF 8FBE B4F0 7B54 B4F1 7629 B4F2 6253 B4F3 5927 B4F4 5446 B4F5 6B79 B4F6 50A3 B4F7 6234 B4F8 5E26 B4F9 6B86 B4FA 4EE3 B4FB 8D37 B4FC 888B B4FD 5F85 B4FE 902E B5A1 6020 B5A2 803D B5A3 62C5 B5A4 4E39 B5A5 5355 B5A6 90F8 B5A7 63B8 B5A8 80C6 B5A9 65E6 B5AA 6C2E B5AB 4F46 B5AC 60EE B5AD 6DE1 B5AE 8BDE B5AF 5F39 B5B0 86CB B5B1 5F53 B5B2 6321 B5B3 515A B5B4 8361 B5B5 6863 B5B6 5200 B5B7 6363 B5B8 8E48 B5B9 5012 B5BA 5C9B B5BB 7977 B5BC 5BFC B5BD 5230 B5BE 7A3B B5BF 60BC B5C0 9053 B5C1 76D7 B5C2 5FB7 B5C3 5F97 B5C4 7684 B5C5 8E6C B5C6 706F B5C7 767B B5C8 7B49 B5C9 77AA B5CA 51F3 B5CB 9093 B5CC 5824 B5CD 4F4E B5CE 6EF4 B5CF 8FEA B5D0 654C B5D1 7B1B B5D2 72C4 B5D3 6DA4 B5D4 7FDF B5D5 5AE1 B5D6 62B5 B5D7 5E95 B5D8 5730 B5D9 8482 B5DA 7B2C B5DB 5E1D B5DC 5F1F B5DD 9012 B5DE 7F14 B5DF 98A0 B5E0 6382 B5E1 6EC7 B5E2 7898 B5E3 70B9 B5E4 5178 B5E5 975B B5E6 57AB B5E7 7535 B5E8 4F43 B5E9 7538 B5EA 5E97 B5EB 60E6 B5EC 5960 B5ED 6DC0 B5EE 6BBF B5EF 7889 B5F0 53FC B5F1 96D5 B5F2 51CB B5F3 5201 B5F4 6389 B5F5 540A B5F6 9493 B5F7 8C03 B5F8 8DCC B5F9 7239 B5FA 789F B5FB 8776 B5FC 8FED B5FD 8C0D B5FE 53E0 B6A1 4E01 B6A2 76EF B6A3 53EE B6A4 9489 B6A5 9876 B6A6 9F0E B6A7 952D B6A8 5B9A B6A9 8BA2 B6AA 4E22 B6AB 4E1C B6AC 51AC B6AD 8463 B6AE 61C2 B6AF 52A8 B6B0 680B B6B1 4F97 B6B2 606B B6B3 51BB B6B4 6D1E B6B5 515C B6B6 6296 B6B7 6597 B6B8 9661 B6B9 8C46 B6BA 9017 B6BB 75D8 B6BC 90FD B6BD 7763 B6BE 6BD2 B6BF 728A B6C0 72EC B6C1 8BFB B6C2 5835 B6C3 7779 B6C4 8D4C B6C5 675C B6C6 9540 B6C7 809A B6C8 5EA6 B6C9 6E21 B6CA 5992 B6CB 7AEF B6CC 77ED B6CD 953B B6CE 6BB5 B6CF 65AD B6D0 7F0E B6D1 5806 B6D2 5151 B6D3 961F B6D4 5BF9 B6D5 58A9 B6D6 5428 B6D7 8E72 B6D8 6566 B6D9 987F B6DA 56E4 B6DB 949D B6DC 76FE B6DD 9041 B6DE 6387 B6DF 54C6 B6E0 591A B6E1 593A B6E2 579B B6E3 8EB2 B6E4 6735 B6E5 8DFA B6E6 8235 B6E7 5241 B6E8 60F0 B6E9 5815 B6EA 86FE B6EB 5CE8 B6EC 9E45 B6ED 4FC4 B6EE 989D B6EF 8BB9 B6F0 5A25 B6F1 6076 B6F2 5384 B6F3 627C B6F4 904F B6F5 9102 B6F6 997F B6F7 6069 B6F8 800C B6F9 513F B6FA 8033 B6FB 5C14 B6FC 9975 B6FD 6D31 B6FE 4E8C B7A1 8D30 B7A2 53D1 B7A3 7F5A B7A4 7B4F B7A5 4F10 B7A6 4E4F B7A7 9600 B7A8 6CD5 B7A9 73D0 B7AA 85E9 B7AB 5E06 B7AC 756A B7AD 7FFB B7AE 6A0A B7AF 77FE B7B0 9492 B7B1 7E41 B7B2 51E1 B7B3 70E6 B7B4 53CD B7B5 8FD4 B7B6 8303 B7B7 8D29 B7B8 72AF B7B9 996D B7BA 6CDB B7BB 574A B7BC 82B3 B7BD 65B9 B7BE 80AA B7BF 623F B7C0 9632 B7C1 59A8 B7C2 4EFF B7C3 8BBF B7C4 7EBA B7C5 653E B7C6 83F2 B7C7 975E B7C8 5561 B7C9 98DE B7CA 80A5 B7CB 532A B7CC 8BFD B7CD 5420 B7CE 80BA B7CF 5E9F B7D0 6CB8 B7D1 8D39 B7D2 82AC B7D3 915A B7D4 5429 B7D5 6C1B B7D6 5206 B7D7 7EB7 B7D8 575F B7D9 711A B7DA 6C7E B7DB 7C89 B7DC 594B B7DD 4EFD B7DE 5FFF B7DF 6124 B7E0 7CAA B7E1 4E30 B7E2 5C01 B7E3 67AB B7E4 8702 B7E5 5CF0 B7E6 950B B7E7 98CE B7E8 75AF B7E9 70FD B7EA 9022 B7EB 51AF B7EC 7F1D B7ED 8BBD B7EE 5949 B7EF 51E4 B7F0 4F5B B7F1 5426 B7F2 592B B7F3 6577 B7F4 80A4 B7F5 5B75 B7F6 6276 B7F7 62C2 B7F8 8F90 B7F9 5E45 B7FA 6C1F B7FB 7B26 B7FC 4F0F B7FD 4FD8 B7FE 670D B8A1 6D6E B8A2 6DAA B8A3 798F B8A4 88B1 B8A5 5F17 B8A6 752B B8A7 629A B8A8 8F85 B8A9 4FEF B8AA 91DC B8AB 65A7 B8AC 812F B8AD 8151 B8AE 5E9C B8AF 8150 B8B0 8D74 B8B1 526F B8B2 8986 B8B3 8D4B B8B4 590D B8B5 5085 B8B6 4ED8 B8B7 961C B8B8 7236 B8B9 8179 B8BA 8D1F B8BB 5BCC B8BC 8BA3 B8BD 9644 B8BE 5987 B8BF 7F1A B8C0 5490 B8C1 5676 B8C2 560E B8C3 8BE5 B8C4 6539 B8C5 6982 B8C6 9499 B8C7 76D6 B8C8 6E89 B8C9 5E72 B8CA 7518 B8CB 6746 B8CC 67D1 B8CD 7AFF B8CE 809D B8CF 8D76 B8D0 611F B8D1 79C6 B8D2 6562 B8D3 8D63 B8D4 5188 B8D5 521A B8D6 94A2 B8D7 7F38 B8D8 809B B8D9 7EB2 B8DA 5C97 B8DB 6E2F B8DC 6760 B8DD 7BD9 B8DE 768B B8DF 9AD8 B8E0 818F B8E1 7F94 B8E2 7CD5 B8E3 641E B8E4 9550 B8E5 7A3F B8E6 544A B8E7 54E5 B8E8 6B4C B8E9 6401 B8EA 6208 B8EB 9E3D B8EC 80F3 B8ED 7599 B8EE 5272 B8EF 9769 B8F0 845B B8F1 683C B8F2 86E4 B8F3 9601 B8F4 9694 B8F5 94EC B8F6 4E2A B8F7 5404 B8F8 7ED9 B8F9 6839 B8FA 8DDF B8FB 8015 B8FC 66F4 B8FD 5E9A B8FE 7FB9 B9A1 57C2 B9A2 803F B9A3 6897 B9A4 5DE5 B9A5 653B B9A6 529F B9A7 606D B9A8 9F9A B9A9 4F9B B9AA 8EAC B9AB 516C B9AC 5BAB B9AD 5F13 B9AE 5DE9 B9AF 6C5E B9B0 62F1 B9B1 8D21 B9B2 5171 B9B3 94A9 B9B4 52FE B9B5 6C9F B9B6 82DF B9B7 72D7 B9B8 57A2 B9B9 6784 B9BA 8D2D B9BB 591F B9BC 8F9C B9BD 83C7 B9BE 5495 B9BF 7B8D B9C0 4F30 B9C1 6CBD B9C2 5B64 B9C3 59D1 B9C4 9F13 B9C5 53E4 B9C6 86CA B9C7 9AA8 B9C8 8C37 B9C9 80A1 B9CA 6545 B9CB 987E B9CC 56FA B9CD 96C7 B9CE 522E B9CF 74DC B9D0 5250 B9D1 5BE1 B9D2 6302 B9D3 8902 B9D4 4E56 B9D5 62D0 B9D6 602A B9D7 68FA B9D8 5173 B9D9 5B98 B9DA 51A0 B9DB 89C2 B9DC 7BA1 B9DD 9986 B9DE 7F50 B9DF 60EF B9E0 704C B9E1 8D2F B9E2 5149 B9E3 5E7F B9E4 901B B9E5 7470 B9E6 89C4 B9E7 572D B9E8 7845 B9E9 5F52 B9EA 9F9F B9EB 95FA B9EC 8F68 B9ED 9B3C B9EE 8BE1 B9EF 7678 B9F0 6842 B9F1 67DC B9F2 8DEA B9F3 8D35 B9F4 523D B9F5 8F8A B9F6 6EDA B9F7 68CD B9F8 9505 B9F9 90ED B9FA 56FD B9FB 679C B9FC 88F9 B9FD 8FC7 B9FE 54C8 BAA1 9AB8 BAA2 5B69 BAA3 6D77 BAA4 6C26 BAA5 4EA5 BAA6 5BB3 BAA7 9A87 BAA8 9163 BAA9 61A8 BAAA 90AF BAAB 97E9 BAAC 542B BAAD 6DB5 BAAE 5BD2 BAAF 51FD BAB0 558A BAB1 7F55 BAB2 7FF0 BAB3 64BC BAB4 634D BAB5 65F1 BAB6 61BE BAB7 608D BAB8 710A BAB9 6C57 BABA 6C49 BABB 592F BABC 676D BABD 822A BABE 58D5 BABF 568E BAC0 8C6A BAC1 6BEB BAC2 90DD BAC3 597D BAC4 8017 BAC5 53F7 BAC6 6D69 BAC7 5475 BAC8 559D BAC9 8377 BACA 83CF BACB 6838 BACC 79BE BACD 548C BACE 4F55 BACF 5408 BAD0 76D2 BAD1 8C89 BAD2 9602 BAD3 6CB3 BAD4 6DB8 BAD5 8D6B BAD6 8910 BAD7 9E64 BAD8 8D3A BAD9 563F BADA 9ED1 BADB 75D5 BADC 5F88 BADD 72E0 BADE 6068 BADF 54FC BAE0 4EA8 BAE1 6A2A BAE2 8861 BAE3 6052 BAE4 8F70 BAE5 54C4 BAE6 70D8 BAE7 8679 BAE8 9E3F BAE9 6D2A BAEA 5B8F BAEB 5F18 BAEC 7EA2 BAED 5589 BAEE 4FAF BAEF 7334 BAF0 543C BAF1 539A BAF2 5019 BAF3 540E BAF4 547C BAF5 4E4E BAF6 5FFD BAF7 745A BAF8 58F6 BAF9 846B BAFA 80E1 BAFB 8774 BAFC 72D0 BAFD 7CCA BAFE 6E56 BBA1 5F27 BBA2 864E BBA3 552C BBA4 62A4 BBA5 4E92 BBA6 6CAA BBA7 6237 BBA8 82B1 BBA9 54D7 BBAA 534E BBAB 733E BBAC 6ED1 BBAD 753B BBAE 5212 BBAF 5316 BBB0 8BDD BBB1 69D0 BBB2 5F8A BBB3 6000 BBB4 6DEE BBB5 574F BBB6 6B22 BBB7 73AF BBB8 6853 BBB9 8FD8 BBBA 7F13 BBBB 6362 BBBC 60A3 BBBD 5524 BBBE 75EA BBBF 8C62 BBC0 7115 BBC1 6DA3 BBC2 5BA6 BBC3 5E7B BBC4 8352 BBC5 614C BBC6 9EC4 BBC7 78FA BBC8 8757 BBC9 7C27 BBCA 7687 BBCB 51F0 BBCC 60F6 BBCD 714C BBCE 6643 BBCF 5E4C BBD0 604D BBD1 8C0E BBD2 7070 BBD3 6325 BBD4 8F89 BBD5 5FBD BBD6 6062 BBD7 86D4 BBD8 56DE BBD9 6BC1 BBDA 6094 BBDB 6167 BBDC 5349 BBDD 60E0 BBDE 6666 BBDF 8D3F BBE0 79FD BBE1 4F1A BBE2 70E9 BBE3 6C47 BBE4 8BB3 BBE5 8BF2 BBE6 7ED8 BBE7 8364 BBE8 660F BBE9 5A5A BBEA 9B42 BBEB 6D51 BBEC 6DF7 BBED 8C41 BBEE 6D3B BBEF 4F19 BBF0 706B BBF1 83B7 BBF2 6216 BBF3 60D1 BBF4 970D BBF5 8D27 BBF6 7978 BBF7 51FB BBF8 573E BBF9 57FA BBFA 673A BBFB 7578 BBFC 7A3D BBFD 79EF BBFE 7B95 BCA1 808C BCA2 9965 BCA3 8FF9 BCA4 6FC0 BCA5 8BA5 BCA6 9E21 BCA7 59EC BCA8 7EE9 BCA9 7F09 BCAA 5409 BCAB 6781 BCAC 68D8 BCAD 8F91 BCAE 7C4D BCAF 96C6 BCB0 53CA BCB1 6025 BCB2 75BE BCB3 6C72 BCB4 5373 BCB5 5AC9 BCB6 7EA7 BCB7 6324 BCB8 51E0 BCB9 810A BCBA 5DF1 BCBB 84DF BCBC 6280 BCBD 5180 BCBE 5B63 BCBF 4F0E BCC0 796D BCC1 5242 BCC2 60B8 BCC3 6D4E BCC4 5BC4 BCC5 5BC2 BCC6 8BA1 BCC7 8BB0 BCC8 65E2 BCC9 5FCC BCCA 9645 BCCB 5993 BCCC 7EE7 BCCD 7EAA BCCE 5609 BCCF 67B7 BCD0 5939 BCD1 4F73 BCD2 5BB6 BCD3 52A0 BCD4 835A BCD5 988A BCD6 8D3E BCD7 7532 BCD8 94BE BCD9 5047 BCDA 7A3C BCDB 4EF7 BCDC 67B6 BCDD 9A7E BCDE 5AC1 BCDF 6B7C BCE0 76D1 BCE1 575A BCE2 5C16 BCE3 7B3A BCE4 95F4 BCE5 714E BCE6 517C BCE7 80A9 BCE8 8270 BCE9 5978 BCEA 7F04 BCEB 8327 BCEC 68C0 BCED 67EC BCEE 78B1 BCEF 7877 BCF0 62E3 BCF1 6361 BCF2 7B80 BCF3 4FED BCF4 526A BCF5 51CF BCF6 8350 BCF7 69DB BCF8 9274 BCF9 8DF5 BCFA 8D31 BCFB 89C1 BCFC 952E BCFD 7BAD BCFE 4EF6 BDA1 5065 BDA2 8230 BDA3 5251 BDA4 996F BDA5 6E10 BDA6 6E85 BDA7 6DA7 BDA8 5EFA BDA9 50F5 BDAA 59DC BDAB 5C06 BDAC 6D46 BDAD 6C5F BDAE 7586 BDAF 848B BDB0 6868 BDB1 5956 BDB2 8BB2 BDB3 5320 BDB4 9171 BDB5 964D BDB6 8549 BDB7 6912 BDB8 7901 BDB9 7126 BDBA 80F6 BDBB 4EA4 BDBC 90CA BDBD 6D47 BDBE 9A84 BDBF 5A07 BDC0 56BC BDC1 6405 BDC2 94F0 BDC3 77EB BDC4 4FA5 BDC5 811A BDC6 72E1 BDC7 89D2 BDC8 997A BDC9 7F34 BDCA 7EDE BDCB 527F BDCC 6559 BDCD 9175 BDCE 8F7F BDCF 8F83 BDD0 53EB BDD1 7A96 BDD2 63ED BDD3 63A5 BDD4 7686 BDD5 79F8 BDD6 8857 BDD7 9636 BDD8 622A BDD9 52AB BDDA 8282 BDDB 6854 BDDC 6770 BDDD 6377 BDDE 776B BDDF 7AED BDE0 6D01 BDE1 7ED3 BDE2 89E3 BDE3 59D0 BDE4 6212 BDE5 85C9 BDE6 82A5 BDE7 754C BDE8 501F BDE9 4ECB BDEA 75A5 BDEB 8BEB BDEC 5C4A BDED 5DFE BDEE 7B4B BDEF 65A4 BDF0 91D1 BDF1 4ECA BDF2 6D25 BDF3 895F BDF4 7D27 BDF5 9526 BDF6 4EC5 BDF7 8C28 BDF8 8FDB BDF9 9773 BDFA 664B BDFB 7981 BDFC 8FD1 BDFD 70EC BDFE 6D78 BEA1 5C3D BEA2 52B2 BEA3 8346 BEA4 5162 BEA5 830E BEA6 775B BEA7 6676 BEA8 9CB8 BEA9 4EAC BEAA 60CA BEAB 7CBE BEAC 7CB3 BEAD 7ECF BEAE 4E95 BEAF 8B66 BEB0 666F BEB1 9888 BEB2 9759 BEB3 5883 BEB4 656C BEB5 955C BEB6 5F84 BEB7 75C9 BEB8 9756 BEB9 7ADF BEBA 7ADE BEBB 51C0 BEBC 70AF BEBD 7A98 BEBE 63EA BEBF 7A76 BEC0 7EA0 BEC1 7396 BEC2 97ED BEC3 4E45 BEC4 7078 BEC5 4E5D BEC6 9152 BEC7 53A9 BEC8 6551 BEC9 65E7 BECA 81FC BECB 8205 BECC 548E BECD 5C31 BECE 759A BECF 97A0 BED0 62D8 BED1 72D9 BED2 75BD BED3 5C45 BED4 9A79 BED5 83CA BED6 5C40 BED7 5480 BED8 77E9 BED9 4E3E BEDA 6CAE BEDB 805A BEDC 62D2 BEDD 636E BEDE 5DE8 BEDF 5177 BEE0 8DDD BEE1 8E1E BEE2 952F BEE3 4FF1 BEE4 53E5 BEE5 60E7 BEE6 70AC BEE7 5267 BEE8 6350 BEE9 9E43 BEEA 5A1F BEEB 5026 BEEC 7737 BEED 5377 BEEE 7EE2 BEEF 6485 BEF0 652B BEF1 6289 BEF2 6398 BEF3 5014 BEF4 7235 BEF5 89C9 BEF6 51B3 BEF7 8BC0 BEF8 7EDD BEF9 5747 BEFA 83CC BEFB 94A7 BEFC 519B BEFD 541B BEFE 5CFB BFA1 4FCA BFA2 7AE3 BFA3 6D5A BFA4 90E1 BFA5 9A8F BFA6 5580 BFA7 5496 BFA8 5361 BFA9 54AF BFAA 5F00 BFAB 63E9 BFAC 6977 BFAD 51EF BFAE 6168 BFAF 520A BFB0 582A BFB1 52D8 BFB2 574E BFB3 780D BFB4 770B BFB5 5EB7 BFB6 6177 BFB7 7CE0 BFB8 625B BFB9 6297 BFBA 4EA2 BFBB 7095 BFBC 8003 BFBD 62F7 BFBE 70E4 BFBF 9760 BFC0 5777 BFC1 82DB BFC2 67EF BFC3 68F5 BFC4 78D5 BFC5 9897 BFC6 79D1 BFC7 58F3 BFC8 54B3 BFC9 53EF BFCA 6E34 BFCB 514B BFCC 523B BFCD 5BA2 BFCE 8BFE BFCF 80AF BFD0 5543 BFD1 57A6 BFD2 6073 BFD3 5751 BFD4 542D BFD5 7A7A BFD6 6050 BFD7 5B54 BFD8 63A7 BFD9 62A0 BFDA 53E3 BFDB 6263 BFDC 5BC7 BFDD 67AF BFDE 54ED BFDF 7A9F BFE0 82E6 BFE1 9177 BFE2 5E93 BFE3 88E4 BFE4 5938 BFE5 57AE BFE6 630E BFE7 8DE8 BFE8 80EF BFE9 5757 BFEA 7B77 BFEB 4FA9 BFEC 5FEB BFED 5BBD BFEE 6B3E BFEF 5321 BFF0 7B50 BFF1 72C2 BFF2 6846 BFF3 77FF BFF4 7736 BFF5 65F7 BFF6 51B5 BFF7 4E8F BFF8 76D4 BFF9 5CBF BFFA 7AA5 BFFB 8475 BFFC 594E BFFD 9B41 BFFE 5080 C0A1 9988 C0A2 6127 C0A3 6E83 C0A4 5764 C0A5 6606 C0A6 6346 C0A7 56F0 C0A8 62EC C0A9 6269 C0AA 5ED3 C0AB 9614 C0AC 5783 C0AD 62C9 C0AE 5587 C0AF 8721 C0B0 814A C0B1 8FA3 C0B2 5566 C0B3 83B1 C0B4 6765 C0B5 8D56 C0B6 84DD C0B7 5A6A C0B8 680F C0B9 62E6 C0BA 7BEE C0BB 9611 C0BC 5170 C0BD 6F9C C0BE 8C30 C0BF 63FD C0C0 89C8 C0C1 61D2 C0C2 7F06 C0C3 70C2 C0C4 6EE5 C0C5 7405 C0C6 6994 C0C7 72FC C0C8 5ECA C0C9 90CE C0CA 6717 C0CB 6D6A C0CC 635E C0CD 52B3 C0CE 7262 C0CF 8001 C0D0 4F6C C0D1 59E5 C0D2 916A C0D3 70D9 C0D4 6D9D C0D5 52D2 C0D6 4E50 C0D7 96F7 C0D8 956D C0D9 857E C0DA 78CA C0DB 7D2F C0DC 5121 C0DD 5792 C0DE 64C2 C0DF 808B C0E0 7C7B C0E1 6CEA C0E2 68F1 C0E3 695E C0E4 51B7 C0E5 5398 C0E6 68A8 C0E7 7281 C0E8 9ECE C0E9 7BF1 C0EA 72F8 C0EB 79BB C0EC 6F13 C0ED 7406 C0EE 674E C0EF 91CC C0F0 9CA4 C0F1 793C C0F2 8389 C0F3 8354 C0F4 540F C0F5 6817 C0F6 4E3D C0F7 5389 C0F8 52B1 C0F9 783E C0FA 5386 C0FB 5229 C0FC 5088 C0FD 4F8B C0FE 4FD0 C1A1 75E2 C1A2 7ACB C1A3 7C92 C1A4 6CA5 C1A5 96B6 C1A6 529B C1A7 7483 C1A8 54E9 C1A9 4FE9 C1AA 8054 C1AB 83B2 C1AC 8FDE C1AD 9570 C1AE 5EC9 C1AF 601C C1B0 6D9F C1B1 5E18 C1B2 655B C1B3 8138 C1B4 94FE C1B5 604B C1B6 70BC C1B7 7EC3 C1B8 7CAE C1B9 51C9 C1BA 6881 C1BB 7CB1 C1BC 826F C1BD 4E24 C1BE 8F86 C1BF 91CF C1C0 667E C1C1 4EAE C1C2 8C05 C1C3 64A9 C1C4 804A C1C5 50DA C1C6 7597 C1C7 71CE C1C8 5BE5 C1C9 8FBD C1CA 6F66 C1CB 4E86 C1CC 6482 C1CD 9563 C1CE 5ED6 C1CF 6599 C1D0 5217 C1D1 88C2 C1D2 70C8 C1D3 52A3 C1D4 730E C1D5 7433 C1D6 6797 C1D7 78F7 C1D8 9716 C1D9 4E34 C1DA 90BB C1DB 9CDE C1DC 6DCB C1DD 51DB C1DE 8D41 C1DF 541D C1E0 62CE C1E1 73B2 C1E2 83F1 C1E3 96F6 C1E4 9F84 C1E5 94C3 C1E6 4F36 C1E7 7F9A C1E8 51CC C1E9 7075 C1EA 9675 C1EB 5CAD C1EC 9886 C1ED 53E6 C1EE 4EE4 C1EF 6E9C C1F0 7409 C1F1 69B4 C1F2 786B C1F3 998F C1F4 7559 C1F5 5218 C1F6 7624 C1F7 6D41 C1F8 67F3 C1F9 516D C1FA 9F99 C1FB 804B C1FC 5499 C1FD 7B3C C1FE 7ABF C2A1 9686 C2A2 5784 C2A3 62E2 C2A4 9647 C2A5 697C C2A6 5A04 C2A7 6402 C2A8 7BD3 C2A9 6F0F C2AA 964B C2AB 82A6 C2AC 5362 C2AD 9885 C2AE 5E90 C2AF 7089 C2B0 63B3 C2B1 5364 C2B2 864F C2B3 9C81 C2B4 9E93 C2B5 788C C2B6 9732 C2B7 8DEF C2B8 8D42 C2B9 9E7F C2BA 6F5E C2BB 7984 C2BC 5F55 C2BD 9646 C2BE 622E C2BF 9A74 C2C0 5415 C2C1 94DD C2C2 4FA3 C2C3 65C5 C2C4 5C65 C2C5 5C61 C2C6 7F15 C2C7 8651 C2C8 6C2F C2C9 5F8B C2CA 7387 C2CB 6EE4 C2CC 7EFF C2CD 5CE6 C2CE 631B C2CF 5B6A C2D0 6EE6 C2D1 5375 C2D2 4E71 C2D3 63A0 C2D4 7565 C2D5 62A1 C2D6 8F6E C2D7 4F26 C2D8 4ED1 C2D9 6CA6 C2DA 7EB6 C2DB 8BBA C2DC 841D C2DD 87BA C2DE 7F57 C2DF 903B C2E0 9523 C2E1 7BA9 C2E2 9AA1 C2E3 88F8 C2E4 843D C2E5 6D1B C2E6 9A86 C2E7 7EDC C2E8 5988 C2E9 9EBB C2EA 739B C2EB 7801 C2EC 8682 C2ED 9A6C C2EE 9A82 C2EF 561B C2F0 5417 C2F1 57CB C2F2 4E70 C2F3 9EA6 C2F4 5356 C2F5 8FC8 C2F6 8109 C2F7 7792 C2F8 9992 C2F9 86EE C2FA 6EE1 C2FB 8513 C2FC 66FC C2FD 6162 C2FE 6F2B C3A1 8C29 C3A2 8292 C3A3 832B C3A4 76F2 C3A5 6C13 C3A6 5FD9 C3A7 83BD C3A8 732B C3A9 8305 C3AA 951A C3AB 6BDB C3AC 77DB C3AD 94C6 C3AE 536F C3AF 8302 C3B0 5192 C3B1 5E3D C3B2 8C8C C3B3 8D38 C3B4 4E48 C3B5 73AB C3B6 679A C3B7 6885 C3B8 9176 C3B9 9709 C3BA 7164 C3BB 6CA1 C3BC 7709 C3BD 5A92 C3BE 9541 C3BF 6BCF C3C0 7F8E C3C1 6627 C3C2 5BD0 C3C3 59B9 C3C4 5A9A C3C5 95E8 C3C6 95F7 C3C7 4EEC C3C8 840C C3C9 8499 C3CA 6AAC C3CB 76DF C3CC 9530 C3CD 731B C3CE 68A6 C3CF 5B5F C3D0 772F C3D1 919A C3D2 9761 C3D3 7CDC C3D4 8FF7 C3D5 8C1C C3D6 5F25 C3D7 7C73 C3D8 79D8 C3D9 89C5 C3DA 6CCC C3DB 871C C3DC 5BC6 C3DD 5E42 C3DE 68C9 C3DF 7720 C3E0 7EF5 C3E1 5195 C3E2 514D C3E3 52C9 C3E4 5A29 C3E5 7F05 C3E6 9762 C3E7 82D7 C3E8 63CF C3E9 7784 C3EA 85D0 C3EB 79D2 C3EC 6E3A C3ED 5E99 C3EE 5999 C3EF 8511 C3F0 706D C3F1 6C11 C3F2 62BF C3F3 76BF C3F4 654F C3F5 60AF C3F6 95FD C3F7 660E C3F8 879F C3F9 9E23 C3FA 94ED C3FB 540D C3FC 547D C3FD 8C2C C3FE 6478 C4A1 6479 C4A2 8611 C4A3 6A21 C4A4 819C C4A5 78E8 C4A6 6469 C4A7 9B54 C4A8 62B9 C4A9 672B C4AA 83AB C4AB 58A8 C4AC 9ED8 C4AD 6CAB C4AE 6F20 C4AF 5BDE C4B0 964C C4B1 8C0B C4B2 725F C4B3 67D0 C4B4 62C7 C4B5 7261 C4B6 4EA9 C4B7 59C6 C4B8 6BCD C4B9 5893 C4BA 66AE C4BB 5E55 C4BC 52DF C4BD 6155 C4BE 6728 C4BF 76EE C4C0 7766 C4C1 7267 C4C2 7A46 C4C3 62FF C4C4 54EA C4C5 5450 C4C6 94A0 C4C7 90A3 C4C8 5A1C C4C9 7EB3 C4CA 6C16 C4CB 4E43 C4CC 5976 C4CD 8010 C4CE 5948 C4CF 5357 C4D0 7537 C4D1 96BE C4D2 56CA C4D3 6320 C4D4 8111 C4D5 607C C4D6 95F9 C4D7 6DD6 C4D8 5462 C4D9 9981 C4DA 5185 C4DB 5AE9 C4DC 80FD C4DD 59AE C4DE 9713 C4DF 502A C4E0 6CE5 C4E1 5C3C C4E2 62DF C4E3 4F60 C4E4 533F C4E5 817B C4E6 9006 C4E7 6EBA C4E8 852B C4E9 62C8 C4EA 5E74 C4EB 78BE C4EC 64B5 C4ED 637B C4EE 5FF5 C4EF 5A18 C4F0 917F C4F1 9E1F C4F2 5C3F C4F3 634F C4F4 8042 C4F5 5B7D C4F6 556E C4F7 954A C4F8 954D C4F9 6D85 C4FA 60A8 C4FB 67E0 C4FC 72DE C4FD 51DD C4FE 5B81 C5A1 62E7 C5A2 6CDE C5A3 725B C5A4 626D C5A5 94AE C5A6 7EBD C5A7 8113 C5A8 6D53 C5A9 519C C5AA 5F04 C5AB 5974 C5AC 52AA C5AD 6012 C5AE 5973 C5AF 6696 C5B0 8650 C5B1 759F C5B2 632A C5B3 61E6 C5B4 7CEF C5B5 8BFA C5B6 54E6 C5B7 6B27 C5B8 9E25 C5B9 6BB4 C5BA 85D5 C5BB 5455 C5BC 5076 C5BD 6CA4 C5BE 556A C5BF 8DB4 C5C0 722C C5C1 5E15 C5C2 6015 C5C3 7436 C5C4 62CD C5C5 6392 C5C6 724C C5C7 5F98 C5C8 6E43 C5C9 6D3E C5CA 6500 C5CB 6F58 C5CC 76D8 C5CD 78D0 C5CE 76FC C5CF 7554 C5D0 5224 C5D1 53DB C5D2 4E53 C5D3 5E9E C5D4 65C1 C5D5 802A C5D6 80D6 C5D7 629B C5D8 5486 C5D9 5228 C5DA 70AE C5DB 888D C5DC 8DD1 C5DD 6CE1 C5DE 5478 C5DF 80DA C5E0 57F9 C5E1 88F4 C5E2 8D54 C5E3 966A C5E4 914D C5E5 4F69 C5E6 6C9B C5E7 55B7 C5E8 76C6 C5E9 7830 C5EA 62A8 C5EB 70F9 C5EC 6F8E C5ED 5F6D C5EE 84EC C5EF 68DA C5F0 787C C5F1 7BF7 C5F2 81A8 C5F3 670B C5F4 9E4F C5F5 6367 C5F6 78B0 C5F7 576F C5F8 7812 C5F9 9739 C5FA 6279 C5FB 62AB C5FC 5288 C5FD 7435 C5FE 6BD7 C6A1 5564 C6A2 813E C6A3 75B2 C6A4 76AE C6A5 5339 C6A6 75DE C6A7 50FB C6A8 5C41 C6A9 8B6C C6AA 7BC7 C6AB 504F C6AC 7247 C6AD 9A97 C6AE 98D8 C6AF 6F02 C6B0 74E2 C6B1 7968 C6B2 6487 C6B3 77A5 C6B4 62FC C6B5 9891 C6B6 8D2B C6B7 54C1 C6B8 8058 C6B9 4E52 C6BA 576A C6BB 82F9 C6BC 840D C6BD 5E73 C6BE 51ED C6BF 74F6 C6C0 8BC4 C6C1 5C4F C6C2 5761 C6C3 6CFC C6C4 9887 C6C5 5A46 C6C6 7834 C6C7 9B44 C6C8 8FEB C6C9 7C95 C6CA 5256 C6CB 6251 C6CC 94FA C6CD 4EC6 C6CE 8386 C6CF 8461 C6D0 83E9 C6D1 84B2 C6D2 57D4 C6D3 6734 C6D4 5703 C6D5 666E C6D6 6D66 C6D7 8C31 C6D8 66DD C6D9 7011 C6DA 671F C6DB 6B3A C6DC 6816 C6DD 621A C6DE 59BB C6DF 4E03 C6E0 51C4 C6E1 6F06 C6E2 67D2 C6E3 6C8F C6E4 5176 C6E5 68CB C6E6 5947 C6E7 6B67 C6E8 7566 C6E9 5D0E C6EA 8110 C6EB 9F50 C6EC 65D7 C6ED 7948 C6EE 7941 C6EF 9A91 C6F0 8D77 C6F1 5C82 C6F2 4E5E C6F3 4F01 C6F4 542F C6F5 5951 C6F6 780C C6F7 5668 C6F8 6C14 C6F9 8FC4 C6FA 5F03 C6FB 6C7D C6FC 6CE3 C6FD 8BAB C6FE 6390 C7A1 6070 C7A2 6D3D C7A3 7275 C7A4 6266 C7A5 948E C7A6 94C5 C7A7 5343 C7A8 8FC1 C7A9 7B7E C7AA 4EDF C7AB 8C26 C7AC 4E7E C7AD 9ED4 C7AE 94B1 C7AF 94B3 C7B0 524D C7B1 6F5C C7B2 9063 C7B3 6D45 C7B4 8C34 C7B5 5811 C7B6 5D4C C7B7 6B20 C7B8 6B49 C7B9 67AA C7BA 545B C7BB 8154 C7BC 7F8C C7BD 5899 C7BE 8537 C7BF 5F3A C7C0 62A2 C7C1 6A47 C7C2 9539 C7C3 6572 C7C4 6084 C7C5 6865 C7C6 77A7 C7C7 4E54 C7C8 4FA8 C7C9 5DE7 C7CA 9798 C7CB 64AC C7CC 7FD8 C7CD 5CED C7CE 4FCF C7CF 7A8D C7D0 5207 C7D1 8304 C7D2 4E14 C7D3 602F C7D4 7A83 C7D5 94A6 C7D6 4FB5 C7D7 4EB2 C7D8 79E6 C7D9 7434 C7DA 52E4 C7DB 82B9 C7DC 64D2 C7DD 79BD C7DE 5BDD C7DF 6C81 C7E0 9752 C7E1 8F7B C7E2 6C22 C7E3 503E C7E4 537F C7E5 6E05 C7E6 64CE C7E7 6674 C7E8 6C30 C7E9 60C5 C7EA 9877 C7EB 8BF7 C7EC 5E86 C7ED 743C C7EE 7A77 C7EF 79CB C7F0 4E18 C7F1 90B1 C7F2 7403 C7F3 6C42 C7F4 56DA C7F5 914B C7F6 6CC5 C7F7 8D8B C7F8 533A C7F9 86C6 C7FA 66F2 C7FB 8EAF C7FC 5C48 C7FD 9A71 C7FE 6E20 C8A1 53D6 C8A2 5A36 C8A3 9F8B C8A4 8DA3 C8A5 53BB C8A6 5708 C8A7 98A7 C8A8 6743 C8A9 919B C8AA 6CC9 C8AB 5168 C8AC 75CA C8AD 62F3 C8AE 72AC C8AF 5238 C8B0 529D C8B1 7F3A C8B2 7094 C8B3 7638 C8B4 5374 C8B5 9E4A C8B6 69B7 C8B7 786E C8B8 96C0 C8B9 88D9 C8BA 7FA4 C8BB 7136 C8BC 71C3 C8BD 5189 C8BE 67D3 C8BF 74E4 C8C0 58E4 C8C1 6518 C8C2 56B7 C8C3 8BA9 C8C4 9976 C8C5 6270 C8C6 7ED5 C8C7 60F9 C8C8 70ED C8C9 58EC C8CA 4EC1 C8CB 4EBA C8CC 5FCD C8CD 97E7 C8CE 4EFB C8CF 8BA4 C8D0 5203 C8D1 598A C8D2 7EAB C8D3 6254 C8D4 4ECD C8D5 65E5 C8D6 620E C8D7 8338 C8D8 84C9 C8D9 8363 C8DA 878D C8DB 7194 C8DC 6EB6 C8DD 5BB9 C8DE 7ED2 C8DF 5197 C8E0 63C9 C8E1 67D4 C8E2 8089 C8E3 8339 C8E4 8815 C8E5 5112 C8E6 5B7A C8E7 5982 C8E8 8FB1 C8E9 4E73 C8EA 6C5D C8EB 5165 C8EC 8925 C8ED 8F6F C8EE 962E C8EF 854A C8F0 745E C8F1 9510 C8F2 95F0 C8F3 6DA6 C8F4 82E5 C8F5 5F31 C8F6 6492 C8F7 6D12 C8F8 8428 C8F9 816E C8FA 9CC3 C8FB 585E C8FC 8D5B C8FD 4E09 C8FE 53C1 C9A1 4F1E C9A2 6563 C9A3 6851 C9A4 55D3 C9A5 4E27 C9A6 6414 C9A7 9A9A C9A8 626B C9A9 5AC2 C9AA 745F C9AB 8272 C9AC 6DA9 C9AD 68EE C9AE 50E7 C9AF 838E C9B0 7802 C9B1 6740 C9B2 5239 C9B3 6C99 C9B4 7EB1 C9B5 50BB C9B6 5565 C9B7 715E C9B8 7B5B C9B9 6652 C9BA 73CA C9BB 82EB C9BC 6749 C9BD 5C71 C9BE 5220 C9BF 717D C9C0 886B C9C1 95EA C9C2 9655 C9C3 64C5 C9C4 8D61 C9C5 81B3 C9C6 5584 C9C7 6C55 C9C8 6247 C9C9 7F2E C9CA 5892 C9CB 4F24 C9CC 5546 C9CD 8D4F C9CE 664C C9CF 4E0A C9D0 5C1A C9D1 88F3 C9D2 68A2 C9D3 634E C9D4 7A0D C9D5 70E7 C9D6 828D C9D7 52FA C9D8 97F6 C9D9 5C11 C9DA 54E8 C9DB 90B5 C9DC 7ECD C9DD 5962 C9DE 8D4A C9DF 86C7 C9E0 820C C9E1 820D C9E2 8D66 C9E3 6444 C9E4 5C04 C9E5 6151 C9E6 6D89 C9E7 793E C9E8 8BBE C9E9 7837 C9EA 7533 C9EB 547B C9EC 4F38 C9ED 8EAB C9EE 6DF1 C9EF 5A20 C9F0 7EC5 C9F1 795E C9F2 6C88 C9F3 5BA1 C9F4 5A76 C9F5 751A C9F6 80BE C9F7 614E C9F8 6E17 C9F9 58F0 C9FA 751F C9FB 7525 C9FC 7272 C9FD 5347 C9FE 7EF3 CAA1 7701 CAA2 76DB CAA3 5269 CAA4 80DC CAA5 5723 CAA6 5E08 CAA7 5931 CAA8 72EE CAA9 65BD CAAA 6E7F CAAB 8BD7 CAAC 5C38 CAAD 8671 CAAE 5341 CAAF 77F3 CAB0 62FE CAB1 65F6 CAB2 4EC0 CAB3 98DF CAB4 8680 CAB5 5B9E CAB6 8BC6 CAB7 53F2 CAB8 77E2 CAB9 4F7F CABA 5C4E CABB 9A76 CABC 59CB CABD 5F0F CABE 793A CABF 58EB CAC0 4E16 CAC1 67FF CAC2 4E8B CAC3 62ED CAC4 8A93 CAC5 901D CAC6 52BF CAC7 662F CAC8 55DC CAC9 566C CACA 9002 CACB 4ED5 CACC 4F8D CACD 91CA CACE 9970 CACF 6C0F CAD0 5E02 CAD1 6043 CAD2 5BA4 CAD3 89C6 CAD4 8BD5 CAD5 6536 CAD6 624B CAD7 9996 CAD8 5B88 CAD9 5BFF CADA 6388 CADB 552E CADC 53D7 CADD 7626 CADE 517D CADF 852C CAE0 67A2 CAE1 68B3 CAE2 6B8A CAE3 6292 CAE4 8F93 CAE5 53D4 CAE6 8212 CAE7 6DD1 CAE8 758F CAE9 4E66 CAEA 8D4E CAEB 5B70 CAEC 719F CAED 85AF CAEE 6691 CAEF 66D9 CAF0 7F72 CAF1 8700 CAF2 9ECD CAF3 9F20 CAF4 5C5E CAF5 672F CAF6 8FF0 CAF7 6811 CAF8 675F CAF9 620D CAFA 7AD6 CAFB 5885 CAFC 5EB6 CAFD 6570 CAFE 6F31 CBA1 6055 CBA2 5237 CBA3 800D CBA4 6454 CBA5 8870 CBA6 7529 CBA7 5E05 CBA8 6813 CBA9 62F4 CBAA 971C CBAB 53CC CBAC 723D CBAD 8C01 CBAE 6C34 CBAF 7761 CBB0 7A0E CBB1 542E CBB2 77AC CBB3 987A CBB4 821C CBB5 8BF4 CBB6 7855 CBB7 6714 CBB8 70C1 CBB9 65AF CBBA 6495 CBBB 5636 CBBC 601D CBBD 79C1 CBBE 53F8 CBBF 4E1D CBC0 6B7B CBC1 8086 CBC2 5BFA CBC3 55E3 CBC4 56DB CBC5 4F3A CBC6 4F3C CBC7 9972 CBC8 5DF3 CBC9 677E CBCA 8038 CBCB 6002 CBCC 9882 CBCD 9001 CBCE 5B8B CBCF 8BBC CBD0 8BF5 CBD1 641C CBD2 8258 CBD3 64DE CBD4 55FD CBD5 82CF CBD6 9165 CBD7 4FD7 CBD8 7D20 CBD9 901F CBDA 7C9F CBDB 50F3 CBDC 5851 CBDD 6EAF CBDE 5BBF CBDF 8BC9 CBE0 8083 CBE1 9178 CBE2 849C CBE3 7B97 CBE4 867D CBE5 968B CBE6 968F CBE7 7EE5 CBE8 9AD3 CBE9 788E CBEA 5C81 CBEB 7A57 CBEC 9042 CBED 96A7 CBEE 795F CBEF 5B59 CBF0 635F CBF1 7B0B CBF2 84D1 CBF3 68AD CBF4 5506 CBF5 7F29 CBF6 7410 CBF7 7D22 CBF8 9501 CBF9 6240 CBFA 584C CBFB 4ED6 CBFC 5B83 CBFD 5979 CBFE 5854 CCA1 736D CCA2 631E CCA3 8E4B CCA4 8E0F CCA5 80CE CCA6 82D4 CCA7 62AC CCA8 53F0 CCA9 6CF0 CCAA 915E CCAB 592A CCAC 6001 CCAD 6C70 CCAE 574D CCAF 644A CCB0 8D2A CCB1 762B CCB2 6EE9 CCB3 575B CCB4 6A80 CCB5 75F0 CCB6 6F6D CCB7 8C2D CCB8 8C08 CCB9 5766 CCBA 6BEF CCBB 8892 CCBC 78B3 CCBD 63A2 CCBE 53F9 CCBF 70AD CCC0 6C64 CCC1 5858 CCC2 642A CCC3 5802 CCC4 68E0 CCC5 819B CCC6 5510 CCC7 7CD6 CCC8 5018 CCC9 8EBA CCCA 6DCC CCCB 8D9F CCCC 70EB CCCD 638F CCCE 6D9B CCCF 6ED4 CCD0 7EE6 CCD1 8404 CCD2 6843 CCD3 9003 CCD4 6DD8 CCD5 9676 CCD6 8BA8 CCD7 5957 CCD8 7279 CCD9 85E4 CCDA 817E CCDB 75BC CCDC 8A8A CCDD 68AF CCDE 5254 CCDF 8E22 CCE0 9511 CCE1 63D0 CCE2 9898 CCE3 8E44 CCE4 557C CCE5 4F53 CCE6 66FF CCE7 568F CCE8 60D5 CCE9 6D95 CCEA 5243 CCEB 5C49 CCEC 5929 CCED 6DFB CCEE 586B CCEF 7530 CCF0 751C CCF1 606C CCF2 8214 CCF3 8146 CCF4 6311 CCF5 6761 CCF6 8FE2 CCF7 773A CCF8 8DF3 CCF9 8D34 CCFA 94C1 CCFB 5E16 CCFC 5385 CCFD 542C CCFE 70C3 CDA1 6C40 CDA2 5EF7 CDA3 505C CDA4 4EAD CDA5 5EAD CDA6 633A CDA7 8247 CDA8 901A CDA9 6850 CDAA 916E CDAB 77B3 CDAC 540C CDAD 94DC CDAE 5F64 CDAF 7AE5 CDB0 6876 CDB1 6345 CDB2 7B52 CDB3 7EDF CDB4 75DB CDB5 5077 CDB6 6295 CDB7 5934 CDB8 900F CDB9 51F8 CDBA 79C3 CDBB 7A81 CDBC 56FE CDBD 5F92 CDBE 9014 CDBF 6D82 CDC0 5C60 CDC1 571F CDC2 5410 CDC3 5154 CDC4 6E4D CDC5 56E2 CDC6 63A8 CDC7 9893 CDC8 817F CDC9 8715 CDCA 892A CDCB 9000 CDCC 541E CDCD 5C6F CDCE 81C0 CDCF 62D6 CDD0 6258 CDD1 8131 CDD2 9E35 CDD3 9640 CDD4 9A6E CDD5 9A7C CDD6 692D CDD7 59A5 CDD8 62D3 CDD9 553E CDDA 6316 CDDB 54C7 CDDC 86D9 CDDD 6D3C CDDE 5A03 CDDF 74E6 CDE0 889C CDE1 6B6A CDE2 5916 CDE3 8C4C CDE4 5F2F CDE5 6E7E CDE6 73A9 CDE7 987D CDE8 4E38 CDE9 70F7 CDEA 5B8C CDEB 7897 CDEC 633D CDED 665A CDEE 7696 CDEF 60CB CDF0 5B9B CDF1 5A49 CDF2 4E07 CDF3 8155 CDF4 6C6A CDF5 738B CDF6 4EA1 CDF7 6789 CDF8 7F51 CDF9 5F80 CDFA 65FA CDFB 671B CDFC 5FD8 CDFD 5984 CDFE 5A01 CEA1 5DCD CEA2 5FAE CEA3 5371 CEA4 97E6 CEA5 8FDD CEA6 6845 CEA7 56F4 CEA8 552F CEA9 60DF CEAA 4E3A CEAB 6F4D CEAC 7EF4 CEAD 82C7 CEAE 840E CEAF 59D4 CEB0 4F1F CEB1 4F2A CEB2 5C3E CEB3 7EAC CEB4 672A CEB5 851A CEB6 5473 CEB7 754F CEB8 80C3 CEB9 5582 CEBA 9B4F CEBB 4F4D CEBC 6E2D CEBD 8C13 CEBE 5C09 CEBF 6170 CEC0 536B CEC1 761F CEC2 6E29 CEC3 868A CEC4 6587 CEC5 95FB CEC6 7EB9 CEC7 543B CEC8 7A33 CEC9 7D0A CECA 95EE CECB 55E1 CECC 7FC1 CECD 74EE CECE 631D CECF 8717 CED0 6DA1 CED1 7A9D CED2 6211 CED3 65A1 CED4 5367 CED5 63E1 CED6 6C83 CED7 5DEB CED8 545C CED9 94A8 CEDA 4E4C CEDB 6C61 CEDC 8BEC CEDD 5C4B CEDE 65E0 CEDF 829C CEE0 68A7 CEE1 543E CEE2 5434 CEE3 6BCB CEE4 6B66 CEE5 4E94 CEE6 6342 CEE7 5348 CEE8 821E CEE9 4F0D CEEA 4FAE CEEB 575E CEEC 620A CEED 96FE CEEE 6664 CEEF 7269 CEF0 52FF CEF1 52A1 CEF2 609F CEF3 8BEF CEF4 6614 CEF5 7199 CEF6 6790 CEF7 897F CEF8 7852 CEF9 77FD CEFA 6670 CEFB 563B CEFC 5438 CEFD 9521 CEFE 727A CFA1 7A00 CFA2 606F CFA3 5E0C CFA4 6089 CFA5 819D CFA6 5915 CFA7 60DC CFA8 7184 CFA9 70EF CFAA 6EAA CFAB 6C50 CFAC 7280 CFAD 6A84 CFAE 88AD CFAF 5E2D CFB0 4E60 CFB1 5AB3 CFB2 559C CFB3 94E3 CFB4 6D17 CFB5 7CFB CFB6 9699 CFB7 620F CFB8 7EC6 CFB9 778E CFBA 867E CFBB 5323 CFBC 971E CFBD 8F96 CFBE 6687 CFBF 5CE1 CFC0 4FA0 CFC1 72ED CFC2 4E0B CFC3 53A6 CFC4 590F CFC5 5413 CFC6 6380 CFC7 9528 CFC8 5148 CFC9 4ED9 CFCA 9C9C CFCB 7EA4 CFCC 54B8 CFCD 8D24 CFCE 8854 CFCF 8237 CFD0 95F2 CFD1 6D8E CFD2 5F26 CFD3 5ACC CFD4 663E CFD5 9669 CFD6 73B0 CFD7 732E CFD8 53BF CFD9 817A CFDA 9985 CFDB 7FA1 CFDC 5BAA CFDD 9677 CFDE 9650 CFDF 7EBF CFE0 76F8 CFE1 53A2 CFE2 9576 CFE3 9999 CFE4 7BB1 CFE5 8944 CFE6 6E58 CFE7 4E61 CFE8 7FD4 CFE9 7965 CFEA 8BE6 CFEB 60F3 CFEC 54CD CFED 4EAB CFEE 9879 CFEF 5DF7 CFF0 6A61 CFF1 50CF CFF2 5411 CFF3 8C61 CFF4 8427 CFF5 785D CFF6 9704 CFF7 524A CFF8 54EE CFF9 56A3 CFFA 9500 CFFB 6D88 CFFC 5BB5 CFFD 6DC6 CFFE 6653 D0A1 5C0F D0A2 5B5D D0A3 6821 D0A4 8096 D0A5 5578 D0A6 7B11 D0A7 6548 D0A8 6954 D0A9 4E9B D0AA 6B47 D0AB 874E D0AC 978B D0AD 534F D0AE 631F D0AF 643A D0B0 90AA D0B1 659C D0B2 80C1 D0B3 8C10 D0B4 5199 D0B5 68B0 D0B6 5378 D0B7 87F9 D0B8 61C8 D0B9 6CC4 D0BA 6CFB D0BB 8C22 D0BC 5C51 D0BD 85AA D0BE 82AF D0BF 950C D0C0 6B23 D0C1 8F9B D0C2 65B0 D0C3 5FFB D0C4 5FC3 D0C5 4FE1 D0C6 8845 D0C7 661F D0C8 8165 D0C9 7329 D0CA 60FA D0CB 5174 D0CC 5211 D0CD 578B D0CE 5F62 D0CF 90A2 D0D0 884C D0D1 9192 D0D2 5E78 D0D3 674F D0D4 6027 D0D5 59D3 D0D6 5144 D0D7 51F6 D0D8 80F8 D0D9 5308 D0DA 6C79 D0DB 96C4 D0DC 718A D0DD 4F11 D0DE 4FEE D0DF 7F9E D0E0 673D D0E1 55C5 D0E2 9508 D0E3 79C0 D0E4 8896 D0E5 7EE3 D0E6 589F D0E7 620C D0E8 9700 D0E9 865A D0EA 5618 D0EB 987B D0EC 5F90 D0ED 8BB8 D0EE 84C4 D0EF 9157 D0F0 53D9 D0F1 65ED D0F2 5E8F D0F3 755C D0F4 6064 D0F5 7D6E D0F6 5A7F D0F7 7EEA D0F8 7EED D0F9 8F69 D0FA 55A7 D0FB 5BA3 D0FC 60AC D0FD 65CB D0FE 7384 D1A1 9009 D1A2 7663 D1A3 7729 D1A4 7EDA D1A5 9774 D1A6 859B D1A7 5B66 D1A8 7A74 D1A9 96EA D1AA 8840 D1AB 52CB D1AC 718F D1AD 5FAA D1AE 65EC D1AF 8BE2 D1B0 5BFB D1B1 9A6F D1B2 5DE1 D1B3 6B89 D1B4 6C5B D1B5 8BAD D1B6 8BAF D1B7 900A D1B8 8FC5 D1B9 538B D1BA 62BC D1BB 9E26 D1BC 9E2D D1BD 5440 D1BE 4E2B D1BF 82BD D1C0 7259 D1C1 869C D1C2 5D16 D1C3 8859 D1C4 6DAF D1C5 96C5 D1C6 54D1 D1C7 4E9A D1C8 8BB6 D1C9 7109 D1CA 54BD D1CB 9609 D1CC 70DF D1CD 6DF9 D1CE 76D0 D1CF 4E25 D1D0 7814 D1D1 8712 D1D2 5CA9 D1D3 5EF6 D1D4 8A00 D1D5 989C D1D6 960E D1D7 708E D1D8 6CBF D1D9 5944 D1DA 63A9 D1DB 773C D1DC 884D D1DD 6F14 D1DE 8273 D1DF 5830 D1E0 71D5 D1E1 538C D1E2 781A D1E3 96C1 D1E4 5501 D1E5 5F66 D1E6 7130 D1E7 5BB4 D1E8 8C1A D1E9 9A8C D1EA 6B83 D1EB 592E D1EC 9E2F D1ED 79E7 D1EE 6768 D1EF 626C D1F0 4F6F D1F1 75A1 D1F2 7F8A D1F3 6D0B D1F4 9633 D1F5 6C27 D1F6 4EF0 D1F7 75D2 D1F8 517B D1F9 6837 D1FA 6F3E D1FB 9080 D1FC 8170 D1FD 5996 D1FE 7476 D2A1 6447 D2A2 5C27 D2A3 9065 D2A4 7A91 D2A5 8C23 D2A6 59DA D2A7 54AC D2A8 8200 D2A9 836F D2AA 8981 D2AB 8000 D2AC 6930 D2AD 564E D2AE 8036 D2AF 7237 D2B0 91CE D2B1 51B6 D2B2 4E5F D2B3 9875 D2B4 6396 D2B5 4E1A D2B6 53F6 D2B7 66F3 D2B8 814B D2B9 591C D2BA 6DB2 D2BB 4E00 D2BC 58F9 D2BD 533B D2BE 63D6 D2BF 94F1 D2C0 4F9D D2C1 4F0A D2C2 8863 D2C3 9890 D2C4 5937 D2C5 9057 D2C6 79FB D2C7 4EEA D2C8 80F0 D2C9 7591 D2CA 6C82 D2CB 5B9C D2CC 59E8 D2CD 5F5D D2CE 6905 D2CF 8681 D2D0 501A D2D1 5DF2 D2D2 4E59 D2D3 77E3 D2D4 4EE5 D2D5 827A D2D6 6291 D2D7 6613 D2D8 9091 D2D9 5C79 D2DA 4EBF D2DB 5F79 D2DC 81C6 D2DD 9038 D2DE 8084 D2DF 75AB D2E0 4EA6 D2E1 88D4 D2E2 610F D2E3 6BC5 D2E4 5FC6 D2E5 4E49 D2E6 76CA D2E7 6EA2 D2E8 8BE3 D2E9 8BAE D2EA 8C0A D2EB 8BD1 D2EC 5F02 D2ED 7FFC D2EE 7FCC D2EF 7ECE D2F0 8335 D2F1 836B D2F2 56E0 D2F3 6BB7 D2F4 97F3 D2F5 9634 D2F6 59FB D2F7 541F D2F8 94F6 D2F9 6DEB D2FA 5BC5 D2FB 996E D2FC 5C39 D2FD 5F15 D2FE 9690 D3A1 5370 D3A2 82F1 D3A3 6A31 D3A4 5A74 D3A5 9E70 D3A6 5E94 D3A7 7F28 D3A8 83B9 D3A9 8424 D3AA 8425 D3AB 8367 D3AC 8747 D3AD 8FCE D3AE 8D62 D3AF 76C8 D3B0 5F71 D3B1 9896 D3B2 786C D3B3 6620 D3B4 54DF D3B5 62E5 D3B6 4F63 D3B7 81C3 D3B8 75C8 D3B9 5EB8 D3BA 96CD D3BB 8E0A D3BC 86F9 D3BD 548F D3BE 6CF3 D3BF 6D8C D3C0 6C38 D3C1 607F D3C2 52C7 D3C3 7528 D3C4 5E7D D3C5 4F18 D3C6 60A0 D3C7 5FE7 D3C8 5C24 D3C9 7531 D3CA 90AE D3CB 94C0 D3CC 72B9 D3CD 6CB9 D3CE 6E38 D3CF 9149 D3D0 6709 D3D1 53CB D3D2 53F3 D3D3 4F51 D3D4 91C9 D3D5 8BF1 D3D6 53C8 D3D7 5E7C D3D8 8FC2 D3D9 6DE4 D3DA 4E8E D3DB 76C2 D3DC 6986 D3DD 865E D3DE 611A D3DF 8206 D3E0 4F59 D3E1 4FDE D3E2 903E D3E3 9C7C D3E4 6109 D3E5 6E1D D3E6 6E14 D3E7 9685 D3E8 4E88 D3E9 5A31 D3EA 96E8 D3EB 4E0E D3EC 5C7F D3ED 79B9 D3EE 5B87 D3EF 8BED D3F0 7FBD D3F1 7389 D3F2 57DF D3F3 828B D3F4 90C1 D3F5 5401 D3F6 9047 D3F7 55BB D3F8 5CEA D3F9 5FA1 D3FA 6108 D3FB 6B32 D3FC 72F1 D3FD 80B2 D3FE 8A89 D4A1 6D74 D4A2 5BD3 D4A3 88D5 D4A4 9884 D4A5 8C6B D4A6 9A6D D4A7 9E33 D4A8 6E0A D4A9 51A4 D4AA 5143 D4AB 57A3 D4AC 8881 D4AD 539F D4AE 63F4 D4AF 8F95 D4B0 56ED D4B1 5458 D4B2 5706 D4B3 733F D4B4 6E90 D4B5 7F18 D4B6 8FDC D4B7 82D1 D4B8 613F D4B9 6028 D4BA 9662 D4BB 66F0 D4BC 7EA6 D4BD 8D8A D4BE 8DC3 D4BF 94A5 D4C0 5CB3 D4C1 7CA4 D4C2 6708 D4C3 60A6 D4C4 9605 D4C5 8018 D4C6 4E91 D4C7 90E7 D4C8 5300 D4C9 9668 D4CA 5141 D4CB 8FD0 D4CC 8574 D4CD 915D D4CE 6655 D4CF 97F5 D4D0 5B55 D4D1 531D D4D2 7838 D4D3 6742 D4D4 683D D4D5 54C9 D4D6 707E D4D7 5BB0 D4D8 8F7D D4D9 518D D4DA 5728 D4DB 54B1 D4DC 6512 D4DD 6682 D4DE 8D5E D4DF 8D43 D4E0 810F D4E1 846C D4E2 906D D4E3 7CDF D4E4 51FF D4E5 85FB D4E6 67A3 D4E7 65E9 D4E8 6FA1 D4E9 86A4 D4EA 8E81 D4EB 566A D4EC 9020 D4ED 7682 D4EE 7076 D4EF 71E5 D4F0 8D23 D4F1 62E9 D4F2 5219 D4F3 6CFD D4F4 8D3C D4F5 600E D4F6 589E D4F7 618E D4F8 66FE D4F9 8D60 D4FA 624E D4FB 55B3 D4FC 6E23 D4FD 672D D4FE 8F67 D5A1 94E1 D5A2 95F8 D5A3 7728 D5A4 6805 D5A5 69A8 D5A6 548B D5A7 4E4D D5A8 70B8 D5A9 8BC8 D5AA 6458 D5AB 658B D5AC 5B85 D5AD 7A84 D5AE 503A D5AF 5BE8 D5B0 77BB D5B1 6BE1 D5B2 8A79 D5B3 7C98 D5B4 6CBE D5B5 76CF D5B6 65A9 D5B7 8F97 D5B8 5D2D D5B9 5C55 D5BA 8638 D5BB 6808 D5BC 5360 D5BD 6218 D5BE 7AD9 D5BF 6E5B D5C0 7EFD D5C1 6A1F D5C2 7AE0 D5C3 5F70 D5C4 6F33 D5C5 5F20 D5C6 638C D5C7 6DA8 D5C8 6756 D5C9 4E08 D5CA 5E10 D5CB 8D26 D5CC 4ED7 D5CD 80C0 D5CE 7634 D5CF 969C D5D0 62DB D5D1 662D D5D2 627E D5D3 6CBC D5D4 8D75 D5D5 7167 D5D6 7F69 D5D7 5146 D5D8 8087 D5D9 53EC D5DA 906E D5DB 6298 D5DC 54F2 D5DD 86F0 D5DE 8F99 D5DF 8005 D5E0 9517 D5E1 8517 D5E2 8FD9 D5E3 6D59 D5E4 73CD D5E5 659F D5E6 771F D5E7 7504 D5E8 7827 D5E9 81FB D5EA 8D1E D5EB 9488 D5EC 4FA6 D5ED 6795 D5EE 75B9 D5EF 8BCA D5F0 9707 D5F1 632F D5F2 9547 D5F3 9635 D5F4 84B8 D5F5 6323 D5F6 7741 D5F7 5F81 D5F8 72F0 D5F9 4E89 D5FA 6014 D5FB 6574 D5FC 62EF D5FD 6B63 D5FE 653F D6A1 5E27 D6A2 75C7 D6A3 90D1 D6A4 8BC1 D6A5 829D D6A6 679D D6A7 652F D6A8 5431 D6A9 8718 D6AA 77E5 D6AB 80A2 D6AC 8102 D6AD 6C41 D6AE 4E4B D6AF 7EC7 D6B0 804C D6B1 76F4 D6B2 690D D6B3 6B96 D6B4 6267 D6B5 503C D6B6 4F84 D6B7 5740 D6B8 6307 D6B9 6B62 D6BA 8DBE D6BB 53EA D6BC 65E8 D6BD 7EB8 D6BE 5FD7 D6BF 631A D6C0 63B7 D6C1 81F3 D6C2 81F4 D6C3 7F6E D6C4 5E1C D6C5 5CD9 D6C6 5236 D6C7 667A D6C8 79E9 D6C9 7A1A D6CA 8D28 D6CB 7099 D6CC 75D4 D6CD 6EDE D6CE 6CBB D6CF 7A92 D6D0 4E2D D6D1 76C5 D6D2 5FE0 D6D3 949F D6D4 8877 D6D5 7EC8 D6D6 79CD D6D7 80BF D6D8 91CD D6D9 4EF2 D6DA 4F17 D6DB 821F D6DC 5468 D6DD 5DDE D6DE 6D32 D6DF 8BCC D6E0 7CA5 D6E1 8F74 D6E2 8098 D6E3 5E1A D6E4 5492 D6E5 76B1 D6E6 5B99 D6E7 663C D6E8 9AA4 D6E9 73E0 D6EA 682A D6EB 86DB D6EC 6731 D6ED 732A D6EE 8BF8 D6EF 8BDB D6F0 9010 D6F1 7AF9 D6F2 70DB D6F3 716E D6F4 62C4 D6F5 77A9 D6F6 5631 D6F7 4E3B D6F8 8457 D6F9 67F1 D6FA 52A9 D6FB 86C0 D6FC 8D2E D6FD 94F8 D6FE 7B51 D7A1 4F4F D7A2 6CE8 D7A3 795D D7A4 9A7B D7A5 6293 D7A6 722A D7A7 62FD D7A8 4E13 D7A9 7816 D7AA 8F6C D7AB 64B0 D7AC 8D5A D7AD 7BC6 D7AE 6869 D7AF 5E84 D7B0 88C5 D7B1 5986 D7B2 649E D7B3 58EE D7B4 72B6 D7B5 690E D7B6 9525 D7B7 8FFD D7B8 8D58 D7B9 5760 D7BA 7F00 D7BB 8C06 D7BC 51C6 D7BD 6349 D7BE 62D9 D7BF 5353 D7C0 684C D7C1 7422 D7C2 8301 D7C3 914C D7C4 5544 D7C5 7740 D7C6 707C D7C7 6D4A D7C8 5179 D7C9 54A8 D7CA 8D44 D7CB 59FF D7CC 6ECB D7CD 6DC4 D7CE 5B5C D7CF 7D2B D7D0 4ED4 D7D1 7C7D D7D2 6ED3 D7D3 5B50 D7D4 81EA D7D5 6E0D D7D6 5B57 D7D7 9B03 D7D8 68D5 D7D9 8E2A D7DA 5B97 D7DB 7EFC D7DC 603B D7DD 7EB5 D7DE 90B9 D7DF 8D70 D7E0 594F D7E1 63CD D7E2 79DF D7E3 8DB3 D7E4 5352 D7E5 65CF D7E6 7956 D7E7 8BC5 D7E8 963B D7E9 7EC4 D7EA 94BB D7EB 7E82 D7EC 5634 D7ED 9189 D7EE 6700 D7EF 7F6A D7F0 5C0A D7F1 9075 D7F2 6628 D7F3 5DE6 D7F4 4F50 D7F5 67DE D7F6 505A D7F7 4F5C D7F8 5750 D7F9 5EA7 D8A1 4E8D D8A2 4E0C D8A3 5140 D8A4 4E10 D8A5 5EFF D8A6 5345 D8A7 4E15 D8A8 4E98 D8A9 4E1E D8AA 9B32 D8AB 5B6C D8AC 5669 D8AD 4E28 D8AE 79BA D8AF 4E3F D8B0 5315 D8B1 4E47 D8B2 592D D8B3 723B D8B4 536E D8B5 6C10 D8B6 56DF D8B7 80E4 D8B8 9997 D8B9 6BD3 D8BA 777E D8BB 9F17 D8BC 4E36 D8BD 4E9F D8BE 9F10 D8BF 4E5C D8C0 4E69 D8C1 4E93 D8C2 8288 D8C3 5B5B D8C4 556C D8C5 560F D8C6 4EC4 D8C7 538D D8C8 539D D8C9 53A3 D8CA 53A5 D8CB 53AE D8CC 9765 D8CD 8D5D D8CE 531A D8CF 53F5 D8D0 5326 D8D1 532E D8D2 533E D8D3 8D5C D8D4 5366 D8D5 5363 D8D6 5202 D8D7 5208 D8D8 520E D8D9 522D D8DA 5233 D8DB 523F D8DC 5240 D8DD 524C D8DE 525E D8DF 5261 D8E0 525C D8E1 84AF D8E2 527D D8E3 5282 D8E4 5281 D8E5 5290 D8E6 5293 D8E7 5182 D8E8 7F54 D8E9 4EBB D8EA 4EC3 D8EB 4EC9 D8EC 4EC2 D8ED 4EE8 D8EE 4EE1 D8EF 4EEB D8F0 4EDE D8F1 4F1B D8F2 4EF3 D8F3 4F22 D8F4 4F64 D8F5 4EF5 D8F6 4F25 D8F7 4F27 D8F8 4F09 D8F9 4F2B D8FA 4F5E D8FB 4F67 D8FC 6538 D8FD 4F5A D8FE 4F5D D9A1 4F5F D9A2 4F57 D9A3 4F32 D9A4 4F3D D9A5 4F76 D9A6 4F74 D9A7 4F91 D9A8 4F89 D9A9 4F83 D9AA 4F8F D9AB 4F7E D9AC 4F7B D9AD 4FAA D9AE 4F7C D9AF 4FAC D9B0 4F94 D9B1 4FE6 D9B2 4FE8 D9B3 4FEA D9B4 4FC5 D9B5 4FDA D9B6 4FE3 D9B7 4FDC D9B8 4FD1 D9B9 4FDF D9BA 4FF8 D9BB 5029 D9BC 504C D9BD 4FF3 D9BE 502C D9BF 500F D9C0 502E D9C1 502D D9C2 4FFE D9C3 501C D9C4 500C D9C5 5025 D9C6 5028 D9C7 507E D9C8 5043 D9C9 5055 D9CA 5048 D9CB 504E D9CC 506C D9CD 507B D9CE 50A5 D9CF 50A7 D9D0 50A9 D9D1 50BA D9D2 50D6 D9D3 5106 D9D4 50ED D9D5 50EC D9D6 50E6 D9D7 50EE D9D8 5107 D9D9 510B D9DA 4EDD D9DB 6C3D D9DC 4F58 D9DD 4F65 D9DE 4FCE D9DF 9FA0 D9E0 6C46 D9E1 7C74 D9E2 516E D9E3 5DFD D9E4 9EC9 D9E5 9998 D9E6 5181 D9E7 5914 D9E8 52F9 D9E9 530D D9EA 8A07 D9EB 5310 D9EC 51EB D9ED 5919 D9EE 5155 D9EF 4EA0 D9F0 5156 D9F1 4EB3 D9F2 886E D9F3 88A4 D9F4 4EB5 D9F5 8114 D9F6 88D2 D9F7 7980 D9F8 5B34 D9F9 8803 D9FA 7FB8 D9FB 51AB D9FC 51B1 D9FD 51BD D9FE 51BC DAA1 51C7 DAA2 5196 DAA3 51A2 DAA4 51A5 DAA5 8BA0 DAA6 8BA6 DAA7 8BA7 DAA8 8BAA DAA9 8BB4 DAAA 8BB5 DAAB 8BB7 DAAC 8BC2 DAAD 8BC3 DAAE 8BCB DAAF 8BCF DAB0 8BCE DAB1 8BD2 DAB2 8BD3 DAB3 8BD4 DAB4 8BD6 DAB5 8BD8 DAB6 8BD9 DAB7 8BDC DAB8 8BDF DAB9 8BE0 DABA 8BE4 DABB 8BE8 DABC 8BE9 DABD 8BEE DABE 8BF0 DABF 8BF3 DAC0 8BF6 DAC1 8BF9 DAC2 8BFC DAC3 8BFF DAC4 8C00 DAC5 8C02 DAC6 8C04 DAC7 8C07 DAC8 8C0C DAC9 8C0F DACA 8C11 DACB 8C12 DACC 8C14 DACD 8C15 DACE 8C16 DACF 8C19 DAD0 8C1B DAD1 8C18 DAD2 8C1D DAD3 8C1F DAD4 8C20 DAD5 8C21 DAD6 8C25 DAD7 8C27 DAD8 8C2A DAD9 8C2B DADA 8C2E DADB 8C2F DADC 8C32 DADD 8C33 DADE 8C35 DADF 8C36 DAE0 5369 DAE1 537A DAE2 961D DAE3 9622 DAE4 9621 DAE5 9631 DAE6 962A DAE7 963D DAE8 963C DAE9 9642 DAEA 9649 DAEB 9654 DAEC 965F DAED 9667 DAEE 966C DAEF 9672 DAF0 9674 DAF1 9688 DAF2 968D DAF3 9697 DAF4 96B0 DAF5 9097 DAF6 909B DAF7 909D DAF8 9099 DAF9 90AC DAFA 90A1 DAFB 90B4 DAFC 90B3 DAFD 90B6 DAFE 90BA DBA1 90B8 DBA2 90B0 DBA3 90CF DBA4 90C5 DBA5 90BE DBA6 90D0 DBA7 90C4 DBA8 90C7 DBA9 90D3 DBAA 90E6 DBAB 90E2 DBAC 90DC DBAD 90D7 DBAE 90DB DBAF 90EB DBB0 90EF DBB1 90FE DBB2 9104 DBB3 9122 DBB4 911E DBB5 9123 DBB6 9131 DBB7 912F DBB8 9139 DBB9 9143 DBBA 9146 DBBB 520D DBBC 5942 DBBD 52A2 DBBE 52AC DBBF 52AD DBC0 52BE DBC1 54FF DBC2 52D0 DBC3 52D6 DBC4 52F0 DBC5 53DF DBC6 71EE DBC7 77CD DBC8 5EF4 DBC9 51F5 DBCA 51FC DBCB 9B2F DBCC 53B6 DBCD 5F01 DBCE 755A DBCF 5DEF DBD0 574C DBD1 57A9 DBD2 57A1 DBD3 587E DBD4 58BC DBD5 58C5 DBD6 58D1 DBD7 5729 DBD8 572C DBD9 572A DBDA 5733 DBDB 5739 DBDC 572E DBDD 572F DBDE 575C DBDF 573B DBE0 5742 DBE1 5769 DBE2 5785 DBE3 576B DBE4 5786 DBE5 577C DBE6 577B DBE7 5768 DBE8 576D DBE9 5776 DBEA 5773 DBEB 57AD DBEC 57A4 DBED 578C DBEE 57B2 DBEF 57CF DBF0 57A7 DBF1 57B4 DBF2 5793 DBF3 57A0 DBF4 57D5 DBF5 57D8 DBF6 57DA DBF7 57D9 DBF8 57D2 DBF9 57B8 DBFA 57F4 DBFB 57EF DBFC 57F8 DBFD 57E4 DBFE 57DD DCA1 580B DCA2 580D DCA3 57FD DCA4 57ED DCA5 5800 DCA6 581E DCA7 5819 DCA8 5844 DCA9 5820 DCAA 5865 DCAB 586C DCAC 5881 DCAD 5889 DCAE 589A DCAF 5880 DCB0 99A8 DCB1 9F19 DCB2 61FF DCB3 8279 DCB4 827D DCB5 827F DCB6 828F DCB7 828A DCB8 82A8 DCB9 8284 DCBA 828E DCBB 8291 DCBC 8297 DCBD 8299 DCBE 82AB DCBF 82B8 DCC0 82BE DCC1 82B0 DCC2 82C8 DCC3 82CA DCC4 82E3 DCC5 8298 DCC6 82B7 DCC7 82AE DCC8 82CB DCC9 82CC DCCA 82C1 DCCB 82A9 DCCC 82B4 DCCD 82A1 DCCE 82AA DCCF 829F DCD0 82C4 DCD1 82CE DCD2 82A4 DCD3 82E1 DCD4 8309 DCD5 82F7 DCD6 82E4 DCD7 830F DCD8 8307 DCD9 82DC DCDA 82F4 DCDB 82D2 DCDC 82D8 DCDD 830C DCDE 82FB DCDF 82D3 DCE0 8311 DCE1 831A DCE2 8306 DCE3 8314 DCE4 8315 DCE5 82E0 DCE6 82D5 DCE7 831C DCE8 8351 DCE9 835B DCEA 835C DCEB 8308 DCEC 8392 DCED 833C DCEE 8334 DCEF 8331 DCF0 839B DCF1 835E DCF2 832F DCF3 834F DCF4 8347 DCF5 8343 DCF6 835F DCF7 8340 DCF8 8317 DCF9 8360 DCFA 832D DCFB 833A DCFC 8333 DCFD 8366 DCFE 8365 DDA1 8368 DDA2 831B DDA3 8369 DDA4 836C DDA5 836A DDA6 836D DDA7 836E DDA8 83B0 DDA9 8378 DDAA 83B3 DDAB 83B4 DDAC 83A0 DDAD 83AA DDAE 8393 DDAF 839C DDB0 8385 DDB1 837C DDB2 83B6 DDB3 83A9 DDB4 837D DDB5 83B8 DDB6 837B DDB7 8398 DDB8 839E DDB9 83A8 DDBA 83BA DDBB 83BC DDBC 83C1 DDBD 8401 DDBE 83E5 DDBF 83D8 DDC0 5807 DDC1 8418 DDC2 840B DDC3 83DD DDC4 83FD DDC5 83D6 DDC6 841C DDC7 8438 DDC8 8411 DDC9 8406 DDCA 83D4 DDCB 83DF DDCC 840F DDCD 8403 DDCE 83F8 DDCF 83F9 DDD0 83EA DDD1 83C5 DDD2 83C0 DDD3 8426 DDD4 83F0 DDD5 83E1 DDD6 845C DDD7 8451 DDD8 845A DDD9 8459 DDDA 8473 DDDB 8487 DDDC 8488 DDDD 847A DDDE 8489 DDDF 8478 DDE0 843C DDE1 8446 DDE2 8469 DDE3 8476 DDE4 848C DDE5 848E DDE6 8431 DDE7 846D DDE8 84C1 DDE9 84CD DDEA 84D0 DDEB 84E6 DDEC 84BD DDED 84D3 DDEE 84CA DDEF 84BF DDF0 84BA DDF1 84E0 DDF2 84A1 DDF3 84B9 DDF4 84B4 DDF5 8497 DDF6 84E5 DDF7 84E3 DDF8 850C DDF9 750D DDFA 8538 DDFB 84F0 DDFC 8539 DDFD 851F DDFE 853A DEA1 8556 DEA2 853B DEA3 84FF DEA4 84FC DEA5 8559 DEA6 8548 DEA7 8568 DEA8 8564 DEA9 855E DEAA 857A DEAB 77A2 DEAC 8543 DEAD 8572 DEAE 857B DEAF 85A4 DEB0 85A8 DEB1 8587 DEB2 858F DEB3 8579 DEB4 85AE DEB5 859C DEB6 8585 DEB7 85B9 DEB8 85B7 DEB9 85B0 DEBA 85D3 DEBB 85C1 DEBC 85DC DEBD 85FF DEBE 8627 DEBF 8605 DEC0 8629 DEC1 8616 DEC2 863C DEC3 5EFE DEC4 5F08 DEC5 593C DEC6 5941 DEC7 8037 DEC8 5955 DEC9 595A DECA 5958 DECB 530F DECC 5C22 DECD 5C25 DECE 5C2C DECF 5C34 DED0 624C DED1 626A DED2 629F DED3 62BB DED4 62CA DED5 62DA DED6 62D7 DED7 62EE DED8 6322 DED9 62F6 DEDA 6339 DEDB 634B DEDC 6343 DEDD 63AD DEDE 63F6 DEDF 6371 DEE0 637A DEE1 638E DEE2 63B4 DEE3 636D DEE4 63AC DEE5 638A DEE6 6369 DEE7 63AE DEE8 63BC DEE9 63F2 DEEA 63F8 DEEB 63E0 DEEC 63FF DEED 63C4 DEEE 63DE DEEF 63CE DEF0 6452 DEF1 63C6 DEF2 63BE DEF3 6445 DEF4 6441 DEF5 640B DEF6 641B DEF7 6420 DEF8 640C DEF9 6426 DEFA 6421 DEFB 645E DEFC 6484 DEFD 646D DEFE 6496 DFA1 647A DFA2 64B7 DFA3 64B8 DFA4 6499 DFA5 64BA DFA6 64C0 DFA7 64D0 DFA8 64D7 DFA9 64E4 DFAA 64E2 DFAB 6509 DFAC 6525 DFAD 652E DFAE 5F0B DFAF 5FD2 DFB0 7519 DFB1 5F11 DFB2 535F DFB3 53F1 DFB4 53FD DFB5 53E9 DFB6 53E8 DFB7 53FB DFB8 5412 DFB9 5416 DFBA 5406 DFBB 544B DFBC 5452 DFBD 5453 DFBE 5454 DFBF 5456 DFC0 5443 DFC1 5421 DFC2 5457 DFC3 5459 DFC4 5423 DFC5 5432 DFC6 5482 DFC7 5494 DFC8 5477 DFC9 5471 DFCA 5464 DFCB 549A DFCC 549B DFCD 5484 DFCE 5476 DFCF 5466 DFD0 549D DFD1 54D0 DFD2 54AD DFD3 54C2 DFD4 54B4 DFD5 54D2 DFD6 54A7 DFD7 54A6 DFD8 54D3 DFD9 54D4 DFDA 5472 DFDB 54A3 DFDC 54D5 DFDD 54BB DFDE 54BF DFDF 54CC DFE0 54D9 DFE1 54DA DFE2 54DC DFE3 54A9 DFE4 54AA DFE5 54A4 DFE6 54DD DFE7 54CF DFE8 54DE DFE9 551B DFEA 54E7 DFEB 5520 DFEC 54FD DFED 5514 DFEE 54F3 DFEF 5522 DFF0 5523 DFF1 550F DFF2 5511 DFF3 5527 DFF4 552A DFF5 5567 DFF6 558F DFF7 55B5 DFF8 5549 DFF9 556D DFFA 5541 DFFB 5555 DFFC 553F DFFD 5550 DFFE 553C E0A1 5537 E0A2 5556 E0A3 5575 E0A4 5576 E0A5 5577 E0A6 5533 E0A7 5530 E0A8 555C E0A9 558B E0AA 55D2 E0AB 5583 E0AC 55B1 E0AD 55B9 E0AE 5588 E0AF 5581 E0B0 559F E0B1 557E E0B2 55D6 E0B3 5591 E0B4 557B E0B5 55DF E0B6 55BD E0B7 55BE E0B8 5594 E0B9 5599 E0BA 55EA E0BB 55F7 E0BC 55C9 E0BD 561F E0BE 55D1 E0BF 55EB E0C0 55EC E0C1 55D4 E0C2 55E6 E0C3 55DD E0C4 55C4 E0C5 55EF E0C6 55E5 E0C7 55F2 E0C8 55F3 E0C9 55CC E0CA 55CD E0CB 55E8 E0CC 55F5 E0CD 55E4 E0CE 8F94 E0CF 561E E0D0 5608 E0D1 560C E0D2 5601 E0D3 5624 E0D4 5623 E0D5 55FE E0D6 5600 E0D7 5627 E0D8 562D E0D9 5658 E0DA 5639 E0DB 5657 E0DC 562C E0DD 564D E0DE 5662 E0DF 5659 E0E0 565C E0E1 564C E0E2 5654 E0E3 5686 E0E4 5664 E0E5 5671 E0E6 566B E0E7 567B E0E8 567C E0E9 5685 E0EA 5693 E0EB 56AF E0EC 56D4 E0ED 56D7 E0EE 56DD E0EF 56E1 E0F0 56F5 E0F1 56EB E0F2 56F9 E0F3 56FF E0F4 5704 E0F5 570A E0F6 5709 E0F7 571C E0F8 5E0F E0F9 5E19 E0FA 5E14 E0FB 5E11 E0FC 5E31 E0FD 5E3B E0FE 5E3C E1A1 5E37 E1A2 5E44 E1A3 5E54 E1A4 5E5B E1A5 5E5E E1A6 5E61 E1A7 5C8C E1A8 5C7A E1A9 5C8D E1AA 5C90 E1AB 5C96 E1AC 5C88 E1AD 5C98 E1AE 5C99 E1AF 5C91 E1B0 5C9A E1B1 5C9C E1B2 5CB5 E1B3 5CA2 E1B4 5CBD E1B5 5CAC E1B6 5CAB E1B7 5CB1 E1B8 5CA3 E1B9 5CC1 E1BA 5CB7 E1BB 5CC4 E1BC 5CD2 E1BD 5CE4 E1BE 5CCB E1BF 5CE5 E1C0 5D02 E1C1 5D03 E1C2 5D27 E1C3 5D26 E1C4 5D2E E1C5 5D24 E1C6 5D1E E1C7 5D06 E1C8 5D1B E1C9 5D58 E1CA 5D3E E1CB 5D34 E1CC 5D3D E1CD 5D6C E1CE 5D5B E1CF 5D6F E1D0 5D5D E1D1 5D6B E1D2 5D4B E1D3 5D4A E1D4 5D69 E1D5 5D74 E1D6 5D82 E1D7 5D99 E1D8 5D9D E1D9 8C73 E1DA 5DB7 E1DB 5DC5 E1DC 5F73 E1DD 5F77 E1DE 5F82 E1DF 5F87 E1E0 5F89 E1E1 5F8C E1E2 5F95 E1E3 5F99 E1E4 5F9C E1E5 5FA8 E1E6 5FAD E1E7 5FB5 E1E8 5FBC E1E9 8862 E1EA 5F61 E1EB 72AD E1EC 72B0 E1ED 72B4 E1EE 72B7 E1EF 72B8 E1F0 72C3 E1F1 72C1 E1F2 72CE E1F3 72CD E1F4 72D2 E1F5 72E8 E1F6 72EF E1F7 72E9 E1F8 72F2 E1F9 72F4 E1FA 72F7 E1FB 7301 E1FC 72F3 E1FD 7303 E1FE 72FA E2A1 72FB E2A2 7317 E2A3 7313 E2A4 7321 E2A5 730A E2A6 731E E2A7 731D E2A8 7315 E2A9 7322 E2AA 7339 E2AB 7325 E2AC 732C E2AD 7338 E2AE 7331 E2AF 7350 E2B0 734D E2B1 7357 E2B2 7360 E2B3 736C E2B4 736F E2B5 737E E2B6 821B E2B7 5925 E2B8 98E7 E2B9 5924 E2BA 5902 E2BB 9963 E2BC 9967 E2BD 9968 E2BE 9969 E2BF 996A E2C0 996B E2C1 996C E2C2 9974 E2C3 9977 E2C4 997D E2C5 9980 E2C6 9984 E2C7 9987 E2C8 998A E2C9 998D E2CA 9990 E2CB 9991 E2CC 9993 E2CD 9994 E2CE 9995 E2CF 5E80 E2D0 5E91 E2D1 5E8B E2D2 5E96 E2D3 5EA5 E2D4 5EA0 E2D5 5EB9 E2D6 5EB5 E2D7 5EBE E2D8 5EB3 E2D9 8D53 E2DA 5ED2 E2DB 5ED1 E2DC 5EDB E2DD 5EE8 E2DE 5EEA E2DF 81BA E2E0 5FC4 E2E1 5FC9 E2E2 5FD6 E2E3 5FCF E2E4 6003 E2E5 5FEE E2E6 6004 E2E7 5FE1 E2E8 5FE4 E2E9 5FFE E2EA 6005 E2EB 6006 E2EC 5FEA E2ED 5FED E2EE 5FF8 E2EF 6019 E2F0 6035 E2F1 6026 E2F2 601B E2F3 600F E2F4 600D E2F5 6029 E2F6 602B E2F7 600A E2F8 603F E2F9 6021 E2FA 6078 E2FB 6079 E2FC 607B E2FD 607A E2FE 6042 E3A1 606A E3A2 607D E3A3 6096 E3A4 609A E3A5 60AD E3A6 609D E3A7 6083 E3A8 6092 E3A9 608C E3AA 609B E3AB 60EC E3AC 60BB E3AD 60B1 E3AE 60DD E3AF 60D8 E3B0 60C6 E3B1 60DA E3B2 60B4 E3B3 6120 E3B4 6126 E3B5 6115 E3B6 6123 E3B7 60F4 E3B8 6100 E3B9 610E E3BA 612B E3BB 614A E3BC 6175 E3BD 61AC E3BE 6194 E3BF 61A7 E3C0 61B7 E3C1 61D4 E3C2 61F5 E3C3 5FDD E3C4 96B3 E3C5 95E9 E3C6 95EB E3C7 95F1 E3C8 95F3 E3C9 95F5 E3CA 95F6 E3CB 95FC E3CC 95FE E3CD 9603 E3CE 9604 E3CF 9606 E3D0 9608 E3D1 960A E3D2 960B E3D3 960C E3D4 960D E3D5 960F E3D6 9612 E3D7 9615 E3D8 9616 E3D9 9617 E3DA 9619 E3DB 961A E3DC 4E2C E3DD 723F E3DE 6215 E3DF 6C35 E3E0 6C54 E3E1 6C5C E3E2 6C4A E3E3 6CA3 E3E4 6C85 E3E5 6C90 E3E6 6C94 E3E7 6C8C E3E8 6C68 E3E9 6C69 E3EA 6C74 E3EB 6C76 E3EC 6C86 E3ED 6CA9 E3EE 6CD0 E3EF 6CD4 E3F0 6CAD E3F1 6CF7 E3F2 6CF8 E3F3 6CF1 E3F4 6CD7 E3F5 6CB2 E3F6 6CE0 E3F7 6CD6 E3F8 6CFA E3F9 6CEB E3FA 6CEE E3FB 6CB1 E3FC 6CD3 E3FD 6CEF E3FE 6CFE E4A1 6D39 E4A2 6D27 E4A3 6D0C E4A4 6D43 E4A5 6D48 E4A6 6D07 E4A7 6D04 E4A8 6D19 E4A9 6D0E E4AA 6D2B E4AB 6D4D E4AC 6D2E E4AD 6D35 E4AE 6D1A E4AF 6D4F E4B0 6D52 E4B1 6D54 E4B2 6D33 E4B3 6D91 E4B4 6D6F E4B5 6D9E E4B6 6DA0 E4B7 6D5E E4B8 6D93 E4B9 6D94 E4BA 6D5C E4BB 6D60 E4BC 6D7C E4BD 6D63 E4BE 6E1A E4BF 6DC7 E4C0 6DC5 E4C1 6DDE E4C2 6E0E E4C3 6DBF E4C4 6DE0 E4C5 6E11 E4C6 6DE6 E4C7 6DDD E4C8 6DD9 E4C9 6E16 E4CA 6DAB E4CB 6E0C E4CC 6DAE E4CD 6E2B E4CE 6E6E E4CF 6E4E E4D0 6E6B E4D1 6EB2 E4D2 6E5F E4D3 6E86 E4D4 6E53 E4D5 6E54 E4D6 6E32 E4D7 6E25 E4D8 6E44 E4D9 6EDF E4DA 6EB1 E4DB 6E98 E4DC 6EE0 E4DD 6F2D E4DE 6EE2 E4DF 6EA5 E4E0 6EA7 E4E1 6EBD E4E2 6EBB E4E3 6EB7 E4E4 6ED7 E4E5 6EB4 E4E6 6ECF E4E7 6E8F E4E8 6EC2 E4E9 6E9F E4EA 6F62 E4EB 6F46 E4EC 6F47 E4ED 6F24 E4EE 6F15 E4EF 6EF9 E4F0 6F2F E4F1 6F36 E4F2 6F4B E4F3 6F74 E4F4 6F2A E4F5 6F09 E4F6 6F29 E4F7 6F89 E4F8 6F8D E4F9 6F8C E4FA 6F78 E4FB 6F72 E4FC 6F7C E4FD 6F7A E4FE 6FD1 E5A1 6FC9 E5A2 6FA7 E5A3 6FB9 E5A4 6FB6 E5A5 6FC2 E5A6 6FE1 E5A7 6FEE E5A8 6FDE E5A9 6FE0 E5AA 6FEF E5AB 701A E5AC 7023 E5AD 701B E5AE 7039 E5AF 7035 E5B0 704F E5B1 705E E5B2 5B80 E5B3 5B84 E5B4 5B95 E5B5 5B93 E5B6 5BA5 E5B7 5BB8 E5B8 752F E5B9 9A9E E5BA 6434 E5BB 5BE4 E5BC 5BEE E5BD 8930 E5BE 5BF0 E5BF 8E47 E5C0 8B07 E5C1 8FB6 E5C2 8FD3 E5C3 8FD5 E5C4 8FE5 E5C5 8FEE E5C6 8FE4 E5C7 8FE9 E5C8 8FE6 E5C9 8FF3 E5CA 8FE8 E5CB 9005 E5CC 9004 E5CD 900B E5CE 9026 E5CF 9011 E5D0 900D E5D1 9016 E5D2 9021 E5D3 9035 E5D4 9036 E5D5 902D E5D6 902F E5D7 9044 E5D8 9051 E5D9 9052 E5DA 9050 E5DB 9068 E5DC 9058 E5DD 9062 E5DE 905B E5DF 66B9 E5E0 9074 E5E1 907D E5E2 9082 E5E3 9088 E5E4 9083 E5E5 908B E5E6 5F50 E5E7 5F57 E5E8 5F56 E5E9 5F58 E5EA 5C3B E5EB 54AB E5EC 5C50 E5ED 5C59 E5EE 5B71 E5EF 5C63 E5F0 5C66 E5F1 7FBC E5F2 5F2A E5F3 5F29 E5F4 5F2D E5F5 8274 E5F6 5F3C E5F7 9B3B E5F8 5C6E E5F9 5981 E5FA 5983 E5FB 598D E5FC 59A9 E5FD 59AA E5FE 59A3 E6A1 5997 E6A2 59CA E6A3 59AB E6A4 599E E6A5 59A4 E6A6 59D2 E6A7 59B2 E6A8 59AF E6A9 59D7 E6AA 59BE E6AB 5A05 E6AC 5A06 E6AD 59DD E6AE 5A08 E6AF 59E3 E6B0 59D8 E6B1 59F9 E6B2 5A0C E6B3 5A09 E6B4 5A32 E6B5 5A34 E6B6 5A11 E6B7 5A23 E6B8 5A13 E6B9 5A40 E6BA 5A67 E6BB 5A4A E6BC 5A55 E6BD 5A3C E6BE 5A62 E6BF 5A75 E6C0 80EC E6C1 5AAA E6C2 5A9B E6C3 5A77 E6C4 5A7A E6C5 5ABE E6C6 5AEB E6C7 5AB2 E6C8 5AD2 E6C9 5AD4 E6CA 5AB8 E6CB 5AE0 E6CC 5AE3 E6CD 5AF1 E6CE 5AD6 E6CF 5AE6 E6D0 5AD8 E6D1 5ADC E6D2 5B09 E6D3 5B17 E6D4 5B16 E6D5 5B32 E6D6 5B37 E6D7 5B40 E6D8 5C15 E6D9 5C1C E6DA 5B5A E6DB 5B65 E6DC 5B73 E6DD 5B51 E6DE 5B53 E6DF 5B62 E6E0 9A75 E6E1 9A77 E6E2 9A78 E6E3 9A7A E6E4 9A7F E6E5 9A7D E6E6 9A80 E6E7 9A81 E6E8 9A85 E6E9 9A88 E6EA 9A8A E6EB 9A90 E6EC 9A92 E6ED 9A93 E6EE 9A96 E6EF 9A98 E6F0 9A9B E6F1 9A9C E6F2 9A9D E6F3 9A9F E6F4 9AA0 E6F5 9AA2 E6F6 9AA3 E6F7 9AA5 E6F8 9AA7 E6F9 7E9F E6FA 7EA1 E6FB 7EA3 E6FC 7EA5 E6FD 7EA8 E6FE 7EA9 E7A1 7EAD E7A2 7EB0 E7A3 7EBE E7A4 7EC0 E7A5 7EC1 E7A6 7EC2 E7A7 7EC9 E7A8 7ECB E7A9 7ECC E7AA 7ED0 E7AB 7ED4 E7AC 7ED7 E7AD 7EDB E7AE 7EE0 E7AF 7EE1 E7B0 7EE8 E7B1 7EEB E7B2 7EEE E7B3 7EEF E7B4 7EF1 E7B5 7EF2 E7B6 7F0D E7B7 7EF6 E7B8 7EFA E7B9 7EFB E7BA 7EFE E7BB 7F01 E7BC 7F02 E7BD 7F03 E7BE 7F07 E7BF 7F08 E7C0 7F0B E7C1 7F0C E7C2 7F0F E7C3 7F11 E7C4 7F12 E7C5 7F17 E7C6 7F19 E7C7 7F1C E7C8 7F1B E7C9 7F1F E7CA 7F21 E7CB 7F22 E7CC 7F23 E7CD 7F24 E7CE 7F25 E7CF 7F26 E7D0 7F27 E7D1 7F2A E7D2 7F2B E7D3 7F2C E7D4 7F2D E7D5 7F2F E7D6 7F30 E7D7 7F31 E7D8 7F32 E7D9 7F33 E7DA 7F35 E7DB 5E7A E7DC 757F E7DD 5DDB E7DE 753E E7DF 9095 E7E0 738E E7E1 7391 E7E2 73AE E7E3 73A2 E7E4 739F E7E5 73CF E7E6 73C2 E7E7 73D1 E7E8 73B7 E7E9 73B3 E7EA 73C0 E7EB 73C9 E7EC 73C8 E7ED 73E5 E7EE 73D9 E7EF 987C E7F0 740A E7F1 73E9 E7F2 73E7 E7F3 73DE E7F4 73BA E7F5 73F2 E7F6 740F E7F7 742A E7F8 745B E7F9 7426 E7FA 7425 E7FB 7428 E7FC 7430 E7FD 742E E7FE 742C E8A1 741B E8A2 741A E8A3 7441 E8A4 745C E8A5 7457 E8A6 7455 E8A7 7459 E8A8 7477 E8A9 746D E8AA 747E E8AB 749C E8AC 748E E8AD 7480 E8AE 7481 E8AF 7487 E8B0 748B E8B1 749E E8B2 74A8 E8B3 74A9 E8B4 7490 E8B5 74A7 E8B6 74D2 E8B7 74BA E8B8 97EA E8B9 97EB E8BA 97EC E8BB 674C E8BC 6753 E8BD 675E E8BE 6748 E8BF 6769 E8C0 67A5 E8C1 6787 E8C2 676A E8C3 6773 E8C4 6798 E8C5 67A7 E8C6 6775 E8C7 67A8 E8C8 679E E8C9 67AD E8CA 678B E8CB 6777 E8CC 677C E8CD 67F0 E8CE 6809 E8CF 67D8 E8D0 680A E8D1 67E9 E8D2 67B0 E8D3 680C E8D4 67D9 E8D5 67B5 E8D6 67DA E8D7 67B3 E8D8 67DD E8D9 6800 E8DA 67C3 E8DB 67B8 E8DC 67E2 E8DD 680E E8DE 67C1 E8DF 67FD E8E0 6832 E8E1 6833 E8E2 6860 E8E3 6861 E8E4 684E E8E5 6862 E8E6 6844 E8E7 6864 E8E8 6883 E8E9 681D E8EA 6855 E8EB 6866 E8EC 6841 E8ED 6867 E8EE 6840 E8EF 683E E8F0 684A E8F1 6849 E8F2 6829 E8F3 68B5 E8F4 688F E8F5 6874 E8F6 6877 E8F7 6893 E8F8 686B E8F9 68C2 E8FA 696E E8FB 68FC E8FC 691F E8FD 6920 E8FE 68F9 E9A1 6924 E9A2 68F0 E9A3 690B E9A4 6901 E9A5 6957 E9A6 68E3 E9A7 6910 E9A8 6971 E9A9 6939 E9AA 6960 E9AB 6942 E9AC 695D E9AD 6984 E9AE 696B E9AF 6980 E9B0 6998 E9B1 6978 E9B2 6934 E9B3 69CC E9B4 6987 E9B5 6988 E9B6 69CE E9B7 6989 E9B8 6966 E9B9 6963 E9BA 6979 E9BB 699B E9BC 69A7 E9BD 69BB E9BE 69AB E9BF 69AD E9C0 69D4 E9C1 69B1 E9C2 69C1 E9C3 69CA E9C4 69DF E9C5 6995 E9C6 69E0 E9C7 698D E9C8 69FF E9C9 6A2F E9CA 69ED E9CB 6A17 E9CC 6A18 E9CD 6A65 E9CE 69F2 E9CF 6A44 E9D0 6A3E E9D1 6AA0 E9D2 6A50 E9D3 6A5B E9D4 6A35 E9D5 6A8E E9D6 6A79 E9D7 6A3D E9D8 6A28 E9D9 6A58 E9DA 6A7C E9DB 6A91 E9DC 6A90 E9DD 6AA9 E9DE 6A97 E9DF 6AAB E9E0 7337 E9E1 7352 E9E2 6B81 E9E3 6B82 E9E4 6B87 E9E5 6B84 E9E6 6B92 E9E7 6B93 E9E8 6B8D E9E9 6B9A E9EA 6B9B E9EB 6BA1 E9EC 6BAA E9ED 8F6B E9EE 8F6D E9EF 8F71 E9F0 8F72 E9F1 8F73 E9F2 8F75 E9F3 8F76 E9F4 8F78 E9F5 8F77 E9F6 8F79 E9F7 8F7A E9F8 8F7C E9F9 8F7E E9FA 8F81 E9FB 8F82 E9FC 8F84 E9FD 8F87 E9FE 8F8B EAA1 8F8D EAA2 8F8E EAA3 8F8F EAA4 8F98 EAA5 8F9A EAA6 8ECE EAA7 620B EAA8 6217 EAA9 621B EAAA 621F EAAB 6222 EAAC 6221 EAAD 6225 EAAE 6224 EAAF 622C EAB0 81E7 EAB1 74EF EAB2 74F4 EAB3 74FF EAB4 750F EAB5 7511 EAB6 7513 EAB7 6534 EAB8 65EE EAB9 65EF EABA 65F0 EABB 660A EABC 6619 EABD 6772 EABE 6603 EABF 6615 EAC0 6600 EAC1 7085 EAC2 66F7 EAC3 661D EAC4 6634 EAC5 6631 EAC6 6636 EAC7 6635 EAC8 8006 EAC9 665F EACA 6654 EACB 6641 EACC 664F EACD 6656 EACE 6661 EACF 6657 EAD0 6677 EAD1 6684 EAD2 668C EAD3 66A7 EAD4 669D EAD5 66BE EAD6 66DB EAD7 66DC EAD8 66E6 EAD9 66E9 EADA 8D32 EADB 8D33 EADC 8D36 EADD 8D3B EADE 8D3D EADF 8D40 EAE0 8D45 EAE1 8D46 EAE2 8D48 EAE3 8D49 EAE4 8D47 EAE5 8D4D EAE6 8D55 EAE7 8D59 EAE8 89C7 EAE9 89CA EAEA 89CB EAEB 89CC EAEC 89CE EAED 89CF EAEE 89D0 EAEF 89D1 EAF0 726E EAF1 729F EAF2 725D EAF3 7266 EAF4 726F EAF5 727E EAF6 727F EAF7 7284 EAF8 728B EAF9 728D EAFA 728F EAFB 7292 EAFC 6308 EAFD 6332 EAFE 63B0 EBA1 643F EBA2 64D8 EBA3 8004 EBA4 6BEA EBA5 6BF3 EBA6 6BFD EBA7 6BF5 EBA8 6BF9 EBA9 6C05 EBAA 6C07 EBAB 6C06 EBAC 6C0D EBAD 6C15 EBAE 6C18 EBAF 6C19 EBB0 6C1A EBB1 6C21 EBB2 6C29 EBB3 6C24 EBB4 6C2A EBB5 6C32 EBB6 6535 EBB7 6555 EBB8 656B EBB9 724D EBBA 7252 EBBB 7256 EBBC 7230 EBBD 8662 EBBE 5216 EBBF 809F EBC0 809C EBC1 8093 EBC2 80BC EBC3 670A EBC4 80BD EBC5 80B1 EBC6 80AB EBC7 80AD EBC8 80B4 EBC9 80B7 EBCA 80E7 EBCB 80E8 EBCC 80E9 EBCD 80EA EBCE 80DB EBCF 80C2 EBD0 80C4 EBD1 80D9 EBD2 80CD EBD3 80D7 EBD4 6710 EBD5 80DD EBD6 80EB EBD7 80F1 EBD8 80F4 EBD9 80ED EBDA 810D EBDB 810E EBDC 80F2 EBDD 80FC EBDE 6715 EBDF 8112 EBE0 8C5A EBE1 8136 EBE2 811E EBE3 812C EBE4 8118 EBE5 8132 EBE6 8148 EBE7 814C EBE8 8153 EBE9 8174 EBEA 8159 EBEB 815A EBEC 8171 EBED 8160 EBEE 8169 EBEF 817C EBF0 817D EBF1 816D EBF2 8167 EBF3 584D EBF4 5AB5 EBF5 8188 EBF6 8182 EBF7 8191 EBF8 6ED5 EBF9 81A3 EBFA 81AA EBFB 81CC EBFC 6726 EBFD 81CA EBFE 81BB ECA1 81C1 ECA2 81A6 ECA3 6B24 ECA4 6B37 ECA5 6B39 ECA6 6B43 ECA7 6B46 ECA8 6B59 ECA9 98D1 ECAA 98D2 ECAB 98D3 ECAC 98D5 ECAD 98D9 ECAE 98DA ECAF 6BB3 ECB0 5F40 ECB1 6BC2 ECB2 89F3 ECB3 6590 ECB4 9F51 ECB5 6593 ECB6 65BC ECB7 65C6 ECB8 65C4 ECB9 65C3 ECBA 65CC ECBB 65CE ECBC 65D2 ECBD 65D6 ECBE 7080 ECBF 709C ECC0 7096 ECC1 709D ECC2 70BB ECC3 70C0 ECC4 70B7 ECC5 70AB ECC6 70B1 ECC7 70E8 ECC8 70CA ECC9 7110 ECCA 7113 ECCB 7116 ECCC 712F ECCD 7131 ECCE 7173 ECCF 715C ECD0 7168 ECD1 7145 ECD2 7172 ECD3 714A ECD4 7178 ECD5 717A ECD6 7198 ECD7 71B3 ECD8 71B5 ECD9 71A8 ECDA 71A0 ECDB 71E0 ECDC 71D4 ECDD 71E7 ECDE 71F9 ECDF 721D ECE0 7228 ECE1 706C ECE2 7118 ECE3 7166 ECE4 71B9 ECE5 623E ECE6 623D ECE7 6243 ECE8 6248 ECE9 6249 ECEA 793B ECEB 7940 ECEC 7946 ECED 7949 ECEE 795B ECEF 795C ECF0 7953 ECF1 795A ECF2 7962 ECF3 7957 ECF4 7960 ECF5 796F ECF6 7967 ECF7 797A ECF8 7985 ECF9 798A ECFA 799A ECFB 79A7 ECFC 79B3 ECFD 5FD1 ECFE 5FD0 EDA1 603C EDA2 605D EDA3 605A EDA4 6067 EDA5 6041 EDA6 6059 EDA7 6063 EDA8 60AB EDA9 6106 EDAA 610D EDAB 615D EDAC 61A9 EDAD 619D EDAE 61CB EDAF 61D1 EDB0 6206 EDB1 8080 EDB2 807F EDB3 6C93 EDB4 6CF6 EDB5 6DFC EDB6 77F6 EDB7 77F8 EDB8 7800 EDB9 7809 EDBA 7817 EDBB 7818 EDBC 7811 EDBD 65AB EDBE 782D EDBF 781C EDC0 781D EDC1 7839 EDC2 783A EDC3 783B EDC4 781F EDC5 783C EDC6 7825 EDC7 782C EDC8 7823 EDC9 7829 EDCA 784E EDCB 786D EDCC 7856 EDCD 7857 EDCE 7826 EDCF 7850 EDD0 7847 EDD1 784C EDD2 786A EDD3 789B EDD4 7893 EDD5 789A EDD6 7887 EDD7 789C EDD8 78A1 EDD9 78A3 EDDA 78B2 EDDB 78B9 EDDC 78A5 EDDD 78D4 EDDE 78D9 EDDF 78C9 EDE0 78EC EDE1 78F2 EDE2 7905 EDE3 78F4 EDE4 7913 EDE5 7924 EDE6 791E EDE7 7934 EDE8 9F9B EDE9 9EF9 EDEA 9EFB EDEB 9EFC EDEC 76F1 EDED 7704 EDEE 770D EDEF 76F9 EDF0 7707 EDF1 7708 EDF2 771A EDF3 7722 EDF4 7719 EDF5 772D EDF6 7726 EDF7 7735 EDF8 7738 EDF9 7750 EDFA 7751 EDFB 7747 EDFC 7743 EDFD 775A EDFE 7768 EEA1 7762 EEA2 7765 EEA3 777F EEA4 778D EEA5 777D EEA6 7780 EEA7 778C EEA8 7791 EEA9 779F EEAA 77A0 EEAB 77B0 EEAC 77B5 EEAD 77BD EEAE 753A EEAF 7540 EEB0 754E EEB1 754B EEB2 7548 EEB3 755B EEB4 7572 EEB5 7579 EEB6 7583 EEB7 7F58 EEB8 7F61 EEB9 7F5F EEBA 8A48 EEBB 7F68 EEBC 7F74 EEBD 7F71 EEBE 7F79 EEBF 7F81 EEC0 7F7E EEC1 76CD EEC2 76E5 EEC3 8832 EEC4 9485 EEC5 9486 EEC6 9487 EEC7 948B EEC8 948A EEC9 948C EECA 948D EECB 948F EECC 9490 EECD 9494 EECE 9497 EECF 9495 EED0 949A EED1 949B EED2 949C EED3 94A3 EED4 94A4 EED5 94AB EED6 94AA EED7 94AD EED8 94AC EED9 94AF EEDA 94B0 EEDB 94B2 EEDC 94B4 EEDD 94B6 EEDE 94B7 EEDF 94B8 EEE0 94B9 EEE1 94BA EEE2 94BC EEE3 94BD EEE4 94BF EEE5 94C4 EEE6 94C8 EEE7 94C9 EEE8 94CA EEE9 94CB EEEA 94CC EEEB 94CD EEEC 94CE EEED 94D0 EEEE 94D1 EEEF 94D2 EEF0 94D5 EEF1 94D6 EEF2 94D7 EEF3 94D9 EEF4 94D8 EEF5 94DB EEF6 94DE EEF7 94DF EEF8 94E0 EEF9 94E2 EEFA 94E4 EEFB 94E5 EEFC 94E7 EEFD 94E8 EEFE 94EA EFA1 94E9 EFA2 94EB EFA3 94EE EFA4 94EF EFA5 94F3 EFA6 94F4 EFA7 94F5 EFA8 94F7 EFA9 94F9 EFAA 94FC EFAB 94FD EFAC 94FF EFAD 9503 EFAE 9502 EFAF 9506 EFB0 9507 EFB1 9509 EFB2 950A EFB3 950D EFB4 950E EFB5 950F EFB6 9512 EFB7 9513 EFB8 9514 EFB9 9515 EFBA 9516 EFBB 9518 EFBC 951B EFBD 951D EFBE 951E EFBF 951F EFC0 9522 EFC1 952A EFC2 952B EFC3 9529 EFC4 952C EFC5 9531 EFC6 9532 EFC7 9534 EFC8 9536 EFC9 9537 EFCA 9538 EFCB 953C EFCC 953E EFCD 953F EFCE 9542 EFCF 9535 EFD0 9544 EFD1 9545 EFD2 9546 EFD3 9549 EFD4 954C EFD5 954E EFD6 954F EFD7 9552 EFD8 9553 EFD9 9554 EFDA 9556 EFDB 9557 EFDC 9558 EFDD 9559 EFDE 955B EFDF 955E EFE0 955F EFE1 955D EFE2 9561 EFE3 9562 EFE4 9564 EFE5 9565 EFE6 9566 EFE7 9567 EFE8 9568 EFE9 9569 EFEA 956A EFEB 956B EFEC 956C EFED 956F EFEE 9571 EFEF 9572 EFF0 9573 EFF1 953A EFF2 77E7 EFF3 77EC EFF4 96C9 EFF5 79D5 EFF6 79ED EFF7 79E3 EFF8 79EB EFF9 7A06 EFFA 5D47 EFFB 7A03 EFFC 7A02 EFFD 7A1E EFFE 7A14 F0A1 7A39 F0A2 7A37 F0A3 7A51 F0A4 9ECF F0A5 99A5 F0A6 7A70 F0A7 7688 F0A8 768E F0A9 7693 F0AA 7699 F0AB 76A4 F0AC 74DE F0AD 74E0 F0AE 752C F0AF 9E20 F0B0 9E22 F0B1 9E28 F0B2 9E29 F0B3 9E2A F0B4 9E2B F0B5 9E2C F0B6 9E32 F0B7 9E31 F0B8 9E36 F0B9 9E38 F0BA 9E37 F0BB 9E39 F0BC 9E3A F0BD 9E3E F0BE 9E41 F0BF 9E42 F0C0 9E44 F0C1 9E46 F0C2 9E47 F0C3 9E48 F0C4 9E49 F0C5 9E4B F0C6 9E4C F0C7 9E4E F0C8 9E51 F0C9 9E55 F0CA 9E57 F0CB 9E5A F0CC 9E5B F0CD 9E5C F0CE 9E5E F0CF 9E63 F0D0 9E66 F0D1 9E67 F0D2 9E68 F0D3 9E69 F0D4 9E6A F0D5 9E6B F0D6 9E6C F0D7 9E71 F0D8 9E6D F0D9 9E73 F0DA 7592 F0DB 7594 F0DC 7596 F0DD 75A0 F0DE 759D F0DF 75AC F0E0 75A3 F0E1 75B3 F0E2 75B4 F0E3 75B8 F0E4 75C4 F0E5 75B1 F0E6 75B0 F0E7 75C3 F0E8 75C2 F0E9 75D6 F0EA 75CD F0EB 75E3 F0EC 75E8 F0ED 75E6 F0EE 75E4 F0EF 75EB F0F0 75E7 F0F1 7603 F0F2 75F1 F0F3 75FC F0F4 75FF F0F5 7610 F0F6 7600 F0F7 7605 F0F8 760C F0F9 7617 F0FA 760A F0FB 7625 F0FC 7618 F0FD 7615 F0FE 7619 F1A1 761B F1A2 763C F1A3 7622 F1A4 7620 F1A5 7640 F1A6 762D F1A7 7630 F1A8 763F F1A9 7635 F1AA 7643 F1AB 763E F1AC 7633 F1AD 764D F1AE 765E F1AF 7654 F1B0 765C F1B1 7656 F1B2 766B F1B3 766F F1B4 7FCA F1B5 7AE6 F1B6 7A78 F1B7 7A79 F1B8 7A80 F1B9 7A86 F1BA 7A88 F1BB 7A95 F1BC 7AA6 F1BD 7AA0 F1BE 7AAC F1BF 7AA8 F1C0 7AAD F1C1 7AB3 F1C2 8864 F1C3 8869 F1C4 8872 F1C5 887D F1C6 887F F1C7 8882 F1C8 88A2 F1C9 88C6 F1CA 88B7 F1CB 88BC F1CC 88C9 F1CD 88E2 F1CE 88CE F1CF 88E3 F1D0 88E5 F1D1 88F1 F1D2 891A F1D3 88FC F1D4 88E8 F1D5 88FE F1D6 88F0 F1D7 8921 F1D8 8919 F1D9 8913 F1DA 891B F1DB 890A F1DC 8934 F1DD 892B F1DE 8936 F1DF 8941 F1E0 8966 F1E1 897B F1E2 758B F1E3 80E5 F1E4 76B2 F1E5 76B4 F1E6 77DC F1E7 8012 F1E8 8014 F1E9 8016 F1EA 801C F1EB 8020 F1EC 8022 F1ED 8025 F1EE 8026 F1EF 8027 F1F0 8029 F1F1 8028 F1F2 8031 F1F3 800B F1F4 8035 F1F5 8043 F1F6 8046 F1F7 804D F1F8 8052 F1F9 8069 F1FA 8071 F1FB 8983 F1FC 9878 F1FD 9880 F1FE 9883 F2A1 9889 F2A2 988C F2A3 988D F2A4 988F F2A5 9894 F2A6 989A F2A7 989B F2A8 989E F2A9 989F F2AA 98A1 F2AB 98A2 F2AC 98A5 F2AD 98A6 F2AE 864D F2AF 8654 F2B0 866C F2B1 866E F2B2 867F F2B3 867A F2B4 867C F2B5 867B F2B6 86A8 F2B7 868D F2B8 868B F2B9 86AC F2BA 869D F2BB 86A7 F2BC 86A3 F2BD 86AA F2BE 8693 F2BF 86A9 F2C0 86B6 F2C1 86C4 F2C2 86B5 F2C3 86CE F2C4 86B0 F2C5 86BA F2C6 86B1 F2C7 86AF F2C8 86C9 F2C9 86CF F2CA 86B4 F2CB 86E9 F2CC 86F1 F2CD 86F2 F2CE 86ED F2CF 86F3 F2D0 86D0 F2D1 8713 F2D2 86DE F2D3 86F4 F2D4 86DF F2D5 86D8 F2D6 86D1 F2D7 8703 F2D8 8707 F2D9 86F8 F2DA 8708 F2DB 870A F2DC 870D F2DD 8709 F2DE 8723 F2DF 873B F2E0 871E F2E1 8725 F2E2 872E F2E3 871A F2E4 873E F2E5 8748 F2E6 8734 F2E7 8731 F2E8 8729 F2E9 8737 F2EA 873F F2EB 8782 F2EC 8722 F2ED 877D F2EE 877E F2EF 877B F2F0 8760 F2F1 8770 F2F2 874C F2F3 876E F2F4 878B F2F5 8753 F2F6 8763 F2F7 877C F2F8 8764 F2F9 8759 F2FA 8765 F2FB 8793 F2FC 87AF F2FD 87A8 F2FE 87D2 F3A1 87C6 F3A2 8788 F3A3 8785 F3A4 87AD F3A5 8797 F3A6 8783 F3A7 87AB F3A8 87E5 F3A9 87AC F3AA 87B5 F3AB 87B3 F3AC 87CB F3AD 87D3 F3AE 87BD F3AF 87D1 F3B0 87C0 F3B1 87CA F3B2 87DB F3B3 87EA F3B4 87E0 F3B5 87EE F3B6 8816 F3B7 8813 F3B8 87FE F3B9 880A F3BA 881B F3BB 8821 F3BC 8839 F3BD 883C F3BE 7F36 F3BF 7F42 F3C0 7F44 F3C1 7F45 F3C2 8210 F3C3 7AFA F3C4 7AFD F3C5 7B08 F3C6 7B03 F3C7 7B04 F3C8 7B15 F3C9 7B0A F3CA 7B2B F3CB 7B0F F3CC 7B47 F3CD 7B38 F3CE 7B2A F3CF 7B19 F3D0 7B2E F3D1 7B31 F3D2 7B20 F3D3 7B25 F3D4 7B24 F3D5 7B33 F3D6 7B3E F3D7 7B1E F3D8 7B58 F3D9 7B5A F3DA 7B45 F3DB 7B75 F3DC 7B4C F3DD 7B5D F3DE 7B60 F3DF 7B6E F3E0 7B7B F3E1 7B62 F3E2 7B72 F3E3 7B71 F3E4 7B90 F3E5 7BA6 F3E6 7BA7 F3E7 7BB8 F3E8 7BAC F3E9 7B9D F3EA 7BA8 F3EB 7B85 F3EC 7BAA F3ED 7B9C F3EE 7BA2 F3EF 7BAB F3F0 7BB4 F3F1 7BD1 F3F2 7BC1 F3F3 7BCC F3F4 7BDD F3F5 7BDA F3F6 7BE5 F3F7 7BE6 F3F8 7BEA F3F9 7C0C F3FA 7BFE F3FB 7BFC F3FC 7C0F F3FD 7C16 F3FE 7C0B F4A1 7C1F F4A2 7C2A F4A3 7C26 F4A4 7C38 F4A5 7C41 F4A6 7C40 F4A7 81FE F4A8 8201 F4A9 8202 F4AA 8204 F4AB 81EC F4AC 8844 F4AD 8221 F4AE 8222 F4AF 8223 F4B0 822D F4B1 822F F4B2 8228 F4B3 822B F4B4 8238 F4B5 823B F4B6 8233 F4B7 8234 F4B8 823E F4B9 8244 F4BA 8249 F4BB 824B F4BC 824F F4BD 825A F4BE 825F F4BF 8268 F4C0 887E F4C1 8885 F4C2 8888 F4C3 88D8 F4C4 88DF F4C5 895E F4C6 7F9D F4C7 7F9F F4C8 7FA7 F4C9 7FAF F4CA 7FB0 F4CB 7FB2 F4CC 7C7C F4CD 6549 F4CE 7C91 F4CF 7C9D F4D0 7C9C F4D1 7C9E F4D2 7CA2 F4D3 7CB2 F4D4 7CBC F4D5 7CBD F4D6 7CC1 F4D7 7CC7 F4D8 7CCC F4D9 7CCD F4DA 7CC8 F4DB 7CC5 F4DC 7CD7 F4DD 7CE8 F4DE 826E F4DF 66A8 F4E0 7FBF F4E1 7FCE F4E2 7FD5 F4E3 7FE5 F4E4 7FE1 F4E5 7FE6 F4E6 7FE9 F4E7 7FEE F4E8 7FF3 F4E9 7CF8 F4EA 7D77 F4EB 7DA6 F4EC 7DAE F4ED 7E47 F4EE 7E9B F4EF 9EB8 F4F0 9EB4 F4F1 8D73 F4F2 8D84 F4F3 8D94 F4F4 8D91 F4F5 8DB1 F4F6 8D67 F4F7 8D6D F4F8 8C47 F4F9 8C49 F4FA 914A F4FB 9150 F4FC 914E F4FD 914F F4FE 9164 F5A1 9162 F5A2 9161 F5A3 9170 F5A4 9169 F5A5 916F F5A6 917D F5A7 917E F5A8 9172 F5A9 9174 F5AA 9179 F5AB 918C F5AC 9185 F5AD 9190 F5AE 918D F5AF 9191 F5B0 91A2 F5B1 91A3 F5B2 91AA F5B3 91AD F5B4 91AE F5B5 91AF F5B6 91B5 F5B7 91B4 F5B8 91BA F5B9 8C55 F5BA 9E7E F5BB 8DB8 F5BC 8DEB F5BD 8E05 F5BE 8E59 F5BF 8E69 F5C0 8DB5 F5C1 8DBF F5C2 8DBC F5C3 8DBA F5C4 8DC4 F5C5 8DD6 F5C6 8DD7 F5C7 8DDA F5C8 8DDE F5C9 8DCE F5CA 8DCF F5CB 8DDB F5CC 8DC6 F5CD 8DEC F5CE 8DF7 F5CF 8DF8 F5D0 8DE3 F5D1 8DF9 F5D2 8DFB F5D3 8DE4 F5D4 8E09 F5D5 8DFD F5D6 8E14 F5D7 8E1D F5D8 8E1F F5D9 8E2C F5DA 8E2E F5DB 8E23 F5DC 8E2F F5DD 8E3A F5DE 8E40 F5DF 8E39 F5E0 8E35 F5E1 8E3D F5E2 8E31 F5E3 8E49 F5E4 8E41 F5E5 8E42 F5E6 8E51 F5E7 8E52 F5E8 8E4A F5E9 8E70 F5EA 8E76 F5EB 8E7C F5EC 8E6F F5ED 8E74 F5EE 8E85 F5EF 8E8F F5F0 8E94 F5F1 8E90 F5F2 8E9C F5F3 8E9E F5F4 8C78 F5F5 8C82 F5F6 8C8A F5F7 8C85 F5F8 8C98 F5F9 8C94 F5FA 659B F5FB 89D6 F5FC 89DE F5FD 89DA F5FE 89DC F6A1 89E5 F6A2 89EB F6A3 89EF F6A4 8A3E F6A5 8B26 F6A6 9753 F6A7 96E9 F6A8 96F3 F6A9 96EF F6AA 9706 F6AB 9701 F6AC 9708 F6AD 970F F6AE 970E F6AF 972A F6B0 972D F6B1 9730 F6B2 973E F6B3 9F80 F6B4 9F83 F6B5 9F85 F6B6 9F86 F6B7 9F87 F6B8 9F88 F6B9 9F89 F6BA 9F8A F6BB 9F8C F6BC 9EFE F6BD 9F0B F6BE 9F0D F6BF 96B9 F6C0 96BC F6C1 96BD F6C2 96CE F6C3 96D2 F6C4 77BF F6C5 96E0 F6C6 928E F6C7 92AE F6C8 92C8 F6C9 933E F6CA 936A F6CB 93CA F6CC 938F F6CD 943E F6CE 946B F6CF 9C7F F6D0 9C82 F6D1 9C85 F6D2 9C86 F6D3 9C87 F6D4 9C88 F6D5 7A23 F6D6 9C8B F6D7 9C8E F6D8 9C90 F6D9 9C91 F6DA 9C92 F6DB 9C94 F6DC 9C95 F6DD 9C9A F6DE 9C9B F6DF 9C9E F6E0 9C9F F6E1 9CA0 F6E2 9CA1 F6E3 9CA2 F6E4 9CA3 F6E5 9CA5 F6E6 9CA6 F6E7 9CA7 F6E8 9CA8 F6E9 9CA9 F6EA 9CAB F6EB 9CAD F6EC 9CAE F6ED 9CB0 F6EE 9CB1 F6EF 9CB2 F6F0 9CB3 F6F1 9CB4 F6F2 9CB5 F6F3 9CB6 F6F4 9CB7 F6F5 9CBA F6F6 9CBB F6F7 9CBC F6F8 9CBD F6F9 9CC4 F6FA 9CC5 F6FB 9CC6 F6FC 9CC7 F6FD 9CCA F6FE 9CCB F7A1 9CCC F7A2 9CCD F7A3 9CCE F7A4 9CCF F7A5 9CD0 F7A6 9CD3 F7A7 9CD4 F7A8 9CD5 F7A9 9CD7 F7AA 9CD8 F7AB 9CD9 F7AC 9CDC F7AD 9CDD F7AE 9CDF F7AF 9CE2 F7B0 977C F7B1 9785 F7B2 9791 F7B3 9792 F7B4 9794 F7B5 97AF F7B6 97AB F7B7 97A3 F7B8 97B2 F7B9 97B4 F7BA 9AB1 F7BB 9AB0 F7BC 9AB7 F7BD 9E58 F7BE 9AB6 F7BF 9ABA F7C0 9ABC F7C1 9AC1 F7C2 9AC0 F7C3 9AC5 F7C4 9AC2 F7C5 9ACB F7C6 9ACC F7C7 9AD1 F7C8 9B45 F7C9 9B43 F7CA 9B47 F7CB 9B49 F7CC 9B48 F7CD 9B4D F7CE 9B51 F7CF 98E8 F7D0 990D F7D1 992E F7D2 9955 F7D3 9954 F7D4 9ADF F7D5 9AE1 F7D6 9AE6 F7D7 9AEF F7D8 9AEB F7D9 9AFB F7DA 9AED F7DB 9AF9 F7DC 9B08 F7DD 9B0F F7DE 9B13 F7DF 9B1F F7E0 9B23 F7E1 9EBD F7E2 9EBE F7E3 7E3B F7E4 9E82 F7E5 9E87 F7E6 9E88 F7E7 9E8B F7E8 9E92 F7E9 93D6 F7EA 9E9D F7EB 9E9F F7EC 9EDB F7ED 9EDC F7EE 9EDD F7EF 9EE0 F7F0 9EDF F7F1 9EE2 F7F2 9EE9 F7F3 9EE7 F7F4 9EE5 F7F5 9EEA F7F6 9EEF F7F7 9F22 F7F8 9F2C F7F9 9F2F F7FA 9F39 F7FB 9F37 F7FC 9F3D F7FD 9F3E F7FE 9F44
75,474
7,574
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_with.py
"""Unit tests for the with statement specified in PEP 343.""" __author__ = "Mike Bland" __email__ = "mbland at acm dot org" import sys import unittest from collections import deque from contextlib import _GeneratorContextManager, contextmanager class MockContextManager(_GeneratorContextManager): def __init__(self, *args): super().__init__(*args) self.enter_called = False self.exit_called = False self.exit_args = None def __enter__(self): self.enter_called = True return _GeneratorContextManager.__enter__(self) def __exit__(self, type, value, traceback): self.exit_called = True self.exit_args = (type, value, traceback) return _GeneratorContextManager.__exit__(self, type, value, traceback) def mock_contextmanager(func): def helper(*args, **kwds): return MockContextManager(func, args, kwds) return helper class MockResource(object): def __init__(self): self.yielded = False self.stopped = False @mock_contextmanager def mock_contextmanager_generator(): mock = MockResource() try: mock.yielded = True yield mock finally: mock.stopped = True class Nested(object): def __init__(self, *managers): self.managers = managers self.entered = None def __enter__(self): if self.entered is not None: raise RuntimeError("Context is not reentrant") self.entered = deque() vars = [] try: for mgr in self.managers: vars.append(mgr.__enter__()) self.entered.appendleft(mgr) except: if not self.__exit__(*sys.exc_info()): raise return vars def __exit__(self, *exc_info): # Behave like nested with statements # first in, last out # New exceptions override old ones ex = exc_info for mgr in self.entered: try: if mgr.__exit__(*ex): ex = (None, None, None) except: ex = sys.exc_info() self.entered = None if ex is not exc_info: raise ex[0](ex[1]).with_traceback(ex[2]) class MockNested(Nested): def __init__(self, *managers): Nested.__init__(self, *managers) self.enter_called = False self.exit_called = False self.exit_args = None def __enter__(self): self.enter_called = True return Nested.__enter__(self) def __exit__(self, *exc_info): self.exit_called = True self.exit_args = exc_info return Nested.__exit__(self, *exc_info) class FailureTestCase(unittest.TestCase): def testNameError(self): def fooNotDeclared(): with foo: pass self.assertRaises(NameError, fooNotDeclared) def testEnterAttributeError1(self): class LacksEnter(object): def __exit__(self, type, value, traceback): pass def fooLacksEnter(): foo = LacksEnter() with foo: pass self.assertRaisesRegex(AttributeError, '__enter__', fooLacksEnter) def testEnterAttributeError2(self): class LacksEnterAndExit(object): pass def fooLacksEnterAndExit(): foo = LacksEnterAndExit() with foo: pass self.assertRaisesRegex(AttributeError, '__enter__', fooLacksEnterAndExit) def testExitAttributeError(self): class LacksExit(object): def __enter__(self): pass def fooLacksExit(): foo = LacksExit() with foo: pass self.assertRaisesRegex(AttributeError, '__exit__', fooLacksExit) def assertRaisesSyntaxError(self, codestr): def shouldRaiseSyntaxError(s): compile(s, '', 'single') self.assertRaises(SyntaxError, shouldRaiseSyntaxError, codestr) def testAssignmentToNoneError(self): self.assertRaisesSyntaxError('with mock as None:\n pass') self.assertRaisesSyntaxError( 'with mock as (None):\n' ' pass') def testAssignmentToTupleOnlyContainingNoneError(self): self.assertRaisesSyntaxError('with mock as None,:\n pass') self.assertRaisesSyntaxError( 'with mock as (None,):\n' ' pass') def testAssignmentToTupleContainingNoneError(self): self.assertRaisesSyntaxError( 'with mock as (foo, None, bar):\n' ' pass') def testEnterThrows(self): class EnterThrows(object): def __enter__(self): raise RuntimeError("Enter threw") def __exit__(self, *args): pass def shouldThrow(): ct = EnterThrows() self.foo = None with ct as self.foo: pass self.assertRaises(RuntimeError, shouldThrow) self.assertEqual(self.foo, None) def testExitThrows(self): class ExitThrows(object): def __enter__(self): return def __exit__(self, *args): raise RuntimeError(42) def shouldThrow(): with ExitThrows(): pass self.assertRaises(RuntimeError, shouldThrow) class ContextmanagerAssertionMixin(object): def setUp(self): self.TEST_EXCEPTION = RuntimeError("test exception") def assertInWithManagerInvariants(self, mock_manager): self.assertTrue(mock_manager.enter_called) self.assertFalse(mock_manager.exit_called) self.assertEqual(mock_manager.exit_args, None) def assertAfterWithManagerInvariants(self, mock_manager, exit_args): self.assertTrue(mock_manager.enter_called) self.assertTrue(mock_manager.exit_called) self.assertEqual(mock_manager.exit_args, exit_args) def assertAfterWithManagerInvariantsNoError(self, mock_manager): self.assertAfterWithManagerInvariants(mock_manager, (None, None, None)) def assertInWithGeneratorInvariants(self, mock_generator): self.assertTrue(mock_generator.yielded) self.assertFalse(mock_generator.stopped) def assertAfterWithGeneratorInvariantsNoError(self, mock_generator): self.assertTrue(mock_generator.yielded) self.assertTrue(mock_generator.stopped) def raiseTestException(self): raise self.TEST_EXCEPTION def assertAfterWithManagerInvariantsWithError(self, mock_manager, exc_type=None): self.assertTrue(mock_manager.enter_called) self.assertTrue(mock_manager.exit_called) if exc_type is None: self.assertEqual(mock_manager.exit_args[1], self.TEST_EXCEPTION) exc_type = type(self.TEST_EXCEPTION) self.assertEqual(mock_manager.exit_args[0], exc_type) # Test the __exit__ arguments. Issue #7853 self.assertIsInstance(mock_manager.exit_args[1], exc_type) self.assertIsNot(mock_manager.exit_args[2], None) def assertAfterWithGeneratorInvariantsWithError(self, mock_generator): self.assertTrue(mock_generator.yielded) self.assertTrue(mock_generator.stopped) class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin): def testInlineGeneratorSyntax(self): with mock_contextmanager_generator(): pass def testUnboundGenerator(self): mock = mock_contextmanager_generator() with mock: pass self.assertAfterWithManagerInvariantsNoError(mock) def testInlineGeneratorBoundSyntax(self): with mock_contextmanager_generator() as foo: self.assertInWithGeneratorInvariants(foo) # FIXME: In the future, we'll try to keep the bound names from leaking self.assertAfterWithGeneratorInvariantsNoError(foo) def testInlineGeneratorBoundToExistingVariable(self): foo = None with mock_contextmanager_generator() as foo: self.assertInWithGeneratorInvariants(foo) self.assertAfterWithGeneratorInvariantsNoError(foo) def testInlineGeneratorBoundToDottedVariable(self): with mock_contextmanager_generator() as self.foo: self.assertInWithGeneratorInvariants(self.foo) self.assertAfterWithGeneratorInvariantsNoError(self.foo) def testBoundGenerator(self): mock = mock_contextmanager_generator() with mock as foo: self.assertInWithGeneratorInvariants(foo) self.assertInWithManagerInvariants(mock) self.assertAfterWithGeneratorInvariantsNoError(foo) self.assertAfterWithManagerInvariantsNoError(mock) def testNestedSingleStatements(self): mock_a = mock_contextmanager_generator() with mock_a as foo: mock_b = mock_contextmanager_generator() with mock_b as bar: self.assertInWithManagerInvariants(mock_a) self.assertInWithManagerInvariants(mock_b) self.assertInWithGeneratorInvariants(foo) self.assertInWithGeneratorInvariants(bar) self.assertAfterWithManagerInvariantsNoError(mock_b) self.assertAfterWithGeneratorInvariantsNoError(bar) self.assertInWithManagerInvariants(mock_a) self.assertInWithGeneratorInvariants(foo) self.assertAfterWithManagerInvariantsNoError(mock_a) self.assertAfterWithGeneratorInvariantsNoError(foo) class NestedNonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin): def testSingleArgInlineGeneratorSyntax(self): with Nested(mock_contextmanager_generator()): pass def testSingleArgBoundToNonTuple(self): m = mock_contextmanager_generator() # This will bind all the arguments to nested() into a single list # assigned to foo. with Nested(m) as foo: self.assertInWithManagerInvariants(m) self.assertAfterWithManagerInvariantsNoError(m) def testSingleArgBoundToSingleElementParenthesizedList(self): m = mock_contextmanager_generator() # This will bind all the arguments to nested() into a single list # assigned to foo. with Nested(m) as (foo): self.assertInWithManagerInvariants(m) self.assertAfterWithManagerInvariantsNoError(m) def testSingleArgBoundToMultipleElementTupleError(self): def shouldThrowValueError(): with Nested(mock_contextmanager_generator()) as (foo, bar): pass self.assertRaises(ValueError, shouldThrowValueError) def testSingleArgUnbound(self): mock_contextmanager = mock_contextmanager_generator() mock_nested = MockNested(mock_contextmanager) with mock_nested: self.assertInWithManagerInvariants(mock_contextmanager) self.assertInWithManagerInvariants(mock_nested) self.assertAfterWithManagerInvariantsNoError(mock_contextmanager) self.assertAfterWithManagerInvariantsNoError(mock_nested) def testMultipleArgUnbound(self): m = mock_contextmanager_generator() n = mock_contextmanager_generator() o = mock_contextmanager_generator() mock_nested = MockNested(m, n, o) with mock_nested: self.assertInWithManagerInvariants(m) self.assertInWithManagerInvariants(n) self.assertInWithManagerInvariants(o) self.assertInWithManagerInvariants(mock_nested) self.assertAfterWithManagerInvariantsNoError(m) self.assertAfterWithManagerInvariantsNoError(n) self.assertAfterWithManagerInvariantsNoError(o) self.assertAfterWithManagerInvariantsNoError(mock_nested) def testMultipleArgBound(self): mock_nested = MockNested(mock_contextmanager_generator(), mock_contextmanager_generator(), mock_contextmanager_generator()) with mock_nested as (m, n, o): self.assertInWithGeneratorInvariants(m) self.assertInWithGeneratorInvariants(n) self.assertInWithGeneratorInvariants(o) self.assertInWithManagerInvariants(mock_nested) self.assertAfterWithGeneratorInvariantsNoError(m) self.assertAfterWithGeneratorInvariantsNoError(n) self.assertAfterWithGeneratorInvariantsNoError(o) self.assertAfterWithManagerInvariantsNoError(mock_nested) class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): def testSingleResource(self): cm = mock_contextmanager_generator() def shouldThrow(): with cm as self.resource: self.assertInWithManagerInvariants(cm) self.assertInWithGeneratorInvariants(self.resource) self.raiseTestException() self.assertRaises(RuntimeError, shouldThrow) self.assertAfterWithManagerInvariantsWithError(cm) self.assertAfterWithGeneratorInvariantsWithError(self.resource) def testExceptionNormalized(self): cm = mock_contextmanager_generator() def shouldThrow(): with cm as self.resource: # Note this relies on the fact that 1 // 0 produces an exception # that is not normalized immediately. 1 // 0 self.assertRaises(ZeroDivisionError, shouldThrow) self.assertAfterWithManagerInvariantsWithError(cm, ZeroDivisionError) def testNestedSingleStatements(self): mock_a = mock_contextmanager_generator() mock_b = mock_contextmanager_generator() def shouldThrow(): with mock_a as self.foo: with mock_b as self.bar: self.assertInWithManagerInvariants(mock_a) self.assertInWithManagerInvariants(mock_b) self.assertInWithGeneratorInvariants(self.foo) self.assertInWithGeneratorInvariants(self.bar) self.raiseTestException() self.assertRaises(RuntimeError, shouldThrow) self.assertAfterWithManagerInvariantsWithError(mock_a) self.assertAfterWithManagerInvariantsWithError(mock_b) self.assertAfterWithGeneratorInvariantsWithError(self.foo) self.assertAfterWithGeneratorInvariantsWithError(self.bar) def testMultipleResourcesInSingleStatement(self): cm_a = mock_contextmanager_generator() cm_b = mock_contextmanager_generator() mock_nested = MockNested(cm_a, cm_b) def shouldThrow(): with mock_nested as (self.resource_a, self.resource_b): self.assertInWithManagerInvariants(cm_a) self.assertInWithManagerInvariants(cm_b) self.assertInWithManagerInvariants(mock_nested) self.assertInWithGeneratorInvariants(self.resource_a) self.assertInWithGeneratorInvariants(self.resource_b) self.raiseTestException() self.assertRaises(RuntimeError, shouldThrow) self.assertAfterWithManagerInvariantsWithError(cm_a) self.assertAfterWithManagerInvariantsWithError(cm_b) self.assertAfterWithManagerInvariantsWithError(mock_nested) self.assertAfterWithGeneratorInvariantsWithError(self.resource_a) self.assertAfterWithGeneratorInvariantsWithError(self.resource_b) def testNestedExceptionBeforeInnerStatement(self): mock_a = mock_contextmanager_generator() mock_b = mock_contextmanager_generator() self.bar = None def shouldThrow(): with mock_a as self.foo: self.assertInWithManagerInvariants(mock_a) self.assertInWithGeneratorInvariants(self.foo) self.raiseTestException() with mock_b as self.bar: pass self.assertRaises(RuntimeError, shouldThrow) self.assertAfterWithManagerInvariantsWithError(mock_a) self.assertAfterWithGeneratorInvariantsWithError(self.foo) # The inner statement stuff should never have been touched self.assertEqual(self.bar, None) self.assertFalse(mock_b.enter_called) self.assertFalse(mock_b.exit_called) self.assertEqual(mock_b.exit_args, None) def testNestedExceptionAfterInnerStatement(self): mock_a = mock_contextmanager_generator() mock_b = mock_contextmanager_generator() def shouldThrow(): with mock_a as self.foo: with mock_b as self.bar: self.assertInWithManagerInvariants(mock_a) self.assertInWithManagerInvariants(mock_b) self.assertInWithGeneratorInvariants(self.foo) self.assertInWithGeneratorInvariants(self.bar) self.raiseTestException() self.assertRaises(RuntimeError, shouldThrow) self.assertAfterWithManagerInvariantsWithError(mock_a) self.assertAfterWithManagerInvariantsNoError(mock_b) self.assertAfterWithGeneratorInvariantsWithError(self.foo) self.assertAfterWithGeneratorInvariantsNoError(self.bar) def testRaisedStopIteration1(self): # From bug 1462485 @contextmanager def cm(): yield def shouldThrow(): with cm(): raise StopIteration("from with") with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): self.assertRaises(StopIteration, shouldThrow) def testRaisedStopIteration2(self): # From bug 1462485 class cm(object): def __enter__(self): pass def __exit__(self, type, value, traceback): pass def shouldThrow(): with cm(): raise StopIteration("from with") self.assertRaises(StopIteration, shouldThrow) def testRaisedStopIteration3(self): # Another variant where the exception hasn't been instantiated # From bug 1705170 @contextmanager def cm(): yield def shouldThrow(): with cm(): raise next(iter([])) with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): self.assertRaises(StopIteration, shouldThrow) def testRaisedGeneratorExit1(self): # From bug 1462485 @contextmanager def cm(): yield def shouldThrow(): with cm(): raise GeneratorExit("from with") self.assertRaises(GeneratorExit, shouldThrow) def testRaisedGeneratorExit2(self): # From bug 1462485 class cm (object): def __enter__(self): pass def __exit__(self, type, value, traceback): pass def shouldThrow(): with cm(): raise GeneratorExit("from with") self.assertRaises(GeneratorExit, shouldThrow) def testErrorsInBool(self): # issue4589: __exit__ return code may raise an exception # when looking at its truth value. class cm(object): def __init__(self, bool_conversion): class Bool: def __bool__(self): return bool_conversion() self.exit_result = Bool() def __enter__(self): return 3 def __exit__(self, a, b, c): return self.exit_result def trueAsBool(): with cm(lambda: True): self.fail("Should NOT see this") trueAsBool() def falseAsBool(): with cm(lambda: False): self.fail("Should raise") self.assertRaises(AssertionError, falseAsBool) def failAsBool(): with cm(lambda: 1//0): self.fail("Should NOT see this") self.assertRaises(ZeroDivisionError, failAsBool) class NonLocalFlowControlTestCase(unittest.TestCase): def testWithBreak(self): counter = 0 while True: counter += 1 with mock_contextmanager_generator(): counter += 10 break counter += 100 # Not reached self.assertEqual(counter, 11) def testWithContinue(self): counter = 0 while True: counter += 1 if counter > 2: break with mock_contextmanager_generator(): counter += 10 continue counter += 100 # Not reached self.assertEqual(counter, 12) def testWithReturn(self): def foo(): counter = 0 while True: counter += 1 with mock_contextmanager_generator(): counter += 10 return counter counter += 100 # Not reached self.assertEqual(foo(), 11) def testWithYield(self): def gen(): with mock_contextmanager_generator(): yield 12 yield 13 x = list(gen()) self.assertEqual(x, [12, 13]) def testWithRaise(self): counter = 0 try: counter += 1 with mock_contextmanager_generator(): counter += 10 raise RuntimeError counter += 100 # Not reached except RuntimeError: self.assertEqual(counter, 11) else: self.fail("Didn't raise RuntimeError") class AssignmentTargetTestCase(unittest.TestCase): def testSingleComplexTarget(self): targets = {1: [0, 1, 2]} with mock_contextmanager_generator() as targets[1][0]: self.assertEqual(list(targets.keys()), [1]) self.assertEqual(targets[1][0].__class__, MockResource) with mock_contextmanager_generator() as list(targets.values())[0][1]: self.assertEqual(list(targets.keys()), [1]) self.assertEqual(targets[1][1].__class__, MockResource) with mock_contextmanager_generator() as targets[2]: keys = list(targets.keys()) keys.sort() self.assertEqual(keys, [1, 2]) class C: pass blah = C() with mock_contextmanager_generator() as blah.foo: self.assertEqual(hasattr(blah, "foo"), True) def testMultipleComplexTargets(self): class C: def __enter__(self): return 1, 2, 3 def __exit__(self, t, v, tb): pass targets = {1: [0, 1, 2]} with C() as (targets[1][0], targets[1][1], targets[1][2]): self.assertEqual(targets, {1: [1, 2, 3]}) with C() as (list(targets.values())[0][2], list(targets.values())[0][1], list(targets.values())[0][0]): self.assertEqual(targets, {1: [3, 2, 1]}) with C() as (targets[1], targets[2], targets[3]): self.assertEqual(targets, {1: 1, 2: 2, 3: 3}) class B: pass blah = B() with C() as (blah.one, blah.two, blah.three): self.assertEqual(blah.one, 1) self.assertEqual(blah.two, 2) self.assertEqual(blah.three, 3) class ExitSwallowsExceptionTestCase(unittest.TestCase): def testExitTrueSwallowsException(self): class AfricanSwallow: def __enter__(self): pass def __exit__(self, t, v, tb): return True try: with AfricanSwallow(): 1/0 except ZeroDivisionError: self.fail("ZeroDivisionError should have been swallowed") def testExitFalseDoesntSwallowException(self): class EuropeanSwallow: def __enter__(self): pass def __exit__(self, t, v, tb): return False try: with EuropeanSwallow(): 1/0 except ZeroDivisionError: pass else: self.fail("ZeroDivisionError should have been raised") class NestedWith(unittest.TestCase): class Dummy(object): def __init__(self, value=None, gobble=False): if value is None: value = self self.value = value self.gobble = gobble self.enter_called = False self.exit_called = False def __enter__(self): self.enter_called = True return self.value def __exit__(self, *exc_info): self.exit_called = True self.exc_info = exc_info if self.gobble: return True class InitRaises(object): def __init__(self): raise RuntimeError() class EnterRaises(object): def __enter__(self): raise RuntimeError() def __exit__(self, *exc_info): pass class ExitRaises(object): def __enter__(self): pass def __exit__(self, *exc_info): raise RuntimeError() def testNoExceptions(self): with self.Dummy() as a, self.Dummy() as b: self.assertTrue(a.enter_called) self.assertTrue(b.enter_called) self.assertTrue(a.exit_called) self.assertTrue(b.exit_called) def testExceptionInExprList(self): try: with self.Dummy() as a, self.InitRaises(): pass except: pass self.assertTrue(a.enter_called) self.assertTrue(a.exit_called) def testExceptionInEnter(self): try: with self.Dummy() as a, self.EnterRaises(): self.fail('body of bad with executed') except RuntimeError: pass else: self.fail('RuntimeError not reraised') self.assertTrue(a.enter_called) self.assertTrue(a.exit_called) def testExceptionInExit(self): body_executed = False with self.Dummy(gobble=True) as a, self.ExitRaises(): body_executed = True self.assertTrue(a.enter_called) self.assertTrue(a.exit_called) self.assertTrue(body_executed) self.assertNotEqual(a.exc_info[0], None) def testEnterReturnsTuple(self): with self.Dummy(value=(1,2)) as (a1, a2), \ self.Dummy(value=(10, 20)) as (b1, b2): self.assertEqual(1, a1) self.assertEqual(2, a2) self.assertEqual(10, b1) self.assertEqual(20, b2) if __name__ == '__main__': unittest.main()
26,459
747
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_poll.py
# Test case for the os.poll() function import os import subprocess import random import select try: import _thread import threading except ImportError: threading = None import time import unittest from test.support import TESTFN, run_unittest, reap_threads, cpython_only try: select.poll except AttributeError: raise unittest.SkipTest("select.poll not defined") def find_ready_matching(ready, flag): match = [] for fd, mode in ready: if mode & flag: match.append(fd) return match class PollTests(unittest.TestCase): def test_poll1(self): # Basic functional test of poll object # Create a bunch of pipe and test that poll works with them. p = select.poll() NUM_PIPES = 12 MSG = b" This is a test." MSG_LEN = len(MSG) readers = [] writers = [] r2w = {} w2r = {} for i in range(NUM_PIPES): rd, wr = os.pipe() p.register(rd) p.modify(rd, select.POLLIN) p.register(wr, select.POLLOUT) readers.append(rd) writers.append(wr) r2w[rd] = wr w2r[wr] = rd bufs = [] while writers: ready = p.poll() ready_writers = find_ready_matching(ready, select.POLLOUT) if not ready_writers: raise RuntimeError("no pipes ready for writing") wr = random.choice(ready_writers) os.write(wr, MSG) ready = p.poll() ready_readers = find_ready_matching(ready, select.POLLIN) if not ready_readers: raise RuntimeError("no pipes ready for reading") rd = random.choice(ready_readers) buf = os.read(rd, MSG_LEN) self.assertEqual(len(buf), MSG_LEN) bufs.append(buf) os.close(r2w[rd]) ; os.close( rd ) p.unregister( r2w[rd] ) p.unregister( rd ) writers.remove(r2w[rd]) self.assertEqual(bufs, [MSG] * NUM_PIPES) def test_poll_unit_tests(self): # returns NVAL for invalid file descriptor FD, w = os.pipe() os.close(FD) os.close(w) p = select.poll() p.register(FD) r = p.poll() self.assertEqual(r[0], (FD, select.POLLNVAL)) f = open(TESTFN, 'w') fd = f.fileno() p = select.poll() p.register(f) r = p.poll() self.assertEqual(r[0][0], fd) f.close() r = p.poll() self.assertEqual(r[0], (fd, select.POLLNVAL)) os.unlink(TESTFN) # type error for invalid arguments p = select.poll() self.assertRaises(TypeError, p.register, p) self.assertRaises(TypeError, p.unregister, p) # can't unregister non-existent object p = select.poll() self.assertRaises(KeyError, p.unregister, 3) # Test error cases pollster = select.poll() class Nope: pass class Almost: def fileno(self): return 'fileno' self.assertRaises(TypeError, pollster.register, Nope(), 0) self.assertRaises(TypeError, pollster.register, Almost(), 0) # Another test case for poll(). This is copied from the test case for # select(), modified to use poll() instead. @unittest.skip("[jart] this test sucks") def test_poll2(self): cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, bufsize=0) proc.__enter__() self.addCleanup(proc.__exit__, None, None, None) p = proc.stdout pollster = select.poll() pollster.register( p, select.POLLIN ) for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: fdlist = pollster.poll(tout) if (fdlist == []): continue fd, flags = fdlist[0] if flags & select.POLLHUP: line = p.readline() if line != b"": self.fail('error: pipe seems to be closed, but still returns data') continue elif flags & select.POLLIN: line = p.readline() if not line: break self.assertEqual(line, b'testing...\n') continue else: self.fail('Unexpected return value from select.poll: %s' % fdlist) def test_poll3(self): # test int overflow pollster = select.poll() pollster.register(1) self.assertRaises(OverflowError, pollster.poll, 1 << 64) x = 2 + 3 if x != 5: self.fail('Overflow must have occurred') # Issues #15989, #17919 self.assertRaises(OverflowError, pollster.register, 0, -1) self.assertRaises(OverflowError, pollster.register, 0, 1 << 64) self.assertRaises(OverflowError, pollster.modify, 1, -1) self.assertRaises(OverflowError, pollster.modify, 1, 1 << 64) @cpython_only def test_poll_c_limits(self): from _testcapi import USHRT_MAX, INT_MAX, UINT_MAX pollster = select.poll() pollster.register(1) # Issues #15989, #17919 self.assertRaises(OverflowError, pollster.register, 0, USHRT_MAX + 1) self.assertRaises(OverflowError, pollster.modify, 1, USHRT_MAX + 1) self.assertRaises(OverflowError, pollster.poll, INT_MAX + 1) self.assertRaises(OverflowError, pollster.poll, UINT_MAX + 1) @unittest.skipUnless(threading, 'Threading required for this test.') @reap_threads def test_threaded_poll(self): r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) rfds = [] for i in range(10): fd = os.dup(r) self.addCleanup(os.close, fd) rfds.append(fd) pollster = select.poll() for fd in rfds: pollster.register(fd, select.POLLIN) t = threading.Thread(target=pollster.poll) t.start() try: time.sleep(0.5) # trigger ufds array reallocation for fd in rfds: pollster.unregister(fd) pollster.register(w, select.POLLOUT) self.assertRaises(RuntimeError, pollster.poll) finally: # and make the call to poll() from the thread return os.write(w, b'spam') t.join() @unittest.skipUnless(threading, 'Threading required for this test.') @reap_threads def test_poll_blocks_with_negative_ms(self): for timeout_ms in [None, -1000, -1, -1.0, -0.1, -1e-100]: # Create two file descriptors. This will be used to unlock # the blocking call to poll.poll inside the thread r, w = os.pipe() pollster = select.poll() pollster.register(r, select.POLLIN) poll_thread = threading.Thread(target=pollster.poll, args=(timeout_ms,)) poll_thread.start() poll_thread.join(timeout=0.1) self.assertTrue(poll_thread.is_alive()) # Write to the pipe so pollster.poll unblocks and the thread ends. os.write(w, b'spam') poll_thread.join() self.assertFalse(poll_thread.is_alive()) os.close(r) os.close(w) def test_main(): run_unittest(PollTests) if __name__ == '__main__': test_main()
7,591
240
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_urllibnet.py
import unittest from test import support import contextlib import socket import urllib.request import os import email.message import time support.requires('network') class URLTimeoutTest(unittest.TestCase): # XXX this test doesn't seem to test anything useful. TIMEOUT = 30.0 def setUp(self): socket.setdefaulttimeout(self.TIMEOUT) def tearDown(self): socket.setdefaulttimeout(None) def testURLread(self): with support.transient_internet("www.example.com"): f = urllib.request.urlopen("http://www.example.com/") f.read() class urlopenNetworkTests(unittest.TestCase): """Tests urllib.request.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. setUp is not used for always constructing a connection to http://www.pythontest.net/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. """ url = 'http://www.pythontest.net/' @contextlib.contextmanager def urlopen(self, *args, **kwargs): resource = args[0] with support.transient_internet(resource): r = urllib.request.urlopen(*args, **kwargs) try: yield r finally: r.close() def test_basic(self): # Simple test expected to pass. with self.urlopen(self.url) as open_url: for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " "urlopen lacks the %s attribute" % attr) self.assertTrue(open_url.read(), "calling 'read' failed") def test_readlines(self): # Test both readline and readlines. with self.urlopen(self.url) as open_url: self.assertIsInstance(open_url.readline(), bytes, "readline did not return a string") self.assertIsInstance(open_url.readlines(), list, "readlines did not return a list") def test_info(self): # Test 'info'. with self.urlopen(self.url) as open_url: info_obj = open_url.info() self.assertIsInstance(info_obj, email.message.Message, "object returned by 'info' is not an " "instance of email.message.Message") self.assertEqual(info_obj.get_content_subtype(), "html") def test_geturl(self): # Make sure same URL as opened is returned by geturl. with self.urlopen(self.url) as open_url: gotten_url = open_url.geturl() self.assertEqual(gotten_url, self.url) def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes URL = self.url + "XXXinvalidXXX" with support.transient_internet(URL): with self.assertWarns(DeprecationWarning): open_url = urllib.request.FancyURLopener().open(URL) try: code = open_url.getcode() finally: open_url.close() self.assertEqual(code, 404) def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. # Given that both VeriSign and various ISPs have in # the past or are presently hijacking various invalid # domain name requests in an attempt to boost traffic # to their own sites, finding a domain name to use # for this test is difficult. RFC2606 leads one to # believe that '.invalid' should work, but experience # seemed to indicate otherwise. Single character # TLDs are likely to remain invalid, so this seems to # be the best choice. The trailing '.' prevents a # related problem: The normal DNS resolver appends # the domain names from the search path if there is # no '.' the end and, and if one of those domains # implements a '*' rule a result is returned. # However, none of this will prevent the test from # failing if the ISP hijacks all invalid domain # requests. The real solution would be to be able to # parameterize the framework with a mock resolver. bogus_domain = "sadflkjsasf.i.nvali.d." try: socket.gethostbyname(bogus_domain) except OSError: # socket.gaierror is too narrow, since getaddrinfo() may also # fail with EAI_SYSTEM and ETIMEDOUT (seen on Ubuntu 13.04), # i.e. Python's TimeoutError. pass else: # This happens with some overzealous DNS providers such as OpenDNS self.skipTest("%r should not resolve for test to work" % bogus_domain) failure_explanation = ('opening an invalid URL did not raise OSError; ' 'can be caused by a broken DNS server ' '(e.g. returns 404 or hijacks page)') with self.assertRaises(OSError, msg=failure_explanation): urllib.request.urlopen("http://{}/".format(bogus_domain)) class urlretrieveNetworkTests(unittest.TestCase): """Tests urllib.request.urlretrieve using the network.""" @contextlib.contextmanager def urlretrieve(self, *args, **kwargs): resource = args[0] with support.transient_internet(resource): file_location, info = urllib.request.urlretrieve(*args, **kwargs) try: yield file_location, info finally: support.unlink(file_location) def test_basic(self): # Test basic functionality. with self.urlretrieve(self.logo) as (file_location, info): self.assertTrue(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") with open(file_location, 'rb') as f: self.assertTrue(f.read(), "reading from the file location returned" " by urlretrieve failed") def test_specified_path(self): # Make sure that specifying the location of the file to write to works. with self.urlretrieve(self.logo, support.TESTFN) as (file_location, info): self.assertEqual(file_location, support.TESTFN) self.assertTrue(os.path.exists(file_location)) with open(file_location, 'rb') as f: self.assertTrue(f.read(), "reading from temporary file failed") def test_header(self): # Make sure header returned as 2nd value from urlretrieve is good. with self.urlretrieve(self.logo) as (file_location, info): self.assertIsInstance(info, email.message.Message, "info is not an instance of email.message.Message") logo = "http://www.pythontest.net/" def test_data_header(self): with self.urlretrieve(self.logo) as (file_location, fileheaders): datevalue = fileheaders.get('Date') dateformat = '%a, %d %b %Y %H:%M:%S GMT' try: time.strptime(datevalue, dateformat) except ValueError: self.fail('Date value not in %r format' % dateformat) def test_reporthook(self): records = [] def recording_reporthook(blocks, block_size, total_size): records.append((blocks, block_size, total_size)) with self.urlretrieve(self.logo, reporthook=recording_reporthook) as ( file_location, fileheaders): expected_size = int(fileheaders['Content-Length']) records_repr = repr(records) # For use in error messages. self.assertGreater(len(records), 1, msg="There should always be two " "calls; the first one before the transfer starts.") self.assertEqual(records[0][0], 0) self.assertGreater(records[0][1], 0, msg="block size can't be 0 in %s" % records_repr) self.assertEqual(records[0][2], expected_size) self.assertEqual(records[-1][2], expected_size) block_sizes = {block_size for _, block_size, _ in records} self.assertEqual({records[0][1]}, block_sizes, msg="block sizes in %s must be equal" % records_repr) self.assertGreaterEqual(records[-1][0]*records[0][1], expected_size, msg="number of blocks * block size must be" " >= total size in %s" % records_repr) if __name__ == "__main__": unittest.main()
9,041
219
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/relimport.py
from .test_import import *
27
2
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_exception_hierarchy.py
import builtins import os import select import socket import unittest import errno from errno import EEXIST class SubOSError(OSError): pass class SubOSErrorWithInit(OSError): def __init__(self, message, bar): self.bar = bar super().__init__(message) class SubOSErrorWithNew(OSError): def __new__(cls, message, baz): self = super().__new__(cls, message) self.baz = baz return self class SubOSErrorCombinedInitFirst(SubOSErrorWithInit, SubOSErrorWithNew): pass class SubOSErrorCombinedNewFirst(SubOSErrorWithNew, SubOSErrorWithInit): pass class SubOSErrorWithStandaloneInit(OSError): def __init__(self): pass class HierarchyTest(unittest.TestCase): def test_builtin_errors(self): self.assertEqual(OSError.__name__, 'OSError') self.assertIs(IOError, OSError) self.assertIs(EnvironmentError, OSError) def test_socket_errors(self): self.assertIs(socket.error, IOError) self.assertIs(socket.gaierror.__base__, OSError) self.assertIs(socket.herror.__base__, OSError) self.assertIs(socket.timeout.__base__, OSError) def test_select_error(self): self.assertIs(select.error, OSError) # mmap.error is tested in test_mmap _pep_map = """ +-- BlockingIOError EAGAIN, EALREADY, EWOULDBLOCK, EINPROGRESS +-- ChildProcessError ECHILD +-- ConnectionError +-- BrokenPipeError EPIPE, ESHUTDOWN +-- ConnectionAbortedError ECONNABORTED +-- ConnectionRefusedError ECONNREFUSED +-- ConnectionResetError ECONNRESET +-- FileExistsError EEXIST +-- FileNotFoundError ENOENT +-- InterruptedError EINTR +-- IsADirectoryError EISDIR +-- NotADirectoryError ENOTDIR +-- PermissionError EACCES, EPERM +-- ProcessLookupError ESRCH +-- TimeoutError ETIMEDOUT """ def _make_map(s): _map = {} for line in s.splitlines(): line = line.strip('+- ') if not line: continue excname, _, errnames = line.partition(' ') for errname in filter(None, errnames.strip().split(', ')): _map[getattr(errno, errname)] = getattr(builtins, excname) return _map _map = _make_map(_pep_map) def test_errno_mapping(self): # The OSError constructor maps errnos to subclasses # A sample test for the basic functionality e = OSError(EEXIST, "Bad file descriptor") self.assertIs(type(e), FileExistsError) # Exhaustive testing for errcode, exc in self._map.items(): e = OSError(errcode, "Some message") self.assertIs(type(e), exc) othercodes = set(errno.errorcode) - set(self._map) for errcode in othercodes: e = OSError(errcode, "Some message") self.assertIs(type(e), OSError) def test_try_except(self): filename = "some_hopefully_non_existing_file" # This checks that try .. except checks the concrete exception # (FileNotFoundError) and not the base type specified when # PyErr_SetFromErrnoWithFilenameObject was called. # (it is therefore deliberate that it doesn't use assertRaises) try: open(filename) except FileNotFoundError: pass else: self.fail("should have raised a FileNotFoundError") # Another test for PyErr_SetExcFromWindowsErrWithFilenameObject() self.assertFalse(os.path.exists(filename)) try: os.unlink(filename) except FileNotFoundError: pass else: self.fail("should have raised a FileNotFoundError") class AttributesTest(unittest.TestCase): def test_windows_error(self): if os.name == "nt": self.assertIn('winerror', dir(OSError)) else: self.assertNotIn('winerror', dir(OSError)) def test_posix_error(self): e = OSError(EEXIST, "File already exists", "foo.txt") self.assertEqual(e.errno, EEXIST) self.assertEqual(e.args[0], EEXIST) self.assertEqual(e.strerror, "File already exists") self.assertEqual(e.filename, "foo.txt") if os.name == "nt": self.assertEqual(e.winerror, None) @unittest.skipUnless(os.name == "nt", "Windows-specific test") def test_errno_translation(self): # ERROR_ALREADY_EXISTS (183) -> EEXIST e = OSError(0, "File already exists", "foo.txt", 183) self.assertEqual(e.winerror, 183) self.assertEqual(e.errno, EEXIST) self.assertEqual(e.args[0], EEXIST) self.assertEqual(e.strerror, "File already exists") self.assertEqual(e.filename, "foo.txt") def test_blockingioerror(self): args = ("a", "b", "c", "d", "e") for n in range(6): e = BlockingIOError(*args[:n]) with self.assertRaises(AttributeError): e.characters_written e = BlockingIOError("a", "b", 3) self.assertEqual(e.characters_written, 3) e.characters_written = 5 self.assertEqual(e.characters_written, 5) class ExplicitSubclassingTest(unittest.TestCase): def test_errno_mapping(self): # When constructing an OSError subclass, errno mapping isn't done e = SubOSError(EEXIST, "Bad file descriptor") self.assertIs(type(e), SubOSError) def test_init_overridden(self): e = SubOSErrorWithInit("some message", "baz") self.assertEqual(e.bar, "baz") self.assertEqual(e.args, ("some message",)) def test_init_kwdargs(self): e = SubOSErrorWithInit("some message", bar="baz") self.assertEqual(e.bar, "baz") self.assertEqual(e.args, ("some message",)) def test_new_overridden(self): e = SubOSErrorWithNew("some message", "baz") self.assertEqual(e.baz, "baz") self.assertEqual(e.args, ("some message",)) def test_new_kwdargs(self): e = SubOSErrorWithNew("some message", baz="baz") self.assertEqual(e.baz, "baz") self.assertEqual(e.args, ("some message",)) def test_init_new_overridden(self): e = SubOSErrorCombinedInitFirst("some message", "baz") self.assertEqual(e.bar, "baz") self.assertEqual(e.baz, "baz") self.assertEqual(e.args, ("some message",)) e = SubOSErrorCombinedNewFirst("some message", "baz") self.assertEqual(e.bar, "baz") self.assertEqual(e.baz, "baz") self.assertEqual(e.args, ("some message",)) def test_init_standalone(self): # __init__ doesn't propagate to OSError.__init__ (see issue #15229) e = SubOSErrorWithStandaloneInit() self.assertEqual(e.args, ()) self.assertEqual(str(e), '') if __name__ == "__main__": unittest.main()
7,403
205
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_multiprocessing_main_handling.py
# tests __main__ module handling in multiprocessing from test import support # Skip tests if _thread or _multiprocessing wasn't built. support.import_module('_thread') support.import_module('_multiprocessing') import importlib import importlib.machinery import unittest import sys import os import os.path import py_compile from test.support.script_helper import ( make_pkg, make_script, make_zip_pkg, make_zip_script, assert_python_ok) if support.PGO: raise unittest.SkipTest("test is not helpful for PGO") # Look up which start methods are available to test import multiprocessing AVAILABLE_START_METHODS = set(multiprocessing.get_all_start_methods()) # Issue #22332: Skip tests if sem_open implementation is broken. support.import_module('multiprocessing.synchronize') verbose = support.verbose test_source = """\ # multiprocessing includes all sorts of shenanigans to make __main__ # attributes accessible in the subprocess in a pickle compatible way. # We run the "doesn't work in the interactive interpreter" example from # the docs to make sure it *does* work from an executed __main__, # regardless of the invocation mechanism import sys import time from multiprocessing import Pool, set_start_method # We use this __main__ defined function in the map call below in order to # check that multiprocessing in correctly running the unguarded # code in child processes and then making it available as __main__ def f(x): return x*x # Check explicit relative imports if "check_sibling" in __file__: # We're inside a package and not in a __main__.py file # so make sure explicit relative imports work correctly from . import sibling if __name__ == '__main__': start_method = sys.argv[1] set_start_method(start_method) p = Pool(5) results = [] p.map_async(f, [1, 2, 3], callback=results.extend) start_time = time.monotonic() while not results: time.sleep(0.05) # up to 1 min to report the results dt = time.monotonic() - start_time if dt > 60.0: raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt) results.sort() print(start_method, "->", results) """ test_source_main_skipped_in_children = """\ # __main__.py files have an implied "if __name__ == '__main__'" so # multiprocessing should always skip running them in child processes # This means we can't use __main__ defined functions in child processes, # so we just use "int" as a passthrough operation below if __name__ != "__main__": raise RuntimeError("Should only be called as __main__!") import sys import time from multiprocessing import Pool, set_start_method start_method = sys.argv[1] set_start_method(start_method) p = Pool(5) results = [] p.map_async(int, [1, 4, 9], callback=results.extend) start_time = time.monotonic() while not results: time.sleep(0.05) # up to 1 min to report the results dt = time.monotonic() - start_time if dt > 60.0: raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt) results.sort() print(start_method, "->", results) """ # These helpers were copied from test_cmd_line_script & tweaked a bit... def _make_test_script(script_dir, script_basename, source=test_source, omit_suffix=False): to_return = make_script(script_dir, script_basename, source, omit_suffix) # Hack to check explicit relative imports if script_basename == "check_sibling": make_script(script_dir, "sibling", "") importlib.invalidate_caches() return to_return def _make_test_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, source=test_source, depth=1): to_return = make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, source, depth) importlib.invalidate_caches() return to_return # There's no easy way to pass the script directory in to get # -m to work (avoiding that is the whole point of making # directories and zipfiles executable!) # So we fake it for testing purposes with a custom launch script launch_source = """\ import sys, os.path, runpy sys.path.insert(0, %s) runpy._run_module_as_main(%r) """ def _make_launch_script(script_dir, script_basename, module_name, path=None): if path is None: path = "os.path.dirname(__file__)" else: path = repr(path) source = launch_source % (path, module_name) to_return = make_script(script_dir, script_basename, source) importlib.invalidate_caches() return to_return class MultiProcessingCmdLineMixin(): maxDiff = None # Show full tracebacks on subprocess failure def setUp(self): if self.start_method not in AVAILABLE_START_METHODS: self.skipTest("%r start method not available" % self.start_method) def _check_output(self, script_name, exit_code, out, err): if verbose > 1: print("Output from test script %r:" % script_name) print(repr(out)) self.assertEqual(exit_code, 0) self.assertEqual(err.decode('utf-8'), '') expected_results = "%s -> [1, 4, 9]" % self.start_method self.assertEqual(out.decode('utf-8').strip(), expected_results) def _check_script(self, script_name, *cmd_line_switches): if not __debug__: cmd_line_switches += ('-' + 'O' * sys.flags.optimize,) run_args = cmd_line_switches + (script_name, self.start_method) rc, out, err = assert_python_ok(*run_args, __isolated=False) self._check_output(script_name, rc, out, err) def test_basic_script(self): with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script') self._check_script(script_name) def test_basic_script_no_suffix(self): with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script', omit_suffix=True) self._check_script(script_name) def test_ipython_workaround(self): # Some versions of the IPython launch script are missing the # __name__ = "__main__" guard, and multiprocessing has long had # a workaround for that case # See https://github.com/ipython/ipython/issues/4698 source = test_source_main_skipped_in_children with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'ipython', source=source) self._check_script(script_name) script_no_suffix = _make_test_script(script_dir, 'ipython', source=source, omit_suffix=True) self._check_script(script_no_suffix) def test_script_compiled(self): with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script') py_compile.compile(script_name, doraise=True) os.remove(script_name) pyc_file = support.make_legacy_pyc(script_name) self._check_script(pyc_file) def test_directory(self): source = self.main_in_children_source with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__', source=source) self._check_script(script_dir) def test_directory_compiled(self): source = self.main_in_children_source with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__', source=source) py_compile.compile(script_name, doraise=True) os.remove(script_name) pyc_file = support.make_legacy_pyc(script_name) self._check_script(script_dir) def test_zipfile(self): source = self.main_in_children_source with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__', source=source) zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name) self._check_script(zip_name) def test_zipfile_compiled(self): source = self.main_in_children_source with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__', source=source) compiled_name = py_compile.compile(script_name, doraise=True) zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name) self._check_script(zip_name) def test_module_in_package(self): with support.temp_dir() as script_dir: pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir) script_name = _make_test_script(pkg_dir, 'check_sibling') launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.check_sibling') self._check_script(launch_name) def test_module_in_package_in_zipfile(self): with support.temp_dir() as script_dir: zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script') launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script', zip_name) self._check_script(launch_name) def test_module_in_subpackage_in_zipfile(self): with support.temp_dir() as script_dir: zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2) launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.test_pkg.script', zip_name) self._check_script(launch_name) def test_package(self): source = self.main_in_children_source with support.temp_dir() as script_dir: pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir) script_name = _make_test_script(pkg_dir, '__main__', source=source) launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg') self._check_script(launch_name) def test_package_compiled(self): source = self.main_in_children_source with support.temp_dir() as script_dir: pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir) script_name = _make_test_script(pkg_dir, '__main__', source=source) compiled_name = py_compile.compile(script_name, doraise=True) os.remove(script_name) pyc_file = support.make_legacy_pyc(script_name) launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg') self._check_script(launch_name) # Test all supported start methods (setupClass skips as appropriate) class SpawnCmdLineTest(MultiProcessingCmdLineMixin, unittest.TestCase): start_method = 'spawn' main_in_children_source = test_source_main_skipped_in_children class ForkCmdLineTest(MultiProcessingCmdLineMixin, unittest.TestCase): start_method = 'fork' main_in_children_source = test_source class ForkServerCmdLineTest(MultiProcessingCmdLineMixin, unittest.TestCase): start_method = 'forkserver' main_in_children_source = test_source_main_skipped_in_children def tearDownModule(): support.reap_children() if __name__ == '__main__': unittest.main()
11,643
295
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_parser.py
import copy import parser import pickle import unittest import operator import struct from test import support from test.support.script_helper import assert_python_failure # # First, we test that we can generate trees from valid source fragments, # and that these valid trees are indeed allowed by the tree-loading side # of the parser module. # class RoundtripLegalSyntaxTestCase(unittest.TestCase): def roundtrip(self, f, s): st1 = f(s) t = st1.totuple() try: st2 = parser.sequence2st(t) except parser.ParserError as why: self.fail("could not roundtrip %r: %s" % (s, why)) self.assertEqual(t, st2.totuple(), "could not re-generate syntax tree") def check_expr(self, s): self.roundtrip(parser.expr, s) def test_flags_passed(self): # The unicode literals flags has to be passed from the parser to AST # generation. suite = parser.suite("from __future__ import unicode_literals; x = ''") code = suite.compile() scope = {} exec(code, {}, scope) self.assertIsInstance(scope["x"], str) def check_suite(self, s): self.roundtrip(parser.suite, s) def test_yield_statement(self): self.check_suite("def f(): yield 1") self.check_suite("def f(): yield") self.check_suite("def f(): x += yield") self.check_suite("def f(): x = yield 1") self.check_suite("def f(): x = y = yield 1") self.check_suite("def f(): x = yield") self.check_suite("def f(): x = y = yield") self.check_suite("def f(): 1 + (yield)*2") self.check_suite("def f(): (yield 1)*2") self.check_suite("def f(): return; yield 1") self.check_suite("def f(): yield 1; return") self.check_suite("def f(): yield from 1") self.check_suite("def f(): x = yield from 1") self.check_suite("def f(): f((yield from 1))") self.check_suite("def f(): yield 1; return 1") self.check_suite("def f():\n" " for x in range(30):\n" " yield x\n") self.check_suite("def f():\n" " if (yield):\n" " yield x\n") def test_await_statement(self): self.check_suite("async def f():\n await smth()") self.check_suite("async def f():\n foo = await smth()") self.check_suite("async def f():\n foo, bar = await smth()") self.check_suite("async def f():\n (await smth())") self.check_suite("async def f():\n foo((await smth()))") self.check_suite("async def f():\n await foo(); return 42") def test_async_with_statement(self): self.check_suite("async def f():\n async with 1: pass") self.check_suite("async def f():\n async with a as b, c as d: pass") def test_async_for_statement(self): self.check_suite("async def f():\n async for i in (): pass") self.check_suite("async def f():\n async for i, b in (): pass") def test_nonlocal_statement(self): self.check_suite("def f():\n" " x = 0\n" " def g():\n" " nonlocal x\n") self.check_suite("def f():\n" " x = y = 0\n" " def g():\n" " nonlocal x, y\n") def test_expressions(self): self.check_expr("foo(1)") self.check_expr("[1, 2, 3]") self.check_expr("[x**3 for x in range(20)]") self.check_expr("[x**3 for x in range(20) if x % 3]") self.check_expr("[x**3 for x in range(20) if x % 2 if x % 3]") self.check_expr("list(x**3 for x in range(20))") self.check_expr("list(x**3 for x in range(20) if x % 3)") self.check_expr("list(x**3 for x in range(20) if x % 2 if x % 3)") self.check_expr("foo(*args)") self.check_expr("foo(*args, **kw)") self.check_expr("foo(**kw)") self.check_expr("foo(key=value)") self.check_expr("foo(key=value, *args)") self.check_expr("foo(key=value, *args, **kw)") self.check_expr("foo(key=value, **kw)") self.check_expr("foo(a, b, c, *args)") self.check_expr("foo(a, b, c, *args, **kw)") self.check_expr("foo(a, b, c, **kw)") self.check_expr("foo(a, *args, keyword=23)") self.check_expr("foo + bar") self.check_expr("foo - bar") self.check_expr("foo * bar") self.check_expr("foo / bar") self.check_expr("foo // bar") self.check_expr("lambda: 0") self.check_expr("lambda x: 0") self.check_expr("lambda *y: 0") self.check_expr("lambda *y, **z: 0") self.check_expr("lambda **z: 0") self.check_expr("lambda x, y: 0") self.check_expr("lambda foo=bar: 0") self.check_expr("lambda foo=bar, spaz=nifty+spit: 0") self.check_expr("lambda foo=bar, **z: 0") self.check_expr("lambda foo=bar, blaz=blat+2, **z: 0") self.check_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0") self.check_expr("lambda x, *y, **z: 0") self.check_expr("(x for x in range(10))") self.check_expr("foo(x for x in range(10))") self.check_expr("...") self.check_expr("a[...]") def test_simple_expression(self): # expr_stmt self.check_suite("a") def test_simple_assignments(self): self.check_suite("a = b") self.check_suite("a = b = c = d = e") def test_var_annot(self): self.check_suite("x: int = 5") self.check_suite("y: List[T] = []; z: [list] = fun()") self.check_suite("x: tuple = (1, 2)") self.check_suite("d[f()]: int = 42") self.check_suite("f(d[x]): str = 'abc'") self.check_suite("x.y.z.w: complex = 42j") self.check_suite("x: int") self.check_suite("def f():\n" " x: str\n" " y: int = 5\n") self.check_suite("class C:\n" " x: str\n" " y: int = 5\n") self.check_suite("class C:\n" " def __init__(self, x: int) -> None:\n" " self.x: int = x\n") # double check for nonsense with self.assertRaises(SyntaxError): exec("2+2: int", {}, {}) with self.assertRaises(SyntaxError): exec("[]: int = 5", {}, {}) with self.assertRaises(SyntaxError): exec("x, *y, z: int = range(5)", {}, {}) with self.assertRaises(SyntaxError): exec("t: tuple = 1, 2", {}, {}) with self.assertRaises(SyntaxError): exec("u = v: int", {}, {}) with self.assertRaises(SyntaxError): exec("False: int", {}, {}) with self.assertRaises(SyntaxError): exec("x.False: int", {}, {}) with self.assertRaises(SyntaxError): exec("x.y,: int", {}, {}) with self.assertRaises(SyntaxError): exec("[0]: int", {}, {}) with self.assertRaises(SyntaxError): exec("f(): int", {}, {}) def test_simple_augmented_assignments(self): self.check_suite("a += b") self.check_suite("a -= b") self.check_suite("a *= b") self.check_suite("a /= b") self.check_suite("a //= b") self.check_suite("a %= b") self.check_suite("a &= b") self.check_suite("a |= b") self.check_suite("a ^= b") self.check_suite("a <<= b") self.check_suite("a >>= b") self.check_suite("a **= b") def test_function_defs(self): self.check_suite("def f(): pass") self.check_suite("def f(*args): pass") self.check_suite("def f(*args, **kw): pass") self.check_suite("def f(**kw): pass") self.check_suite("def f(foo=bar): pass") self.check_suite("def f(foo=bar, *args): pass") self.check_suite("def f(foo=bar, *args, **kw): pass") self.check_suite("def f(foo=bar, **kw): pass") self.check_suite("def f(a, b): pass") self.check_suite("def f(a, b, *args): pass") self.check_suite("def f(a, b, *args, **kw): pass") self.check_suite("def f(a, b, **kw): pass") self.check_suite("def f(a, b, foo=bar): pass") self.check_suite("def f(a, b, foo=bar, *args): pass") self.check_suite("def f(a, b, foo=bar, *args, **kw): pass") self.check_suite("def f(a, b, foo=bar, **kw): pass") self.check_suite("@staticmethod\n" "def f(): pass") self.check_suite("@staticmethod\n" "@funcattrs(x, y)\n" "def f(): pass") self.check_suite("@funcattrs()\n" "def f(): pass") # keyword-only arguments self.check_suite("def f(*, a): pass") self.check_suite("def f(*, a = 5): pass") self.check_suite("def f(*, a = 5, b): pass") self.check_suite("def f(*, a, b = 5): pass") self.check_suite("def f(*, a, b = 5, **kwds): pass") self.check_suite("def f(*args, a): pass") self.check_suite("def f(*args, a = 5): pass") self.check_suite("def f(*args, a = 5, b): pass") self.check_suite("def f(*args, a, b = 5): pass") self.check_suite("def f(*args, a, b = 5, **kwds): pass") # function annotations self.check_suite("def f(a: int): pass") self.check_suite("def f(a: int = 5): pass") self.check_suite("def f(*args: list): pass") self.check_suite("def f(**kwds: dict): pass") self.check_suite("def f(*, a: int): pass") self.check_suite("def f(*, a: int = 5): pass") self.check_suite("def f() -> int: pass") def test_class_defs(self): self.check_suite("class foo():pass") self.check_suite("class foo(object):pass") self.check_suite("@class_decorator\n" "class foo():pass") self.check_suite("@class_decorator(arg)\n" "class foo():pass") self.check_suite("@decorator1\n" "@decorator2\n" "class foo():pass") def test_import_from_statement(self): self.check_suite("from sys.path import *") self.check_suite("from sys.path import dirname") self.check_suite("from sys.path import (dirname)") self.check_suite("from sys.path import (dirname,)") self.check_suite("from sys.path import dirname as my_dirname") self.check_suite("from sys.path import (dirname as my_dirname)") self.check_suite("from sys.path import (dirname as my_dirname,)") self.check_suite("from sys.path import dirname, basename") self.check_suite("from sys.path import (dirname, basename)") self.check_suite("from sys.path import (dirname, basename,)") self.check_suite( "from sys.path import dirname as my_dirname, basename") self.check_suite( "from sys.path import (dirname as my_dirname, basename)") self.check_suite( "from sys.path import (dirname as my_dirname, basename,)") self.check_suite( "from sys.path import dirname, basename as my_basename") self.check_suite( "from sys.path import (dirname, basename as my_basename)") self.check_suite( "from sys.path import (dirname, basename as my_basename,)") self.check_suite("from .bogus import x") def test_basic_import_statement(self): self.check_suite("import sys") self.check_suite("import sys as system") self.check_suite("import sys, math") self.check_suite("import sys as system, math") self.check_suite("import sys, math as my_math") def test_relative_imports(self): self.check_suite("from . import name") self.check_suite("from .. import name") # check all the way up to '....', since '...' is tokenized # differently from '.' (it's an ellipsis token). self.check_suite("from ... import name") self.check_suite("from .... import name") self.check_suite("from .pkg import name") self.check_suite("from ..pkg import name") self.check_suite("from ...pkg import name") self.check_suite("from ....pkg import name") def test_pep263(self): self.check_suite("# -*- coding: iso-8859-1 -*-\n" "pass\n") def test_assert(self): self.check_suite("assert alo < ahi and blo < bhi\n") def test_with(self): self.check_suite("with open('x'): pass\n") self.check_suite("with open('x') as f: pass\n") self.check_suite("with open('x') as f, open('y') as g: pass\n") def test_try_stmt(self): self.check_suite("try: pass\nexcept: pass\n") self.check_suite("try: pass\nfinally: pass\n") self.check_suite("try: pass\nexcept A: pass\nfinally: pass\n") self.check_suite("try: pass\nexcept A: pass\nexcept: pass\n" "finally: pass\n") self.check_suite("try: pass\nexcept: pass\nelse: pass\n") self.check_suite("try: pass\nexcept: pass\nelse: pass\n" "finally: pass\n") def test_position(self): # An absolutely minimal test of position information. Better # tests would be a big project. code = "def f(x):\n return x + 1" st = parser.suite(code) def walk(tree): node_type = tree[0] next = tree[1] if isinstance(next, (tuple, list)): for elt in tree[1:]: for x in walk(elt): yield x else: yield tree expected = [ (1, 'def', 1, 0), (1, 'f', 1, 4), (7, '(', 1, 5), (1, 'x', 1, 6), (8, ')', 1, 7), (11, ':', 1, 8), (4, '', 1, 9), (5, '', 2, -1), (1, 'return', 2, 4), (1, 'x', 2, 11), (14, '+', 2, 13), (2, '1', 2, 15), (4, '', 2, 16), (6, '', 2, -1), (4, '', 2, -1), (0, '', 2, -1), ] self.assertEqual(list(walk(st.totuple(line_info=True, col_info=True))), expected) self.assertEqual(list(walk(st.totuple())), [(t, n) for t, n, l, c in expected]) self.assertEqual(list(walk(st.totuple(line_info=True))), [(t, n, l) for t, n, l, c in expected]) self.assertEqual(list(walk(st.totuple(col_info=True))), [(t, n, c) for t, n, l, c in expected]) self.assertEqual(list(walk(st.tolist(line_info=True, col_info=True))), [list(x) for x in expected]) self.assertEqual(list(walk(parser.st2tuple(st, line_info=True, col_info=True))), expected) self.assertEqual(list(walk(parser.st2list(st, line_info=True, col_info=True))), [list(x) for x in expected]) def test_extended_unpacking(self): self.check_suite("*a = y") self.check_suite("x, *b, = m") self.check_suite("[*a, *b] = y") self.check_suite("for [*x, b] in x: pass") def test_raise_statement(self): self.check_suite("raise\n") self.check_suite("raise e\n") self.check_suite("try:\n" " suite\n" "except Exception as e:\n" " raise ValueError from e\n") def test_list_displays(self): self.check_expr('[]') self.check_expr('[*{2}, 3, *[4]]') def test_set_displays(self): self.check_expr('{*{2}, 3, *[4]}') self.check_expr('{2}') self.check_expr('{2,}') self.check_expr('{2, 3}') self.check_expr('{2, 3,}') def test_dict_displays(self): self.check_expr('{}') self.check_expr('{a:b}') self.check_expr('{a:b,}') self.check_expr('{a:b, c:d}') self.check_expr('{a:b, c:d,}') self.check_expr('{**{}}') self.check_expr('{**{}, 3:4, **{5:6, 7:8}}') def test_argument_unpacking(self): self.check_expr("f(*a, **b)") self.check_expr('f(a, *b, *c, *d)') self.check_expr('f(**a, **b)') self.check_expr('f(2, *a, *b, **b, **c, **d)') self.check_expr("f(*b, *() or () and (), **{} and {}, **() or {})") def test_set_comprehensions(self): self.check_expr('{x for x in seq}') self.check_expr('{f(x) for x in seq}') self.check_expr('{f(x) for x in seq if condition(x)}') def test_dict_comprehensions(self): self.check_expr('{x:x for x in seq}') self.check_expr('{x**2:x[3] for x in seq if condition(x)}') self.check_expr('{x:x for x in seq1 for y in seq2 if condition(x, y)}') # # Second, we take *invalid* trees and make sure we get ParserError # rejections for them. # class IllegalSyntaxTestCase(unittest.TestCase): def check_bad_tree(self, tree, label): try: parser.sequence2st(tree) except parser.ParserError: pass else: self.fail("did not detect invalid tree for %r" % label) def test_junk(self): # not even remotely valid: self.check_bad_tree((1, 2, 3), "<junk>") def test_illegal_terminal(self): tree = \ (257, (269, (270, (271, (277, (1,))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "too small items in terminal node") tree = \ (257, (269, (270, (271, (277, (1, b'pass'))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "non-string second item in terminal node") tree = \ (257, (269, (270, (271, (277, (1, 'pass', '0', 0))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "non-integer third item in terminal node") tree = \ (257, (269, (270, (271, (277, (1, 'pass', 0, 0))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "too many items in terminal node") def test_illegal_yield_1(self): # Illegal yield statement: def f(): return 1; yield 1 tree = \ (257, (264, (285, (259, (1, 'def'), (1, 'f'), (260, (7, '('), (8, ')')), (11, ':'), (291, (4, ''), (5, ''), (264, (265, (266, (272, (275, (1, 'return'), (313, (292, (293, (294, (295, (297, (298, (299, (300, (301, (302, (303, (304, (305, (2, '1')))))))))))))))))), (264, (265, (266, (272, (276, (1, 'yield'), (313, (292, (293, (294, (295, (297, (298, (299, (300, (301, (302, (303, (304, (305, (2, '1')))))))))))))))))), (4, ''))), (6, ''))))), (4, ''), (0, '')))) self.check_bad_tree(tree, "def f():\n return 1\n yield 1") def test_illegal_yield_2(self): # Illegal return in generator: def f(): return 1; yield 1 tree = \ (257, (264, (265, (266, (278, (1, 'from'), (281, (1, '__future__')), (1, 'import'), (279, (1, 'generators')))), (4, ''))), (264, (285, (259, (1, 'def'), (1, 'f'), (260, (7, '('), (8, ')')), (11, ':'), (291, (4, ''), (5, ''), (264, (265, (266, (272, (275, (1, 'return'), (313, (292, (293, (294, (295, (297, (298, (299, (300, (301, (302, (303, (304, (305, (2, '1')))))))))))))))))), (264, (265, (266, (272, (276, (1, 'yield'), (313, (292, (293, (294, (295, (297, (298, (299, (300, (301, (302, (303, (304, (305, (2, '1')))))))))))))))))), (4, ''))), (6, ''))))), (4, ''), (0, '')))) self.check_bad_tree(tree, "def f():\n return 1\n yield 1") def test_a_comma_comma_c(self): # Illegal input: a,,c tree = \ (258, (311, (290, (291, (292, (293, (295, (296, (297, (298, (299, (300, (301, (302, (303, (1, 'a')))))))))))))), (12, ','), (12, ','), (290, (291, (292, (293, (295, (296, (297, (298, (299, (300, (301, (302, (303, (1, 'c'))))))))))))))), (4, ''), (0, '')) self.check_bad_tree(tree, "a,,c") def test_illegal_operator(self): # Illegal input: a $= b tree = \ (257, (264, (265, (266, (267, (312, (291, (292, (293, (294, (296, (297, (298, (299, (300, (301, (302, (303, (304, (1, 'a'))))))))))))))), (268, (37, '$=')), (312, (291, (292, (293, (294, (296, (297, (298, (299, (300, (301, (302, (303, (304, (1, 'b'))))))))))))))))), (4, ''))), (0, '')) self.check_bad_tree(tree, "a $= b") def test_malformed_global(self): #doesn't have global keyword in ast tree = (257, (264, (265, (266, (282, (1, 'foo'))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "malformed global ast") def test_missing_import_source(self): # from import fred tree = \ (257, (268, (269, (270, (282, (284, (1, 'from'), (1, 'import'), (287, (285, (1, 'fred')))))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "from import fred") def test_illegal_encoding(self): # Illegal encoding declaration tree = \ (339, (257, (0, ''))) self.check_bad_tree(tree, "missed encoding") tree = \ (339, (257, (0, '')), b'iso-8859-1') self.check_bad_tree(tree, "non-string encoding") tree = \ (339, (257, (0, '')), '\udcff') with self.assertRaises(UnicodeEncodeError): parser.sequence2st(tree) class CompileTestCase(unittest.TestCase): # These tests are very minimal. :-( def test_compile_expr(self): st = parser.expr('2 + 3') code = parser.compilest(st) self.assertEqual(eval(code), 5) def test_compile_suite(self): st = parser.suite('x = 2; y = x + 3') code = parser.compilest(st) globs = {} exec(code, globs) self.assertEqual(globs['y'], 5) def test_compile_error(self): st = parser.suite('1 = 3 + 4') self.assertRaises(SyntaxError, parser.compilest, st) def test_compile_badunicode(self): st = parser.suite('a = "\\U12345678"') self.assertRaises(SyntaxError, parser.compilest, st) st = parser.suite('a = "\\u1"') self.assertRaises(SyntaxError, parser.compilest, st) def test_issue_9011(self): # Issue 9011: compilation of an unary minus expression changed # the meaning of the ST, so that a second compilation produced # incorrect results. st = parser.expr('-3') code1 = parser.compilest(st) self.assertEqual(eval(code1), -3) code2 = parser.compilest(st) self.assertEqual(eval(code2), -3) def test_compile_filename(self): st = parser.expr('a + 5') code = parser.compilest(st) self.assertEqual(code.co_filename, '<syntax-tree>') code = st.compile() self.assertEqual(code.co_filename, '<syntax-tree>') for filename in 'file.py', b'file.py': code = parser.compilest(st, filename) self.assertEqual(code.co_filename, 'file.py') code = st.compile(filename) self.assertEqual(code.co_filename, 'file.py') for filename in bytearray(b'file.py'), memoryview(b'file.py'): with self.assertWarns(DeprecationWarning): code = parser.compilest(st, filename) self.assertEqual(code.co_filename, 'file.py') with self.assertWarns(DeprecationWarning): code = st.compile(filename) self.assertEqual(code.co_filename, 'file.py') self.assertRaises(TypeError, parser.compilest, st, list(b'file.py')) self.assertRaises(TypeError, st.compile, list(b'file.py')) class ParserStackLimitTestCase(unittest.TestCase): """try to push the parser to/over its limits. see http://bugs.python.org/issue1881 for a discussion """ def _nested_expression(self, level): return "["*level+"]"*level def test_deeply_nested_list(self): # XXX used to be 99 levels in 2.x e = self._nested_expression(93) st = parser.expr(e) st.compile() def test_trigger_memory_error(self): e = self._nested_expression(100) rc, out, err = assert_python_failure('-c', e) # parsing the expression will result in an error message # followed by a MemoryError (see #11963) self.assertIn(b's_push: parser stack overflow', err) self.assertIn(b'MemoryError', err) class STObjectTestCase(unittest.TestCase): """Test operations on ST objects themselves""" def test_comparisons(self): # ST objects should support order and equality comparisons st1 = parser.expr('2 + 3') st2 = parser.suite('x = 2; y = x + 3') st3 = parser.expr('list(x**3 for x in range(20))') st1_copy = parser.expr('2 + 3') st2_copy = parser.suite('x = 2; y = x + 3') st3_copy = parser.expr('list(x**3 for x in range(20))') # exercise fast path for object identity self.assertEqual(st1 == st1, True) self.assertEqual(st2 == st2, True) self.assertEqual(st3 == st3, True) # slow path equality self.assertEqual(st1, st1_copy) self.assertEqual(st2, st2_copy) self.assertEqual(st3, st3_copy) self.assertEqual(st1 == st2, False) self.assertEqual(st1 == st3, False) self.assertEqual(st2 == st3, False) self.assertEqual(st1 != st1, False) self.assertEqual(st2 != st2, False) self.assertEqual(st3 != st3, False) self.assertEqual(st1 != st1_copy, False) self.assertEqual(st2 != st2_copy, False) self.assertEqual(st3 != st3_copy, False) self.assertEqual(st2 != st1, True) self.assertEqual(st1 != st3, True) self.assertEqual(st3 != st2, True) # we don't particularly care what the ordering is; just that # it's usable and self-consistent self.assertEqual(st1 < st2, not (st2 <= st1)) self.assertEqual(st1 < st3, not (st3 <= st1)) self.assertEqual(st2 < st3, not (st3 <= st2)) self.assertEqual(st1 < st2, st2 > st1) self.assertEqual(st1 < st3, st3 > st1) self.assertEqual(st2 < st3, st3 > st2) self.assertEqual(st1 <= st2, st2 >= st1) self.assertEqual(st3 <= st1, st1 >= st3) self.assertEqual(st2 <= st3, st3 >= st2) # transitivity bottom = min(st1, st2, st3) top = max(st1, st2, st3) mid = sorted([st1, st2, st3])[1] self.assertTrue(bottom < mid) self.assertTrue(bottom < top) self.assertTrue(mid < top) self.assertTrue(bottom <= mid) self.assertTrue(bottom <= top) self.assertTrue(mid <= top) self.assertTrue(bottom <= bottom) self.assertTrue(mid <= mid) self.assertTrue(top <= top) # interaction with other types self.assertEqual(st1 == 1588.602459, False) self.assertEqual('spanish armada' != st2, True) self.assertRaises(TypeError, operator.ge, st3, None) self.assertRaises(TypeError, operator.le, False, st1) self.assertRaises(TypeError, operator.lt, st1, 1815) self.assertRaises(TypeError, operator.gt, b'waterloo', st2) def test_copy_pickle(self): sts = [ parser.expr('2 + 3'), parser.suite('x = 2; y = x + 3'), parser.expr('list(x**3 for x in range(20))') ] for st in sts: st_copy = copy.copy(st) self.assertEqual(st_copy.totuple(), st.totuple()) st_copy = copy.deepcopy(st) self.assertEqual(st_copy.totuple(), st.totuple()) for proto in range(pickle.HIGHEST_PROTOCOL+1): st_copy = pickle.loads(pickle.dumps(st, proto)) self.assertEqual(st_copy.totuple(), st.totuple()) check_sizeof = support.check_sizeof @support.cpython_only def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here class OtherParserCase(unittest.TestCase): def test_two_args_to_expr(self): # See bug #12264 with self.assertRaises(TypeError): parser.expr("a", "b") if __name__ == "__main__": unittest.main()
33,153
921
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_sunau.py
import unittest from test import audiotests from audioop import byteswap import sys import sunau class SunauTest(audiotests.AudioWriteTests, audiotests.AudioTestsWithSourceFile): module = sunau class SunauPCM8Test(SunauTest, unittest.TestCase): sndfilename = 'pluck-pcm8.au' sndfilenframes = 3307 nchannels = 2 sampwidth = 1 framerate = 11025 nframes = 48 comptype = 'NONE' compname = 'not compressed' frames = bytes.fromhex("""\ 02FF 4B00 3104 8008 CB06 4803 BF01 03FE B8FA B4F3 29EB 1AE6 \ EDE4 C6E2 0EE0 EFE0 57E2 FBE8 13EF D8F7 97FB F5FC 08FB DFFB \ 11FA 3EFB BCFC 66FF CF04 4309 C10E 5112 EE17 8216 7F14 8012 \ 490E 520D EF0F CE0F E40C 630A 080A 2B0B 510E 8B11 B60E 440A \ """) class SunauPCM16Test(SunauTest, unittest.TestCase): sndfilename = 'pluck-pcm16.au' sndfilenframes = 3307 nchannels = 2 sampwidth = 2 framerate = 11025 nframes = 48 comptype = 'NONE' compname = 'not compressed' frames = bytes.fromhex("""\ 022EFFEA 4B5C00F9 311404EF 80DB0844 CBE006B0 48AB03F3 BFE601B5 0367FE80 \ B853FA42 B4AFF351 2997EBCD 1A5AE6DC EDF9E492 C627E277 0E06E0B7 EF29E029 \ 5759E271 FB34E83F 1377EF85 D82CF727 978EFB79 F5F7FC12 0864FB9E DF30FB40 \ 1183FA30 3EEAFB59 BC78FCB4 66D5FF60 CF130415 431A097D C1BA0EC7 512312A0 \ EEE11754 82071666 7FFE1448 80001298 49990EB7 52B40DC1 EFAD0F65 CE3A0FBE \ E4B70CE6 63490A57 08CC0A1D 2BBC0B09 51480E46 8BCB113C B6F60EE9 44150A5A \ """) class SunauPCM24Test(SunauTest, unittest.TestCase): sndfilename = 'pluck-pcm24.au' sndfilenframes = 3307 nchannels = 2 sampwidth = 3 framerate = 11025 nframes = 48 comptype = 'NONE' compname = 'not compressed' frames = bytes.fromhex("""\ 022D65FFEB9D 4B5A0F00FA54 3113C304EE2B 80DCD6084303 \ CBDEC006B261 48A99803F2F8 BFE82401B07D 036BFBFE7B5D \ B85756FA3EC9 B4B055F3502B 299830EBCB62 1A5CA7E6D99A \ EDFA3EE491BD C625EBE27884 0E05A9E0B6CF EF2929E02922 \ 5758D8E27067 FB3557E83E16 1377BFEF8402 D82C5BF7272A \ 978F16FB7745 F5F865FC1013 086635FB9C4E DF30FCFB40EE \ 117FE0FA3438 3EE6B8FB5AC3 BC77A3FCB2F4 66D6DAFF5F32 \ CF13B9041275 431D69097A8C C1BB600EC74E 5120B912A2BA \ EEDF641754C0 8207001664B7 7FFFFF14453F 8000001294E6 \ 499C1B0EB3B2 52B73E0DBCA0 EFB2B20F5FD8 CE3CDB0FBE12 \ E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E \ 51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48 \ """) class SunauPCM32Test(SunauTest, unittest.TestCase): sndfilename = 'pluck-pcm32.au' sndfilenframes = 3307 nchannels = 2 sampwidth = 4 framerate = 11025 nframes = 48 comptype = 'NONE' compname = 'not compressed' frames = bytes.fromhex("""\ 022D65BCFFEB9D92 4B5A0F8000FA549C 3113C34004EE2BC0 80DCD680084303E0 \ CBDEC0C006B26140 48A9980003F2F8FC BFE8248001B07D92 036BFB60FE7B5D34 \ B8575600FA3EC920 B4B05500F3502BC0 29983000EBCB6240 1A5CA7A0E6D99A60 \ EDFA3E80E491BD40 C625EB80E27884A0 0E05A9A0E0B6CFE0 EF292940E0292280 \ 5758D800E2706700 FB3557D8E83E1640 1377BF00EF840280 D82C5B80F7272A80 \ 978F1600FB774560 F5F86510FC101364 086635A0FB9C4E20 DF30FC40FB40EE28 \ 117FE0A0FA3438B0 3EE6B840FB5AC3F0 BC77A380FCB2F454 66D6DA80FF5F32B4 \ CF13B980041275B0 431D6980097A8C00 C1BB60000EC74E00 5120B98012A2BAA0 \ EEDF64C01754C060 820700001664B780 7FFFFFFF14453F40 800000001294E6E0 \ 499C1B000EB3B270 52B73E000DBCA020 EFB2B2E00F5FD880 CE3CDB400FBE1270 \ E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00 \ 51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0 \ """) class SunauULAWTest(SunauTest, unittest.TestCase): sndfilename = 'pluck-ulaw.au' sndfilenframes = 3307 nchannels = 2 sampwidth = 2 framerate = 11025 nframes = 48 comptype = 'ULAW' compname = 'CCITT G.711 u-law' frames = bytes.fromhex("""\ 022CFFE8 497C00F4 307C04DC 8284083C CB84069C 497C03DC BE8401AC 036CFE74 \ B684FA24 B684F344 2A7CEC04 19FCE704 EE04E504 C584E204 0E3CE104 EF04DF84 \ 557CE204 FB24E804 12FCEF04 D784F744 9684FB64 F5C4FC24 083CFBA4 DF84FB24 \ 11FCFA24 3E7CFB64 BA84FCB4 657CFF5C CF84041C 417C09BC C1840EBC 517C12FC \ EF0416FC 828415FC 7D7C13FC 828412FC 497C0EBC 517C0DBC F0040F3C CD840FFC \ E5040CBC 617C0A3C 08BC0A3C 2C7C0B3C 517C0E3C 8A8410FC B6840EBC 457C0A3C \ """) if sys.byteorder != 'big': frames = byteswap(frames, 2) if __name__ == "__main__": unittest.main()
4,631
122
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_sys_setprofile.py
import gc import pprint import sys import unittest class TestGetProfile(unittest.TestCase): def setUp(self): sys.setprofile(None) def tearDown(self): sys.setprofile(None) def test_empty(self): self.assertIsNone(sys.getprofile()) def test_setget(self): def fn(*args): pass sys.setprofile(fn) self.assertIs(sys.getprofile(), fn) class HookWatcher: def __init__(self): self.frames = [] self.events = [] def callback(self, frame, event, arg): if (event == "call" or event == "return" or event == "exception"): self.add_event(event, frame) def add_event(self, event, frame=None): """Add an event to the log.""" if frame is None: frame = sys._getframe(1) try: frameno = self.frames.index(frame) except ValueError: frameno = len(self.frames) self.frames.append(frame) self.events.append((frameno, event, ident(frame))) def get_events(self): """Remove calls to add_event().""" disallowed = [ident(self.add_event.__func__), ident(ident)] self.frames = None return [item for item in self.events if item[2] not in disallowed] class ProfileSimulator(HookWatcher): def __init__(self, testcase): self.testcase = testcase self.stack = [] HookWatcher.__init__(self) def callback(self, frame, event, arg): # Callback registered with sys.setprofile()/sys.settrace() self.dispatch[event](self, frame) def trace_call(self, frame): self.add_event('call', frame) self.stack.append(frame) def trace_return(self, frame): self.add_event('return', frame) self.stack.pop() def trace_exception(self, frame): self.testcase.fail( "the profiler should never receive exception events") def trace_pass(self, frame): pass dispatch = { 'call': trace_call, 'exception': trace_exception, 'return': trace_return, 'c_call': trace_pass, 'c_return': trace_pass, 'c_exception': trace_pass, } class TestCaseBase(unittest.TestCase): def check_events(self, callable, expected): events = capture_events(callable, self.new_watcher()) if events != expected: self.fail("Expected events:\n%s\nReceived events:\n%s" % (pprint.pformat(expected), pprint.pformat(events))) class ProfileHookTestCase(TestCaseBase): def new_watcher(self): return HookWatcher() def test_simple(self): def f(p): pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_exception(self): def f(p): 1/0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_caught_exception(self): def f(p): try: 1/0 except: pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_caught_nested_exception(self): def f(p): try: 1/0 except: pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_nested_exception(self): def f(p): 1/0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), # This isn't what I expected: # (0, 'exception', protect_ident), # I expected this again: (1, 'return', f_ident), ]) def test_exception_in_except_clause(self): def f(p): 1/0 def g(p): try: f(p) except: try: f(p) except: pass f_ident = ident(f) g_ident = ident(g) self.check_events(g, [(1, 'call', g_ident), (2, 'call', f_ident), (2, 'return', f_ident), (3, 'call', f_ident), (3, 'return', f_ident), (1, 'return', g_ident), ]) def test_exception_propagation(self): def f(p): 1/0 def g(p): try: f(p) finally: p.add_event("falling through") f_ident = ident(f) g_ident = ident(g) self.check_events(g, [(1, 'call', g_ident), (2, 'call', f_ident), (2, 'return', f_ident), (1, 'falling through', g_ident), (1, 'return', g_ident), ]) def test_raise_twice(self): def f(p): try: 1/0 except: 1/0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_raise_reraise(self): def f(p): try: 1/0 except: raise f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_raise(self): def f(p): raise Exception() f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_distant_exception(self): def f(): 1/0 def g(): f() def h(): g() def i(): h() def j(p): i() f_ident = ident(f) g_ident = ident(g) h_ident = ident(h) i_ident = ident(i) j_ident = ident(j) self.check_events(j, [(1, 'call', j_ident), (2, 'call', i_ident), (3, 'call', h_ident), (4, 'call', g_ident), (5, 'call', f_ident), (5, 'return', f_ident), (4, 'return', g_ident), (3, 'return', h_ident), (2, 'return', i_ident), (1, 'return', j_ident), ]) def test_generator(self): def f(): for i in range(2): yield i def g(p): for i in f(): pass f_ident = ident(f) g_ident = ident(g) self.check_events(g, [(1, 'call', g_ident), # call the iterator twice to generate values (2, 'call', f_ident), (2, 'return', f_ident), (2, 'call', f_ident), (2, 'return', f_ident), # once more; returns end-of-iteration with # actually raising an exception (2, 'call', f_ident), (2, 'return', f_ident), (1, 'return', g_ident), ]) def test_stop_iteration(self): def f(): for i in range(2): yield i def g(p): for i in f(): pass f_ident = ident(f) g_ident = ident(g) self.check_events(g, [(1, 'call', g_ident), # call the iterator twice to generate values (2, 'call', f_ident), (2, 'return', f_ident), (2, 'call', f_ident), (2, 'return', f_ident), # once more to hit the raise: (2, 'call', f_ident), (2, 'return', f_ident), (1, 'return', g_ident), ]) class ProfileSimulatorTestCase(TestCaseBase): def new_watcher(self): return ProfileSimulator(self) def test_simple(self): def f(p): pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_basic_exception(self): def f(p): 1/0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_caught_exception(self): def f(p): try: 1/0 except: pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), ]) def test_distant_exception(self): def f(): 1/0 def g(): f() def h(): g() def i(): h() def j(p): i() f_ident = ident(f) g_ident = ident(g) h_ident = ident(h) i_ident = ident(i) j_ident = ident(j) self.check_events(j, [(1, 'call', j_ident), (2, 'call', i_ident), (3, 'call', h_ident), (4, 'call', g_ident), (5, 'call', f_ident), (5, 'return', f_ident), (4, 'return', g_ident), (3, 'return', h_ident), (2, 'return', i_ident), (1, 'return', j_ident), ]) def ident(function): if hasattr(function, "f_code"): code = function.f_code else: code = function.__code__ return code.co_firstlineno, code.co_name def protect(f, p): try: f(p) except: pass protect_ident = ident(protect) def capture_events(callable, p=None): if p is None: p = HookWatcher() # Disable the garbage collector. This prevents __del__s from showing up in # traces. old_gc = gc.isenabled() gc.disable() try: sys.setprofile(p.callback) protect(callable, p) sys.setprofile(None) finally: if old_gc: gc.enable() return p.get_events()[1:-1] def show_events(callable): import pprint pprint.pprint(capture_events(callable)) if __name__ == "__main__": unittest.main()
11,165
377
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/SHIFTJIS.TXT
# # Name: Shift-JIS to Unicode # Unicode version: 1.1 # Table version: 1.0 # Table format: Format A # Date: 2011 October 14 # # Copyright (c) 1994-2011 Unicode, Inc. All Rights reserved. # # This file is provided as-is by Unicode, Inc. (The Unicode Consortium). # No claims are made as to fitness for any particular purpose. No # warranties of any kind are expressed or implied. The recipient # agrees to determine applicability of information provided. If this # file has been provided on magnetic media by Unicode, Inc., the sole # remedy for any claim will be exchange of defective media within 90 # days of receipt. # # Unicode, Inc. hereby grants the right to freely use the information # supplied in this file in the creation of products supporting the # Unicode Standard, and to make copies of this file in any form for # internal or external distribution as long as this notice remains # attached. # # General notes: # # # This table contains one set of mappings from Shift-JIS into Unicode. # Note that these data are *possible* mappings only and may not be the # same as those used by actual products, nor may they be the best suited # for all uses. For more information on the mappings between various code # pages incorporating the repertoire of Shift-JIS and Unicode, consult the # VENDORS mapping data. # # # Format: Three tab-separated columns # Column #1 is the shift-JIS code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 the Unicode name (follows a comment sign, '#') # The official names for Unicode characters U+4E00 # to U+9FA5, inclusive, is "CJK UNIFIED IDEOGRAPH-XXXX", # where XXXX is the code point. Including all these # names in this file increases its size substantially # and needlessly. The token "<CJK>" is used for the # name of these characters. If necessary, it can be # expanded algorithmically by a parser or editor. # # The entries are ordered by their Shift-JIS codes as follows: # Single-byte characters precede double-byte characters # The single-byte and double-byte blocks are in ascending # hexadecimal order # There is an alternative order some people might be preferred, # where all the entries are in order of the top (or only) byte. # This alternate order can be generated from the one given here # by a simple sort. # # Revision History: # # [v1.0, 2011 October 14] # Updated terms of use to current wording. # Updated contact information. # No changes to the mapping data. # # [v0.9, 8 March 1994] # First release. # # Use the Unicode reporting form <http://www.unicode.org/reporting.html> # for any questions or comments or to report errors in the data. # 20 0020 21 0021 22 0022 23 0023 24 0024 25 0025 26 0026 27 0027 28 0028 29 0029 2A 002A 2B 002B 2C 002C 2D 002D 2E 002E 2F 002F 30 0030 31 0031 32 0032 33 0033 34 0034 35 0035 36 0036 37 0037 38 0038 39 0039 3A 003A 3B 003B 3C 003C 3D 003D 3E 003E 3F 003F 40 0040 41 0041 42 0042 43 0043 44 0044 45 0045 46 0046 47 0047 48 0048 49 0049 4A 004A 4B 004B 4C 004C 4D 004D 4E 004E 4F 004F 50 0050 51 0051 52 0052 53 0053 54 0054 55 0055 56 0056 57 0057 58 0058 59 0059 5A 005A 5B 005B 5C 00A5 5D 005D 5E 005E 5F 005F 60 0060 61 0061 62 0062 63 0063 64 0064 65 0065 66 0066 67 0067 68 0068 69 0069 6A 006A 6B 006B 6C 006C 6D 006D 6E 006E 6F 006F 70 0070 71 0071 72 0072 73 0073 74 0074 75 0075 76 0076 77 0077 78 0078 79 0079 7A 007A 7B 007B 7C 007C 7D 007D 7E 203E 8140 3000 8141 3001 8142 3002 8143 FF0C 8144 FF0E 8145 30FB 8146 FF1A 8147 FF1B 8148 FF1F 8149 FF01 814A 309B 814B 309C 814C 00B4 814D FF40 814E 00A8 814F FF3E 8150 FFE3 8151 FF3F 8152 30FD 8153 30FE 8154 309D 8155 309E 8156 3003 8157 4EDD 8158 3005 8159 3006 815A 3007 815B 30FC 815C 2015 815D 2010 815E FF0F 815F 005C 8160 301C 8161 2016 8162 FF5C 8163 2026 8164 2025 8165 2018 8166 2019 8167 201C 8168 201D 8169 FF08 816A FF09 816B 3014 816C 3015 816D FF3B 816E FF3D 816F FF5B 8170 FF5D 8171 3008 8172 3009 8173 300A 8174 300B 8175 300C 8176 300D 8177 300E 8178 300F 8179 3010 817A 3011 817B FF0B 817C 2212 817D 00B1 817E 00D7 8180 00F7 8181 FF1D 8182 2260 8183 FF1C 8184 FF1E 8185 2266 8186 2267 8187 221E 8188 2234 8189 2642 818A 2640 818B 00B0 818C 2032 818D 2033 818E 2103 818F FFE5 8190 FF04 8191 00A2 8192 00A3 8193 FF05 8194 FF03 8195 FF06 8196 FF0A 8197 FF20 8198 00A7 8199 2606 819A 2605 819B 25CB 819C 25CF 819D 25CE 819E 25C7 819F 25C6 81A0 25A1 81A1 25A0 81A2 25B3 81A3 25B2 81A4 25BD 81A5 25BC 81A6 203B 81A7 3012 81A8 2192 81A9 2190 81AA 2191 81AB 2193 81AC 3013 81B8 2208 81B9 220B 81BA 2286 81BB 2287 81BC 2282 81BD 2283 81BE 222A 81BF 2229 81C8 2227 81C9 2228 81CA 00AC 81CB 21D2 81CC 21D4 81CD 2200 81CE 2203 81DA 2220 81DB 22A5 81DC 2312 81DD 2202 81DE 2207 81DF 2261 81E0 2252 81E1 226A 81E2 226B 81E3 221A 81E4 223D 81E5 221D 81E6 2235 81E7 222B 81E8 222C 81F0 212B 81F1 2030 81F2 266F 81F3 266D 81F4 266A 81F5 2020 81F6 2021 81F7 00B6 81FC 25EF 824F FF10 8250 FF11 8251 FF12 8252 FF13 8253 FF14 8254 FF15 8255 FF16 8256 FF17 8257 FF18 8258 FF19 8260 FF21 8261 FF22 8262 FF23 8263 FF24 8264 FF25 8265 FF26 8266 FF27 8267 FF28 8268 FF29 8269 FF2A 826A FF2B 826B FF2C 826C FF2D 826D FF2E 826E FF2F 826F FF30 8270 FF31 8271 FF32 8272 FF33 8273 FF34 8274 FF35 8275 FF36 8276 FF37 8277 FF38 8278 FF39 8279 FF3A 8281 FF41 8282 FF42 8283 FF43 8284 FF44 8285 FF45 8286 FF46 8287 FF47 8288 FF48 8289 FF49 828A FF4A 828B FF4B 828C FF4C 828D FF4D 828E FF4E 828F FF4F 8290 FF50 8291 FF51 8292 FF52 8293 FF53 8294 FF54 8295 FF55 8296 FF56 8297 FF57 8298 FF58 8299 FF59 829A FF5A 829F 3041 82A0 3042 82A1 3043 82A2 3044 82A3 3045 82A4 3046 82A5 3047 82A6 3048 82A7 3049 82A8 304A 82A9 304B 82AA 304C 82AB 304D 82AC 304E 82AD 304F 82AE 3050 82AF 3051 82B0 3052 82B1 3053 82B2 3054 82B3 3055 82B4 3056 82B5 3057 82B6 3058 82B7 3059 82B8 305A 82B9 305B 82BA 305C 82BB 305D 82BC 305E 82BD 305F 82BE 3060 82BF 3061 82C0 3062 82C1 3063 82C2 3064 82C3 3065 82C4 3066 82C5 3067 82C6 3068 82C7 3069 82C8 306A 82C9 306B 82CA 306C 82CB 306D 82CC 306E 82CD 306F 82CE 3070 82CF 3071 82D0 3072 82D1 3073 82D2 3074 82D3 3075 82D4 3076 82D5 3077 82D6 3078 82D7 3079 82D8 307A 82D9 307B 82DA 307C 82DB 307D 82DC 307E 82DD 307F 82DE 3080 82DF 3081 82E0 3082 82E1 3083 82E2 3084 82E3 3085 82E4 3086 82E5 3087 82E6 3088 82E7 3089 82E8 308A 82E9 308B 82EA 308C 82EB 308D 82EC 308E 82ED 308F 82EE 3090 82EF 3091 82F0 3092 82F1 3093 8340 30A1 8341 30A2 8342 30A3 8343 30A4 8344 30A5 8345 30A6 8346 30A7 8347 30A8 8348 30A9 8349 30AA 834A 30AB 834B 30AC 834C 30AD 834D 30AE 834E 30AF 834F 30B0 8350 30B1 8351 30B2 8352 30B3 8353 30B4 8354 30B5 8355 30B6 8356 30B7 8357 30B8 8358 30B9 8359 30BA 835A 30BB 835B 30BC 835C 30BD 835D 30BE 835E 30BF 835F 30C0 8360 30C1 8361 30C2 8362 30C3 8363 30C4 8364 30C5 8365 30C6 8366 30C7 8367 30C8 8368 30C9 8369 30CA 836A 30CB 836B 30CC 836C 30CD 836D 30CE 836E 30CF 836F 30D0 8370 30D1 8371 30D2 8372 30D3 8373 30D4 8374 30D5 8375 30D6 8376 30D7 8377 30D8 8378 30D9 8379 30DA 837A 30DB 837B 30DC 837C 30DD 837D 30DE 837E 30DF 8380 30E0 8381 30E1 8382 30E2 8383 30E3 8384 30E4 8385 30E5 8386 30E6 8387 30E7 8388 30E8 8389 30E9 838A 30EA 838B 30EB 838C 30EC 838D 30ED 838E 30EE 838F 30EF 8390 30F0 8391 30F1 8392 30F2 8393 30F3 8394 30F4 8395 30F5 8396 30F6 839F 0391 83A0 0392 83A1 0393 83A2 0394 83A3 0395 83A4 0396 83A5 0397 83A6 0398 83A7 0399 83A8 039A 83A9 039B 83AA 039C 83AB 039D 83AC 039E 83AD 039F 83AE 03A0 83AF 03A1 83B0 03A3 83B1 03A4 83B2 03A5 83B3 03A6 83B4 03A7 83B5 03A8 83B6 03A9 83BF 03B1 83C0 03B2 83C1 03B3 83C2 03B4 83C3 03B5 83C4 03B6 83C5 03B7 83C6 03B8 83C7 03B9 83C8 03BA 83C9 03BB 83CA 03BC 83CB 03BD 83CC 03BE 83CD 03BF 83CE 03C0 83CF 03C1 83D0 03C3 83D1 03C4 83D2 03C5 83D3 03C6 83D4 03C7 83D5 03C8 83D6 03C9 8440 0410 8441 0411 8442 0412 8443 0413 8444 0414 8445 0415 8446 0401 8447 0416 8448 0417 8449 0418 844A 0419 844B 041A 844C 041B 844D 041C 844E 041D 844F 041E 8450 041F 8451 0420 8452 0421 8453 0422 8454 0423 8455 0424 8456 0425 8457 0426 8458 0427 8459 0428 845A 0429 845B 042A 845C 042B 845D 042C 845E 042D 845F 042E 8460 042F 8470 0430 8471 0431 8472 0432 8473 0433 8474 0434 8475 0435 8476 0451 8477 0436 8478 0437 8479 0438 847A 0439 847B 043A 847C 043B 847D 043C 847E 043D 8480 043E 8481 043F 8482 0440 8483 0441 8484 0442 8485 0443 8486 0444 8487 0445 8488 0446 8489 0447 848A 0448 848B 0449 848C 044A 848D 044B 848E 044C 848F 044D 8490 044E 8491 044F 849F 2500 84A0 2502 84A1 250C 84A2 2510 84A3 2518 84A4 2514 84A5 251C 84A6 252C 84A7 2524 84A8 2534 84A9 253C 84AA 2501 84AB 2503 84AC 250F 84AD 2513 84AE 251B 84AF 2517 84B0 2523 84B1 2533 84B2 252B 84B3 253B 84B4 254B 84B5 2520 84B6 252F 84B7 2528 84B8 2537 84B9 253F 84BA 251D 84BB 2530 84BC 2525 84BD 2538 84BE 2542 889F 4E9C 88A0 5516 88A1 5A03 88A2 963F 88A3 54C0 88A4 611B 88A5 6328 88A6 59F6 88A7 9022 88A8 8475 88A9 831C 88AA 7A50 88AB 60AA 88AC 63E1 88AD 6E25 88AE 65ED 88AF 8466 88B0 82A6 88B1 9BF5 88B2 6893 88B3 5727 88B4 65A1 88B5 6271 88B6 5B9B 88B7 59D0 88B8 867B 88B9 98F4 88BA 7D62 88BB 7DBE 88BC 9B8E 88BD 6216 88BE 7C9F 88BF 88B7 88C0 5B89 88C1 5EB5 88C2 6309 88C3 6697 88C4 6848 88C5 95C7 88C6 978D 88C7 674F 88C8 4EE5 88C9 4F0A 88CA 4F4D 88CB 4F9D 88CC 5049 88CD 56F2 88CE 5937 88CF 59D4 88D0 5A01 88D1 5C09 88D2 60DF 88D3 610F 88D4 6170 88D5 6613 88D6 6905 88D7 70BA 88D8 754F 88D9 7570 88DA 79FB 88DB 7DAD 88DC 7DEF 88DD 80C3 88DE 840E 88DF 8863 88E0 8B02 88E1 9055 88E2 907A 88E3 533B 88E4 4E95 88E5 4EA5 88E6 57DF 88E7 80B2 88E8 90C1 88E9 78EF 88EA 4E00 88EB 58F1 88EC 6EA2 88ED 9038 88EE 7A32 88EF 8328 88F0 828B 88F1 9C2F 88F2 5141 88F3 5370 88F4 54BD 88F5 54E1 88F6 56E0 88F7 59FB 88F8 5F15 88F9 98F2 88FA 6DEB 88FB 80E4 88FC 852D 8940 9662 8941 9670 8942 96A0 8943 97FB 8944 540B 8945 53F3 8946 5B87 8947 70CF 8948 7FBD 8949 8FC2 894A 96E8 894B 536F 894C 9D5C 894D 7ABA 894E 4E11 894F 7893 8950 81FC 8951 6E26 8952 5618 8953 5504 8954 6B1D 8955 851A 8956 9C3B 8957 59E5 8958 53A9 8959 6D66 895A 74DC 895B 958F 895C 5642 895D 4E91 895E 904B 895F 96F2 8960 834F 8961 990C 8962 53E1 8963 55B6 8964 5B30 8965 5F71 8966 6620 8967 66F3 8968 6804 8969 6C38 896A 6CF3 896B 6D29 896C 745B 896D 76C8 896E 7A4E 896F 9834 8970 82F1 8971 885B 8972 8A60 8973 92ED 8974 6DB2 8975 75AB 8976 76CA 8977 99C5 8978 60A6 8979 8B01 897A 8D8A 897B 95B2 897C 698E 897D 53AD 897E 5186 8980 5712 8981 5830 8982 5944 8983 5BB4 8984 5EF6 8985 6028 8986 63A9 8987 63F4 8988 6CBF 8989 6F14 898A 708E 898B 7114 898C 7159 898D 71D5 898E 733F 898F 7E01 8990 8276 8991 82D1 8992 8597 8993 9060 8994 925B 8995 9D1B 8996 5869 8997 65BC 8998 6C5A 8999 7525 899A 51F9 899B 592E 899C 5965 899D 5F80 899E 5FDC 899F 62BC 89A0 65FA 89A1 6A2A 89A2 6B27 89A3 6BB4 89A4 738B 89A5 7FC1 89A6 8956 89A7 9D2C 89A8 9D0E 89A9 9EC4 89AA 5CA1 89AB 6C96 89AC 837B 89AD 5104 89AE 5C4B 89AF 61B6 89B0 81C6 89B1 6876 89B2 7261 89B3 4E59 89B4 4FFA 89B5 5378 89B6 6069 89B7 6E29 89B8 7A4F 89B9 97F3 89BA 4E0B 89BB 5316 89BC 4EEE 89BD 4F55 89BE 4F3D 89BF 4FA1 89C0 4F73 89C1 52A0 89C2 53EF 89C3 5609 89C4 590F 89C5 5AC1 89C6 5BB6 89C7 5BE1 89C8 79D1 89C9 6687 89CA 679C 89CB 67B6 89CC 6B4C 89CD 6CB3 89CE 706B 89CF 73C2 89D0 798D 89D1 79BE 89D2 7A3C 89D3 7B87 89D4 82B1 89D5 82DB 89D6 8304 89D7 8377 89D8 83EF 89D9 83D3 89DA 8766 89DB 8AB2 89DC 5629 89DD 8CA8 89DE 8FE6 89DF 904E 89E0 971E 89E1 868A 89E2 4FC4 89E3 5CE8 89E4 6211 89E5 7259 89E6 753B 89E7 81E5 89E8 82BD 89E9 86FE 89EA 8CC0 89EB 96C5 89EC 9913 89ED 99D5 89EE 4ECB 89EF 4F1A 89F0 89E3 89F1 56DE 89F2 584A 89F3 58CA 89F4 5EFB 89F5 5FEB 89F6 602A 89F7 6094 89F8 6062 89F9 61D0 89FA 6212 89FB 62D0 89FC 6539 8A40 9B41 8A41 6666 8A42 68B0 8A43 6D77 8A44 7070 8A45 754C 8A46 7686 8A47 7D75 8A48 82A5 8A49 87F9 8A4A 958B 8A4B 968E 8A4C 8C9D 8A4D 51F1 8A4E 52BE 8A4F 5916 8A50 54B3 8A51 5BB3 8A52 5D16 8A53 6168 8A54 6982 8A55 6DAF 8A56 788D 8A57 84CB 8A58 8857 8A59 8A72 8A5A 93A7 8A5B 9AB8 8A5C 6D6C 8A5D 99A8 8A5E 86D9 8A5F 57A3 8A60 67FF 8A61 86CE 8A62 920E 8A63 5283 8A64 5687 8A65 5404 8A66 5ED3 8A67 62E1 8A68 64B9 8A69 683C 8A6A 6838 8A6B 6BBB 8A6C 7372 8A6D 78BA 8A6E 7A6B 8A6F 899A 8A70 89D2 8A71 8D6B 8A72 8F03 8A73 90ED 8A74 95A3 8A75 9694 8A76 9769 8A77 5B66 8A78 5CB3 8A79 697D 8A7A 984D 8A7B 984E 8A7C 639B 8A7D 7B20 8A7E 6A2B 8A80 6A7F 8A81 68B6 8A82 9C0D 8A83 6F5F 8A84 5272 8A85 559D 8A86 6070 8A87 62EC 8A88 6D3B 8A89 6E07 8A8A 6ED1 8A8B 845B 8A8C 8910 8A8D 8F44 8A8E 4E14 8A8F 9C39 8A90 53F6 8A91 691B 8A92 6A3A 8A93 9784 8A94 682A 8A95 515C 8A96 7AC3 8A97 84B2 8A98 91DC 8A99 938C 8A9A 565B 8A9B 9D28 8A9C 6822 8A9D 8305 8A9E 8431 8A9F 7CA5 8AA0 5208 8AA1 82C5 8AA2 74E6 8AA3 4E7E 8AA4 4F83 8AA5 51A0 8AA6 5BD2 8AA7 520A 8AA8 52D8 8AA9 52E7 8AAA 5DFB 8AAB 559A 8AAC 582A 8AAD 59E6 8AAE 5B8C 8AAF 5B98 8AB0 5BDB 8AB1 5E72 8AB2 5E79 8AB3 60A3 8AB4 611F 8AB5 6163 8AB6 61BE 8AB7 63DB 8AB8 6562 8AB9 67D1 8ABA 6853 8ABB 68FA 8ABC 6B3E 8ABD 6B53 8ABE 6C57 8ABF 6F22 8AC0 6F97 8AC1 6F45 8AC2 74B0 8AC3 7518 8AC4 76E3 8AC5 770B 8AC6 7AFF 8AC7 7BA1 8AC8 7C21 8AC9 7DE9 8ACA 7F36 8ACB 7FF0 8ACC 809D 8ACD 8266 8ACE 839E 8ACF 89B3 8AD0 8ACC 8AD1 8CAB 8AD2 9084 8AD3 9451 8AD4 9593 8AD5 9591 8AD6 95A2 8AD7 9665 8AD8 97D3 8AD9 9928 8ADA 8218 8ADB 4E38 8ADC 542B 8ADD 5CB8 8ADE 5DCC 8ADF 73A9 8AE0 764C 8AE1 773C 8AE2 5CA9 8AE3 7FEB 8AE4 8D0B 8AE5 96C1 8AE6 9811 8AE7 9854 8AE8 9858 8AE9 4F01 8AEA 4F0E 8AEB 5371 8AEC 559C 8AED 5668 8AEE 57FA 8AEF 5947 8AF0 5B09 8AF1 5BC4 8AF2 5C90 8AF3 5E0C 8AF4 5E7E 8AF5 5FCC 8AF6 63EE 8AF7 673A 8AF8 65D7 8AF9 65E2 8AFA 671F 8AFB 68CB 8AFC 68C4 8B40 6A5F 8B41 5E30 8B42 6BC5 8B43 6C17 8B44 6C7D 8B45 757F 8B46 7948 8B47 5B63 8B48 7A00 8B49 7D00 8B4A 5FBD 8B4B 898F 8B4C 8A18 8B4D 8CB4 8B4E 8D77 8B4F 8ECC 8B50 8F1D 8B51 98E2 8B52 9A0E 8B53 9B3C 8B54 4E80 8B55 507D 8B56 5100 8B57 5993 8B58 5B9C 8B59 622F 8B5A 6280 8B5B 64EC 8B5C 6B3A 8B5D 72A0 8B5E 7591 8B5F 7947 8B60 7FA9 8B61 87FB 8B62 8ABC 8B63 8B70 8B64 63AC 8B65 83CA 8B66 97A0 8B67 5409 8B68 5403 8B69 55AB 8B6A 6854 8B6B 6A58 8B6C 8A70 8B6D 7827 8B6E 6775 8B6F 9ECD 8B70 5374 8B71 5BA2 8B72 811A 8B73 8650 8B74 9006 8B75 4E18 8B76 4E45 8B77 4EC7 8B78 4F11 8B79 53CA 8B7A 5438 8B7B 5BAE 8B7C 5F13 8B7D 6025 8B7E 6551 8B80 673D 8B81 6C42 8B82 6C72 8B83 6CE3 8B84 7078 8B85 7403 8B86 7A76 8B87 7AAE 8B88 7B08 8B89 7D1A 8B8A 7CFE 8B8B 7D66 8B8C 65E7 8B8D 725B 8B8E 53BB 8B8F 5C45 8B90 5DE8 8B91 62D2 8B92 62E0 8B93 6319 8B94 6E20 8B95 865A 8B96 8A31 8B97 8DDD 8B98 92F8 8B99 6F01 8B9A 79A6 8B9B 9B5A 8B9C 4EA8 8B9D 4EAB 8B9E 4EAC 8B9F 4F9B 8BA0 4FA0 8BA1 50D1 8BA2 5147 8BA3 7AF6 8BA4 5171 8BA5 51F6 8BA6 5354 8BA7 5321 8BA8 537F 8BA9 53EB 8BAA 55AC 8BAB 5883 8BAC 5CE1 8BAD 5F37 8BAE 5F4A 8BAF 602F 8BB0 6050 8BB1 606D 8BB2 631F 8BB3 6559 8BB4 6A4B 8BB5 6CC1 8BB6 72C2 8BB7 72ED 8BB8 77EF 8BB9 80F8 8BBA 8105 8BBB 8208 8BBC 854E 8BBD 90F7 8BBE 93E1 8BBF 97FF 8BC0 9957 8BC1 9A5A 8BC2 4EF0 8BC3 51DD 8BC4 5C2D 8BC5 6681 8BC6 696D 8BC7 5C40 8BC8 66F2 8BC9 6975 8BCA 7389 8BCB 6850 8BCC 7C81 8BCD 50C5 8BCE 52E4 8BCF 5747 8BD0 5DFE 8BD1 9326 8BD2 65A4 8BD3 6B23 8BD4 6B3D 8BD5 7434 8BD6 7981 8BD7 79BD 8BD8 7B4B 8BD9 7DCA 8BDA 82B9 8BDB 83CC 8BDC 887F 8BDD 895F 8BDE 8B39 8BDF 8FD1 8BE0 91D1 8BE1 541F 8BE2 9280 8BE3 4E5D 8BE4 5036 8BE5 53E5 8BE6 533A 8BE7 72D7 8BE8 7396 8BE9 77E9 8BEA 82E6 8BEB 8EAF 8BEC 99C6 8BED 99C8 8BEE 99D2 8BEF 5177 8BF0 611A 8BF1 865E 8BF2 55B0 8BF3 7A7A 8BF4 5076 8BF5 5BD3 8BF6 9047 8BF7 9685 8BF8 4E32 8BF9 6ADB 8BFA 91E7 8BFB 5C51 8BFC 5C48 8C40 6398 8C41 7A9F 8C42 6C93 8C43 9774 8C44 8F61 8C45 7AAA 8C46 718A 8C47 9688 8C48 7C82 8C49 6817 8C4A 7E70 8C4B 6851 8C4C 936C 8C4D 52F2 8C4E 541B 8C4F 85AB 8C50 8A13 8C51 7FA4 8C52 8ECD 8C53 90E1 8C54 5366 8C55 8888 8C56 7941 8C57 4FC2 8C58 50BE 8C59 5211 8C5A 5144 8C5B 5553 8C5C 572D 8C5D 73EA 8C5E 578B 8C5F 5951 8C60 5F62 8C61 5F84 8C62 6075 8C63 6176 8C64 6167 8C65 61A9 8C66 63B2 8C67 643A 8C68 656C 8C69 666F 8C6A 6842 8C6B 6E13 8C6C 7566 8C6D 7A3D 8C6E 7CFB 8C6F 7D4C 8C70 7D99 8C71 7E4B 8C72 7F6B 8C73 830E 8C74 834A 8C75 86CD 8C76 8A08 8C77 8A63 8C78 8B66 8C79 8EFD 8C7A 981A 8C7B 9D8F 8C7C 82B8 8C7D 8FCE 8C7E 9BE8 8C80 5287 8C81 621F 8C82 6483 8C83 6FC0 8C84 9699 8C85 6841 8C86 5091 8C87 6B20 8C88 6C7A 8C89 6F54 8C8A 7A74 8C8B 7D50 8C8C 8840 8C8D 8A23 8C8E 6708 8C8F 4EF6 8C90 5039 8C91 5026 8C92 5065 8C93 517C 8C94 5238 8C95 5263 8C96 55A7 8C97 570F 8C98 5805 8C99 5ACC 8C9A 5EFA 8C9B 61B2 8C9C 61F8 8C9D 62F3 8C9E 6372 8C9F 691C 8CA0 6A29 8CA1 727D 8CA2 72AC 8CA3 732E 8CA4 7814 8CA5 786F 8CA6 7D79 8CA7 770C 8CA8 80A9 8CA9 898B 8CAA 8B19 8CAB 8CE2 8CAC 8ED2 8CAD 9063 8CAE 9375 8CAF 967A 8CB0 9855 8CB1 9A13 8CB2 9E78 8CB3 5143 8CB4 539F 8CB5 53B3 8CB6 5E7B 8CB7 5F26 8CB8 6E1B 8CB9 6E90 8CBA 7384 8CBB 73FE 8CBC 7D43 8CBD 8237 8CBE 8A00 8CBF 8AFA 8CC0 9650 8CC1 4E4E 8CC2 500B 8CC3 53E4 8CC4 547C 8CC5 56FA 8CC6 59D1 8CC7 5B64 8CC8 5DF1 8CC9 5EAB 8CCA 5F27 8CCB 6238 8CCC 6545 8CCD 67AF 8CCE 6E56 8CCF 72D0 8CD0 7CCA 8CD1 88B4 8CD2 80A1 8CD3 80E1 8CD4 83F0 8CD5 864E 8CD6 8A87 8CD7 8DE8 8CD8 9237 8CD9 96C7 8CDA 9867 8CDB 9F13 8CDC 4E94 8CDD 4E92 8CDE 4F0D 8CDF 5348 8CE0 5449 8CE1 543E 8CE2 5A2F 8CE3 5F8C 8CE4 5FA1 8CE5 609F 8CE6 68A7 8CE7 6A8E 8CE8 745A 8CE9 7881 8CEA 8A9E 8CEB 8AA4 8CEC 8B77 8CED 9190 8CEE 4E5E 8CEF 9BC9 8CF0 4EA4 8CF1 4F7C 8CF2 4FAF 8CF3 5019 8CF4 5016 8CF5 5149 8CF6 516C 8CF7 529F 8CF8 52B9 8CF9 52FE 8CFA 539A 8CFB 53E3 8CFC 5411 8D40 540E 8D41 5589 8D42 5751 8D43 57A2 8D44 597D 8D45 5B54 8D46 5B5D 8D47 5B8F 8D48 5DE5 8D49 5DE7 8D4A 5DF7 8D4B 5E78 8D4C 5E83 8D4D 5E9A 8D4E 5EB7 8D4F 5F18 8D50 6052 8D51 614C 8D52 6297 8D53 62D8 8D54 63A7 8D55 653B 8D56 6602 8D57 6643 8D58 66F4 8D59 676D 8D5A 6821 8D5B 6897 8D5C 69CB 8D5D 6C5F 8D5E 6D2A 8D5F 6D69 8D60 6E2F 8D61 6E9D 8D62 7532 8D63 7687 8D64 786C 8D65 7A3F 8D66 7CE0 8D67 7D05 8D68 7D18 8D69 7D5E 8D6A 7DB1 8D6B 8015 8D6C 8003 8D6D 80AF 8D6E 80B1 8D6F 8154 8D70 818F 8D71 822A 8D72 8352 8D73 884C 8D74 8861 8D75 8B1B 8D76 8CA2 8D77 8CFC 8D78 90CA 8D79 9175 8D7A 9271 8D7B 783F 8D7C 92FC 8D7D 95A4 8D7E 964D 8D80 9805 8D81 9999 8D82 9AD8 8D83 9D3B 8D84 525B 8D85 52AB 8D86 53F7 8D87 5408 8D88 58D5 8D89 62F7 8D8A 6FE0 8D8B 8C6A 8D8C 8F5F 8D8D 9EB9 8D8E 514B 8D8F 523B 8D90 544A 8D91 56FD 8D92 7A40 8D93 9177 8D94 9D60 8D95 9ED2 8D96 7344 8D97 6F09 8D98 8170 8D99 7511 8D9A 5FFD 8D9B 60DA 8D9C 9AA8 8D9D 72DB 8D9E 8FBC 8D9F 6B64 8DA0 9803 8DA1 4ECA 8DA2 56F0 8DA3 5764 8DA4 58BE 8DA5 5A5A 8DA6 6068 8DA7 61C7 8DA8 660F 8DA9 6606 8DAA 6839 8DAB 68B1 8DAC 6DF7 8DAD 75D5 8DAE 7D3A 8DAF 826E 8DB0 9B42 8DB1 4E9B 8DB2 4F50 8DB3 53C9 8DB4 5506 8DB5 5D6F 8DB6 5DE6 8DB7 5DEE 8DB8 67FB 8DB9 6C99 8DBA 7473 8DBB 7802 8DBC 8A50 8DBD 9396 8DBE 88DF 8DBF 5750 8DC0 5EA7 8DC1 632B 8DC2 50B5 8DC3 50AC 8DC4 518D 8DC5 6700 8DC6 54C9 8DC7 585E 8DC8 59BB 8DC9 5BB0 8DCA 5F69 8DCB 624D 8DCC 63A1 8DCD 683D 8DCE 6B73 8DCF 6E08 8DD0 707D 8DD1 91C7 8DD2 7280 8DD3 7815 8DD4 7826 8DD5 796D 8DD6 658E 8DD7 7D30 8DD8 83DC 8DD9 88C1 8DDA 8F09 8DDB 969B 8DDC 5264 8DDD 5728 8DDE 6750 8DDF 7F6A 8DE0 8CA1 8DE1 51B4 8DE2 5742 8DE3 962A 8DE4 583A 8DE5 698A 8DE6 80B4 8DE7 54B2 8DE8 5D0E 8DE9 57FC 8DEA 7895 8DEB 9DFA 8DEC 4F5C 8DED 524A 8DEE 548B 8DEF 643E 8DF0 6628 8DF1 6714 8DF2 67F5 8DF3 7A84 8DF4 7B56 8DF5 7D22 8DF6 932F 8DF7 685C 8DF8 9BAD 8DF9 7B39 8DFA 5319 8DFB 518A 8DFC 5237 8E40 5BDF 8E41 62F6 8E42 64AE 8E43 64E6 8E44 672D 8E45 6BBA 8E46 85A9 8E47 96D1 8E48 7690 8E49 9BD6 8E4A 634C 8E4B 9306 8E4C 9BAB 8E4D 76BF 8E4E 6652 8E4F 4E09 8E50 5098 8E51 53C2 8E52 5C71 8E53 60E8 8E54 6492 8E55 6563 8E56 685F 8E57 71E6 8E58 73CA 8E59 7523 8E5A 7B97 8E5B 7E82 8E5C 8695 8E5D 8B83 8E5E 8CDB 8E5F 9178 8E60 9910 8E61 65AC 8E62 66AB 8E63 6B8B 8E64 4ED5 8E65 4ED4 8E66 4F3A 8E67 4F7F 8E68 523A 8E69 53F8 8E6A 53F2 8E6B 55E3 8E6C 56DB 8E6D 58EB 8E6E 59CB 8E6F 59C9 8E70 59FF 8E71 5B50 8E72 5C4D 8E73 5E02 8E74 5E2B 8E75 5FD7 8E76 601D 8E77 6307 8E78 652F 8E79 5B5C 8E7A 65AF 8E7B 65BD 8E7C 65E8 8E7D 679D 8E7E 6B62 8E80 6B7B 8E81 6C0F 8E82 7345 8E83 7949 8E84 79C1 8E85 7CF8 8E86 7D19 8E87 7D2B 8E88 80A2 8E89 8102 8E8A 81F3 8E8B 8996 8E8C 8A5E 8E8D 8A69 8E8E 8A66 8E8F 8A8C 8E90 8AEE 8E91 8CC7 8E92 8CDC 8E93 96CC 8E94 98FC 8E95 6B6F 8E96 4E8B 8E97 4F3C 8E98 4F8D 8E99 5150 8E9A 5B57 8E9B 5BFA 8E9C 6148 8E9D 6301 8E9E 6642 8E9F 6B21 8EA0 6ECB 8EA1 6CBB 8EA2 723E 8EA3 74BD 8EA4 75D4 8EA5 78C1 8EA6 793A 8EA7 800C 8EA8 8033 8EA9 81EA 8EAA 8494 8EAB 8F9E 8EAC 6C50 8EAD 9E7F 8EAE 5F0F 8EAF 8B58 8EB0 9D2B 8EB1 7AFA 8EB2 8EF8 8EB3 5B8D 8EB4 96EB 8EB5 4E03 8EB6 53F1 8EB7 57F7 8EB8 5931 8EB9 5AC9 8EBA 5BA4 8EBB 6089 8EBC 6E7F 8EBD 6F06 8EBE 75BE 8EBF 8CEA 8EC0 5B9F 8EC1 8500 8EC2 7BE0 8EC3 5072 8EC4 67F4 8EC5 829D 8EC6 5C61 8EC7 854A 8EC8 7E1E 8EC9 820E 8ECA 5199 8ECB 5C04 8ECC 6368 8ECD 8D66 8ECE 659C 8ECF 716E 8ED0 793E 8ED1 7D17 8ED2 8005 8ED3 8B1D 8ED4 8ECA 8ED5 906E 8ED6 86C7 8ED7 90AA 8ED8 501F 8ED9 52FA 8EDA 5C3A 8EDB 6753 8EDC 707C 8EDD 7235 8EDE 914C 8EDF 91C8 8EE0 932B 8EE1 82E5 8EE2 5BC2 8EE3 5F31 8EE4 60F9 8EE5 4E3B 8EE6 53D6 8EE7 5B88 8EE8 624B 8EE9 6731 8EEA 6B8A 8EEB 72E9 8EEC 73E0 8EED 7A2E 8EEE 816B 8EEF 8DA3 8EF0 9152 8EF1 9996 8EF2 5112 8EF3 53D7 8EF4 546A 8EF5 5BFF 8EF6 6388 8EF7 6A39 8EF8 7DAC 8EF9 9700 8EFA 56DA 8EFB 53CE 8EFC 5468 8F40 5B97 8F41 5C31 8F42 5DDE 8F43 4FEE 8F44 6101 8F45 62FE 8F46 6D32 8F47 79C0 8F48 79CB 8F49 7D42 8F4A 7E4D 8F4B 7FD2 8F4C 81ED 8F4D 821F 8F4E 8490 8F4F 8846 8F50 8972 8F51 8B90 8F52 8E74 8F53 8F2F 8F54 9031 8F55 914B 8F56 916C 8F57 96C6 8F58 919C 8F59 4EC0 8F5A 4F4F 8F5B 5145 8F5C 5341 8F5D 5F93 8F5E 620E 8F5F 67D4 8F60 6C41 8F61 6E0B 8F62 7363 8F63 7E26 8F64 91CD 8F65 9283 8F66 53D4 8F67 5919 8F68 5BBF 8F69 6DD1 8F6A 795D 8F6B 7E2E 8F6C 7C9B 8F6D 587E 8F6E 719F 8F6F 51FA 8F70 8853 8F71 8FF0 8F72 4FCA 8F73 5CFB 8F74 6625 8F75 77AC 8F76 7AE3 8F77 821C 8F78 99FF 8F79 51C6 8F7A 5FAA 8F7B 65EC 8F7C 696F 8F7D 6B89 8F7E 6DF3 8F80 6E96 8F81 6F64 8F82 76FE 8F83 7D14 8F84 5DE1 8F85 9075 8F86 9187 8F87 9806 8F88 51E6 8F89 521D 8F8A 6240 8F8B 6691 8F8C 66D9 8F8D 6E1A 8F8E 5EB6 8F8F 7DD2 8F90 7F72 8F91 66F8 8F92 85AF 8F93 85F7 8F94 8AF8 8F95 52A9 8F96 53D9 8F97 5973 8F98 5E8F 8F99 5F90 8F9A 6055 8F9B 92E4 8F9C 9664 8F9D 50B7 8F9E 511F 8F9F 52DD 8FA0 5320 8FA1 5347 8FA2 53EC 8FA3 54E8 8FA4 5546 8FA5 5531 8FA6 5617 8FA7 5968 8FA8 59BE 8FA9 5A3C 8FAA 5BB5 8FAB 5C06 8FAC 5C0F 8FAD 5C11 8FAE 5C1A 8FAF 5E84 8FB0 5E8A 8FB1 5EE0 8FB2 5F70 8FB3 627F 8FB4 6284 8FB5 62DB 8FB6 638C 8FB7 6377 8FB8 6607 8FB9 660C 8FBA 662D 8FBB 6676 8FBC 677E 8FBD 68A2 8FBE 6A1F 8FBF 6A35 8FC0 6CBC 8FC1 6D88 8FC2 6E09 8FC3 6E58 8FC4 713C 8FC5 7126 8FC6 7167 8FC7 75C7 8FC8 7701 8FC9 785D 8FCA 7901 8FCB 7965 8FCC 79F0 8FCD 7AE0 8FCE 7B11 8FCF 7CA7 8FD0 7D39 8FD1 8096 8FD2 83D6 8FD3 848B 8FD4 8549 8FD5 885D 8FD6 88F3 8FD7 8A1F 8FD8 8A3C 8FD9 8A54 8FDA 8A73 8FDB 8C61 8FDC 8CDE 8FDD 91A4 8FDE 9266 8FDF 937E 8FE0 9418 8FE1 969C 8FE2 9798 8FE3 4E0A 8FE4 4E08 8FE5 4E1E 8FE6 4E57 8FE7 5197 8FE8 5270 8FE9 57CE 8FEA 5834 8FEB 58CC 8FEC 5B22 8FED 5E38 8FEE 60C5 8FEF 64FE 8FF0 6761 8FF1 6756 8FF2 6D44 8FF3 72B6 8FF4 7573 8FF5 7A63 8FF6 84B8 8FF7 8B72 8FF8 91B8 8FF9 9320 8FFA 5631 8FFB 57F4 8FFC 98FE 9040 62ED 9041 690D 9042 6B96 9043 71ED 9044 7E54 9045 8077 9046 8272 9047 89E6 9048 98DF 9049 8755 904A 8FB1 904B 5C3B 904C 4F38 904D 4FE1 904E 4FB5 904F 5507 9050 5A20 9051 5BDD 9052 5BE9 9053 5FC3 9054 614E 9055 632F 9056 65B0 9057 664B 9058 68EE 9059 699B 905A 6D78 905B 6DF1 905C 7533 905D 75B9 905E 771F 905F 795E 9060 79E6 9061 7D33 9062 81E3 9063 82AF 9064 85AA 9065 89AA 9066 8A3A 9067 8EAB 9068 8F9B 9069 9032 906A 91DD 906B 9707 906C 4EBA 906D 4EC1 906E 5203 906F 5875 9070 58EC 9071 5C0B 9072 751A 9073 5C3D 9074 814E 9075 8A0A 9076 8FC5 9077 9663 9078 976D 9079 7B25 907A 8ACF 907B 9808 907C 9162 907D 56F3 907E 53A8 9080 9017 9081 5439 9082 5782 9083 5E25 9084 63A8 9085 6C34 9086 708A 9087 7761 9088 7C8B 9089 7FE0 908A 8870 908B 9042 908C 9154 908D 9310 908E 9318 908F 968F 9090 745E 9091 9AC4 9092 5D07 9093 5D69 9094 6570 9095 67A2 9096 8DA8 9097 96DB 9098 636E 9099 6749 909A 6919 909B 83C5 909C 9817 909D 96C0 909E 88FE 909F 6F84 90A0 647A 90A1 5BF8 90A2 4E16 90A3 702C 90A4 755D 90A5 662F 90A6 51C4 90A7 5236 90A8 52E2 90A9 59D3 90AA 5F81 90AB 6027 90AC 6210 90AD 653F 90AE 6574 90AF 661F 90B0 6674 90B1 68F2 90B2 6816 90B3 6B63 90B4 6E05 90B5 7272 90B6 751F 90B7 76DB 90B8 7CBE 90B9 8056 90BA 58F0 90BB 88FD 90BC 897F 90BD 8AA0 90BE 8A93 90BF 8ACB 90C0 901D 90C1 9192 90C2 9752 90C3 9759 90C4 6589 90C5 7A0E 90C6 8106 90C7 96BB 90C8 5E2D 90C9 60DC 90CA 621A 90CB 65A5 90CC 6614 90CD 6790 90CE 77F3 90CF 7A4D 90D0 7C4D 90D1 7E3E 90D2 810A 90D3 8CAC 90D4 8D64 90D5 8DE1 90D6 8E5F 90D7 78A9 90D8 5207 90D9 62D9 90DA 63A5 90DB 6442 90DC 6298 90DD 8A2D 90DE 7A83 90DF 7BC0 90E0 8AAC 90E1 96EA 90E2 7D76 90E3 820C 90E4 8749 90E5 4ED9 90E6 5148 90E7 5343 90E8 5360 90E9 5BA3 90EA 5C02 90EB 5C16 90EC 5DDD 90ED 6226 90EE 6247 90EF 64B0 90F0 6813 90F1 6834 90F2 6CC9 90F3 6D45 90F4 6D17 90F5 67D3 90F6 6F5C 90F7 714E 90F8 717D 90F9 65CB 90FA 7A7F 90FB 7BAD 90FC 7DDA 9140 7E4A 9141 7FA8 9142 817A 9143 821B 9144 8239 9145 85A6 9146 8A6E 9147 8CCE 9148 8DF5 9149 9078 914A 9077 914B 92AD 914C 9291 914D 9583 914E 9BAE 914F 524D 9150 5584 9151 6F38 9152 7136 9153 5168 9154 7985 9155 7E55 9156 81B3 9157 7CCE 9158 564C 9159 5851 915A 5CA8 915B 63AA 915C 66FE 915D 66FD 915E 695A 915F 72D9 9160 758F 9161 758E 9162 790E 9163 7956 9164 79DF 9165 7C97 9166 7D20 9167 7D44 9168 8607 9169 8A34 916A 963B 916B 9061 916C 9F20 916D 50E7 916E 5275 916F 53CC 9170 53E2 9171 5009 9172 55AA 9173 58EE 9174 594F 9175 723D 9176 5B8B 9177 5C64 9178 531D 9179 60E3 917A 60F3 917B 635C 917C 6383 917D 633F 917E 63BB 9180 64CD 9181 65E9 9182 66F9 9183 5DE3 9184 69CD 9185 69FD 9186 6F15 9187 71E5 9188 4E89 9189 75E9 918A 76F8 918B 7A93 918C 7CDF 918D 7DCF 918E 7D9C 918F 8061 9190 8349 9191 8358 9192 846C 9193 84BC 9194 85FB 9195 88C5 9196 8D70 9197 9001 9198 906D 9199 9397 919A 971C 919B 9A12 919C 50CF 919D 5897 919E 618E 919F 81D3 91A0 8535 91A1 8D08 91A2 9020 91A3 4FC3 91A4 5074 91A5 5247 91A6 5373 91A7 606F 91A8 6349 91A9 675F 91AA 6E2C 91AB 8DB3 91AC 901F 91AD 4FD7 91AE 5C5E 91AF 8CCA 91B0 65CF 91B1 7D9A 91B2 5352 91B3 8896 91B4 5176 91B5 63C3 91B6 5B58 91B7 5B6B 91B8 5C0A 91B9 640D 91BA 6751 91BB 905C 91BC 4ED6 91BD 591A 91BE 592A 91BF 6C70 91C0 8A51 91C1 553E 91C2 5815 91C3 59A5 91C4 60F0 91C5 6253 91C6 67C1 91C7 8235 91C8 6955 91C9 9640 91CA 99C4 91CB 9A28 91CC 4F53 91CD 5806 91CE 5BFE 91CF 8010 91D0 5CB1 91D1 5E2F 91D2 5F85 91D3 6020 91D4 614B 91D5 6234 91D6 66FF 91D7 6CF0 91D8 6EDE 91D9 80CE 91DA 817F 91DB 82D4 91DC 888B 91DD 8CB8 91DE 9000 91DF 902E 91E0 968A 91E1 9EDB 91E2 9BDB 91E3 4EE3 91E4 53F0 91E5 5927 91E6 7B2C 91E7 918D 91E8 984C 91E9 9DF9 91EA 6EDD 91EB 7027 91EC 5353 91ED 5544 91EE 5B85 91EF 6258 91F0 629E 91F1 62D3 91F2 6CA2 91F3 6FEF 91F4 7422 91F5 8A17 91F6 9438 91F7 6FC1 91F8 8AFE 91F9 8338 91FA 51E7 91FB 86F8 91FC 53EA 9240 53E9 9241 4F46 9242 9054 9243 8FB0 9244 596A 9245 8131 9246 5DFD 9247 7AEA 9248 8FBF 9249 68DA 924A 8C37 924B 72F8 924C 9C48 924D 6A3D 924E 8AB0 924F 4E39 9250 5358 9251 5606 9252 5766 9253 62C5 9254 63A2 9255 65E6 9256 6B4E 9257 6DE1 9258 6E5B 9259 70AD 925A 77ED 925B 7AEF 925C 7BAA 925D 7DBB 925E 803D 925F 80C6 9260 86CB 9261 8A95 9262 935B 9263 56E3 9264 58C7 9265 5F3E 9266 65AD 9267 6696 9268 6A80 9269 6BB5 926A 7537 926B 8AC7 926C 5024 926D 77E5 926E 5730 926F 5F1B 9270 6065 9271 667A 9272 6C60 9273 75F4 9274 7A1A 9275 7F6E 9276 81F4 9277 8718 9278 9045 9279 99B3 927A 7BC9 927B 755C 927C 7AF9 927D 7B51 927E 84C4 9280 9010 9281 79E9 9282 7A92 9283 8336 9284 5AE1 9285 7740 9286 4E2D 9287 4EF2 9288 5B99 9289 5FE0 928A 62BD 928B 663C 928C 67F1 928D 6CE8 928E 866B 928F 8877 9290 8A3B 9291 914E 9292 92F3 9293 99D0 9294 6A17 9295 7026 9296 732A 9297 82E7 9298 8457 9299 8CAF 929A 4E01 929B 5146 929C 51CB 929D 558B 929E 5BF5 929F 5E16 92A0 5E33 92A1 5E81 92A2 5F14 92A3 5F35 92A4 5F6B 92A5 5FB4 92A6 61F2 92A7 6311 92A8 66A2 92A9 671D 92AA 6F6E 92AB 7252 92AC 753A 92AD 773A 92AE 8074 92AF 8139 92B0 8178 92B1 8776 92B2 8ABF 92B3 8ADC 92B4 8D85 92B5 8DF3 92B6 929A 92B7 9577 92B8 9802 92B9 9CE5 92BA 52C5 92BB 6357 92BC 76F4 92BD 6715 92BE 6C88 92BF 73CD 92C0 8CC3 92C1 93AE 92C2 9673 92C3 6D25 92C4 589C 92C5 690E 92C6 69CC 92C7 8FFD 92C8 939A 92C9 75DB 92CA 901A 92CB 585A 92CC 6802 92CD 63B4 92CE 69FB 92CF 4F43 92D0 6F2C 92D1 67D8 92D2 8FBB 92D3 8526 92D4 7DB4 92D5 9354 92D6 693F 92D7 6F70 92D8 576A 92D9 58F7 92DA 5B2C 92DB 7D2C 92DC 722A 92DD 540A 92DE 91E3 92DF 9DB4 92E0 4EAD 92E1 4F4E 92E2 505C 92E3 5075 92E4 5243 92E5 8C9E 92E6 5448 92E7 5824 92E8 5B9A 92E9 5E1D 92EA 5E95 92EB 5EAD 92EC 5EF7 92ED 5F1F 92EE 608C 92EF 62B5 92F0 633A 92F1 63D0 92F2 68AF 92F3 6C40 92F4 7887 92F5 798E 92F6 7A0B 92F7 7DE0 92F8 8247 92F9 8A02 92FA 8AE6 92FB 8E44 92FC 9013 9340 90B8 9341 912D 9342 91D8 9343 9F0E 9344 6CE5 9345 6458 9346 64E2 9347 6575 9348 6EF4 9349 7684 934A 7B1B 934B 9069 934C 93D1 934D 6EBA 934E 54F2 934F 5FB9 9350 64A4 9351 8F4D 9352 8FED 9353 9244 9354 5178 9355 586B 9356 5929 9357 5C55 9358 5E97 9359 6DFB 935A 7E8F 935B 751C 935C 8CBC 935D 8EE2 935E 985B 935F 70B9 9360 4F1D 9361 6BBF 9362 6FB1 9363 7530 9364 96FB 9365 514E 9366 5410 9367 5835 9368 5857 9369 59AC 936A 5C60 936B 5F92 936C 6597 936D 675C 936E 6E21 936F 767B 9370 83DF 9371 8CED 9372 9014 9373 90FD 9374 934D 9375 7825 9376 783A 9377 52AA 9378 5EA6 9379 571F 937A 5974 937B 6012 937C 5012 937D 515A 937E 51AC 9380 51CD 9381 5200 9382 5510 9383 5854 9384 5858 9385 5957 9386 5B95 9387 5CF6 9388 5D8B 9389 60BC 938A 6295 938B 642D 938C 6771 938D 6843 938E 68BC 938F 68DF 9390 76D7 9391 6DD8 9392 6E6F 9393 6D9B 9394 706F 9395 71C8 9396 5F53 9397 75D8 9398 7977 9399 7B49 939A 7B54 939B 7B52 939C 7CD6 939D 7D71 939E 5230 939F 8463 93A0 8569 93A1 85E4 93A2 8A0E 93A3 8B04 93A4 8C46 93A5 8E0F 93A6 9003 93A7 900F 93A8 9419 93A9 9676 93AA 982D 93AB 9A30 93AC 95D8 93AD 50CD 93AE 52D5 93AF 540C 93B0 5802 93B1 5C0E 93B2 61A7 93B3 649E 93B4 6D1E 93B5 77B3 93B6 7AE5 93B7 80F4 93B8 8404 93B9 9053 93BA 9285 93BB 5CE0 93BC 9D07 93BD 533F 93BE 5F97 93BF 5FB3 93C0 6D9C 93C1 7279 93C2 7763 93C3 79BF 93C4 7BE4 93C5 6BD2 93C6 72EC 93C7 8AAD 93C8 6803 93C9 6A61 93CA 51F8 93CB 7A81 93CC 6934 93CD 5C4A 93CE 9CF6 93CF 82EB 93D0 5BC5 93D1 9149 93D2 701E 93D3 5678 93D4 5C6F 93D5 60C7 93D6 6566 93D7 6C8C 93D8 8C5A 93D9 9041 93DA 9813 93DB 5451 93DC 66C7 93DD 920D 93DE 5948 93DF 90A3 93E0 5185 93E1 4E4D 93E2 51EA 93E3 8599 93E4 8B0E 93E5 7058 93E6 637A 93E7 934B 93E8 6962 93E9 99B4 93EA 7E04 93EB 7577 93EC 5357 93ED 6960 93EE 8EDF 93EF 96E3 93F0 6C5D 93F1 4E8C 93F2 5C3C 93F3 5F10 93F4 8FE9 93F5 5302 93F6 8CD1 93F7 8089 93F8 8679 93F9 5EFF 93FA 65E5 93FB 4E73 93FC 5165 9440 5982 9441 5C3F 9442 97EE 9443 4EFB 9444 598A 9445 5FCD 9446 8A8D 9447 6FE1 9448 79B0 9449 7962 944A 5BE7 944B 8471 944C 732B 944D 71B1 944E 5E74 944F 5FF5 9450 637B 9451 649A 9452 71C3 9453 7C98 9454 4E43 9455 5EFC 9456 4E4B 9457 57DC 9458 56A2 9459 60A9 945A 6FC3 945B 7D0D 945C 80FD 945D 8133 945E 81BF 945F 8FB2 9460 8997 9461 86A4 9462 5DF4 9463 628A 9464 64AD 9465 8987 9466 6777 9467 6CE2 9468 6D3E 9469 7436 946A 7834 946B 5A46 946C 7F75 946D 82AD 946E 99AC 946F 4FF3 9470 5EC3 9471 62DD 9472 6392 9473 6557 9474 676F 9475 76C3 9476 724C 9477 80CC 9478 80BA 9479 8F29 947A 914D 947B 500D 947C 57F9 947D 5A92 947E 6885 9480 6973 9481 7164 9482 72FD 9483 8CB7 9484 58F2 9485 8CE0 9486 966A 9487 9019 9488 877F 9489 79E4 948A 77E7 948B 8429 948C 4F2F 948D 5265 948E 535A 948F 62CD 9490 67CF 9491 6CCA 9492 767D 9493 7B94 9494 7C95 9495 8236 9496 8584 9497 8FEB 9498 66DD 9499 6F20 949A 7206 949B 7E1B 949C 83AB 949D 99C1 949E 9EA6 949F 51FD 94A0 7BB1 94A1 7872 94A2 7BB8 94A3 8087 94A4 7B48 94A5 6AE8 94A6 5E61 94A7 808C 94A8 7551 94A9 7560 94AA 516B 94AB 9262 94AC 6E8C 94AD 767A 94AE 9197 94AF 9AEA 94B0 4F10 94B1 7F70 94B2 629C 94B3 7B4F 94B4 95A5 94B5 9CE9 94B6 567A 94B7 5859 94B8 86E4 94B9 96BC 94BA 4F34 94BB 5224 94BC 534A 94BD 53CD 94BE 53DB 94BF 5E06 94C0 642C 94C1 6591 94C2 677F 94C3 6C3E 94C4 6C4E 94C5 7248 94C6 72AF 94C7 73ED 94C8 7554 94C9 7E41 94CA 822C 94CB 85E9 94CC 8CA9 94CD 7BC4 94CE 91C6 94CF 7169 94D0 9812 94D1 98EF 94D2 633D 94D3 6669 94D4 756A 94D5 76E4 94D6 78D0 94D7 8543 94D8 86EE 94D9 532A 94DA 5351 94DB 5426 94DC 5983 94DD 5E87 94DE 5F7C 94DF 60B2 94E0 6249 94E1 6279 94E2 62AB 94E3 6590 94E4 6BD4 94E5 6CCC 94E6 75B2 94E7 76AE 94E8 7891 94E9 79D8 94EA 7DCB 94EB 7F77 94EC 80A5 94ED 88AB 94EE 8AB9 94EF 8CBB 94F0 907F 94F1 975E 94F2 98DB 94F3 6A0B 94F4 7C38 94F5 5099 94F6 5C3E 94F7 5FAE 94F8 6787 94F9 6BD8 94FA 7435 94FB 7709 94FC 7F8E 9540 9F3B 9541 67CA 9542 7A17 9543 5339 9544 758B 9545 9AED 9546 5F66 9547 819D 9548 83F1 9549 8098 954A 5F3C 954B 5FC5 954C 7562 954D 7B46 954E 903C 954F 6867 9550 59EB 9551 5A9B 9552 7D10 9553 767E 9554 8B2C 9555 4FF5 9556 5F6A 9557 6A19 9558 6C37 9559 6F02 955A 74E2 955B 7968 955C 8868 955D 8A55 955E 8C79 955F 5EDF 9560 63CF 9561 75C5 9562 79D2 9563 82D7 9564 9328 9565 92F2 9566 849C 9567 86ED 9568 9C2D 9569 54C1 956A 5F6C 956B 658C 956C 6D5C 956D 7015 956E 8CA7 956F 8CD3 9570 983B 9571 654F 9572 74F6 9573 4E0D 9574 4ED8 9575 57E0 9576 592B 9577 5A66 9578 5BCC 9579 51A8 957A 5E03 957B 5E9C 957C 6016 957D 6276 957E 6577 9580 65A7 9581 666E 9582 6D6E 9583 7236 9584 7B26 9585 8150 9586 819A 9587 8299 9588 8B5C 9589 8CA0 958A 8CE6 958B 8D74 958C 961C 958D 9644 958E 4FAE 958F 64AB 9590 6B66 9591 821E 9592 8461 9593 856A 9594 90E8 9595 5C01 9596 6953 9597 98A8 9598 847A 9599 8557 959A 4F0F 959B 526F 959C 5FA9 959D 5E45 959E 670D 959F 798F 95A0 8179 95A1 8907 95A2 8986 95A3 6DF5 95A4 5F17 95A5 6255 95A6 6CB8 95A7 4ECF 95A8 7269 95A9 9B92 95AA 5206 95AB 543B 95AC 5674 95AD 58B3 95AE 61A4 95AF 626E 95B0 711A 95B1 596E 95B2 7C89 95B3 7CDE 95B4 7D1B 95B5 96F0 95B6 6587 95B7 805E 95B8 4E19 95B9 4F75 95BA 5175 95BB 5840 95BC 5E63 95BD 5E73 95BE 5F0A 95BF 67C4 95C0 4E26 95C1 853D 95C2 9589 95C3 965B 95C4 7C73 95C5 9801 95C6 50FB 95C7 58C1 95C8 7656 95C9 78A7 95CA 5225 95CB 77A5 95CC 8511 95CD 7B86 95CE 504F 95CF 5909 95D0 7247 95D1 7BC7 95D2 7DE8 95D3 8FBA 95D4 8FD4 95D5 904D 95D6 4FBF 95D7 52C9 95D8 5A29 95D9 5F01 95DA 97AD 95DB 4FDD 95DC 8217 95DD 92EA 95DE 5703 95DF 6355 95E0 6B69 95E1 752B 95E2 88DC 95E3 8F14 95E4 7A42 95E5 52DF 95E6 5893 95E7 6155 95E8 620A 95E9 66AE 95EA 6BCD 95EB 7C3F 95EC 83E9 95ED 5023 95EE 4FF8 95EF 5305 95F0 5446 95F1 5831 95F2 5949 95F3 5B9D 95F4 5CF0 95F5 5CEF 95F6 5D29 95F7 5E96 95F8 62B1 95F9 6367 95FA 653E 95FB 65B9 95FC 670B 9640 6CD5 9641 6CE1 9642 70F9 9643 7832 9644 7E2B 9645 80DE 9646 82B3 9647 840C 9648 84EC 9649 8702 964A 8912 964B 8A2A 964C 8C4A 964D 90A6 964E 92D2 964F 98FD 9650 9CF3 9651 9D6C 9652 4E4F 9653 4EA1 9654 508D 9655 5256 9656 574A 9657 59A8 9658 5E3D 9659 5FD8 965A 5FD9 965B 623F 965C 66B4 965D 671B 965E 67D0 965F 68D2 9660 5192 9661 7D21 9662 80AA 9663 81A8 9664 8B00 9665 8C8C 9666 8CBF 9667 927E 9668 9632 9669 5420 966A 982C 966B 5317 966C 50D5 966D 535C 966E 58A8 966F 64B2 9670 6734 9671 7267 9672 7766 9673 7A46 9674 91E6 9675 52C3 9676 6CA1 9677 6B86 9678 5800 9679 5E4C 967A 5954 967B 672C 967C 7FFB 967D 51E1 967E 76C6 9680 6469 9681 78E8 9682 9B54 9683 9EBB 9684 57CB 9685 59B9 9686 6627 9687 679A 9688 6BCE 9689 54E9 968A 69D9 968B 5E55 968C 819C 968D 6795 968E 9BAA 968F 67FE 9690 9C52 9691 685D 9692 4EA6 9693 4FE3 9694 53C8 9695 62B9 9696 672B 9697 6CAB 9698 8FC4 9699 4FAD 969A 7E6D 969B 9EBF 969C 4E07 969D 6162 969E 6E80 969F 6F2B 96A0 8513 96A1 5473 96A2 672A 96A3 9B45 96A4 5DF3 96A5 7B95 96A6 5CAC 96A7 5BC6 96A8 871C 96A9 6E4A 96AA 84D1 96AB 7A14 96AC 8108 96AD 5999 96AE 7C8D 96AF 6C11 96B0 7720 96B1 52D9 96B2 5922 96B3 7121 96B4 725F 96B5 77DB 96B6 9727 96B7 9D61 96B8 690B 96B9 5A7F 96BA 5A18 96BB 51A5 96BC 540D 96BD 547D 96BE 660E 96BF 76DF 96C0 8FF7 96C1 9298 96C2 9CF4 96C3 59EA 96C4 725D 96C5 6EC5 96C6 514D 96C7 68C9 96C8 7DBF 96C9 7DEC 96CA 9762 96CB 9EBA 96CC 6478 96CD 6A21 96CE 8302 96CF 5984 96D0 5B5F 96D1 6BDB 96D2 731B 96D3 76F2 96D4 7DB2 96D5 8017 96D6 8499 96D7 5132 96D8 6728 96D9 9ED9 96DA 76EE 96DB 6762 96DC 52FF 96DD 9905 96DE 5C24 96DF 623B 96E0 7C7E 96E1 8CB0 96E2 554F 96E3 60B6 96E4 7D0B 96E5 9580 96E6 5301 96E7 4E5F 96E8 51B6 96E9 591C 96EA 723A 96EB 8036 96EC 91CE 96ED 5F25 96EE 77E2 96EF 5384 96F0 5F79 96F1 7D04 96F2 85AC 96F3 8A33 96F4 8E8D 96F5 9756 96F6 67F3 96F7 85AE 96F8 9453 96F9 6109 96FA 6108 96FB 6CB9 96FC 7652 9740 8AED 9741 8F38 9742 552F 9743 4F51 9744 512A 9745 52C7 9746 53CB 9747 5BA5 9748 5E7D 9749 60A0 974A 6182 974B 63D6 974C 6709 974D 67DA 974E 6E67 974F 6D8C 9750 7336 9751 7337 9752 7531 9753 7950 9754 88D5 9755 8A98 9756 904A 9757 9091 9758 90F5 9759 96C4 975A 878D 975B 5915 975C 4E88 975D 4F59 975E 4E0E 975F 8A89 9760 8F3F 9761 9810 9762 50AD 9763 5E7C 9764 5996 9765 5BB9 9766 5EB8 9767 63DA 9768 63FA 9769 64C1 976A 66DC 976B 694A 976C 69D8 976D 6D0B 976E 6EB6 976F 7194 9770 7528 9771 7AAF 9772 7F8A 9773 8000 9774 8449 9775 84C9 9776 8981 9777 8B21 9778 8E0A 9779 9065 977A 967D 977B 990A 977C 617E 977D 6291 977E 6B32 9780 6C83 9781 6D74 9782 7FCC 9783 7FFC 9784 6DC0 9785 7F85 9786 87BA 9787 88F8 9788 6765 9789 83B1 978A 983C 978B 96F7 978C 6D1B 978D 7D61 978E 843D 978F 916A 9790 4E71 9791 5375 9792 5D50 9793 6B04 9794 6FEB 9795 85CD 9796 862D 9797 89A7 9798 5229 9799 540F 979A 5C65 979B 674E 979C 68A8 979D 7406 979E 7483 979F 75E2 97A0 88CF 97A1 88E1 97A2 91CC 97A3 96E2 97A4 9678 97A5 5F8B 97A6 7387 97A7 7ACB 97A8 844E 97A9 63A0 97AA 7565 97AB 5289 97AC 6D41 97AD 6E9C 97AE 7409 97AF 7559 97B0 786B 97B1 7C92 97B2 9686 97B3 7ADC 97B4 9F8D 97B5 4FB6 97B6 616E 97B7 65C5 97B8 865C 97B9 4E86 97BA 4EAE 97BB 50DA 97BC 4E21 97BD 51CC 97BE 5BEE 97BF 6599 97C0 6881 97C1 6DBC 97C2 731F 97C3 7642 97C4 77AD 97C5 7A1C 97C6 7CE7 97C7 826F 97C8 8AD2 97C9 907C 97CA 91CF 97CB 9675 97CC 9818 97CD 529B 97CE 7DD1 97CF 502B 97D0 5398 97D1 6797 97D2 6DCB 97D3 71D0 97D4 7433 97D5 81E8 97D6 8F2A 97D7 96A3 97D8 9C57 97D9 9E9F 97DA 7460 97DB 5841 97DC 6D99 97DD 7D2F 97DE 985E 97DF 4EE4 97E0 4F36 97E1 4F8B 97E2 51B7 97E3 52B1 97E4 5DBA 97E5 601C 97E6 73B2 97E7 793C 97E8 82D3 97E9 9234 97EA 96B7 97EB 96F6 97EC 970A 97ED 9E97 97EE 9F62 97EF 66A6 97F0 6B74 97F1 5217 97F2 52A3 97F3 70C8 97F4 88C2 97F5 5EC9 97F6 604B 97F7 6190 97F8 6F23 97F9 7149 97FA 7C3E 97FB 7DF4 97FC 806F 9840 84EE 9841 9023 9842 932C 9843 5442 9844 9B6F 9845 6AD3 9846 7089 9847 8CC2 9848 8DEF 9849 9732 984A 52B4 984B 5A41 984C 5ECA 984D 5F04 984E 6717 984F 697C 9850 6994 9851 6D6A 9852 6F0F 9853 7262 9854 72FC 9855 7BED 9856 8001 9857 807E 9858 874B 9859 90CE 985A 516D 985B 9E93 985C 7984 985D 808B 985E 9332 985F 8AD6 9860 502D 9861 548C 9862 8A71 9863 6B6A 9864 8CC4 9865 8107 9866 60D1 9867 67A0 9868 9DF2 9869 4E99 986A 4E98 986B 9C10 986C 8A6B 986D 85C1 986E 8568 986F 6900 9870 6E7E 9871 7897 9872 8155 989F 5F0C 98A0 4E10 98A1 4E15 98A2 4E2A 98A3 4E31 98A4 4E36 98A5 4E3C 98A6 4E3F 98A7 4E42 98A8 4E56 98A9 4E58 98AA 4E82 98AB 4E85 98AC 8C6B 98AD 4E8A 98AE 8212 98AF 5F0D 98B0 4E8E 98B1 4E9E 98B2 4E9F 98B3 4EA0 98B4 4EA2 98B5 4EB0 98B6 4EB3 98B7 4EB6 98B8 4ECE 98B9 4ECD 98BA 4EC4 98BB 4EC6 98BC 4EC2 98BD 4ED7 98BE 4EDE 98BF 4EED 98C0 4EDF 98C1 4EF7 98C2 4F09 98C3 4F5A 98C4 4F30 98C5 4F5B 98C6 4F5D 98C7 4F57 98C8 4F47 98C9 4F76 98CA 4F88 98CB 4F8F 98CC 4F98 98CD 4F7B 98CE 4F69 98CF 4F70 98D0 4F91 98D1 4F6F 98D2 4F86 98D3 4F96 98D4 5118 98D5 4FD4 98D6 4FDF 98D7 4FCE 98D8 4FD8 98D9 4FDB 98DA 4FD1 98DB 4FDA 98DC 4FD0 98DD 4FE4 98DE 4FE5 98DF 501A 98E0 5028 98E1 5014 98E2 502A 98E3 5025 98E4 5005 98E5 4F1C 98E6 4FF6 98E7 5021 98E8 5029 98E9 502C 98EA 4FFE 98EB 4FEF 98EC 5011 98ED 5006 98EE 5043 98EF 5047 98F0 6703 98F1 5055 98F2 5050 98F3 5048 98F4 505A 98F5 5056 98F6 506C 98F7 5078 98F8 5080 98F9 509A 98FA 5085 98FB 50B4 98FC 50B2 9940 50C9 9941 50CA 9942 50B3 9943 50C2 9944 50D6 9945 50DE 9946 50E5 9947 50ED 9948 50E3 9949 50EE 994A 50F9 994B 50F5 994C 5109 994D 5101 994E 5102 994F 5116 9950 5115 9951 5114 9952 511A 9953 5121 9954 513A 9955 5137 9956 513C 9957 513B 9958 513F 9959 5140 995A 5152 995B 514C 995C 5154 995D 5162 995E 7AF8 995F 5169 9960 516A 9961 516E 9962 5180 9963 5182 9964 56D8 9965 518C 9966 5189 9967 518F 9968 5191 9969 5193 996A 5195 996B 5196 996C 51A4 996D 51A6 996E 51A2 996F 51A9 9970 51AA 9971 51AB 9972 51B3 9973 51B1 9974 51B2 9975 51B0 9976 51B5 9977 51BD 9978 51C5 9979 51C9 997A 51DB 997B 51E0 997C 8655 997D 51E9 997E 51ED 9980 51F0 9981 51F5 9982 51FE 9983 5204 9984 520B 9985 5214 9986 520E 9987 5227 9988 522A 9989 522E 998A 5233 998B 5239 998C 524F 998D 5244 998E 524B 998F 524C 9990 525E 9991 5254 9992 526A 9993 5274 9994 5269 9995 5273 9996 527F 9997 527D 9998 528D 9999 5294 999A 5292 999B 5271 999C 5288 999D 5291 999E 8FA8 999F 8FA7 99A0 52AC 99A1 52AD 99A2 52BC 99A3 52B5 99A4 52C1 99A5 52CD 99A6 52D7 99A7 52DE 99A8 52E3 99A9 52E6 99AA 98ED 99AB 52E0 99AC 52F3 99AD 52F5 99AE 52F8 99AF 52F9 99B0 5306 99B1 5308 99B2 7538 99B3 530D 99B4 5310 99B5 530F 99B6 5315 99B7 531A 99B8 5323 99B9 532F 99BA 5331 99BB 5333 99BC 5338 99BD 5340 99BE 5346 99BF 5345 99C0 4E17 99C1 5349 99C2 534D 99C3 51D6 99C4 535E 99C5 5369 99C6 536E 99C7 5918 99C8 537B 99C9 5377 99CA 5382 99CB 5396 99CC 53A0 99CD 53A6 99CE 53A5 99CF 53AE 99D0 53B0 99D1 53B6 99D2 53C3 99D3 7C12 99D4 96D9 99D5 53DF 99D6 66FC 99D7 71EE 99D8 53EE 99D9 53E8 99DA 53ED 99DB 53FA 99DC 5401 99DD 543D 99DE 5440 99DF 542C 99E0 542D 99E1 543C 99E2 542E 99E3 5436 99E4 5429 99E5 541D 99E6 544E 99E7 548F 99E8 5475 99E9 548E 99EA 545F 99EB 5471 99EC 5477 99ED 5470 99EE 5492 99EF 547B 99F0 5480 99F1 5476 99F2 5484 99F3 5490 99F4 5486 99F5 54C7 99F6 54A2 99F7 54B8 99F8 54A5 99F9 54AC 99FA 54C4 99FB 54C8 99FC 54A8 9A40 54AB 9A41 54C2 9A42 54A4 9A43 54BE 9A44 54BC 9A45 54D8 9A46 54E5 9A47 54E6 9A48 550F 9A49 5514 9A4A 54FD 9A4B 54EE 9A4C 54ED 9A4D 54FA 9A4E 54E2 9A4F 5539 9A50 5540 9A51 5563 9A52 554C 9A53 552E 9A54 555C 9A55 5545 9A56 5556 9A57 5557 9A58 5538 9A59 5533 9A5A 555D 9A5B 5599 9A5C 5580 9A5D 54AF 9A5E 558A 9A5F 559F 9A60 557B 9A61 557E 9A62 5598 9A63 559E 9A64 55AE 9A65 557C 9A66 5583 9A67 55A9 9A68 5587 9A69 55A8 9A6A 55DA 9A6B 55C5 9A6C 55DF 9A6D 55C4 9A6E 55DC 9A6F 55E4 9A70 55D4 9A71 5614 9A72 55F7 9A73 5616 9A74 55FE 9A75 55FD 9A76 561B 9A77 55F9 9A78 564E 9A79 5650 9A7A 71DF 9A7B 5634 9A7C 5636 9A7D 5632 9A7E 5638 9A80 566B 9A81 5664 9A82 562F 9A83 566C 9A84 566A 9A85 5686 9A86 5680 9A87 568A 9A88 56A0 9A89 5694 9A8A 568F 9A8B 56A5 9A8C 56AE 9A8D 56B6 9A8E 56B4 9A8F 56C2 9A90 56BC 9A91 56C1 9A92 56C3 9A93 56C0 9A94 56C8 9A95 56CE 9A96 56D1 9A97 56D3 9A98 56D7 9A99 56EE 9A9A 56F9 9A9B 5700 9A9C 56FF 9A9D 5704 9A9E 5709 9A9F 5708 9AA0 570B 9AA1 570D 9AA2 5713 9AA3 5718 9AA4 5716 9AA5 55C7 9AA6 571C 9AA7 5726 9AA8 5737 9AA9 5738 9AAA 574E 9AAB 573B 9AAC 5740 9AAD 574F 9AAE 5769 9AAF 57C0 9AB0 5788 9AB1 5761 9AB2 577F 9AB3 5789 9AB4 5793 9AB5 57A0 9AB6 57B3 9AB7 57A4 9AB8 57AA 9AB9 57B0 9ABA 57C3 9ABB 57C6 9ABC 57D4 9ABD 57D2 9ABE 57D3 9ABF 580A 9AC0 57D6 9AC1 57E3 9AC2 580B 9AC3 5819 9AC4 581D 9AC5 5872 9AC6 5821 9AC7 5862 9AC8 584B 9AC9 5870 9ACA 6BC0 9ACB 5852 9ACC 583D 9ACD 5879 9ACE 5885 9ACF 58B9 9AD0 589F 9AD1 58AB 9AD2 58BA 9AD3 58DE 9AD4 58BB 9AD5 58B8 9AD6 58AE 9AD7 58C5 9AD8 58D3 9AD9 58D1 9ADA 58D7 9ADB 58D9 9ADC 58D8 9ADD 58E5 9ADE 58DC 9ADF 58E4 9AE0 58DF 9AE1 58EF 9AE2 58FA 9AE3 58F9 9AE4 58FB 9AE5 58FC 9AE6 58FD 9AE7 5902 9AE8 590A 9AE9 5910 9AEA 591B 9AEB 68A6 9AEC 5925 9AED 592C 9AEE 592D 9AEF 5932 9AF0 5938 9AF1 593E 9AF2 7AD2 9AF3 5955 9AF4 5950 9AF5 594E 9AF6 595A 9AF7 5958 9AF8 5962 9AF9 5960 9AFA 5967 9AFB 596C 9AFC 5969 9B40 5978 9B41 5981 9B42 599D 9B43 4F5E 9B44 4FAB 9B45 59A3 9B46 59B2 9B47 59C6 9B48 59E8 9B49 59DC 9B4A 598D 9B4B 59D9 9B4C 59DA 9B4D 5A25 9B4E 5A1F 9B4F 5A11 9B50 5A1C 9B51 5A09 9B52 5A1A 9B53 5A40 9B54 5A6C 9B55 5A49 9B56 5A35 9B57 5A36 9B58 5A62 9B59 5A6A 9B5A 5A9A 9B5B 5ABC 9B5C 5ABE 9B5D 5ACB 9B5E 5AC2 9B5F 5ABD 9B60 5AE3 9B61 5AD7 9B62 5AE6 9B63 5AE9 9B64 5AD6 9B65 5AFA 9B66 5AFB 9B67 5B0C 9B68 5B0B 9B69 5B16 9B6A 5B32 9B6B 5AD0 9B6C 5B2A 9B6D 5B36 9B6E 5B3E 9B6F 5B43 9B70 5B45 9B71 5B40 9B72 5B51 9B73 5B55 9B74 5B5A 9B75 5B5B 9B76 5B65 9B77 5B69 9B78 5B70 9B79 5B73 9B7A 5B75 9B7B 5B78 9B7C 6588 9B7D 5B7A 9B7E 5B80 9B80 5B83 9B81 5BA6 9B82 5BB8 9B83 5BC3 9B84 5BC7 9B85 5BC9 9B86 5BD4 9B87 5BD0 9B88 5BE4 9B89 5BE6 9B8A 5BE2 9B8B 5BDE 9B8C 5BE5 9B8D 5BEB 9B8E 5BF0 9B8F 5BF6 9B90 5BF3 9B91 5C05 9B92 5C07 9B93 5C08 9B94 5C0D 9B95 5C13 9B96 5C20 9B97 5C22 9B98 5C28 9B99 5C38 9B9A 5C39 9B9B 5C41 9B9C 5C46 9B9D 5C4E 9B9E 5C53 9B9F 5C50 9BA0 5C4F 9BA1 5B71 9BA2 5C6C 9BA3 5C6E 9BA4 4E62 9BA5 5C76 9BA6 5C79 9BA7 5C8C 9BA8 5C91 9BA9 5C94 9BAA 599B 9BAB 5CAB 9BAC 5CBB 9BAD 5CB6 9BAE 5CBC 9BAF 5CB7 9BB0 5CC5 9BB1 5CBE 9BB2 5CC7 9BB3 5CD9 9BB4 5CE9 9BB5 5CFD 9BB6 5CFA 9BB7 5CED 9BB8 5D8C 9BB9 5CEA 9BBA 5D0B 9BBB 5D15 9BBC 5D17 9BBD 5D5C 9BBE 5D1F 9BBF 5D1B 9BC0 5D11 9BC1 5D14 9BC2 5D22 9BC3 5D1A 9BC4 5D19 9BC5 5D18 9BC6 5D4C 9BC7 5D52 9BC8 5D4E 9BC9 5D4B 9BCA 5D6C 9BCB 5D73 9BCC 5D76 9BCD 5D87 9BCE 5D84 9BCF 5D82 9BD0 5DA2 9BD1 5D9D 9BD2 5DAC 9BD3 5DAE 9BD4 5DBD 9BD5 5D90 9BD6 5DB7 9BD7 5DBC 9BD8 5DC9 9BD9 5DCD 9BDA 5DD3 9BDB 5DD2 9BDC 5DD6 9BDD 5DDB 9BDE 5DEB 9BDF 5DF2 9BE0 5DF5 9BE1 5E0B 9BE2 5E1A 9BE3 5E19 9BE4 5E11 9BE5 5E1B 9BE6 5E36 9BE7 5E37 9BE8 5E44 9BE9 5E43 9BEA 5E40 9BEB 5E4E 9BEC 5E57 9BED 5E54 9BEE 5E5F 9BEF 5E62 9BF0 5E64 9BF1 5E47 9BF2 5E75 9BF3 5E76 9BF4 5E7A 9BF5 9EBC 9BF6 5E7F 9BF7 5EA0 9BF8 5EC1 9BF9 5EC2 9BFA 5EC8 9BFB 5ED0 9BFC 5ECF 9C40 5ED6 9C41 5EE3 9C42 5EDD 9C43 5EDA 9C44 5EDB 9C45 5EE2 9C46 5EE1 9C47 5EE8 9C48 5EE9 9C49 5EEC 9C4A 5EF1 9C4B 5EF3 9C4C 5EF0 9C4D 5EF4 9C4E 5EF8 9C4F 5EFE 9C50 5F03 9C51 5F09 9C52 5F5D 9C53 5F5C 9C54 5F0B 9C55 5F11 9C56 5F16 9C57 5F29 9C58 5F2D 9C59 5F38 9C5A 5F41 9C5B 5F48 9C5C 5F4C 9C5D 5F4E 9C5E 5F2F 9C5F 5F51 9C60 5F56 9C61 5F57 9C62 5F59 9C63 5F61 9C64 5F6D 9C65 5F73 9C66 5F77 9C67 5F83 9C68 5F82 9C69 5F7F 9C6A 5F8A 9C6B 5F88 9C6C 5F91 9C6D 5F87 9C6E 5F9E 9C6F 5F99 9C70 5F98 9C71 5FA0 9C72 5FA8 9C73 5FAD 9C74 5FBC 9C75 5FD6 9C76 5FFB 9C77 5FE4 9C78 5FF8 9C79 5FF1 9C7A 5FDD 9C7B 60B3 9C7C 5FFF 9C7D 6021 9C7E 6060 9C80 6019 9C81 6010 9C82 6029 9C83 600E 9C84 6031 9C85 601B 9C86 6015 9C87 602B 9C88 6026 9C89 600F 9C8A 603A 9C8B 605A 9C8C 6041 9C8D 606A 9C8E 6077 9C8F 605F 9C90 604A 9C91 6046 9C92 604D 9C93 6063 9C94 6043 9C95 6064 9C96 6042 9C97 606C 9C98 606B 9C99 6059 9C9A 6081 9C9B 608D 9C9C 60E7 9C9D 6083 9C9E 609A 9C9F 6084 9CA0 609B 9CA1 6096 9CA2 6097 9CA3 6092 9CA4 60A7 9CA5 608B 9CA6 60E1 9CA7 60B8 9CA8 60E0 9CA9 60D3 9CAA 60B4 9CAB 5FF0 9CAC 60BD 9CAD 60C6 9CAE 60B5 9CAF 60D8 9CB0 614D 9CB1 6115 9CB2 6106 9CB3 60F6 9CB4 60F7 9CB5 6100 9CB6 60F4 9CB7 60FA 9CB8 6103 9CB9 6121 9CBA 60FB 9CBB 60F1 9CBC 610D 9CBD 610E 9CBE 6147 9CBF 613E 9CC0 6128 9CC1 6127 9CC2 614A 9CC3 613F 9CC4 613C 9CC5 612C 9CC6 6134 9CC7 613D 9CC8 6142 9CC9 6144 9CCA 6173 9CCB 6177 9CCC 6158 9CCD 6159 9CCE 615A 9CCF 616B 9CD0 6174 9CD1 616F 9CD2 6165 9CD3 6171 9CD4 615F 9CD5 615D 9CD6 6153 9CD7 6175 9CD8 6199 9CD9 6196 9CDA 6187 9CDB 61AC 9CDC 6194 9CDD 619A 9CDE 618A 9CDF 6191 9CE0 61AB 9CE1 61AE 9CE2 61CC 9CE3 61CA 9CE4 61C9 9CE5 61F7 9CE6 61C8 9CE7 61C3 9CE8 61C6 9CE9 61BA 9CEA 61CB 9CEB 7F79 9CEC 61CD 9CED 61E6 9CEE 61E3 9CEF 61F6 9CF0 61FA 9CF1 61F4 9CF2 61FF 9CF3 61FD 9CF4 61FC 9CF5 61FE 9CF6 6200 9CF7 6208 9CF8 6209 9CF9 620D 9CFA 620C 9CFB 6214 9CFC 621B 9D40 621E 9D41 6221 9D42 622A 9D43 622E 9D44 6230 9D45 6232 9D46 6233 9D47 6241 9D48 624E 9D49 625E 9D4A 6263 9D4B 625B 9D4C 6260 9D4D 6268 9D4E 627C 9D4F 6282 9D50 6289 9D51 627E 9D52 6292 9D53 6293 9D54 6296 9D55 62D4 9D56 6283 9D57 6294 9D58 62D7 9D59 62D1 9D5A 62BB 9D5B 62CF 9D5C 62FF 9D5D 62C6 9D5E 64D4 9D5F 62C8 9D60 62DC 9D61 62CC 9D62 62CA 9D63 62C2 9D64 62C7 9D65 629B 9D66 62C9 9D67 630C 9D68 62EE 9D69 62F1 9D6A 6327 9D6B 6302 9D6C 6308 9D6D 62EF 9D6E 62F5 9D6F 6350 9D70 633E 9D71 634D 9D72 641C 9D73 634F 9D74 6396 9D75 638E 9D76 6380 9D77 63AB 9D78 6376 9D79 63A3 9D7A 638F 9D7B 6389 9D7C 639F 9D7D 63B5 9D7E 636B 9D80 6369 9D81 63BE 9D82 63E9 9D83 63C0 9D84 63C6 9D85 63E3 9D86 63C9 9D87 63D2 9D88 63F6 9D89 63C4 9D8A 6416 9D8B 6434 9D8C 6406 9D8D 6413 9D8E 6426 9D8F 6436 9D90 651D 9D91 6417 9D92 6428 9D93 640F 9D94 6467 9D95 646F 9D96 6476 9D97 644E 9D98 652A 9D99 6495 9D9A 6493 9D9B 64A5 9D9C 64A9 9D9D 6488 9D9E 64BC 9D9F 64DA 9DA0 64D2 9DA1 64C5 9DA2 64C7 9DA3 64BB 9DA4 64D8 9DA5 64C2 9DA6 64F1 9DA7 64E7 9DA8 8209 9DA9 64E0 9DAA 64E1 9DAB 62AC 9DAC 64E3 9DAD 64EF 9DAE 652C 9DAF 64F6 9DB0 64F4 9DB1 64F2 9DB2 64FA 9DB3 6500 9DB4 64FD 9DB5 6518 9DB6 651C 9DB7 6505 9DB8 6524 9DB9 6523 9DBA 652B 9DBB 6534 9DBC 6535 9DBD 6537 9DBE 6536 9DBF 6538 9DC0 754B 9DC1 6548 9DC2 6556 9DC3 6555 9DC4 654D 9DC5 6558 9DC6 655E 9DC7 655D 9DC8 6572 9DC9 6578 9DCA 6582 9DCB 6583 9DCC 8B8A 9DCD 659B 9DCE 659F 9DCF 65AB 9DD0 65B7 9DD1 65C3 9DD2 65C6 9DD3 65C1 9DD4 65C4 9DD5 65CC 9DD6 65D2 9DD7 65DB 9DD8 65D9 9DD9 65E0 9DDA 65E1 9DDB 65F1 9DDC 6772 9DDD 660A 9DDE 6603 9DDF 65FB 9DE0 6773 9DE1 6635 9DE2 6636 9DE3 6634 9DE4 661C 9DE5 664F 9DE6 6644 9DE7 6649 9DE8 6641 9DE9 665E 9DEA 665D 9DEB 6664 9DEC 6667 9DED 6668 9DEE 665F 9DEF 6662 9DF0 6670 9DF1 6683 9DF2 6688 9DF3 668E 9DF4 6689 9DF5 6684 9DF6 6698 9DF7 669D 9DF8 66C1 9DF9 66B9 9DFA 66C9 9DFB 66BE 9DFC 66BC 9E40 66C4 9E41 66B8 9E42 66D6 9E43 66DA 9E44 66E0 9E45 663F 9E46 66E6 9E47 66E9 9E48 66F0 9E49 66F5 9E4A 66F7 9E4B 670F 9E4C 6716 9E4D 671E 9E4E 6726 9E4F 6727 9E50 9738 9E51 672E 9E52 673F 9E53 6736 9E54 6741 9E55 6738 9E56 6737 9E57 6746 9E58 675E 9E59 6760 9E5A 6759 9E5B 6763 9E5C 6764 9E5D 6789 9E5E 6770 9E5F 67A9 9E60 677C 9E61 676A 9E62 678C 9E63 678B 9E64 67A6 9E65 67A1 9E66 6785 9E67 67B7 9E68 67EF 9E69 67B4 9E6A 67EC 9E6B 67B3 9E6C 67E9 9E6D 67B8 9E6E 67E4 9E6F 67DE 9E70 67DD 9E71 67E2 9E72 67EE 9E73 67B9 9E74 67CE 9E75 67C6 9E76 67E7 9E77 6A9C 9E78 681E 9E79 6846 9E7A 6829 9E7B 6840 9E7C 684D 9E7D 6832 9E7E 684E 9E80 68B3 9E81 682B 9E82 6859 9E83 6863 9E84 6877 9E85 687F 9E86 689F 9E87 688F 9E88 68AD 9E89 6894 9E8A 689D 9E8B 689B 9E8C 6883 9E8D 6AAE 9E8E 68B9 9E8F 6874 9E90 68B5 9E91 68A0 9E92 68BA 9E93 690F 9E94 688D 9E95 687E 9E96 6901 9E97 68CA 9E98 6908 9E99 68D8 9E9A 6922 9E9B 6926 9E9C 68E1 9E9D 690C 9E9E 68CD 9E9F 68D4 9EA0 68E7 9EA1 68D5 9EA2 6936 9EA3 6912 9EA4 6904 9EA5 68D7 9EA6 68E3 9EA7 6925 9EA8 68F9 9EA9 68E0 9EAA 68EF 9EAB 6928 9EAC 692A 9EAD 691A 9EAE 6923 9EAF 6921 9EB0 68C6 9EB1 6979 9EB2 6977 9EB3 695C 9EB4 6978 9EB5 696B 9EB6 6954 9EB7 697E 9EB8 696E 9EB9 6939 9EBA 6974 9EBB 693D 9EBC 6959 9EBD 6930 9EBE 6961 9EBF 695E 9EC0 695D 9EC1 6981 9EC2 696A 9EC3 69B2 9EC4 69AE 9EC5 69D0 9EC6 69BF 9EC7 69C1 9EC8 69D3 9EC9 69BE 9ECA 69CE 9ECB 5BE8 9ECC 69CA 9ECD 69DD 9ECE 69BB 9ECF 69C3 9ED0 69A7 9ED1 6A2E 9ED2 6991 9ED3 69A0 9ED4 699C 9ED5 6995 9ED6 69B4 9ED7 69DE 9ED8 69E8 9ED9 6A02 9EDA 6A1B 9EDB 69FF 9EDC 6B0A 9EDD 69F9 9EDE 69F2 9EDF 69E7 9EE0 6A05 9EE1 69B1 9EE2 6A1E 9EE3 69ED 9EE4 6A14 9EE5 69EB 9EE6 6A0A 9EE7 6A12 9EE8 6AC1 9EE9 6A23 9EEA 6A13 9EEB 6A44 9EEC 6A0C 9EED 6A72 9EEE 6A36 9EEF 6A78 9EF0 6A47 9EF1 6A62 9EF2 6A59 9EF3 6A66 9EF4 6A48 9EF5 6A38 9EF6 6A22 9EF7 6A90 9EF8 6A8D 9EF9 6AA0 9EFA 6A84 9EFB 6AA2 9EFC 6AA3 9F40 6A97 9F41 8617 9F42 6ABB 9F43 6AC3 9F44 6AC2 9F45 6AB8 9F46 6AB3 9F47 6AAC 9F48 6ADE 9F49 6AD1 9F4A 6ADF 9F4B 6AAA 9F4C 6ADA 9F4D 6AEA 9F4E 6AFB 9F4F 6B05 9F50 8616 9F51 6AFA 9F52 6B12 9F53 6B16 9F54 9B31 9F55 6B1F 9F56 6B38 9F57 6B37 9F58 76DC 9F59 6B39 9F5A 98EE 9F5B 6B47 9F5C 6B43 9F5D 6B49 9F5E 6B50 9F5F 6B59 9F60 6B54 9F61 6B5B 9F62 6B5F 9F63 6B61 9F64 6B78 9F65 6B79 9F66 6B7F 9F67 6B80 9F68 6B84 9F69 6B83 9F6A 6B8D 9F6B 6B98 9F6C 6B95 9F6D 6B9E 9F6E 6BA4 9F6F 6BAA 9F70 6BAB 9F71 6BAF 9F72 6BB2 9F73 6BB1 9F74 6BB3 9F75 6BB7 9F76 6BBC 9F77 6BC6 9F78 6BCB 9F79 6BD3 9F7A 6BDF 9F7B 6BEC 9F7C 6BEB 9F7D 6BF3 9F7E 6BEF 9F80 9EBE 9F81 6C08 9F82 6C13 9F83 6C14 9F84 6C1B 9F85 6C24 9F86 6C23 9F87 6C5E 9F88 6C55 9F89 6C62 9F8A 6C6A 9F8B 6C82 9F8C 6C8D 9F8D 6C9A 9F8E 6C81 9F8F 6C9B 9F90 6C7E 9F91 6C68 9F92 6C73 9F93 6C92 9F94 6C90 9F95 6CC4 9F96 6CF1 9F97 6CD3 9F98 6CBD 9F99 6CD7 9F9A 6CC5 9F9B 6CDD 9F9C 6CAE 9F9D 6CB1 9F9E 6CBE 9F9F 6CBA 9FA0 6CDB 9FA1 6CEF 9FA2 6CD9 9FA3 6CEA 9FA4 6D1F 9FA5 884D 9FA6 6D36 9FA7 6D2B 9FA8 6D3D 9FA9 6D38 9FAA 6D19 9FAB 6D35 9FAC 6D33 9FAD 6D12 9FAE 6D0C 9FAF 6D63 9FB0 6D93 9FB1 6D64 9FB2 6D5A 9FB3 6D79 9FB4 6D59 9FB5 6D8E 9FB6 6D95 9FB7 6FE4 9FB8 6D85 9FB9 6DF9 9FBA 6E15 9FBB 6E0A 9FBC 6DB5 9FBD 6DC7 9FBE 6DE6 9FBF 6DB8 9FC0 6DC6 9FC1 6DEC 9FC2 6DDE 9FC3 6DCC 9FC4 6DE8 9FC5 6DD2 9FC6 6DC5 9FC7 6DFA 9FC8 6DD9 9FC9 6DE4 9FCA 6DD5 9FCB 6DEA 9FCC 6DEE 9FCD 6E2D 9FCE 6E6E 9FCF 6E2E 9FD0 6E19 9FD1 6E72 9FD2 6E5F 9FD3 6E3E 9FD4 6E23 9FD5 6E6B 9FD6 6E2B 9FD7 6E76 9FD8 6E4D 9FD9 6E1F 9FDA 6E43 9FDB 6E3A 9FDC 6E4E 9FDD 6E24 9FDE 6EFF 9FDF 6E1D 9FE0 6E38 9FE1 6E82 9FE2 6EAA 9FE3 6E98 9FE4 6EC9 9FE5 6EB7 9FE6 6ED3 9FE7 6EBD 9FE8 6EAF 9FE9 6EC4 9FEA 6EB2 9FEB 6ED4 9FEC 6ED5 9FED 6E8F 9FEE 6EA5 9FEF 6EC2 9FF0 6E9F 9FF1 6F41 9FF2 6F11 9FF3 704C 9FF4 6EEC 9FF5 6EF8 9FF6 6EFE 9FF7 6F3F 9FF8 6EF2 9FF9 6F31 9FFA 6EEF 9FFB 6F32 9FFC 6ECC A1 FF61 A2 FF62 A3 FF63 A4 FF64 A5 FF65 A6 FF66 A7 FF67 A8 FF68 A9 FF69 AA FF6A AB FF6B AC FF6C AD FF6D AE FF6E AF FF6F B0 FF70 B1 FF71 B2 FF72 B3 FF73 B4 FF74 B5 FF75 B6 FF76 B7 FF77 B8 FF78 B9 FF79 BA FF7A BB FF7B BC FF7C BD FF7D BE FF7E BF FF7F C0 FF80 C1 FF81 C2 FF82 C3 FF83 C4 FF84 C5 FF85 C6 FF86 C7 FF87 C8 FF88 C9 FF89 CA FF8A CB FF8B CC FF8C CD FF8D CE FF8E CF FF8F D0 FF90 D1 FF91 D2 FF92 D3 FF93 D4 FF94 D5 FF95 D6 FF96 D7 FF97 D8 FF98 D9 FF99 DA FF9A DB FF9B DC FF9C DD FF9D DE FF9E DF FF9F E040 6F3E E041 6F13 E042 6EF7 E043 6F86 E044 6F7A E045 6F78 E046 6F81 E047 6F80 E048 6F6F E049 6F5B E04A 6FF3 E04B 6F6D E04C 6F82 E04D 6F7C E04E 6F58 E04F 6F8E E050 6F91 E051 6FC2 E052 6F66 E053 6FB3 E054 6FA3 E055 6FA1 E056 6FA4 E057 6FB9 E058 6FC6 E059 6FAA E05A 6FDF E05B 6FD5 E05C 6FEC E05D 6FD4 E05E 6FD8 E05F 6FF1 E060 6FEE E061 6FDB E062 7009 E063 700B E064 6FFA E065 7011 E066 7001 E067 700F E068 6FFE E069 701B E06A 701A E06B 6F74 E06C 701D E06D 7018 E06E 701F E06F 7030 E070 703E E071 7032 E072 7051 E073 7063 E074 7099 E075 7092 E076 70AF E077 70F1 E078 70AC E079 70B8 E07A 70B3 E07B 70AE E07C 70DF E07D 70CB E07E 70DD E080 70D9 E081 7109 E082 70FD E083 711C E084 7119 E085 7165 E086 7155 E087 7188 E088 7166 E089 7162 E08A 714C E08B 7156 E08C 716C E08D 718F E08E 71FB E08F 7184 E090 7195 E091 71A8 E092 71AC E093 71D7 E094 71B9 E095 71BE E096 71D2 E097 71C9 E098 71D4 E099 71CE E09A 71E0 E09B 71EC E09C 71E7 E09D 71F5 E09E 71FC E09F 71F9 E0A0 71FF E0A1 720D E0A2 7210 E0A3 721B E0A4 7228 E0A5 722D E0A6 722C E0A7 7230 E0A8 7232 E0A9 723B E0AA 723C E0AB 723F E0AC 7240 E0AD 7246 E0AE 724B E0AF 7258 E0B0 7274 E0B1 727E E0B2 7282 E0B3 7281 E0B4 7287 E0B5 7292 E0B6 7296 E0B7 72A2 E0B8 72A7 E0B9 72B9 E0BA 72B2 E0BB 72C3 E0BC 72C6 E0BD 72C4 E0BE 72CE E0BF 72D2 E0C0 72E2 E0C1 72E0 E0C2 72E1 E0C3 72F9 E0C4 72F7 E0C5 500F E0C6 7317 E0C7 730A E0C8 731C E0C9 7316 E0CA 731D E0CB 7334 E0CC 732F E0CD 7329 E0CE 7325 E0CF 733E E0D0 734E E0D1 734F E0D2 9ED8 E0D3 7357 E0D4 736A E0D5 7368 E0D6 7370 E0D7 7378 E0D8 7375 E0D9 737B E0DA 737A E0DB 73C8 E0DC 73B3 E0DD 73CE E0DE 73BB E0DF 73C0 E0E0 73E5 E0E1 73EE E0E2 73DE E0E3 74A2 E0E4 7405 E0E5 746F E0E6 7425 E0E7 73F8 E0E8 7432 E0E9 743A E0EA 7455 E0EB 743F E0EC 745F E0ED 7459 E0EE 7441 E0EF 745C E0F0 7469 E0F1 7470 E0F2 7463 E0F3 746A E0F4 7476 E0F5 747E E0F6 748B E0F7 749E E0F8 74A7 E0F9 74CA E0FA 74CF E0FB 74D4 E0FC 73F1 E140 74E0 E141 74E3 E142 74E7 E143 74E9 E144 74EE E145 74F2 E146 74F0 E147 74F1 E148 74F8 E149 74F7 E14A 7504 E14B 7503 E14C 7505 E14D 750C E14E 750E E14F 750D E150 7515 E151 7513 E152 751E E153 7526 E154 752C E155 753C E156 7544 E157 754D E158 754A E159 7549 E15A 755B E15B 7546 E15C 755A E15D 7569 E15E 7564 E15F 7567 E160 756B E161 756D E162 7578 E163 7576 E164 7586 E165 7587 E166 7574 E167 758A E168 7589 E169 7582 E16A 7594 E16B 759A E16C 759D E16D 75A5 E16E 75A3 E16F 75C2 E170 75B3 E171 75C3 E172 75B5 E173 75BD E174 75B8 E175 75BC E176 75B1 E177 75CD E178 75CA E179 75D2 E17A 75D9 E17B 75E3 E17C 75DE E17D 75FE E17E 75FF E180 75FC E181 7601 E182 75F0 E183 75FA E184 75F2 E185 75F3 E186 760B E187 760D E188 7609 E189 761F E18A 7627 E18B 7620 E18C 7621 E18D 7622 E18E 7624 E18F 7634 E190 7630 E191 763B E192 7647 E193 7648 E194 7646 E195 765C E196 7658 E197 7661 E198 7662 E199 7668 E19A 7669 E19B 766A E19C 7667 E19D 766C E19E 7670 E19F 7672 E1A0 7676 E1A1 7678 E1A2 767C E1A3 7680 E1A4 7683 E1A5 7688 E1A6 768B E1A7 768E E1A8 7696 E1A9 7693 E1AA 7699 E1AB 769A E1AC 76B0 E1AD 76B4 E1AE 76B8 E1AF 76B9 E1B0 76BA E1B1 76C2 E1B2 76CD E1B3 76D6 E1B4 76D2 E1B5 76DE E1B6 76E1 E1B7 76E5 E1B8 76E7 E1B9 76EA E1BA 862F E1BB 76FB E1BC 7708 E1BD 7707 E1BE 7704 E1BF 7729 E1C0 7724 E1C1 771E E1C2 7725 E1C3 7726 E1C4 771B E1C5 7737 E1C6 7738 E1C7 7747 E1C8 775A E1C9 7768 E1CA 776B E1CB 775B E1CC 7765 E1CD 777F E1CE 777E E1CF 7779 E1D0 778E E1D1 778B E1D2 7791 E1D3 77A0 E1D4 779E E1D5 77B0 E1D6 77B6 E1D7 77B9 E1D8 77BF E1D9 77BC E1DA 77BD E1DB 77BB E1DC 77C7 E1DD 77CD E1DE 77D7 E1DF 77DA E1E0 77DC E1E1 77E3 E1E2 77EE E1E3 77FC E1E4 780C E1E5 7812 E1E6 7926 E1E7 7820 E1E8 792A E1E9 7845 E1EA 788E E1EB 7874 E1EC 7886 E1ED 787C E1EE 789A E1EF 788C E1F0 78A3 E1F1 78B5 E1F2 78AA E1F3 78AF E1F4 78D1 E1F5 78C6 E1F6 78CB E1F7 78D4 E1F8 78BE E1F9 78BC E1FA 78C5 E1FB 78CA E1FC 78EC E240 78E7 E241 78DA E242 78FD E243 78F4 E244 7907 E245 7912 E246 7911 E247 7919 E248 792C E249 792B E24A 7940 E24B 7960 E24C 7957 E24D 795F E24E 795A E24F 7955 E250 7953 E251 797A E252 797F E253 798A E254 799D E255 79A7 E256 9F4B E257 79AA E258 79AE E259 79B3 E25A 79B9 E25B 79BA E25C 79C9 E25D 79D5 E25E 79E7 E25F 79EC E260 79E1 E261 79E3 E262 7A08 E263 7A0D E264 7A18 E265 7A19 E266 7A20 E267 7A1F E268 7980 E269 7A31 E26A 7A3B E26B 7A3E E26C 7A37 E26D 7A43 E26E 7A57 E26F 7A49 E270 7A61 E271 7A62 E272 7A69 E273 9F9D E274 7A70 E275 7A79 E276 7A7D E277 7A88 E278 7A97 E279 7A95 E27A 7A98 E27B 7A96 E27C 7AA9 E27D 7AC8 E27E 7AB0 E280 7AB6 E281 7AC5 E282 7AC4 E283 7ABF E284 9083 E285 7AC7 E286 7ACA E287 7ACD E288 7ACF E289 7AD5 E28A 7AD3 E28B 7AD9 E28C 7ADA E28D 7ADD E28E 7AE1 E28F 7AE2 E290 7AE6 E291 7AED E292 7AF0 E293 7B02 E294 7B0F E295 7B0A E296 7B06 E297 7B33 E298 7B18 E299 7B19 E29A 7B1E E29B 7B35 E29C 7B28 E29D 7B36 E29E 7B50 E29F 7B7A E2A0 7B04 E2A1 7B4D E2A2 7B0B E2A3 7B4C E2A4 7B45 E2A5 7B75 E2A6 7B65 E2A7 7B74 E2A8 7B67 E2A9 7B70 E2AA 7B71 E2AB 7B6C E2AC 7B6E E2AD 7B9D E2AE 7B98 E2AF 7B9F E2B0 7B8D E2B1 7B9C E2B2 7B9A E2B3 7B8B E2B4 7B92 E2B5 7B8F E2B6 7B5D E2B7 7B99 E2B8 7BCB E2B9 7BC1 E2BA 7BCC E2BB 7BCF E2BC 7BB4 E2BD 7BC6 E2BE 7BDD E2BF 7BE9 E2C0 7C11 E2C1 7C14 E2C2 7BE6 E2C3 7BE5 E2C4 7C60 E2C5 7C00 E2C6 7C07 E2C7 7C13 E2C8 7BF3 E2C9 7BF7 E2CA 7C17 E2CB 7C0D E2CC 7BF6 E2CD 7C23 E2CE 7C27 E2CF 7C2A E2D0 7C1F E2D1 7C37 E2D2 7C2B E2D3 7C3D E2D4 7C4C E2D5 7C43 E2D6 7C54 E2D7 7C4F E2D8 7C40 E2D9 7C50 E2DA 7C58 E2DB 7C5F E2DC 7C64 E2DD 7C56 E2DE 7C65 E2DF 7C6C E2E0 7C75 E2E1 7C83 E2E2 7C90 E2E3 7CA4 E2E4 7CAD E2E5 7CA2 E2E6 7CAB E2E7 7CA1 E2E8 7CA8 E2E9 7CB3 E2EA 7CB2 E2EB 7CB1 E2EC 7CAE E2ED 7CB9 E2EE 7CBD E2EF 7CC0 E2F0 7CC5 E2F1 7CC2 E2F2 7CD8 E2F3 7CD2 E2F4 7CDC E2F5 7CE2 E2F6 9B3B E2F7 7CEF E2F8 7CF2 E2F9 7CF4 E2FA 7CF6 E2FB 7CFA E2FC 7D06 E340 7D02 E341 7D1C E342 7D15 E343 7D0A E344 7D45 E345 7D4B E346 7D2E E347 7D32 E348 7D3F E349 7D35 E34A 7D46 E34B 7D73 E34C 7D56 E34D 7D4E E34E 7D72 E34F 7D68 E350 7D6E E351 7D4F E352 7D63 E353 7D93 E354 7D89 E355 7D5B E356 7D8F E357 7D7D E358 7D9B E359 7DBA E35A 7DAE E35B 7DA3 E35C 7DB5 E35D 7DC7 E35E 7DBD E35F 7DAB E360 7E3D E361 7DA2 E362 7DAF E363 7DDC E364 7DB8 E365 7D9F E366 7DB0 E367 7DD8 E368 7DDD E369 7DE4 E36A 7DDE E36B 7DFB E36C 7DF2 E36D 7DE1 E36E 7E05 E36F 7E0A E370 7E23 E371 7E21 E372 7E12 E373 7E31 E374 7E1F E375 7E09 E376 7E0B E377 7E22 E378 7E46 E379 7E66 E37A 7E3B E37B 7E35 E37C 7E39 E37D 7E43 E37E 7E37 E380 7E32 E381 7E3A E382 7E67 E383 7E5D E384 7E56 E385 7E5E E386 7E59 E387 7E5A E388 7E79 E389 7E6A E38A 7E69 E38B 7E7C E38C 7E7B E38D 7E83 E38E 7DD5 E38F 7E7D E390 8FAE E391 7E7F E392 7E88 E393 7E89 E394 7E8C E395 7E92 E396 7E90 E397 7E93 E398 7E94 E399 7E96 E39A 7E8E E39B 7E9B E39C 7E9C E39D 7F38 E39E 7F3A E39F 7F45 E3A0 7F4C E3A1 7F4D E3A2 7F4E E3A3 7F50 E3A4 7F51 E3A5 7F55 E3A6 7F54 E3A7 7F58 E3A8 7F5F E3A9 7F60 E3AA 7F68 E3AB 7F69 E3AC 7F67 E3AD 7F78 E3AE 7F82 E3AF 7F86 E3B0 7F83 E3B1 7F88 E3B2 7F87 E3B3 7F8C E3B4 7F94 E3B5 7F9E E3B6 7F9D E3B7 7F9A E3B8 7FA3 E3B9 7FAF E3BA 7FB2 E3BB 7FB9 E3BC 7FAE E3BD 7FB6 E3BE 7FB8 E3BF 8B71 E3C0 7FC5 E3C1 7FC6 E3C2 7FCA E3C3 7FD5 E3C4 7FD4 E3C5 7FE1 E3C6 7FE6 E3C7 7FE9 E3C8 7FF3 E3C9 7FF9 E3CA 98DC E3CB 8006 E3CC 8004 E3CD 800B E3CE 8012 E3CF 8018 E3D0 8019 E3D1 801C E3D2 8021 E3D3 8028 E3D4 803F E3D5 803B E3D6 804A E3D7 8046 E3D8 8052 E3D9 8058 E3DA 805A E3DB 805F E3DC 8062 E3DD 8068 E3DE 8073 E3DF 8072 E3E0 8070 E3E1 8076 E3E2 8079 E3E3 807D E3E4 807F E3E5 8084 E3E6 8086 E3E7 8085 E3E8 809B E3E9 8093 E3EA 809A E3EB 80AD E3EC 5190 E3ED 80AC E3EE 80DB E3EF 80E5 E3F0 80D9 E3F1 80DD E3F2 80C4 E3F3 80DA E3F4 80D6 E3F5 8109 E3F6 80EF E3F7 80F1 E3F8 811B E3F9 8129 E3FA 8123 E3FB 812F E3FC 814B E440 968B E441 8146 E442 813E E443 8153 E444 8151 E445 80FC E446 8171 E447 816E E448 8165 E449 8166 E44A 8174 E44B 8183 E44C 8188 E44D 818A E44E 8180 E44F 8182 E450 81A0 E451 8195 E452 81A4 E453 81A3 E454 815F E455 8193 E456 81A9 E457 81B0 E458 81B5 E459 81BE E45A 81B8 E45B 81BD E45C 81C0 E45D 81C2 E45E 81BA E45F 81C9 E460 81CD E461 81D1 E462 81D9 E463 81D8 E464 81C8 E465 81DA E466 81DF E467 81E0 E468 81E7 E469 81FA E46A 81FB E46B 81FE E46C 8201 E46D 8202 E46E 8205 E46F 8207 E470 820A E471 820D E472 8210 E473 8216 E474 8229 E475 822B E476 8238 E477 8233 E478 8240 E479 8259 E47A 8258 E47B 825D E47C 825A E47D 825F E47E 8264 E480 8262 E481 8268 E482 826A E483 826B E484 822E E485 8271 E486 8277 E487 8278 E488 827E E489 828D E48A 8292 E48B 82AB E48C 829F E48D 82BB E48E 82AC E48F 82E1 E490 82E3 E491 82DF E492 82D2 E493 82F4 E494 82F3 E495 82FA E496 8393 E497 8303 E498 82FB E499 82F9 E49A 82DE E49B 8306 E49C 82DC E49D 8309 E49E 82D9 E49F 8335 E4A0 8334 E4A1 8316 E4A2 8332 E4A3 8331 E4A4 8340 E4A5 8339 E4A6 8350 E4A7 8345 E4A8 832F E4A9 832B E4AA 8317 E4AB 8318 E4AC 8385 E4AD 839A E4AE 83AA E4AF 839F E4B0 83A2 E4B1 8396 E4B2 8323 E4B3 838E E4B4 8387 E4B5 838A E4B6 837C E4B7 83B5 E4B8 8373 E4B9 8375 E4BA 83A0 E4BB 8389 E4BC 83A8 E4BD 83F4 E4BE 8413 E4BF 83EB E4C0 83CE E4C1 83FD E4C2 8403 E4C3 83D8 E4C4 840B E4C5 83C1 E4C6 83F7 E4C7 8407 E4C8 83E0 E4C9 83F2 E4CA 840D E4CB 8422 E4CC 8420 E4CD 83BD E4CE 8438 E4CF 8506 E4D0 83FB E4D1 846D E4D2 842A E4D3 843C E4D4 855A E4D5 8484 E4D6 8477 E4D7 846B E4D8 84AD E4D9 846E E4DA 8482 E4DB 8469 E4DC 8446 E4DD 842C E4DE 846F E4DF 8479 E4E0 8435 E4E1 84CA E4E2 8462 E4E3 84B9 E4E4 84BF E4E5 849F E4E6 84D9 E4E7 84CD E4E8 84BB E4E9 84DA E4EA 84D0 E4EB 84C1 E4EC 84C6 E4ED 84D6 E4EE 84A1 E4EF 8521 E4F0 84FF E4F1 84F4 E4F2 8517 E4F3 8518 E4F4 852C E4F5 851F E4F6 8515 E4F7 8514 E4F8 84FC E4F9 8540 E4FA 8563 E4FB 8558 E4FC 8548 E540 8541 E541 8602 E542 854B E543 8555 E544 8580 E545 85A4 E546 8588 E547 8591 E548 858A E549 85A8 E54A 856D E54B 8594 E54C 859B E54D 85EA E54E 8587 E54F 859C E550 8577 E551 857E E552 8590 E553 85C9 E554 85BA E555 85CF E556 85B9 E557 85D0 E558 85D5 E559 85DD E55A 85E5 E55B 85DC E55C 85F9 E55D 860A E55E 8613 E55F 860B E560 85FE E561 85FA E562 8606 E563 8622 E564 861A E565 8630 E566 863F E567 864D E568 4E55 E569 8654 E56A 865F E56B 8667 E56C 8671 E56D 8693 E56E 86A3 E56F 86A9 E570 86AA E571 868B E572 868C E573 86B6 E574 86AF E575 86C4 E576 86C6 E577 86B0 E578 86C9 E579 8823 E57A 86AB E57B 86D4 E57C 86DE E57D 86E9 E57E 86EC E580 86DF E581 86DB E582 86EF E583 8712 E584 8706 E585 8708 E586 8700 E587 8703 E588 86FB E589 8711 E58A 8709 E58B 870D E58C 86F9 E58D 870A E58E 8734 E58F 873F E590 8737 E591 873B E592 8725 E593 8729 E594 871A E595 8760 E596 875F E597 8778 E598 874C E599 874E E59A 8774 E59B 8757 E59C 8768 E59D 876E E59E 8759 E59F 8753 E5A0 8763 E5A1 876A E5A2 8805 E5A3 87A2 E5A4 879F E5A5 8782 E5A6 87AF E5A7 87CB E5A8 87BD E5A9 87C0 E5AA 87D0 E5AB 96D6 E5AC 87AB E5AD 87C4 E5AE 87B3 E5AF 87C7 E5B0 87C6 E5B1 87BB E5B2 87EF E5B3 87F2 E5B4 87E0 E5B5 880F E5B6 880D E5B7 87FE E5B8 87F6 E5B9 87F7 E5BA 880E E5BB 87D2 E5BC 8811 E5BD 8816 E5BE 8815 E5BF 8822 E5C0 8821 E5C1 8831 E5C2 8836 E5C3 8839 E5C4 8827 E5C5 883B E5C6 8844 E5C7 8842 E5C8 8852 E5C9 8859 E5CA 885E E5CB 8862 E5CC 886B E5CD 8881 E5CE 887E E5CF 889E E5D0 8875 E5D1 887D E5D2 88B5 E5D3 8872 E5D4 8882 E5D5 8897 E5D6 8892 E5D7 88AE E5D8 8899 E5D9 88A2 E5DA 888D E5DB 88A4 E5DC 88B0 E5DD 88BF E5DE 88B1 E5DF 88C3 E5E0 88C4 E5E1 88D4 E5E2 88D8 E5E3 88D9 E5E4 88DD E5E5 88F9 E5E6 8902 E5E7 88FC E5E8 88F4 E5E9 88E8 E5EA 88F2 E5EB 8904 E5EC 890C E5ED 890A E5EE 8913 E5EF 8943 E5F0 891E E5F1 8925 E5F2 892A E5F3 892B E5F4 8941 E5F5 8944 E5F6 893B E5F7 8936 E5F8 8938 E5F9 894C E5FA 891D E5FB 8960 E5FC 895E E640 8966 E641 8964 E642 896D E643 896A E644 896F E645 8974 E646 8977 E647 897E E648 8983 E649 8988 E64A 898A E64B 8993 E64C 8998 E64D 89A1 E64E 89A9 E64F 89A6 E650 89AC E651 89AF E652 89B2 E653 89BA E654 89BD E655 89BF E656 89C0 E657 89DA E658 89DC E659 89DD E65A 89E7 E65B 89F4 E65C 89F8 E65D 8A03 E65E 8A16 E65F 8A10 E660 8A0C E661 8A1B E662 8A1D E663 8A25 E664 8A36 E665 8A41 E666 8A5B E667 8A52 E668 8A46 E669 8A48 E66A 8A7C E66B 8A6D E66C 8A6C E66D 8A62 E66E 8A85 E66F 8A82 E670 8A84 E671 8AA8 E672 8AA1 E673 8A91 E674 8AA5 E675 8AA6 E676 8A9A E677 8AA3 E678 8AC4 E679 8ACD E67A 8AC2 E67B 8ADA E67C 8AEB E67D 8AF3 E67E 8AE7 E680 8AE4 E681 8AF1 E682 8B14 E683 8AE0 E684 8AE2 E685 8AF7 E686 8ADE E687 8ADB E688 8B0C E689 8B07 E68A 8B1A E68B 8AE1 E68C 8B16 E68D 8B10 E68E 8B17 E68F 8B20 E690 8B33 E691 97AB E692 8B26 E693 8B2B E694 8B3E E695 8B28 E696 8B41 E697 8B4C E698 8B4F E699 8B4E E69A 8B49 E69B 8B56 E69C 8B5B E69D 8B5A E69E 8B6B E69F 8B5F E6A0 8B6C E6A1 8B6F E6A2 8B74 E6A3 8B7D E6A4 8B80 E6A5 8B8C E6A6 8B8E E6A7 8B92 E6A8 8B93 E6A9 8B96 E6AA 8B99 E6AB 8B9A E6AC 8C3A E6AD 8C41 E6AE 8C3F E6AF 8C48 E6B0 8C4C E6B1 8C4E E6B2 8C50 E6B3 8C55 E6B4 8C62 E6B5 8C6C E6B6 8C78 E6B7 8C7A E6B8 8C82 E6B9 8C89 E6BA 8C85 E6BB 8C8A E6BC 8C8D E6BD 8C8E E6BE 8C94 E6BF 8C7C E6C0 8C98 E6C1 621D E6C2 8CAD E6C3 8CAA E6C4 8CBD E6C5 8CB2 E6C6 8CB3 E6C7 8CAE E6C8 8CB6 E6C9 8CC8 E6CA 8CC1 E6CB 8CE4 E6CC 8CE3 E6CD 8CDA E6CE 8CFD E6CF 8CFA E6D0 8CFB E6D1 8D04 E6D2 8D05 E6D3 8D0A E6D4 8D07 E6D5 8D0F E6D6 8D0D E6D7 8D10 E6D8 9F4E E6D9 8D13 E6DA 8CCD E6DB 8D14 E6DC 8D16 E6DD 8D67 E6DE 8D6D E6DF 8D71 E6E0 8D73 E6E1 8D81 E6E2 8D99 E6E3 8DC2 E6E4 8DBE E6E5 8DBA E6E6 8DCF E6E7 8DDA E6E8 8DD6 E6E9 8DCC E6EA 8DDB E6EB 8DCB E6EC 8DEA E6ED 8DEB E6EE 8DDF E6EF 8DE3 E6F0 8DFC E6F1 8E08 E6F2 8E09 E6F3 8DFF E6F4 8E1D E6F5 8E1E E6F6 8E10 E6F7 8E1F E6F8 8E42 E6F9 8E35 E6FA 8E30 E6FB 8E34 E6FC 8E4A E740 8E47 E741 8E49 E742 8E4C E743 8E50 E744 8E48 E745 8E59 E746 8E64 E747 8E60 E748 8E2A E749 8E63 E74A 8E55 E74B 8E76 E74C 8E72 E74D 8E7C E74E 8E81 E74F 8E87 E750 8E85 E751 8E84 E752 8E8B E753 8E8A E754 8E93 E755 8E91 E756 8E94 E757 8E99 E758 8EAA E759 8EA1 E75A 8EAC E75B 8EB0 E75C 8EC6 E75D 8EB1 E75E 8EBE E75F 8EC5 E760 8EC8 E761 8ECB E762 8EDB E763 8EE3 E764 8EFC E765 8EFB E766 8EEB E767 8EFE E768 8F0A E769 8F05 E76A 8F15 E76B 8F12 E76C 8F19 E76D 8F13 E76E 8F1C E76F 8F1F E770 8F1B E771 8F0C E772 8F26 E773 8F33 E774 8F3B E775 8F39 E776 8F45 E777 8F42 E778 8F3E E779 8F4C E77A 8F49 E77B 8F46 E77C 8F4E E77D 8F57 E77E 8F5C E780 8F62 E781 8F63 E782 8F64 E783 8F9C E784 8F9F E785 8FA3 E786 8FAD E787 8FAF E788 8FB7 E789 8FDA E78A 8FE5 E78B 8FE2 E78C 8FEA E78D 8FEF E78E 9087 E78F 8FF4 E790 9005 E791 8FF9 E792 8FFA E793 9011 E794 9015 E795 9021 E796 900D E797 901E E798 9016 E799 900B E79A 9027 E79B 9036 E79C 9035 E79D 9039 E79E 8FF8 E79F 904F E7A0 9050 E7A1 9051 E7A2 9052 E7A3 900E E7A4 9049 E7A5 903E E7A6 9056 E7A7 9058 E7A8 905E E7A9 9068 E7AA 906F E7AB 9076 E7AC 96A8 E7AD 9072 E7AE 9082 E7AF 907D E7B0 9081 E7B1 9080 E7B2 908A E7B3 9089 E7B4 908F E7B5 90A8 E7B6 90AF E7B7 90B1 E7B8 90B5 E7B9 90E2 E7BA 90E4 E7BB 6248 E7BC 90DB E7BD 9102 E7BE 9112 E7BF 9119 E7C0 9132 E7C1 9130 E7C2 914A E7C3 9156 E7C4 9158 E7C5 9163 E7C6 9165 E7C7 9169 E7C8 9173 E7C9 9172 E7CA 918B E7CB 9189 E7CC 9182 E7CD 91A2 E7CE 91AB E7CF 91AF E7D0 91AA E7D1 91B5 E7D2 91B4 E7D3 91BA E7D4 91C0 E7D5 91C1 E7D6 91C9 E7D7 91CB E7D8 91D0 E7D9 91D6 E7DA 91DF E7DB 91E1 E7DC 91DB E7DD 91FC E7DE 91F5 E7DF 91F6 E7E0 921E E7E1 91FF E7E2 9214 E7E3 922C E7E4 9215 E7E5 9211 E7E6 925E E7E7 9257 E7E8 9245 E7E9 9249 E7EA 9264 E7EB 9248 E7EC 9295 E7ED 923F E7EE 924B E7EF 9250 E7F0 929C E7F1 9296 E7F2 9293 E7F3 929B E7F4 925A E7F5 92CF E7F6 92B9 E7F7 92B7 E7F8 92E9 E7F9 930F E7FA 92FA E7FB 9344 E7FC 932E E840 9319 E841 9322 E842 931A E843 9323 E844 933A E845 9335 E846 933B E847 935C E848 9360 E849 937C E84A 936E E84B 9356 E84C 93B0 E84D 93AC E84E 93AD E84F 9394 E850 93B9 E851 93D6 E852 93D7 E853 93E8 E854 93E5 E855 93D8 E856 93C3 E857 93DD E858 93D0 E859 93C8 E85A 93E4 E85B 941A E85C 9414 E85D 9413 E85E 9403 E85F 9407 E860 9410 E861 9436 E862 942B E863 9435 E864 9421 E865 943A E866 9441 E867 9452 E868 9444 E869 945B E86A 9460 E86B 9462 E86C 945E E86D 946A E86E 9229 E86F 9470 E870 9475 E871 9477 E872 947D E873 945A E874 947C E875 947E E876 9481 E877 947F E878 9582 E879 9587 E87A 958A E87B 9594 E87C 9596 E87D 9598 E87E 9599 E880 95A0 E881 95A8 E882 95A7 E883 95AD E884 95BC E885 95BB E886 95B9 E887 95BE E888 95CA E889 6FF6 E88A 95C3 E88B 95CD E88C 95CC E88D 95D5 E88E 95D4 E88F 95D6 E890 95DC E891 95E1 E892 95E5 E893 95E2 E894 9621 E895 9628 E896 962E E897 962F E898 9642 E899 964C E89A 964F E89B 964B E89C 9677 E89D 965C E89E 965E E89F 965D E8A0 965F E8A1 9666 E8A2 9672 E8A3 966C E8A4 968D E8A5 9698 E8A6 9695 E8A7 9697 E8A8 96AA E8A9 96A7 E8AA 96B1 E8AB 96B2 E8AC 96B0 E8AD 96B4 E8AE 96B6 E8AF 96B8 E8B0 96B9 E8B1 96CE E8B2 96CB E8B3 96C9 E8B4 96CD E8B5 894D E8B6 96DC E8B7 970D E8B8 96D5 E8B9 96F9 E8BA 9704 E8BB 9706 E8BC 9708 E8BD 9713 E8BE 970E E8BF 9711 E8C0 970F E8C1 9716 E8C2 9719 E8C3 9724 E8C4 972A E8C5 9730 E8C6 9739 E8C7 973D E8C8 973E E8C9 9744 E8CA 9746 E8CB 9748 E8CC 9742 E8CD 9749 E8CE 975C E8CF 9760 E8D0 9764 E8D1 9766 E8D2 9768 E8D3 52D2 E8D4 976B E8D5 9771 E8D6 9779 E8D7 9785 E8D8 977C E8D9 9781 E8DA 977A E8DB 9786 E8DC 978B E8DD 978F E8DE 9790 E8DF 979C E8E0 97A8 E8E1 97A6 E8E2 97A3 E8E3 97B3 E8E4 97B4 E8E5 97C3 E8E6 97C6 E8E7 97C8 E8E8 97CB E8E9 97DC E8EA 97ED E8EB 9F4F E8EC 97F2 E8ED 7ADF E8EE 97F6 E8EF 97F5 E8F0 980F E8F1 980C E8F2 9838 E8F3 9824 E8F4 9821 E8F5 9837 E8F6 983D E8F7 9846 E8F8 984F E8F9 984B E8FA 986B E8FB 986F E8FC 9870 E940 9871 E941 9874 E942 9873 E943 98AA E944 98AF E945 98B1 E946 98B6 E947 98C4 E948 98C3 E949 98C6 E94A 98E9 E94B 98EB E94C 9903 E94D 9909 E94E 9912 E94F 9914 E950 9918 E951 9921 E952 991D E953 991E E954 9924 E955 9920 E956 992C E957 992E E958 993D E959 993E E95A 9942 E95B 9949 E95C 9945 E95D 9950 E95E 994B E95F 9951 E960 9952 E961 994C E962 9955 E963 9997 E964 9998 E965 99A5 E966 99AD E967 99AE E968 99BC E969 99DF E96A 99DB E96B 99DD E96C 99D8 E96D 99D1 E96E 99ED E96F 99EE E970 99F1 E971 99F2 E972 99FB E973 99F8 E974 9A01 E975 9A0F E976 9A05 E977 99E2 E978 9A19 E979 9A2B E97A 9A37 E97B 9A45 E97C 9A42 E97D 9A40 E97E 9A43 E980 9A3E E981 9A55 E982 9A4D E983 9A5B E984 9A57 E985 9A5F E986 9A62 E987 9A65 E988 9A64 E989 9A69 E98A 9A6B E98B 9A6A E98C 9AAD E98D 9AB0 E98E 9ABC E98F 9AC0 E990 9ACF E991 9AD1 E992 9AD3 E993 9AD4 E994 9ADE E995 9ADF E996 9AE2 E997 9AE3 E998 9AE6 E999 9AEF E99A 9AEB E99B 9AEE E99C 9AF4 E99D 9AF1 E99E 9AF7 E99F 9AFB E9A0 9B06 E9A1 9B18 E9A2 9B1A E9A3 9B1F E9A4 9B22 E9A5 9B23 E9A6 9B25 E9A7 9B27 E9A8 9B28 E9A9 9B29 E9AA 9B2A E9AB 9B2E E9AC 9B2F E9AD 9B32 E9AE 9B44 E9AF 9B43 E9B0 9B4F E9B1 9B4D E9B2 9B4E E9B3 9B51 E9B4 9B58 E9B5 9B74 E9B6 9B93 E9B7 9B83 E9B8 9B91 E9B9 9B96 E9BA 9B97 E9BB 9B9F E9BC 9BA0 E9BD 9BA8 E9BE 9BB4 E9BF 9BC0 E9C0 9BCA E9C1 9BB9 E9C2 9BC6 E9C3 9BCF E9C4 9BD1 E9C5 9BD2 E9C6 9BE3 E9C7 9BE2 E9C8 9BE4 E9C9 9BD4 E9CA 9BE1 E9CB 9C3A E9CC 9BF2 E9CD 9BF1 E9CE 9BF0 E9CF 9C15 E9D0 9C14 E9D1 9C09 E9D2 9C13 E9D3 9C0C E9D4 9C06 E9D5 9C08 E9D6 9C12 E9D7 9C0A E9D8 9C04 E9D9 9C2E E9DA 9C1B E9DB 9C25 E9DC 9C24 E9DD 9C21 E9DE 9C30 E9DF 9C47 E9E0 9C32 E9E1 9C46 E9E2 9C3E E9E3 9C5A E9E4 9C60 E9E5 9C67 E9E6 9C76 E9E7 9C78 E9E8 9CE7 E9E9 9CEC E9EA 9CF0 E9EB 9D09 E9EC 9D08 E9ED 9CEB E9EE 9D03 E9EF 9D06 E9F0 9D2A E9F1 9D26 E9F2 9DAF E9F3 9D23 E9F4 9D1F E9F5 9D44 E9F6 9D15 E9F7 9D12 E9F8 9D41 E9F9 9D3F E9FA 9D3E E9FB 9D46 E9FC 9D48 EA40 9D5D EA41 9D5E EA42 9D64 EA43 9D51 EA44 9D50 EA45 9D59 EA46 9D72 EA47 9D89 EA48 9D87 EA49 9DAB EA4A 9D6F EA4B 9D7A EA4C 9D9A EA4D 9DA4 EA4E 9DA9 EA4F 9DB2 EA50 9DC4 EA51 9DC1 EA52 9DBB EA53 9DB8 EA54 9DBA EA55 9DC6 EA56 9DCF EA57 9DC2 EA58 9DD9 EA59 9DD3 EA5A 9DF8 EA5B 9DE6 EA5C 9DED EA5D 9DEF EA5E 9DFD EA5F 9E1A EA60 9E1B EA61 9E1E EA62 9E75 EA63 9E79 EA64 9E7D EA65 9E81 EA66 9E88 EA67 9E8B EA68 9E8C EA69 9E92 EA6A 9E95 EA6B 9E91 EA6C 9E9D EA6D 9EA5 EA6E 9EA9 EA6F 9EB8 EA70 9EAA EA71 9EAD EA72 9761 EA73 9ECC EA74 9ECE EA75 9ECF EA76 9ED0 EA77 9ED4 EA78 9EDC EA79 9EDE EA7A 9EDD EA7B 9EE0 EA7C 9EE5 EA7D 9EE8 EA7E 9EEF EA80 9EF4 EA81 9EF6 EA82 9EF7 EA83 9EF9 EA84 9EFB EA85 9EFC EA86 9EFD EA87 9F07 EA88 9F08 EA89 76B7 EA8A 9F15 EA8B 9F21 EA8C 9F2C EA8D 9F3E EA8E 9F4A EA8F 9F52 EA90 9F54 EA91 9F63 EA92 9F5F EA93 9F60 EA94 9F61 EA95 9F66 EA96 9F67 EA97 9F6C EA98 9F6A EA99 9F77 EA9A 9F72 EA9B 9F76 EA9C 9F95 EA9D 9F9C EA9E 9FA0 EA9F 582F EAA0 69C7 EAA1 9059 EAA2 7464 EAA3 51DC EAA4 7199
72,777
7,106
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_setcomps.py
doctests = """ ########### Tests mostly copied from test_listcomps.py ############ Test simple loop with conditional >>> sum({i*i for i in range(100) if i&1 == 1}) 166650 Test simple case >>> {2*y + x + 1 for x in (0,) for y in (1,)} {3} Test simple nesting >>> list(sorted({(i,j) for i in range(3) for j in range(4)})) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)] Test nesting with the inner expression dependent on the outer >>> list(sorted({(i,j) for i in range(4) for j in range(i)})) [(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2)] Make sure the induction variable is not exposed >>> i = 20 >>> sum({i*i for i in range(100)}) 328350 >>> i 20 Verify that syntax error's are raised for setcomps used as lvalues >>> {y for y in (1,2)} = 10 # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... SyntaxError: ... >>> {y for y in (1,2)} += 10 # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... SyntaxError: ... Make a nested set comprehension that acts like set(range()) >>> def srange(n): ... return {i for i in range(n)} >>> list(sorted(srange(10))) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Same again, only as a lambda expression instead of a function definition >>> lrange = lambda n: {i for i in range(n)} >>> list(sorted(lrange(10))) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Generators can call other generators: >>> def grange(n): ... for x in {i for i in range(n)}: ... yield x >>> list(sorted(grange(5))) [0, 1, 2, 3, 4] Make sure that None is a valid return value >>> {None for i in range(10)} {None} ########### Tests for various scoping corner cases ############ Return lambdas that use the iteration variable as a default argument >>> items = {(lambda i=i: i) for i in range(5)} >>> {x() for x in items} == set(range(5)) True Same again, only this time as a closure variable >>> items = {(lambda: i) for i in range(5)} >>> {x() for x in items} {4} Another way to test that the iteration variable is local to the list comp >>> items = {(lambda: i) for i in range(5)} >>> i = 20 >>> {x() for x in items} {4} And confirm that a closure can jump over the list comp scope >>> items = {(lambda: y) for i in range(5)} >>> y = 2 >>> {x() for x in items} {2} We also repeat each of the above scoping tests inside a function >>> def test_func(): ... items = {(lambda i=i: i) for i in range(5)} ... return {x() for x in items} >>> test_func() == set(range(5)) True >>> def test_func(): ... items = {(lambda: i) for i in range(5)} ... return {x() for x in items} >>> test_func() {4} >>> def test_func(): ... items = {(lambda: i) for i in range(5)} ... i = 20 ... return {x() for x in items} >>> test_func() {4} >>> def test_func(): ... items = {(lambda: y) for i in range(5)} ... y = 2 ... return {x() for x in items} >>> test_func() {2} """ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys from test import support from test import test_setcomps support.run_doctest(test_setcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): support.run_doctest(test_setcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) if __name__ == "__main__": test_main(verbose=True)
3,792
152
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/final_b.py
""" Fodder for module finalization tests in test_module. """ import shutil import test.final_a x = 'b' class C: def __del__(self): # Inspect module globals and builtins print("x =", x) print("final_a.x =", test.final_a.x) print("shutil.rmtree =", getattr(shutil.rmtree, '__name__', None)) print("len =", getattr(len, '__name__', None)) c = C() _underscored = C()
411
20
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_decimal.py
# Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price <eprice at tjhsst.edu> # and Facundo Batista <facundo at taniquetil.com.ar> # and Raymond Hettinger <python at rcn.com> # and Aahz (aahz at pobox.com) # and Tim Peters """ These are the test cases for the Decimal module. There are two groups of tests, Arithmetic and Behaviour. The former test the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter test the pythonic behaviour according to PEP 327. Cowlishaw's tests can be downloaded from: http://speleotrove.com/decimal/dectest.zip This test module can be called from command line with one parameter (Arithmetic or Behaviour) to test each part, or without parameter to test both parts. If you're working through IDLE, you can import this test module and call test_main() with the corresponding argument. """ import os import sys import math import operator import warnings import pickle, copy import unittest import numbers import locale from test.support import (run_unittest, run_doctest, is_resource_enabled, requires_IEEE_754, requires_docstrings) from test.support import (check_warnings, import_fresh_module, TestFailed, run_with_locale, cpython_only) import random import time import warnings import inspect try: import _thread import threading except ImportError: threading = None if __name__ == 'PYOBJ.COM': import decimal import fractions C = import_fresh_module('decimal', fresh=['_decimal']) P = import_fresh_module('decimal', blocked=['_decimal']) orig_sys_decimal = sys.modules['decimal'] # fractions module must import the correct decimal module. cfractions = import_fresh_module('fractions', fresh=['fractions']) sys.modules['decimal'] = P pfractions = import_fresh_module('fractions', fresh=['fractions']) sys.modules['decimal'] = C fractions = {C:cfractions, P:pfractions} sys.modules['decimal'] = orig_sys_decimal # Useful Test Constant Signals = { C: tuple(C.getcontext().flags.keys()) if C else None, P: tuple(P.getcontext().flags.keys()) } # Signals ordered with respect to precedence: when an operation # produces multiple signals, signals occurring later in the list # should be handled before those occurring earlier in the list. OrderedSignals = { C: [C.Clamped, C.Rounded, C.Inexact, C.Subnormal, C.Underflow, C.Overflow, C.DivisionByZero, C.InvalidOperation, C.FloatOperation] if C else None, P: [P.Clamped, P.Rounded, P.Inexact, P.Subnormal, P.Underflow, P.Overflow, P.DivisionByZero, P.InvalidOperation, P.FloatOperation] } def assert_signals(cls, context, attr, expected): d = getattr(context, attr) cls.assertTrue(all(d[s] if s in expected else not d[s] for s in d)) ROUND_UP = P.ROUND_UP ROUND_DOWN = P.ROUND_DOWN ROUND_CEILING = P.ROUND_CEILING ROUND_FLOOR = P.ROUND_FLOOR ROUND_HALF_UP = P.ROUND_HALF_UP ROUND_HALF_DOWN = P.ROUND_HALF_DOWN ROUND_HALF_EVEN = P.ROUND_HALF_EVEN ROUND_05UP = P.ROUND_05UP RoundingModes = [ ROUND_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR, ROUND_HALF_UP, ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_05UP ] # Tests are built around these assumed context defaults. # test_main() restores the original context. ORIGINAL_CONTEXT = { C: C.getcontext().copy() if C else None, P: P.getcontext().copy() } def init(m): if not m: return DefaultTestContext = m.Context( prec=9, rounding=ROUND_HALF_EVEN, traps=dict.fromkeys(Signals[m], 0) ) m.setcontext(DefaultTestContext) directory = '/zip/.python/test/decimaltestdata' skip_expected = not os.path.isdir(directory) # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. EXTENDEDERRORTEST = False # Test extra functionality in the C version (-DEXTRA_FUNCTIONALITY). EXTRA_FUNCTIONALITY = True if hasattr(C, 'DecClamped') else False requires_extra_functionality = unittest.skipUnless( EXTRA_FUNCTIONALITY, "test requires build with -DEXTRA_FUNCTIONALITY") skip_if_extra_functionality = unittest.skipIf( EXTRA_FUNCTIONALITY, "test requires regular build") class IBMTestCases(unittest.TestCase): """Class which tests the Decimal class against the IBM test cases.""" def setUp(self): self.context = self.decimal.Context() self.readcontext = self.decimal.Context() self.ignore_list = ['#'] # List of individual .decTest test ids that correspond to tests that # we're skipping for one reason or another. self.skipped_test_ids = set([ # Skip implementation-specific scaleb tests. 'scbx164', 'scbx165', # For some operations (currently exp, ln, log10, power), the decNumber # reference implementation imposes additional restrictions on the context # and operands. These restrictions are not part of the specification; # however, the effect of these restrictions does show up in some of the # testcases. We skip testcases that violate these restrictions, since # Decimal behaves differently from decNumber for these testcases so these # testcases would otherwise fail. 'expx901', 'expx902', 'expx903', 'expx905', 'lnx901', 'lnx902', 'lnx903', 'lnx905', 'logx901', 'logx902', 'logx903', 'logx905', 'powx1183', 'powx1184', 'powx4001', 'powx4002', 'powx4003', 'powx4005', 'powx4008', 'powx4010', 'powx4012', 'powx4014', ]) if self.decimal == C: # status has additional Subnormal, Underflow self.skipped_test_ids.add('pwsx803') self.skipped_test_ids.add('pwsx805') # Correct rounding (skipped for decNumber, too) self.skipped_test_ids.add('powx4302') self.skipped_test_ids.add('powx4303') self.skipped_test_ids.add('powx4342') self.skipped_test_ids.add('powx4343') # http://bugs.python.org/issue7049 self.skipped_test_ids.add('pwmx325') self.skipped_test_ids.add('pwmx326') # Map test directives to setter functions. self.ChangeDict = {'precision' : self.change_precision, 'rounding' : self.change_rounding_method, 'maxexponent' : self.change_max_exponent, 'minexponent' : self.change_min_exponent, 'clamp' : self.change_clamp} # Name adapter to be able to change the Decimal and Context # interface without changing the test files from Cowlishaw. self.NameAdapter = {'and':'logical_and', 'apply':'_apply', 'class':'number_class', 'comparesig':'compare_signal', 'comparetotal':'compare_total', 'comparetotmag':'compare_total_mag', 'copy':'copy_decimal', 'copyabs':'copy_abs', 'copynegate':'copy_negate', 'copysign':'copy_sign', 'divideint':'divide_int', 'invert':'logical_invert', 'iscanonical':'is_canonical', 'isfinite':'is_finite', 'isinfinite':'is_infinite', 'isnan':'is_nan', 'isnormal':'is_normal', 'isqnan':'is_qnan', 'issigned':'is_signed', 'issnan':'is_snan', 'issubnormal':'is_subnormal', 'iszero':'is_zero', 'maxmag':'max_mag', 'minmag':'min_mag', 'nextminus':'next_minus', 'nextplus':'next_plus', 'nexttoward':'next_toward', 'or':'logical_or', 'reduce':'normalize', 'remaindernear':'remainder_near', 'samequantum':'same_quantum', 'squareroot':'sqrt', 'toeng':'to_eng_string', 'tointegral':'to_integral_value', 'tointegralx':'to_integral_exact', 'tosci':'to_sci_string', 'xor':'logical_xor'} # Map test-case names to roundings. self.RoundingDict = {'ceiling' : ROUND_CEILING, 'down' : ROUND_DOWN, 'floor' : ROUND_FLOOR, 'half_down' : ROUND_HALF_DOWN, 'half_even' : ROUND_HALF_EVEN, 'half_up' : ROUND_HALF_UP, 'up' : ROUND_UP, '05up' : ROUND_05UP} # Map the test cases' error names to the actual errors. self.ErrorNames = {'clamped' : self.decimal.Clamped, 'conversion_syntax' : self.decimal.InvalidOperation, 'division_by_zero' : self.decimal.DivisionByZero, 'division_impossible' : self.decimal.InvalidOperation, 'division_undefined' : self.decimal.InvalidOperation, 'inexact' : self.decimal.Inexact, 'invalid_context' : self.decimal.InvalidOperation, 'invalid_operation' : self.decimal.InvalidOperation, 'overflow' : self.decimal.Overflow, 'rounded' : self.decimal.Rounded, 'subnormal' : self.decimal.Subnormal, 'underflow' : self.decimal.Underflow} # The following functions return True/False rather than a # Decimal instance. self.LogicalFunctions = ('is_canonical', 'is_finite', 'is_infinite', 'is_nan', 'is_normal', 'is_qnan', 'is_signed', 'is_snan', 'is_subnormal', 'is_zero', 'same_quantum') def read_unlimited(self, v, context): """Work around the limitations of the 32-bit _decimal version. The guaranteed maximum values for prec, Emax etc. are 425000000, but higher values usually work, except for rare corner cases. In particular, all of the IBM tests pass with maximum values of 1070000000.""" if self.decimal == C and self.decimal.MAX_EMAX == 425000000: self.readcontext._unsafe_setprec(1070000000) self.readcontext._unsafe_setemax(1070000000) self.readcontext._unsafe_setemin(-1070000000) return self.readcontext.create_decimal(v) else: return self.decimal.Decimal(v, context) def eval_file(self, file): global skip_expected if skip_expected: raise unittest.SkipTest with open(file) as f: for line in f: line = line.replace('\r\n', '').replace('\n', '') #print line try: t = self.eval_line(line) except self.decimal.DecimalException as exception: #Exception raised where there shouldn't have been one. self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line) def eval_line(self, s): if s.find(' -> ') >= 0 and s[:2] != '--' and not s.startswith(' --'): s = (s.split('->')[0] + '->' + s.split('->')[1].split('--')[0]).strip() else: s = s.split('--')[0].strip() for ignore in self.ignore_list: if s.find(ignore) >= 0: #print s.split()[0], 'NotImplemented--', ignore return if not s: return elif ':' in s: return self.eval_directive(s) else: return self.eval_equation(s) def eval_directive(self, s): funct, value = (x.strip().lower() for x in s.split(':')) if funct == 'rounding': value = self.RoundingDict[value] else: try: value = int(value) except ValueError: pass funct = self.ChangeDict.get(funct, (lambda *args: None)) funct(value) def eval_equation(self, s): if not TEST_ALL and random.random() < 0.90: return self.context.clear_flags() try: Sides = s.split('->') L = Sides[0].strip().split() id = L[0] if DEBUG: print("Test ", id, end=" ") funct = L[1].lower() valstemp = L[2:] L = Sides[1].strip().split() ans = L[0] exceptions = L[1:] except (TypeError, AttributeError, IndexError): raise self.decimal.InvalidOperation def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val if id in self.skipped_test_ids: return fname = self.NameAdapter.get(funct, funct) if fname == 'rescale': return funct = getattr(self.context, fname) vals = [] conglomerate = '' quote = 0 theirexceptions = [self.ErrorNames[x.lower()] for x in exceptions] for exception in Signals[self.decimal]: self.context.traps[exception] = 1 #Catch these bugs... for exception in theirexceptions: self.context.traps[exception] = 0 for i, val in enumerate(valstemp): if val.count("'") % 2 == 1: quote = 1 - quote if quote: conglomerate = conglomerate + ' ' + val continue else: val = conglomerate + val conglomerate = '' v = FixQuotes(val) if fname in ('to_sci_string', 'to_eng_string'): if EXTENDEDERRORTEST: for error in theirexceptions: self.context.traps[error] = 1 try: funct(self.context.create_decimal(v)) except error: pass except Signals[self.decimal] as e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) else: self.fail("Did not raise %s in %s" % (error, s)) self.context.traps[error] = 0 v = self.context.create_decimal(v) else: v = self.read_unlimited(v, self.context) vals.append(v) ans = FixQuotes(ans) if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'): for error in theirexceptions: self.context.traps[error] = 1 try: funct(*vals) except error: pass except Signals[self.decimal] as e: self.fail("Raised %s in %s when %s disabled" % \ (e, s, error)) else: self.fail("Did not raise %s in %s" % (error, s)) self.context.traps[error] = 0 # as above, but add traps cumulatively, to check precedence ordered_errors = [e for e in OrderedSignals[self.decimal] if e in theirexceptions] for error in ordered_errors: self.context.traps[error] = 1 try: funct(*vals) except error: pass except Signals[self.decimal] as e: self.fail("Raised %s in %s; expected %s" % (type(e), s, error)) else: self.fail("Did not raise %s in %s" % (error, s)) # reset traps for error in ordered_errors: self.context.traps[error] = 0 if DEBUG: print("--", self.context) try: result = str(funct(*vals)) if fname in self.LogicalFunctions: result = str(int(eval(result))) # 'True', 'False' -> '1', '0' except Signals[self.decimal] as error: self.fail("Raised %s in %s" % (error, s)) except: #Catch any error long enough to state the test case. print("ERROR:", s) raise myexceptions = self.getexceptions() myexceptions.sort(key=repr) theirexceptions.sort(key=repr) self.assertEqual(result, ans, 'Incorrect answer for ' + s + ' -- got ' + result) self.assertEqual(myexceptions, theirexceptions, 'Incorrect flags set in ' + s + ' -- got ' + str(myexceptions)) def getexceptions(self): return [e for e in Signals[self.decimal] if self.context.flags[e]] def change_precision(self, prec): if self.decimal == C and self.decimal.MAX_PREC == 425000000: self.context._unsafe_setprec(prec) else: self.context.prec = prec def change_rounding_method(self, rounding): self.context.rounding = rounding def change_min_exponent(self, exp): if self.decimal == C and self.decimal.MAX_PREC == 425000000: self.context._unsafe_setemin(exp) else: self.context.Emin = exp def change_max_exponent(self, exp): if self.decimal == C and self.decimal.MAX_PREC == 425000000: self.context._unsafe_setemax(exp) else: self.context.Emax = exp def change_clamp(self, clamp): self.context.clamp = clamp class CIBMTestCases(IBMTestCases): decimal = C class PyIBMTestCases(IBMTestCases): decimal = P # The following classes test the behaviour of Decimal according to PEP 327 class ExplicitConstructionTest(unittest.TestCase): '''Unit tests for Explicit Construction cases of Decimal.''' def test_explicit_empty(self): Decimal = self.decimal.Decimal self.assertEqual(Decimal(), Decimal("0")) def test_explicit_from_None(self): Decimal = self.decimal.Decimal self.assertRaises(TypeError, Decimal, None) def test_explicit_from_int(self): Decimal = self.decimal.Decimal #positive d = Decimal(45) self.assertEqual(str(d), '45') #very large positive d = Decimal(500000123) self.assertEqual(str(d), '500000123') #negative d = Decimal(-45) self.assertEqual(str(d), '-45') #zero d = Decimal(0) self.assertEqual(str(d), '0') # single word longs for n in range(0, 32): for sign in (-1, 1): for x in range(-5, 5): i = sign * (2**n + x) d = Decimal(i) self.assertEqual(str(d), str(i)) def test_explicit_from_string(self): Decimal = self.decimal.Decimal InvalidOperation = self.decimal.InvalidOperation localcontext = self.decimal.localcontext #empty self.assertEqual(str(Decimal('')), 'NaN') #int self.assertEqual(str(Decimal('45')), '45') #float self.assertEqual(str(Decimal('45.34')), '45.34') #engineer notation self.assertEqual(str(Decimal('45e2')), '4.5E+3') #just not a number self.assertEqual(str(Decimal('ugly')), 'NaN') #leading and trailing whitespace permitted self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4') self.assertEqual(str(Decimal(' -7.89')), '-7.89') self.assertEqual(str(Decimal(" 3.45679 ")), '3.45679') # underscores self.assertEqual(str(Decimal('1_3.3e4_0')), '1.33E+41') self.assertEqual(str(Decimal('1_0_0_0')), '1000') # unicode whitespace for lead in ["", ' ', '\u00a0', '\u205f']: for trail in ["", ' ', '\u00a0', '\u205f']: self.assertEqual(str(Decimal(lead + '9.311E+28' + trail)), '9.311E+28') with localcontext() as c: c.traps[InvalidOperation] = True # Invalid string self.assertRaises(InvalidOperation, Decimal, "xyz") # Two arguments max self.assertRaises(TypeError, Decimal, "1234", "x", "y") # space within the numeric part self.assertRaises(InvalidOperation, Decimal, "1\u00a02\u00a03") self.assertRaises(InvalidOperation, Decimal, "\u00a01\u00a02\u00a0") # unicode whitespace self.assertRaises(InvalidOperation, Decimal, "\u00a0") self.assertRaises(InvalidOperation, Decimal, "\u00a0\u00a0") # embedded NUL self.assertRaises(InvalidOperation, Decimal, "12\u00003") # underscores don't prevent errors self.assertRaises(InvalidOperation, Decimal, "1_2_\u00003") @cpython_only def test_from_legacy_strings(self): import _testcapi Decimal = self.decimal.Decimal context = self.decimal.Context() s = _testcapi.unicode_legacy_string('9.999999') self.assertEqual(str(Decimal(s)), '9.999999') self.assertEqual(str(context.create_decimal(s)), '9.999999') def test_explicit_from_tuples(self): Decimal = self.decimal.Decimal #zero d = Decimal( (0, (0,), 0) ) self.assertEqual(str(d), '0') #int d = Decimal( (1, (4, 5), 0) ) self.assertEqual(str(d), '-45') #float d = Decimal( (0, (4, 5, 3, 4), -2) ) self.assertEqual(str(d), '45.34') #weird d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) self.assertEqual(str(d), '-4.34913534E-17') #inf d = Decimal( (0, (), "F") ) self.assertEqual(str(d), 'Infinity') #wrong number of items self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1)) ) #bad sign self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) ) self.assertRaises(ValueError, Decimal, (0., (4, 3, 4, 9, 1), 2) ) self.assertRaises(ValueError, Decimal, (Decimal(1), (4, 3, 4, 9, 1), 2)) #bad exp self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') ) self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 0.) ) self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), '1') ) #bad coefficients self.assertRaises(ValueError, Decimal, (1, "xyz", 2) ) self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) ) self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) ) self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) ) self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 'a', 1), 2) ) def test_explicit_from_list(self): Decimal = self.decimal.Decimal d = Decimal([0, [0], 0]) self.assertEqual(str(d), '0') d = Decimal([1, [4, 3, 4, 9, 1, 3, 5, 3, 4], -25]) self.assertEqual(str(d), '-4.34913534E-17') d = Decimal([1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25]) self.assertEqual(str(d), '-4.34913534E-17') d = Decimal((1, [4, 3, 4, 9, 1, 3, 5, 3, 4], -25)) self.assertEqual(str(d), '-4.34913534E-17') def test_explicit_from_bool(self): Decimal = self.decimal.Decimal self.assertIs(bool(Decimal(0)), False) self.assertIs(bool(Decimal(1)), True) self.assertEqual(Decimal(False), Decimal(0)) self.assertEqual(Decimal(True), Decimal(1)) def test_explicit_from_Decimal(self): Decimal = self.decimal.Decimal #positive d = Decimal(45) e = Decimal(d) self.assertEqual(str(e), '45') #very large positive d = Decimal(500000123) e = Decimal(d) self.assertEqual(str(e), '500000123') #negative d = Decimal(-45) e = Decimal(d) self.assertEqual(str(e), '-45') #zero d = Decimal(0) e = Decimal(d) self.assertEqual(str(e), '0') @requires_IEEE_754 def test_explicit_from_float(self): Decimal = self.decimal.Decimal r = Decimal(0.1) self.assertEqual(type(r), Decimal) self.assertEqual(str(r), '0.1000000000000000055511151231257827021181583404541015625') self.assertTrue(Decimal(float('nan')).is_qnan()) self.assertTrue(Decimal(float('inf')).is_infinite()) self.assertTrue(Decimal(float('-inf')).is_infinite()) self.assertEqual(str(Decimal(float('nan'))), str(Decimal('NaN'))) self.assertEqual(str(Decimal(float('inf'))), str(Decimal('Infinity'))) self.assertEqual(str(Decimal(float('-inf'))), str(Decimal('-Infinity'))) self.assertEqual(str(Decimal(float('-0.0'))), str(Decimal('-0'))) for i in range(200): x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0) self.assertEqual(x, float(Decimal(x))) # roundtrip def test_explicit_context_create_decimal(self): Decimal = self.decimal.Decimal InvalidOperation = self.decimal.InvalidOperation Rounded = self.decimal.Rounded nc = copy.copy(self.decimal.getcontext()) nc.prec = 3 # empty d = Decimal() self.assertEqual(str(d), '0') d = nc.create_decimal() self.assertEqual(str(d), '0') # from None self.assertRaises(TypeError, nc.create_decimal, None) # from int d = nc.create_decimal(456) self.assertIsInstance(d, Decimal) self.assertEqual(nc.create_decimal(45678), nc.create_decimal('457E+2')) # from string d = Decimal('456789') self.assertEqual(str(d), '456789') d = nc.create_decimal('456789') self.assertEqual(str(d), '4.57E+5') # leading and trailing whitespace should result in a NaN; # spaces are already checked in Cowlishaw's test-suite, so # here we just check that a trailing newline results in a NaN self.assertEqual(str(nc.create_decimal('3.14\n')), 'NaN') # from tuples d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) self.assertEqual(str(d), '-4.34913534E-17') d = nc.create_decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) self.assertEqual(str(d), '-4.35E-17') # from Decimal prevdec = Decimal(500000123) d = Decimal(prevdec) self.assertEqual(str(d), '500000123') d = nc.create_decimal(prevdec) self.assertEqual(str(d), '5.00E+8') # more integers nc.prec = 28 nc.traps[InvalidOperation] = True for v in [-2**63-1, -2**63, -2**31-1, -2**31, 0, 2**31-1, 2**31, 2**63-1, 2**63]: d = nc.create_decimal(v) self.assertTrue(isinstance(d, Decimal)) self.assertEqual(int(d), v) nc.prec = 3 nc.traps[Rounded] = True self.assertRaises(Rounded, nc.create_decimal, 1234) # from string nc.prec = 28 self.assertEqual(str(nc.create_decimal('0E-017')), '0E-17') self.assertEqual(str(nc.create_decimal('45')), '45') self.assertEqual(str(nc.create_decimal('-Inf')), '-Infinity') self.assertEqual(str(nc.create_decimal('NaN123')), 'NaN123') # invalid arguments self.assertRaises(InvalidOperation, nc.create_decimal, "xyz") self.assertRaises(ValueError, nc.create_decimal, (1, "xyz", -25)) self.assertRaises(TypeError, nc.create_decimal, "1234", "5678") # no whitespace and underscore stripping is done with this method self.assertRaises(InvalidOperation, nc.create_decimal, " 1234") self.assertRaises(InvalidOperation, nc.create_decimal, "12_34") # too many NaN payload digits nc.prec = 3 self.assertRaises(InvalidOperation, nc.create_decimal, 'NaN12345') self.assertRaises(InvalidOperation, nc.create_decimal, Decimal('NaN12345')) nc.traps[InvalidOperation] = False self.assertEqual(str(nc.create_decimal('NaN12345')), 'NaN') self.assertTrue(nc.flags[InvalidOperation]) nc.flags[InvalidOperation] = False self.assertEqual(str(nc.create_decimal(Decimal('NaN12345'))), 'NaN') self.assertTrue(nc.flags[InvalidOperation]) def test_explicit_context_create_from_float(self): Decimal = self.decimal.Decimal nc = self.decimal.Context() r = nc.create_decimal(0.1) self.assertEqual(type(r), Decimal) self.assertEqual(str(r), '0.1000000000000000055511151231') self.assertTrue(nc.create_decimal(float('nan')).is_qnan()) self.assertTrue(nc.create_decimal(float('inf')).is_infinite()) self.assertTrue(nc.create_decimal(float('-inf')).is_infinite()) self.assertEqual(str(nc.create_decimal(float('nan'))), str(nc.create_decimal('NaN'))) self.assertEqual(str(nc.create_decimal(float('inf'))), str(nc.create_decimal('Infinity'))) self.assertEqual(str(nc.create_decimal(float('-inf'))), str(nc.create_decimal('-Infinity'))) self.assertEqual(str(nc.create_decimal(float('-0.0'))), str(nc.create_decimal('-0'))) nc.prec = 100 for i in range(200): x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0) self.assertEqual(x, float(nc.create_decimal(x))) # roundtrip def test_unicode_digits(self): Decimal = self.decimal.Decimal test_values = { '\uff11': '1', '\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372', '-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400', } for input, expected in test_values.items(): self.assertEqual(str(Decimal(input)), expected) class CExplicitConstructionTest(ExplicitConstructionTest): decimal = C class PyExplicitConstructionTest(ExplicitConstructionTest): decimal = P class ImplicitConstructionTest(unittest.TestCase): '''Unit tests for Implicit Construction cases of Decimal.''' def test_implicit_from_None(self): Decimal = self.decimal.Decimal self.assertRaises(TypeError, eval, 'Decimal(5) + None', locals()) def test_implicit_from_int(self): Decimal = self.decimal.Decimal #normal self.assertEqual(str(Decimal(5) + 45), '50') #exceeding precision self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000)) def test_implicit_from_string(self): Decimal = self.decimal.Decimal self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', locals()) def test_implicit_from_float(self): Decimal = self.decimal.Decimal self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', locals()) def test_implicit_from_Decimal(self): Decimal = self.decimal.Decimal self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) def test_rop(self): Decimal = self.decimal.Decimal # Allow other classes to be trained to interact with Decimals class E: def __divmod__(self, other): return 'divmod ' + str(other) def __rdivmod__(self, other): return str(other) + ' rdivmod' def __lt__(self, other): return 'lt ' + str(other) def __gt__(self, other): return 'gt ' + str(other) def __le__(self, other): return 'le ' + str(other) def __ge__(self, other): return 'ge ' + str(other) def __eq__(self, other): return 'eq ' + str(other) def __ne__(self, other): return 'ne ' + str(other) self.assertEqual(divmod(E(), Decimal(10)), 'divmod 10') self.assertEqual(divmod(Decimal(10), E()), '10 rdivmod') self.assertEqual(eval('Decimal(10) < E()'), 'gt 10') self.assertEqual(eval('Decimal(10) > E()'), 'lt 10') self.assertEqual(eval('Decimal(10) <= E()'), 'ge 10') self.assertEqual(eval('Decimal(10) >= E()'), 'le 10') self.assertEqual(eval('Decimal(10) == E()'), 'eq 10') self.assertEqual(eval('Decimal(10) != E()'), 'ne 10') # insert operator methods and then exercise them oplist = [ ('+', '__add__', '__radd__'), ('-', '__sub__', '__rsub__'), ('*', '__mul__', '__rmul__'), ('/', '__truediv__', '__rtruediv__'), ('%', '__mod__', '__rmod__'), ('//', '__floordiv__', '__rfloordiv__'), ('**', '__pow__', '__rpow__') ] for sym, lop, rop in oplist: setattr(E, lop, lambda self, other: 'str' + lop + str(other)) setattr(E, rop, lambda self, other: str(other) + rop + 'str') self.assertEqual(eval('E()' + sym + 'Decimal(10)'), 'str' + lop + '10') self.assertEqual(eval('Decimal(10)' + sym + 'E()'), '10' + rop + 'str') class CImplicitConstructionTest(ImplicitConstructionTest): decimal = C class PyImplicitConstructionTest(ImplicitConstructionTest): decimal = P class FormatTest(unittest.TestCase): '''Unit tests for the format function.''' def test_formatting(self): Decimal = self.decimal.Decimal # triples giving a format, a Decimal, and the expected result test_values = [ ('e', '0E-15', '0e-15'), ('e', '2.3E-15', '2.3e-15'), ('e', '2.30E+2', '2.30e+2'), # preserve significant zeros ('e', '2.30000E-15', '2.30000e-15'), ('e', '1.23456789123456789e40', '1.23456789123456789e+40'), ('e', '1.5', '1.5e+0'), ('e', '0.15', '1.5e-1'), ('e', '0.015', '1.5e-2'), ('e', '0.0000000000015', '1.5e-12'), ('e', '15.0', '1.50e+1'), ('e', '-15', '-1.5e+1'), ('e', '0', '0e+0'), ('e', '0E1', '0e+1'), ('e', '0.0', '0e-1'), ('e', '0.00', '0e-2'), ('.6e', '0E-15', '0.000000e-9'), ('.6e', '0', '0.000000e+6'), ('.6e', '9.999999', '9.999999e+0'), ('.6e', '9.9999999', '1.000000e+1'), ('.6e', '-1.23e5', '-1.230000e+5'), ('.6e', '1.23456789e-3', '1.234568e-3'), ('f', '0', '0'), ('f', '0.0', '0.0'), ('f', '0E-2', '0.00'), ('f', '0.00E-8', '0.0000000000'), ('f', '0E1', '0'), # loses exponent information ('f', '3.2E1', '32'), ('f', '3.2E2', '320'), ('f', '3.20E2', '320'), ('f', '3.200E2', '320.0'), ('f', '3.2E-6', '0.0000032'), ('.6f', '0E-15', '0.000000'), # all zeros treated equally ('.6f', '0E1', '0.000000'), ('.6f', '0', '0.000000'), ('.0f', '0', '0'), # no decimal point ('.0f', '0e-2', '0'), ('.0f', '3.14159265', '3'), ('.1f', '3.14159265', '3.1'), ('.4f', '3.14159265', '3.1416'), ('.6f', '3.14159265', '3.141593'), ('.7f', '3.14159265', '3.1415926'), # round-half-even! ('.8f', '3.14159265', '3.14159265'), ('.9f', '3.14159265', '3.141592650'), ('g', '0', '0'), ('g', '0.0', '0.0'), ('g', '0E1', '0e+1'), ('G', '0E1', '0E+1'), ('g', '0E-5', '0.00000'), ('g', '0E-6', '0.000000'), ('g', '0E-7', '0e-7'), ('g', '-0E2', '-0e+2'), ('.0g', '3.14159265', '3'), # 0 sig fig -> 1 sig fig ('.0n', '3.14159265', '3'), # same for 'n' ('.1g', '3.14159265', '3'), ('.2g', '3.14159265', '3.1'), ('.5g', '3.14159265', '3.1416'), ('.7g', '3.14159265', '3.141593'), ('.8g', '3.14159265', '3.1415926'), # round-half-even! ('.9g', '3.14159265', '3.14159265'), ('.10g', '3.14159265', '3.14159265'), # don't pad ('%', '0E1', '0%'), ('%', '0E0', '0%'), ('%', '0E-1', '0%'), ('%', '0E-2', '0%'), ('%', '0E-3', '0.0%'), ('%', '0E-4', '0.00%'), ('.3%', '0', '0.000%'), # all zeros treated equally ('.3%', '0E10', '0.000%'), ('.3%', '0E-10', '0.000%'), ('.3%', '2.34', '234.000%'), ('.3%', '1.234567', '123.457%'), ('.0%', '1.23', '123%'), ('e', 'NaN', 'NaN'), ('f', '-NaN123', '-NaN123'), ('+g', 'NaN456', '+NaN456'), ('.3e', 'Inf', 'Infinity'), ('.16f', '-Inf', '-Infinity'), ('.0g', '-sNaN', '-sNaN'), ('', '1.00', '1.00'), # test alignment and padding ('6', '123', ' 123'), ('<6', '123', '123 '), ('>6', '123', ' 123'), ('^6', '123', ' 123 '), ('=+6', '123', '+ 123'), ('#<10', 'NaN', 'NaN#######'), ('#<10', '-4.3', '-4.3######'), ('#<+10', '0.0130', '+0.0130###'), ('#< 10', '0.0130', ' 0.0130###'), ('@>10', '-Inf', '@-Infinity'), ('#>5', '-Inf', '-Infinity'), ('?^5', '123', '?123?'), ('%^6', '123', '%123%%'), (' ^6', '-45.6', '-45.6 '), ('/=10', '-45.6', '-/////45.6'), ('/=+10', '45.6', '+/////45.6'), ('/= 10', '45.6', ' /////45.6'), ('\x00=10', '-inf', '-\x00Infinity'), ('\x00^16', '-inf', '\x00\x00\x00-Infinity\x00\x00\x00\x00'), ('\x00>10', '1.2345', '\x00\x00\x00\x001.2345'), ('\x00<10', '1.2345', '1.2345\x00\x00\x00\x00'), # thousands separator (',', '1234567', '1,234,567'), (',', '123456', '123,456'), (',', '12345', '12,345'), (',', '1234', '1,234'), (',', '123', '123'), (',', '12', '12'), (',', '1', '1'), (',', '0', '0'), (',', '-1234567', '-1,234,567'), (',', '-123456', '-123,456'), ('7,', '123456', '123,456'), ('8,', '123456', ' 123,456'), ('08,', '123456', '0,123,456'), # special case: extra 0 needed ('+08,', '123456', '+123,456'), # but not if there's a sign (' 08,', '123456', ' 123,456'), ('08,', '-123456', '-123,456'), ('+09,', '123456', '+0,123,456'), # ... with fractional part... ('07,', '1234.56', '1,234.56'), ('08,', '1234.56', '1,234.56'), ('09,', '1234.56', '01,234.56'), ('010,', '1234.56', '001,234.56'), ('011,', '1234.56', '0,001,234.56'), ('012,', '1234.56', '0,001,234.56'), ('08,.1f', '1234.5', '01,234.5'), # no thousands separators in fraction part (',', '1.23456789', '1.23456789'), (',%', '123.456789', '12,345.6789%'), (',e', '123456', '1.23456e+5'), (',E', '123456', '1.23456E+5'), # issue 6850 ('a=-7.0', '0.12345', 'aaaa0.1'), # issue 22090 ('<^+15.20%', 'inf', '<<+Infinity%<<<'), ('\x07>,%', 'sNaN1234567', 'sNaN1234567%'), ('=10.10%', 'NaN123', ' NaN123%'), ] for fmt, d, result in test_values: self.assertEqual(format(Decimal(d), fmt), result) # bytes format argument self.assertRaises(TypeError, Decimal(1).__format__, b'-020') def test_n_format(self): Decimal = self.decimal.Decimal try: from locale import CHAR_MAX except ImportError: self.skipTest('locale.CHAR_MAX not available') def make_grouping(lst): return ''.join([chr(x) for x in lst]) if self.decimal == C else lst def get_fmt(x, override=None, fmt='n'): if self.decimal == C: return Decimal(x).__format__(fmt, override) else: return Decimal(x).__format__(fmt, _localeconv=override) # Set up some localeconv-like dictionaries en_US = { 'decimal_point' : '.', 'grouping' : make_grouping([3, 3, 0]), 'thousands_sep' : ',' } fr_FR = { 'decimal_point' : ',', 'grouping' : make_grouping([CHAR_MAX]), 'thousands_sep' : '' } ru_RU = { 'decimal_point' : ',', 'grouping': make_grouping([3, 3, 0]), 'thousands_sep' : ' ' } crazy = { 'decimal_point' : '&', 'grouping': make_grouping([1, 4, 2, CHAR_MAX]), 'thousands_sep' : '-' } dotsep_wide = { 'decimal_point' : b'\xc2\xbf'.decode('utf-8'), 'grouping': make_grouping([3, 3, 0]), 'thousands_sep' : b'\xc2\xb4'.decode('utf-8') } self.assertEqual(get_fmt(Decimal('12.7'), en_US), '12.7') self.assertEqual(get_fmt(Decimal('12.7'), fr_FR), '12,7') self.assertEqual(get_fmt(Decimal('12.7'), ru_RU), '12,7') self.assertEqual(get_fmt(Decimal('12.7'), crazy), '1-2&7') self.assertEqual(get_fmt(123456789, en_US), '123,456,789') self.assertEqual(get_fmt(123456789, fr_FR), '123456789') self.assertEqual(get_fmt(123456789, ru_RU), '123 456 789') self.assertEqual(get_fmt(1234567890123, crazy), '123456-78-9012-3') self.assertEqual(get_fmt(123456789, en_US, '.6n'), '1.23457e+8') self.assertEqual(get_fmt(123456789, fr_FR, '.6n'), '1,23457e+8') self.assertEqual(get_fmt(123456789, ru_RU, '.6n'), '1,23457e+8') self.assertEqual(get_fmt(123456789, crazy, '.6n'), '1&23457e+8') # zero padding self.assertEqual(get_fmt(1234, fr_FR, '03n'), '1234') self.assertEqual(get_fmt(1234, fr_FR, '04n'), '1234') self.assertEqual(get_fmt(1234, fr_FR, '05n'), '01234') self.assertEqual(get_fmt(1234, fr_FR, '06n'), '001234') self.assertEqual(get_fmt(12345, en_US, '05n'), '12,345') self.assertEqual(get_fmt(12345, en_US, '06n'), '12,345') self.assertEqual(get_fmt(12345, en_US, '07n'), '012,345') self.assertEqual(get_fmt(12345, en_US, '08n'), '0,012,345') self.assertEqual(get_fmt(12345, en_US, '09n'), '0,012,345') self.assertEqual(get_fmt(12345, en_US, '010n'), '00,012,345') self.assertEqual(get_fmt(123456, crazy, '06n'), '1-2345-6') self.assertEqual(get_fmt(123456, crazy, '07n'), '1-2345-6') self.assertEqual(get_fmt(123456, crazy, '08n'), '1-2345-6') self.assertEqual(get_fmt(123456, crazy, '09n'), '01-2345-6') self.assertEqual(get_fmt(123456, crazy, '010n'), '0-01-2345-6') self.assertEqual(get_fmt(123456, crazy, '011n'), '0-01-2345-6') self.assertEqual(get_fmt(123456, crazy, '012n'), '00-01-2345-6') self.assertEqual(get_fmt(123456, crazy, '013n'), '000-01-2345-6') # wide char separator and decimal point self.assertEqual(get_fmt(Decimal('-1.5'), dotsep_wide, '020n'), '-0\u00b4000\u00b4000\u00b4000\u00b4001\u00bf5') @run_with_locale('LC_ALL', 'ps_AF') def test_wide_char_separator_decimal_point(self): # locale with wide char separator and decimal point import locale Decimal = self.decimal.Decimal decimal_point = locale.localeconv()['decimal_point'] thousands_sep = locale.localeconv()['thousands_sep'] if decimal_point != '\u066b': self.skipTest('inappropriate decimal point separator ' '({!a} not {!a})'.format(decimal_point, '\u066b')) if thousands_sep != '\u066c': self.skipTest('inappropriate thousands separator ' '({!a} not {!a})'.format(thousands_sep, '\u066c')) self.assertEqual(format(Decimal('100000000.123'), 'n'), '100\u066c000\u066c000\u066b123') class CFormatTest(FormatTest): decimal = C class PyFormatTest(FormatTest): decimal = P class ArithmeticOperatorsTest(unittest.TestCase): '''Unit tests for all arithmetic operators, binary and unary.''' def test_addition(self): Decimal = self.decimal.Decimal d1 = Decimal('-11.1') d2 = Decimal('22.2') #two Decimals self.assertEqual(d1+d2, Decimal('11.1')) self.assertEqual(d2+d1, Decimal('11.1')) #with other type, left c = d1 + 5 self.assertEqual(c, Decimal('-6.1')) self.assertEqual(type(c), type(d1)) #with other type, right c = 5 + d1 self.assertEqual(c, Decimal('-6.1')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 += d2 self.assertEqual(d1, Decimal('11.1')) #inline with other type d1 += 5 self.assertEqual(d1, Decimal('16.1')) def test_subtraction(self): Decimal = self.decimal.Decimal d1 = Decimal('-11.1') d2 = Decimal('22.2') #two Decimals self.assertEqual(d1-d2, Decimal('-33.3')) self.assertEqual(d2-d1, Decimal('33.3')) #with other type, left c = d1 - 5 self.assertEqual(c, Decimal('-16.1')) self.assertEqual(type(c), type(d1)) #with other type, right c = 5 - d1 self.assertEqual(c, Decimal('16.1')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 -= d2 self.assertEqual(d1, Decimal('-33.3')) #inline with other type d1 -= 5 self.assertEqual(d1, Decimal('-38.3')) def test_multiplication(self): Decimal = self.decimal.Decimal d1 = Decimal('-5') d2 = Decimal('3') #two Decimals self.assertEqual(d1*d2, Decimal('-15')) self.assertEqual(d2*d1, Decimal('-15')) #with other type, left c = d1 * 5 self.assertEqual(c, Decimal('-25')) self.assertEqual(type(c), type(d1)) #with other type, right c = 5 * d1 self.assertEqual(c, Decimal('-25')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 *= d2 self.assertEqual(d1, Decimal('-15')) #inline with other type d1 *= 5 self.assertEqual(d1, Decimal('-75')) def test_division(self): Decimal = self.decimal.Decimal d1 = Decimal('-5') d2 = Decimal('2') #two Decimals self.assertEqual(d1/d2, Decimal('-2.5')) self.assertEqual(d2/d1, Decimal('-0.4')) #with other type, left c = d1 / 4 self.assertEqual(c, Decimal('-1.25')) self.assertEqual(type(c), type(d1)) #with other type, right c = 4 / d1 self.assertEqual(c, Decimal('-0.8')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 /= d2 self.assertEqual(d1, Decimal('-2.5')) #inline with other type d1 /= 4 self.assertEqual(d1, Decimal('-0.625')) def test_floor_division(self): Decimal = self.decimal.Decimal d1 = Decimal('5') d2 = Decimal('2') #two Decimals self.assertEqual(d1//d2, Decimal('2')) self.assertEqual(d2//d1, Decimal('0')) #with other type, left c = d1 // 4 self.assertEqual(c, Decimal('1')) self.assertEqual(type(c), type(d1)) #with other type, right c = 7 // d1 self.assertEqual(c, Decimal('1')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 //= d2 self.assertEqual(d1, Decimal('2')) #inline with other type d1 //= 2 self.assertEqual(d1, Decimal('1')) def test_powering(self): Decimal = self.decimal.Decimal d1 = Decimal('5') d2 = Decimal('2') #two Decimals self.assertEqual(d1**d2, Decimal('25')) self.assertEqual(d2**d1, Decimal('32')) #with other type, left c = d1 ** 4 self.assertEqual(c, Decimal('625')) self.assertEqual(type(c), type(d1)) #with other type, right c = 7 ** d1 self.assertEqual(c, Decimal('16807')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 **= d2 self.assertEqual(d1, Decimal('25')) #inline with other type d1 **= 4 self.assertEqual(d1, Decimal('390625')) def test_module(self): Decimal = self.decimal.Decimal d1 = Decimal('5') d2 = Decimal('2') #two Decimals self.assertEqual(d1%d2, Decimal('1')) self.assertEqual(d2%d1, Decimal('2')) #with other type, left c = d1 % 4 self.assertEqual(c, Decimal('1')) self.assertEqual(type(c), type(d1)) #with other type, right c = 7 % d1 self.assertEqual(c, Decimal('2')) self.assertEqual(type(c), type(d1)) #inline with decimal d1 %= d2 self.assertEqual(d1, Decimal('1')) #inline with other type d1 %= 4 self.assertEqual(d1, Decimal('1')) def test_floor_div_module(self): Decimal = self.decimal.Decimal d1 = Decimal('5') d2 = Decimal('2') #two Decimals (p, q) = divmod(d1, d2) self.assertEqual(p, Decimal('2')) self.assertEqual(q, Decimal('1')) self.assertEqual(type(p), type(d1)) self.assertEqual(type(q), type(d1)) #with other type, left (p, q) = divmod(d1, 4) self.assertEqual(p, Decimal('1')) self.assertEqual(q, Decimal('1')) self.assertEqual(type(p), type(d1)) self.assertEqual(type(q), type(d1)) #with other type, right (p, q) = divmod(7, d1) self.assertEqual(p, Decimal('1')) self.assertEqual(q, Decimal('2')) self.assertEqual(type(p), type(d1)) self.assertEqual(type(q), type(d1)) def test_unary_operators(self): Decimal = self.decimal.Decimal self.assertEqual(+Decimal(45), Decimal(+45)) # + self.assertEqual(-Decimal(45), Decimal(-45)) # - self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs def test_nan_comparisons(self): # comparisons involving signaling nans signal InvalidOperation # order comparisons (<, <=, >, >=) involving only quiet nans # also signal InvalidOperation # equality comparisons (==, !=) involving only quiet nans # don't signal, but return False or True respectively. Decimal = self.decimal.Decimal InvalidOperation = self.decimal.InvalidOperation localcontext = self.decimal.localcontext n = Decimal('NaN') s = Decimal('sNaN') i = Decimal('Inf') f = Decimal('2') qnan_pairs = (n, n), (n, i), (i, n), (n, f), (f, n) snan_pairs = (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s) order_ops = operator.lt, operator.le, operator.gt, operator.ge equality_ops = operator.eq, operator.ne # results when InvalidOperation is not trapped for x, y in qnan_pairs + snan_pairs: for op in order_ops + equality_ops: got = op(x, y) expected = True if op is operator.ne else False self.assertIs(expected, got, "expected {0!r} for operator.{1}({2!r}, {3!r}); " "got {4!r}".format( expected, op.__name__, x, y, got)) # repeat the above, but this time trap the InvalidOperation with localcontext() as ctx: ctx.traps[InvalidOperation] = 1 for x, y in qnan_pairs: for op in equality_ops: got = op(x, y) expected = True if op is operator.ne else False self.assertIs(expected, got, "expected {0!r} for " "operator.{1}({2!r}, {3!r}); " "got {4!r}".format( expected, op.__name__, x, y, got)) for x, y in snan_pairs: for op in equality_ops: self.assertRaises(InvalidOperation, operator.eq, x, y) self.assertRaises(InvalidOperation, operator.ne, x, y) for x, y in qnan_pairs + snan_pairs: for op in order_ops: self.assertRaises(InvalidOperation, op, x, y) def test_copy_sign(self): Decimal = self.decimal.Decimal d = Decimal(1).copy_sign(Decimal(-2)) self.assertEqual(Decimal(1).copy_sign(-2), d) self.assertRaises(TypeError, Decimal(1).copy_sign, '-2') class CArithmeticOperatorsTest(ArithmeticOperatorsTest): decimal = C class PyArithmeticOperatorsTest(ArithmeticOperatorsTest): decimal = P # The following are two functions used to test threading in the next class def thfunc1(cls): Decimal = cls.decimal.Decimal InvalidOperation = cls.decimal.InvalidOperation DivisionByZero = cls.decimal.DivisionByZero Overflow = cls.decimal.Overflow Underflow = cls.decimal.Underflow Inexact = cls.decimal.Inexact getcontext = cls.decimal.getcontext localcontext = cls.decimal.localcontext d1 = Decimal(1) d3 = Decimal(3) test1 = d1/d3 cls.finish1.set() cls.synchro.wait() test2 = d1/d3 with localcontext() as c2: cls.assertTrue(c2.flags[Inexact]) cls.assertRaises(DivisionByZero, c2.divide, d1, 0) cls.assertTrue(c2.flags[DivisionByZero]) with localcontext() as c3: cls.assertTrue(c3.flags[Inexact]) cls.assertTrue(c3.flags[DivisionByZero]) cls.assertRaises(InvalidOperation, c3.compare, d1, Decimal('sNaN')) cls.assertTrue(c3.flags[InvalidOperation]) del c3 cls.assertFalse(c2.flags[InvalidOperation]) del c2 cls.assertEqual(test1, Decimal('0.333333333333333333333333')) cls.assertEqual(test2, Decimal('0.333333333333333333333333')) c1 = getcontext() cls.assertTrue(c1.flags[Inexact]) for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: cls.assertFalse(c1.flags[sig]) def thfunc2(cls): Decimal = cls.decimal.Decimal InvalidOperation = cls.decimal.InvalidOperation DivisionByZero = cls.decimal.DivisionByZero Overflow = cls.decimal.Overflow Underflow = cls.decimal.Underflow Inexact = cls.decimal.Inexact getcontext = cls.decimal.getcontext localcontext = cls.decimal.localcontext d1 = Decimal(1) d3 = Decimal(3) test1 = d1/d3 thiscontext = getcontext() thiscontext.prec = 18 test2 = d1/d3 with localcontext() as c2: cls.assertTrue(c2.flags[Inexact]) cls.assertRaises(Overflow, c2.multiply, Decimal('1e425000000'), 999) cls.assertTrue(c2.flags[Overflow]) with localcontext(thiscontext) as c3: cls.assertTrue(c3.flags[Inexact]) cls.assertFalse(c3.flags[Overflow]) c3.traps[Underflow] = True cls.assertRaises(Underflow, c3.divide, Decimal('1e-425000000'), 999) cls.assertTrue(c3.flags[Underflow]) del c3 cls.assertFalse(c2.flags[Underflow]) cls.assertFalse(c2.traps[Underflow]) del c2 cls.synchro.set() cls.finish2.set() cls.assertEqual(test1, Decimal('0.333333333333333333333333')) cls.assertEqual(test2, Decimal('0.333333333333333333')) cls.assertFalse(thiscontext.traps[Underflow]) cls.assertTrue(thiscontext.flags[Inexact]) for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: cls.assertFalse(thiscontext.flags[sig]) class ThreadingTest(unittest.TestCase): '''Unit tests for thread local contexts in Decimal.''' # Take care executing this test from IDLE, there's an issue in threading # that hangs IDLE and I couldn't find it def test_threading(self): DefaultContext = self.decimal.DefaultContext if self.decimal == C and not self.decimal.HAVE_THREADS: self.skipTest("compiled without threading") # Test the "threading isolation" of a Context. Also test changing # the DefaultContext, which acts as a template for the thread-local # contexts. save_prec = DefaultContext.prec save_emax = DefaultContext.Emax save_emin = DefaultContext.Emin DefaultContext.prec = 24 DefaultContext.Emax = 425000000 DefaultContext.Emin = -425000000 self.synchro = threading.Event() self.finish1 = threading.Event() self.finish2 = threading.Event() th1 = threading.Thread(target=thfunc1, args=(self,)) th2 = threading.Thread(target=thfunc2, args=(self,)) th1.start() th2.start() self.finish1.wait() self.finish2.wait() for sig in Signals[self.decimal]: self.assertFalse(DefaultContext.flags[sig]) th1.join() th2.join() DefaultContext.prec = save_prec DefaultContext.Emax = save_emax DefaultContext.Emin = save_emin @unittest.skipUnless(threading, 'threading required') class CThreadingTest(ThreadingTest): decimal = C @unittest.skipUnless(threading, 'threading required') class PyThreadingTest(ThreadingTest): decimal = P class UsabilityTest(unittest.TestCase): '''Unit tests for Usability cases of Decimal.''' def test_comparison_operators(self): Decimal = self.decimal.Decimal da = Decimal('23.42') db = Decimal('23.42') dc = Decimal('45') #two Decimals self.assertGreater(dc, da) self.assertGreaterEqual(dc, da) self.assertLess(da, dc) self.assertLessEqual(da, dc) self.assertEqual(da, db) self.assertNotEqual(da, dc) self.assertLessEqual(da, db) self.assertGreaterEqual(da, db) #a Decimal and an int self.assertGreater(dc, 23) self.assertLess(23, dc) self.assertEqual(dc, 45) #a Decimal and uncomparable self.assertNotEqual(da, 'ugly') self.assertNotEqual(da, 32.7) self.assertNotEqual(da, object()) self.assertNotEqual(da, object) # sortable a = list(map(Decimal, range(100))) b = a[:] random.shuffle(a) a.sort() self.assertEqual(a, b) def test_decimal_float_comparison(self): Decimal = self.decimal.Decimal da = Decimal('0.25') db = Decimal('3.0') self.assertLess(da, 3.0) self.assertLessEqual(da, 3.0) self.assertGreater(db, 0.25) self.assertGreaterEqual(db, 0.25) self.assertNotEqual(da, 1.5) self.assertEqual(da, 0.25) self.assertGreater(3.0, da) self.assertGreaterEqual(3.0, da) self.assertLess(0.25, db) self.assertLessEqual(0.25, db) self.assertNotEqual(0.25, db) self.assertEqual(3.0, db) self.assertNotEqual(0.1, Decimal('0.1')) def test_decimal_complex_comparison(self): Decimal = self.decimal.Decimal da = Decimal('0.25') db = Decimal('3.0') self.assertNotEqual(da, (1.5+0j)) self.assertNotEqual((1.5+0j), da) self.assertEqual(da, (0.25+0j)) self.assertEqual((0.25+0j), da) self.assertEqual((3.0+0j), db) self.assertEqual(db, (3.0+0j)) self.assertNotEqual(db, (3.0+1j)) self.assertNotEqual((3.0+1j), db) self.assertIs(db.__lt__(3.0+0j), NotImplemented) self.assertIs(db.__le__(3.0+0j), NotImplemented) self.assertIs(db.__gt__(3.0+0j), NotImplemented) self.assertIs(db.__le__(3.0+0j), NotImplemented) def test_decimal_fraction_comparison(self): D = self.decimal.Decimal F = fractions[self.decimal].Fraction Context = self.decimal.Context localcontext = self.decimal.localcontext InvalidOperation = self.decimal.InvalidOperation emax = C.MAX_EMAX if C else 999999999 emin = C.MIN_EMIN if C else -999999999 etiny = C.MIN_ETINY if C else -1999999997 c = Context(Emax=emax, Emin=emin) with localcontext(c): c.prec = emax self.assertLess(D(0), F(1,9999999999999999999999999999999999999)) self.assertLess(F(-1,9999999999999999999999999999999999999), D(0)) self.assertLess(F(0,1), D("1e" + str(etiny))) self.assertLess(D("-1e" + str(etiny)), F(0,1)) self.assertLess(F(0,9999999999999999999999999), D("1e" + str(etiny))) self.assertLess(D("-1e" + str(etiny)), F(0,9999999999999999999999999)) self.assertEqual(D("0.1"), F(1,10)) self.assertEqual(F(1,10), D("0.1")) c.prec = 300 self.assertNotEqual(D(1)/3, F(1,3)) self.assertNotEqual(F(1,3), D(1)/3) self.assertLessEqual(F(120984237, 9999999999), D("9e" + str(emax))) self.assertGreaterEqual(D("9e" + str(emax)), F(120984237, 9999999999)) self.assertGreater(D('inf'), F(99999999999,123)) self.assertGreater(D('inf'), F(-99999999999,123)) self.assertLess(D('-inf'), F(99999999999,123)) self.assertLess(D('-inf'), F(-99999999999,123)) self.assertRaises(InvalidOperation, D('nan').__gt__, F(-9,123)) self.assertIs(NotImplemented, F(-9,123).__lt__(D('nan'))) self.assertNotEqual(D('nan'), F(-9,123)) self.assertNotEqual(F(-9,123), D('nan')) def test_copy_and_deepcopy_methods(self): Decimal = self.decimal.Decimal d = Decimal('43.24') c = copy.copy(d) self.assertEqual(id(c), id(d)) dc = copy.deepcopy(d) self.assertEqual(id(dc), id(d)) def test_hash_method(self): Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext def hashit(d): a = hash(d) b = d.__hash__() self.assertEqual(a, b) return a #just that it's hashable hashit(Decimal(23)) hashit(Decimal('Infinity')) hashit(Decimal('-Infinity')) hashit(Decimal('nan123')) hashit(Decimal('-NaN')) test_values = [Decimal(sign*(2**m + n)) for m in [0, 14, 15, 16, 17, 30, 31, 32, 33, 61, 62, 63, 64, 65, 66] for n in range(-10, 10) for sign in [-1, 1]] test_values.extend([ Decimal("-1"), # ==> -2 Decimal("-0"), # zeros Decimal("0.00"), Decimal("-0.000"), Decimal("0E10"), Decimal("-0E12"), Decimal("10.0"), # negative exponent Decimal("-23.00000"), Decimal("1230E100"), # positive exponent Decimal("-4.5678E50"), # a value for which hash(n) != hash(n % (2**64-1)) # in Python pre-2.6 Decimal(2**64 + 2**32 - 1), # selection of values which fail with the old (before # version 2.6) long.__hash__ Decimal("1.634E100"), Decimal("90.697E100"), Decimal("188.83E100"), Decimal("1652.9E100"), Decimal("56531E100"), ]) # check that hash(d) == hash(int(d)) for integral values for value in test_values: self.assertEqual(hashit(value), hashit(int(value))) #the same hash that to an int self.assertEqual(hashit(Decimal(23)), hashit(23)) self.assertRaises(TypeError, hash, Decimal('sNaN')) self.assertTrue(hashit(Decimal('Inf'))) self.assertTrue(hashit(Decimal('-Inf'))) # check that the hashes of a Decimal float match when they # represent exactly the same values test_strings = ['inf', '-Inf', '0.0', '-.0e1', '34.0', '2.5', '112390.625', '-0.515625'] for s in test_strings: f = float(s) d = Decimal(s) self.assertEqual(hashit(f), hashit(d)) with localcontext() as c: # check that the value of the hash doesn't depend on the # current context (issue #1757) x = Decimal("123456789.1") c.prec = 6 h1 = hashit(x) c.prec = 10 h2 = hashit(x) c.prec = 16 h3 = hashit(x) self.assertEqual(h1, h2) self.assertEqual(h1, h3) c.prec = 10000 x = 1100 ** 1248 self.assertEqual(hashit(Decimal(x)), hashit(x)) def test_min_and_max_methods(self): Decimal = self.decimal.Decimal d1 = Decimal('15.32') d2 = Decimal('28.5') l1 = 15 l2 = 28 #between Decimals self.assertIs(min(d1,d2), d1) self.assertIs(min(d2,d1), d1) self.assertIs(max(d1,d2), d2) self.assertIs(max(d2,d1), d2) #between Decimal and int self.assertIs(min(d1,l2), d1) self.assertIs(min(l2,d1), d1) self.assertIs(max(l1,d2), d2) self.assertIs(max(d2,l1), d2) def test_as_nonzero(self): Decimal = self.decimal.Decimal #as false self.assertFalse(Decimal(0)) #as true self.assertTrue(Decimal('0.372')) def test_tostring_methods(self): #Test str and repr methods. Decimal = self.decimal.Decimal d = Decimal('15.32') self.assertEqual(str(d), '15.32') # str self.assertEqual(repr(d), "Decimal('15.32')") # repr def test_tonum_methods(self): #Test float and int methods. Decimal = self.decimal.Decimal d1 = Decimal('66') d2 = Decimal('15.32') #int self.assertEqual(int(d1), 66) self.assertEqual(int(d2), 15) #float self.assertEqual(float(d1), 66) self.assertEqual(float(d2), 15.32) #floor test_pairs = [ ('123.00', 123), ('3.2', 3), ('3.54', 3), ('3.899', 3), ('-2.3', -3), ('-11.0', -11), ('0.0', 0), ('-0E3', 0), ('89891211712379812736.1', 89891211712379812736), ] for d, i in test_pairs: self.assertEqual(math.floor(Decimal(d)), i) self.assertRaises(ValueError, math.floor, Decimal('-NaN')) self.assertRaises(ValueError, math.floor, Decimal('sNaN')) self.assertRaises(ValueError, math.floor, Decimal('NaN123')) self.assertRaises(OverflowError, math.floor, Decimal('Inf')) self.assertRaises(OverflowError, math.floor, Decimal('-Inf')) #ceiling test_pairs = [ ('123.00', 123), ('3.2', 4), ('3.54', 4), ('3.899', 4), ('-2.3', -2), ('-11.0', -11), ('0.0', 0), ('-0E3', 0), ('89891211712379812736.1', 89891211712379812737), ] for d, i in test_pairs: self.assertEqual(math.ceil(Decimal(d)), i) self.assertRaises(ValueError, math.ceil, Decimal('-NaN')) self.assertRaises(ValueError, math.ceil, Decimal('sNaN')) self.assertRaises(ValueError, math.ceil, Decimal('NaN123')) self.assertRaises(OverflowError, math.ceil, Decimal('Inf')) self.assertRaises(OverflowError, math.ceil, Decimal('-Inf')) #round, single argument test_pairs = [ ('123.00', 123), ('3.2', 3), ('3.54', 4), ('3.899', 4), ('-2.3', -2), ('-11.0', -11), ('0.0', 0), ('-0E3', 0), ('-3.5', -4), ('-2.5', -2), ('-1.5', -2), ('-0.5', 0), ('0.5', 0), ('1.5', 2), ('2.5', 2), ('3.5', 4), ] for d, i in test_pairs: self.assertEqual(round(Decimal(d)), i) self.assertRaises(ValueError, round, Decimal('-NaN')) self.assertRaises(ValueError, round, Decimal('sNaN')) self.assertRaises(ValueError, round, Decimal('NaN123')) self.assertRaises(OverflowError, round, Decimal('Inf')) self.assertRaises(OverflowError, round, Decimal('-Inf')) #round, two arguments; this is essentially equivalent #to quantize, which is already extensively tested test_triples = [ ('123.456', -4, '0E+4'), ('123.456', -3, '0E+3'), ('123.456', -2, '1E+2'), ('123.456', -1, '1.2E+2'), ('123.456', 0, '123'), ('123.456', 1, '123.5'), ('123.456', 2, '123.46'), ('123.456', 3, '123.456'), ('123.456', 4, '123.4560'), ('123.455', 2, '123.46'), ('123.445', 2, '123.44'), ('Inf', 4, 'NaN'), ('-Inf', -23, 'NaN'), ('sNaN314', 3, 'NaN314'), ] for d, n, r in test_triples: self.assertEqual(str(round(Decimal(d), n)), r) def test_nan_to_float(self): # Test conversions of decimal NANs to float. # See http://bugs.python.org/issue15544 Decimal = self.decimal.Decimal for s in ('nan', 'nan1234', '-nan', '-nan2468'): f = float(Decimal(s)) self.assertTrue(math.isnan(f)) sign = math.copysign(1.0, f) self.assertEqual(sign, -1.0 if s.startswith('-') else 1.0) def test_snan_to_float(self): Decimal = self.decimal.Decimal for s in ('snan', '-snan', 'snan1357', '-snan1234'): d = Decimal(s) self.assertRaises(ValueError, float, d) def test_eval_round_trip(self): Decimal = self.decimal.Decimal #with zero d = Decimal( (0, (0,), 0) ) self.assertEqual(d, eval(repr(d))) #int d = Decimal( (1, (4, 5), 0) ) self.assertEqual(d, eval(repr(d))) #float d = Decimal( (0, (4, 5, 3, 4), -2) ) self.assertEqual(d, eval(repr(d))) #weird d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) self.assertEqual(d, eval(repr(d))) def test_as_tuple(self): Decimal = self.decimal.Decimal #with zero d = Decimal(0) self.assertEqual(d.as_tuple(), (0, (0,), 0) ) #int d = Decimal(-45) self.assertEqual(d.as_tuple(), (1, (4, 5), 0) ) #complicated string d = Decimal("-4.34913534E-17") self.assertEqual(d.as_tuple(), (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) # The '0' coefficient is implementation specific to decimal.py. # It has no meaning in the C-version and is ignored there. d = Decimal("Infinity") self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) #leading zeros in coefficient should be stripped d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), -2) ) self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), -2) ) d = Decimal( (1, (0, 0, 0), 37) ) self.assertEqual(d.as_tuple(), (1, (0,), 37)) d = Decimal( (1, (), 37) ) self.assertEqual(d.as_tuple(), (1, (0,), 37)) #leading zeros in NaN diagnostic info should be stripped d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), 'n') ) self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), 'n') ) d = Decimal( (1, (0, 0, 0), 'N') ) self.assertEqual(d.as_tuple(), (1, (), 'N') ) d = Decimal( (1, (), 'n') ) self.assertEqual(d.as_tuple(), (1, (), 'n') ) # For infinities, decimal.py has always silently accepted any # coefficient tuple. d = Decimal( (0, (0,), 'F') ) self.assertEqual(d.as_tuple(), (0, (0,), 'F')) d = Decimal( (0, (4, 5, 3, 4), 'F') ) self.assertEqual(d.as_tuple(), (0, (0,), 'F')) d = Decimal( (1, (0, 2, 7, 1), 'F') ) self.assertEqual(d.as_tuple(), (1, (0,), 'F')) def test_as_integer_ratio(self): Decimal = self.decimal.Decimal # exceptional cases self.assertRaises(OverflowError, Decimal.as_integer_ratio, Decimal('inf')) self.assertRaises(OverflowError, Decimal.as_integer_ratio, Decimal('-inf')) self.assertRaises(ValueError, Decimal.as_integer_ratio, Decimal('-nan')) self.assertRaises(ValueError, Decimal.as_integer_ratio, Decimal('snan123')) for exp in range(-4, 2): for coeff in range(1000): for sign in '+', '-': d = Decimal('%s%dE%d' % (sign, coeff, exp)) pq = d.as_integer_ratio() p, q = pq # check return type self.assertIsInstance(pq, tuple) self.assertIsInstance(p, int) self.assertIsInstance(q, int) # check normalization: q should be positive; # p should be relatively prime to q. self.assertGreater(q, 0) self.assertEqual(math.gcd(p, q), 1) # check that p/q actually gives the correct value self.assertEqual(Decimal(p) / Decimal(q), d) def test_subclassing(self): # Different behaviours when subclassing Decimal Decimal = self.decimal.Decimal class MyDecimal(Decimal): y = None d1 = MyDecimal(1) d2 = MyDecimal(2) d = d1 + d2 self.assertIs(type(d), Decimal) d = d1.max(d2) self.assertIs(type(d), Decimal) d = copy.copy(d1) self.assertIs(type(d), MyDecimal) self.assertEqual(d, d1) d = copy.deepcopy(d1) self.assertIs(type(d), MyDecimal) self.assertEqual(d, d1) # Decimal(Decimal) d = Decimal('1.0') x = Decimal(d) self.assertIs(type(x), Decimal) self.assertEqual(x, d) # MyDecimal(Decimal) m = MyDecimal(d) self.assertIs(type(m), MyDecimal) self.assertEqual(m, d) self.assertIs(m.y, None) # Decimal(MyDecimal) x = Decimal(m) self.assertIs(type(x), Decimal) self.assertEqual(x, d) # MyDecimal(MyDecimal) m.y = 9 x = MyDecimal(m) self.assertIs(type(x), MyDecimal) self.assertEqual(x, d) self.assertIs(x.y, None) def test_implicit_context(self): Decimal = self.decimal.Decimal getcontext = self.decimal.getcontext # Check results when context given implicitly. (Issue 2478) c = getcontext() self.assertEqual(str(Decimal(0).sqrt()), str(c.sqrt(Decimal(0)))) def test_none_args(self): Decimal = self.decimal.Decimal Context = self.decimal.Context localcontext = self.decimal.localcontext InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero Overflow = self.decimal.Overflow Underflow = self.decimal.Underflow Subnormal = self.decimal.Subnormal Inexact = self.decimal.Inexact Rounded = self.decimal.Rounded Clamped = self.decimal.Clamped with localcontext(Context()) as c: c.prec = 7 c.Emax = 999 c.Emin = -999 x = Decimal("111") y = Decimal("1e9999") z = Decimal("1e-9999") ##### Unary functions c.clear_flags() self.assertEqual(str(x.exp(context=None)), '1.609487E+48') self.assertTrue(c.flags[Inexact]) self.assertTrue(c.flags[Rounded]) c.clear_flags() self.assertRaises(Overflow, y.exp, context=None) self.assertTrue(c.flags[Overflow]) self.assertIs(z.is_normal(context=None), False) self.assertIs(z.is_subnormal(context=None), True) c.clear_flags() self.assertEqual(str(x.ln(context=None)), '4.709530') self.assertTrue(c.flags[Inexact]) self.assertTrue(c.flags[Rounded]) c.clear_flags() self.assertRaises(InvalidOperation, Decimal(-1).ln, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() self.assertEqual(str(x.log10(context=None)), '2.045323') self.assertTrue(c.flags[Inexact]) self.assertTrue(c.flags[Rounded]) c.clear_flags() self.assertRaises(InvalidOperation, Decimal(-1).log10, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() self.assertEqual(str(x.logb(context=None)), '2') self.assertRaises(DivisionByZero, Decimal(0).logb, context=None) self.assertTrue(c.flags[DivisionByZero]) c.clear_flags() self.assertEqual(str(x.logical_invert(context=None)), '1111000') self.assertRaises(InvalidOperation, y.logical_invert, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() self.assertEqual(str(y.next_minus(context=None)), '9.999999E+999') self.assertRaises(InvalidOperation, Decimal('sNaN').next_minus, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() self.assertEqual(str(y.next_plus(context=None)), 'Infinity') self.assertRaises(InvalidOperation, Decimal('sNaN').next_plus, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() self.assertEqual(str(z.normalize(context=None)), '0') self.assertRaises(Overflow, y.normalize, context=None) self.assertTrue(c.flags[Overflow]) self.assertEqual(str(z.number_class(context=None)), '+Subnormal') c.clear_flags() self.assertEqual(str(z.sqrt(context=None)), '0E-1005') self.assertTrue(c.flags[Clamped]) self.assertTrue(c.flags[Inexact]) self.assertTrue(c.flags[Rounded]) self.assertTrue(c.flags[Subnormal]) self.assertTrue(c.flags[Underflow]) c.clear_flags() self.assertRaises(Overflow, y.sqrt, context=None) self.assertTrue(c.flags[Overflow]) c.capitals = 0 self.assertEqual(str(z.to_eng_string(context=None)), '1e-9999') c.capitals = 1 ##### Binary functions c.clear_flags() ans = str(x.compare(Decimal('Nan891287828'), context=None)) self.assertEqual(ans, 'NaN1287828') self.assertRaises(InvalidOperation, x.compare, Decimal('sNaN'), context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.compare_signal(8224, context=None)) self.assertEqual(ans, '-1') self.assertRaises(InvalidOperation, x.compare_signal, Decimal('NaN'), context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.logical_and(101, context=None)) self.assertEqual(ans, '101') self.assertRaises(InvalidOperation, x.logical_and, 123, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.logical_or(101, context=None)) self.assertEqual(ans, '111') self.assertRaises(InvalidOperation, x.logical_or, 123, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.logical_xor(101, context=None)) self.assertEqual(ans, '10') self.assertRaises(InvalidOperation, x.logical_xor, 123, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.max(101, context=None)) self.assertEqual(ans, '111') self.assertRaises(InvalidOperation, x.max, Decimal('sNaN'), context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.max_mag(101, context=None)) self.assertEqual(ans, '111') self.assertRaises(InvalidOperation, x.max_mag, Decimal('sNaN'), context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.min(101, context=None)) self.assertEqual(ans, '101') self.assertRaises(InvalidOperation, x.min, Decimal('sNaN'), context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.min_mag(101, context=None)) self.assertEqual(ans, '101') self.assertRaises(InvalidOperation, x.min_mag, Decimal('sNaN'), context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.remainder_near(101, context=None)) self.assertEqual(ans, '10') self.assertRaises(InvalidOperation, y.remainder_near, 101, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.rotate(2, context=None)) self.assertEqual(ans, '11100') self.assertRaises(InvalidOperation, x.rotate, 101, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.scaleb(7, context=None)) self.assertEqual(ans, '1.11E+9') self.assertRaises(InvalidOperation, x.scaleb, 10000, context=None) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() ans = str(x.shift(2, context=None)) self.assertEqual(ans, '11100') self.assertRaises(InvalidOperation, x.shift, 10000, context=None) self.assertTrue(c.flags[InvalidOperation]) ##### Ternary functions c.clear_flags() ans = str(x.fma(2, 3, context=None)) self.assertEqual(ans, '225') self.assertRaises(Overflow, x.fma, Decimal('1e9999'), 3, context=None) self.assertTrue(c.flags[Overflow]) ##### Special cases c.rounding = ROUND_HALF_EVEN ans = str(Decimal('1.5').to_integral(rounding=None, context=None)) self.assertEqual(ans, '2') c.rounding = ROUND_DOWN ans = str(Decimal('1.5').to_integral(rounding=None, context=None)) self.assertEqual(ans, '1') ans = str(Decimal('1.5').to_integral(rounding=ROUND_UP, context=None)) self.assertEqual(ans, '2') c.clear_flags() self.assertRaises(InvalidOperation, Decimal('sNaN').to_integral, context=None) self.assertTrue(c.flags[InvalidOperation]) c.rounding = ROUND_HALF_EVEN ans = str(Decimal('1.5').to_integral_value(rounding=None, context=None)) self.assertEqual(ans, '2') c.rounding = ROUND_DOWN ans = str(Decimal('1.5').to_integral_value(rounding=None, context=None)) self.assertEqual(ans, '1') ans = str(Decimal('1.5').to_integral_value(rounding=ROUND_UP, context=None)) self.assertEqual(ans, '2') c.clear_flags() self.assertRaises(InvalidOperation, Decimal('sNaN').to_integral_value, context=None) self.assertTrue(c.flags[InvalidOperation]) c.rounding = ROUND_HALF_EVEN ans = str(Decimal('1.5').to_integral_exact(rounding=None, context=None)) self.assertEqual(ans, '2') c.rounding = ROUND_DOWN ans = str(Decimal('1.5').to_integral_exact(rounding=None, context=None)) self.assertEqual(ans, '1') ans = str(Decimal('1.5').to_integral_exact(rounding=ROUND_UP, context=None)) self.assertEqual(ans, '2') c.clear_flags() self.assertRaises(InvalidOperation, Decimal('sNaN').to_integral_exact, context=None) self.assertTrue(c.flags[InvalidOperation]) c.rounding = ROUND_UP ans = str(Decimal('1.50001').quantize(exp=Decimal('1e-3'), rounding=None, context=None)) self.assertEqual(ans, '1.501') c.rounding = ROUND_DOWN ans = str(Decimal('1.50001').quantize(exp=Decimal('1e-3'), rounding=None, context=None)) self.assertEqual(ans, '1.500') ans = str(Decimal('1.50001').quantize(exp=Decimal('1e-3'), rounding=ROUND_UP, context=None)) self.assertEqual(ans, '1.501') c.clear_flags() self.assertRaises(InvalidOperation, y.quantize, Decimal('1e-10'), rounding=ROUND_UP, context=None) self.assertTrue(c.flags[InvalidOperation]) with localcontext(Context()) as context: context.prec = 7 context.Emax = 999 context.Emin = -999 with localcontext(ctx=None) as c: self.assertEqual(c.prec, 7) self.assertEqual(c.Emax, 999) self.assertEqual(c.Emin, -999) def test_conversions_from_int(self): # Check that methods taking a second Decimal argument will # always accept an integer in place of a Decimal. Decimal = self.decimal.Decimal self.assertEqual(Decimal(4).compare(3), Decimal(4).compare(Decimal(3))) self.assertEqual(Decimal(4).compare_signal(3), Decimal(4).compare_signal(Decimal(3))) self.assertEqual(Decimal(4).compare_total(3), Decimal(4).compare_total(Decimal(3))) self.assertEqual(Decimal(4).compare_total_mag(3), Decimal(4).compare_total_mag(Decimal(3))) self.assertEqual(Decimal(10101).logical_and(1001), Decimal(10101).logical_and(Decimal(1001))) self.assertEqual(Decimal(10101).logical_or(1001), Decimal(10101).logical_or(Decimal(1001))) self.assertEqual(Decimal(10101).logical_xor(1001), Decimal(10101).logical_xor(Decimal(1001))) self.assertEqual(Decimal(567).max(123), Decimal(567).max(Decimal(123))) self.assertEqual(Decimal(567).max_mag(123), Decimal(567).max_mag(Decimal(123))) self.assertEqual(Decimal(567).min(123), Decimal(567).min(Decimal(123))) self.assertEqual(Decimal(567).min_mag(123), Decimal(567).min_mag(Decimal(123))) self.assertEqual(Decimal(567).next_toward(123), Decimal(567).next_toward(Decimal(123))) self.assertEqual(Decimal(1234).quantize(100), Decimal(1234).quantize(Decimal(100))) self.assertEqual(Decimal(768).remainder_near(1234), Decimal(768).remainder_near(Decimal(1234))) self.assertEqual(Decimal(123).rotate(1), Decimal(123).rotate(Decimal(1))) self.assertEqual(Decimal(1234).same_quantum(1000), Decimal(1234).same_quantum(Decimal(1000))) self.assertEqual(Decimal('9.123').scaleb(-100), Decimal('9.123').scaleb(Decimal(-100))) self.assertEqual(Decimal(456).shift(-1), Decimal(456).shift(Decimal(-1))) self.assertEqual(Decimal(-12).fma(Decimal(45), 67), Decimal(-12).fma(Decimal(45), Decimal(67))) self.assertEqual(Decimal(-12).fma(45, 67), Decimal(-12).fma(Decimal(45), Decimal(67))) self.assertEqual(Decimal(-12).fma(45, Decimal(67)), Decimal(-12).fma(Decimal(45), Decimal(67))) class CUsabilityTest(UsabilityTest): decimal = C class PyUsabilityTest(UsabilityTest): decimal = P class PythonAPItests(unittest.TestCase): def test_abc(self): Decimal = self.decimal.Decimal self.assertTrue(issubclass(Decimal, numbers.Number)) self.assertFalse(issubclass(Decimal, numbers.Real)) self.assertIsInstance(Decimal(0), numbers.Number) self.assertNotIsInstance(Decimal(0), numbers.Real) def test_pickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): Decimal = self.decimal.Decimal savedecimal = sys.modules['decimal'] # Round trip sys.modules['decimal'] = self.decimal d = Decimal('-3.141590000') p = pickle.dumps(d, proto) e = pickle.loads(p) self.assertEqual(d, e) if C: # Test interchangeability x = C.Decimal('-3.123e81723') y = P.Decimal('-3.123e81723') sys.modules['decimal'] = C sx = pickle.dumps(x, proto) sys.modules['decimal'] = P r = pickle.loads(sx) self.assertIsInstance(r, P.Decimal) self.assertEqual(r, y) sys.modules['decimal'] = P sy = pickle.dumps(y, proto) sys.modules['decimal'] = C r = pickle.loads(sy) self.assertIsInstance(r, C.Decimal) self.assertEqual(r, x) x = C.Decimal('-3.123e81723').as_tuple() y = P.Decimal('-3.123e81723').as_tuple() sys.modules['decimal'] = C sx = pickle.dumps(x, proto) sys.modules['decimal'] = P r = pickle.loads(sx) self.assertIsInstance(r, P.DecimalTuple) self.assertEqual(r, y) sys.modules['decimal'] = P sy = pickle.dumps(y, proto) sys.modules['decimal'] = C r = pickle.loads(sy) self.assertIsInstance(r, C.DecimalTuple) self.assertEqual(r, x) sys.modules['decimal'] = savedecimal def test_int(self): Decimal = self.decimal.Decimal for x in range(-250, 250): s = '%0.2f' % (x / 100.0) # should work the same as for floats self.assertEqual(int(Decimal(s)), int(float(s))) # should work the same as to_integral in the ROUND_DOWN mode d = Decimal(s) r = d.to_integral(ROUND_DOWN) self.assertEqual(Decimal(int(d)), r) self.assertRaises(ValueError, int, Decimal('-nan')) self.assertRaises(ValueError, int, Decimal('snan')) self.assertRaises(OverflowError, int, Decimal('inf')) self.assertRaises(OverflowError, int, Decimal('-inf')) def test_trunc(self): Decimal = self.decimal.Decimal for x in range(-250, 250): s = '%0.2f' % (x / 100.0) # should work the same as for floats self.assertEqual(int(Decimal(s)), int(float(s))) # should work the same as to_integral in the ROUND_DOWN mode d = Decimal(s) r = d.to_integral(ROUND_DOWN) self.assertEqual(Decimal(math.trunc(d)), r) def test_from_float(self): Decimal = self.decimal.Decimal class MyDecimal(Decimal): def __init__(self, _): self.x = 'y' self.assertTrue(issubclass(MyDecimal, Decimal)) r = MyDecimal.from_float(0.1) self.assertEqual(type(r), MyDecimal) self.assertEqual(str(r), '0.1000000000000000055511151231257827021181583404541015625') self.assertEqual(r.x, 'y') bigint = 12345678901234567890123456789 self.assertEqual(MyDecimal.from_float(bigint), MyDecimal(bigint)) self.assertTrue(MyDecimal.from_float(float('nan')).is_qnan()) self.assertTrue(MyDecimal.from_float(float('inf')).is_infinite()) self.assertTrue(MyDecimal.from_float(float('-inf')).is_infinite()) self.assertEqual(str(MyDecimal.from_float(float('nan'))), str(Decimal('NaN'))) self.assertEqual(str(MyDecimal.from_float(float('inf'))), str(Decimal('Infinity'))) self.assertEqual(str(MyDecimal.from_float(float('-inf'))), str(Decimal('-Infinity'))) self.assertRaises(TypeError, MyDecimal.from_float, 'abc') for i in range(200): x = random.expovariate(0.01) * (random.random() * 2.0 - 1.0) self.assertEqual(x, float(MyDecimal.from_float(x))) # roundtrip def test_create_decimal_from_float(self): Decimal = self.decimal.Decimal Context = self.decimal.Context Inexact = self.decimal.Inexact context = Context(prec=5, rounding=ROUND_DOWN) self.assertEqual( context.create_decimal_from_float(math.pi), Decimal('3.1415') ) context = Context(prec=5, rounding=ROUND_UP) self.assertEqual( context.create_decimal_from_float(math.pi), Decimal('3.1416') ) context = Context(prec=5, traps=[Inexact]) self.assertRaises( Inexact, context.create_decimal_from_float, math.pi ) self.assertEqual(repr(context.create_decimal_from_float(-0.0)), "Decimal('-0')") self.assertEqual(repr(context.create_decimal_from_float(1.0)), "Decimal('1')") self.assertEqual(repr(context.create_decimal_from_float(10)), "Decimal('10')") def test_quantize(self): Decimal = self.decimal.Decimal Context = self.decimal.Context InvalidOperation = self.decimal.InvalidOperation c = Context(Emax=99999, Emin=-99999) self.assertEqual( Decimal('7.335').quantize(Decimal('.01')), Decimal('7.34') ) self.assertEqual( Decimal('7.335').quantize(Decimal('.01'), rounding=ROUND_DOWN), Decimal('7.33') ) self.assertRaises( InvalidOperation, Decimal("10e99999").quantize, Decimal('1e100000'), context=c ) c = Context() d = Decimal("0.871831e800") x = d.quantize(context=c, exp=Decimal("1e797"), rounding=ROUND_DOWN) self.assertEqual(x, Decimal('8.71E+799')) def test_complex(self): Decimal = self.decimal.Decimal x = Decimal("9.8182731e181273") self.assertEqual(x.real, x) self.assertEqual(x.imag, 0) self.assertEqual(x.conjugate(), x) x = Decimal("1") self.assertEqual(complex(x), complex(float(1))) self.assertRaises(AttributeError, setattr, x, 'real', 100) self.assertRaises(AttributeError, setattr, x, 'imag', 100) self.assertRaises(AttributeError, setattr, x, 'conjugate', 100) self.assertRaises(AttributeError, setattr, x, '__complex__', 100) def test_named_parameters(self): D = self.decimal.Decimal Context = self.decimal.Context localcontext = self.decimal.localcontext InvalidOperation = self.decimal.InvalidOperation Overflow = self.decimal.Overflow xc = Context() xc.prec = 1 xc.Emax = 1 xc.Emin = -1 with localcontext() as c: c.clear_flags() self.assertEqual(D(9, xc), 9) self.assertEqual(D(9, context=xc), 9) self.assertEqual(D(context=xc, value=9), 9) self.assertEqual(D(context=xc), 0) xc.clear_flags() self.assertRaises(InvalidOperation, D, "xyz", context=xc) self.assertTrue(xc.flags[InvalidOperation]) self.assertFalse(c.flags[InvalidOperation]) xc.clear_flags() self.assertEqual(D(2).exp(context=xc), 7) self.assertRaises(Overflow, D(8).exp, context=xc) self.assertTrue(xc.flags[Overflow]) self.assertFalse(c.flags[Overflow]) xc.clear_flags() self.assertEqual(D(2).ln(context=xc), D('0.7')) self.assertRaises(InvalidOperation, D(-1).ln, context=xc) self.assertTrue(xc.flags[InvalidOperation]) self.assertFalse(c.flags[InvalidOperation]) self.assertEqual(D(0).log10(context=xc), D('-inf')) self.assertEqual(D(-1).next_minus(context=xc), -2) self.assertEqual(D(-1).next_plus(context=xc), D('-0.9')) self.assertEqual(D("9.73").normalize(context=xc), D('1E+1')) self.assertEqual(D("9999").to_integral(context=xc), 9999) self.assertEqual(D("-2000").to_integral_exact(context=xc), -2000) self.assertEqual(D("123").to_integral_value(context=xc), 123) self.assertEqual(D("0.0625").sqrt(context=xc), D('0.2')) self.assertEqual(D("0.0625").compare(context=xc, other=3), -1) xc.clear_flags() self.assertRaises(InvalidOperation, D("0").compare_signal, D('nan'), context=xc) self.assertTrue(xc.flags[InvalidOperation]) self.assertFalse(c.flags[InvalidOperation]) self.assertEqual(D("0.01").max(D('0.0101'), context=xc), D('0.0')) self.assertEqual(D("0.01").max(D('0.0101'), context=xc), D('0.0')) self.assertEqual(D("0.2").max_mag(D('-0.3'), context=xc), D('-0.3')) self.assertEqual(D("0.02").min(D('-0.03'), context=xc), D('-0.0')) self.assertEqual(D("0.02").min_mag(D('-0.03'), context=xc), D('0.0')) self.assertEqual(D("0.2").next_toward(D('-1'), context=xc), D('0.1')) xc.clear_flags() self.assertRaises(InvalidOperation, D("0.2").quantize, D('1e10'), context=xc) self.assertTrue(xc.flags[InvalidOperation]) self.assertFalse(c.flags[InvalidOperation]) self.assertEqual(D("9.99").remainder_near(D('1.5'), context=xc), D('-0.5')) self.assertEqual(D("9.9").fma(third=D('0.9'), context=xc, other=7), D('7E+1')) self.assertRaises(TypeError, D(1).is_canonical, context=xc) self.assertRaises(TypeError, D(1).is_finite, context=xc) self.assertRaises(TypeError, D(1).is_infinite, context=xc) self.assertRaises(TypeError, D(1).is_nan, context=xc) self.assertRaises(TypeError, D(1).is_qnan, context=xc) self.assertRaises(TypeError, D(1).is_snan, context=xc) self.assertRaises(TypeError, D(1).is_signed, context=xc) self.assertRaises(TypeError, D(1).is_zero, context=xc) self.assertFalse(D("0.01").is_normal(context=xc)) self.assertTrue(D("0.01").is_subnormal(context=xc)) self.assertRaises(TypeError, D(1).adjusted, context=xc) self.assertRaises(TypeError, D(1).conjugate, context=xc) self.assertRaises(TypeError, D(1).radix, context=xc) self.assertEqual(D(-111).logb(context=xc), 2) self.assertEqual(D(0).logical_invert(context=xc), 1) self.assertEqual(D('0.01').number_class(context=xc), '+Subnormal') self.assertEqual(D('0.21').to_eng_string(context=xc), '0.21') self.assertEqual(D('11').logical_and(D('10'), context=xc), 0) self.assertEqual(D('11').logical_or(D('10'), context=xc), 1) self.assertEqual(D('01').logical_xor(D('10'), context=xc), 1) self.assertEqual(D('23').rotate(1, context=xc), 3) self.assertEqual(D('23').rotate(1, context=xc), 3) xc.clear_flags() self.assertRaises(Overflow, D('23').scaleb, 1, context=xc) self.assertTrue(xc.flags[Overflow]) self.assertFalse(c.flags[Overflow]) self.assertEqual(D('23').shift(-1, context=xc), 0) self.assertRaises(TypeError, D.from_float, 1.1, context=xc) self.assertRaises(TypeError, D(0).as_tuple, context=xc) self.assertEqual(D(1).canonical(), 1) self.assertRaises(TypeError, D("-1").copy_abs, context=xc) self.assertRaises(TypeError, D("-1").copy_negate, context=xc) self.assertRaises(TypeError, D(1).canonical, context="x") self.assertRaises(TypeError, D(1).canonical, xyz="x") def test_exception_hierarchy(self): decimal = self.decimal DecimalException = decimal.DecimalException InvalidOperation = decimal.InvalidOperation FloatOperation = decimal.FloatOperation DivisionByZero = decimal.DivisionByZero Overflow = decimal.Overflow Underflow = decimal.Underflow Subnormal = decimal.Subnormal Inexact = decimal.Inexact Rounded = decimal.Rounded Clamped = decimal.Clamped self.assertTrue(issubclass(DecimalException, ArithmeticError)) self.assertTrue(issubclass(InvalidOperation, DecimalException)) self.assertTrue(issubclass(FloatOperation, DecimalException)) self.assertTrue(issubclass(FloatOperation, TypeError)) self.assertTrue(issubclass(DivisionByZero, DecimalException)) self.assertTrue(issubclass(DivisionByZero, ZeroDivisionError)) self.assertTrue(issubclass(Overflow, Rounded)) self.assertTrue(issubclass(Overflow, Inexact)) self.assertTrue(issubclass(Overflow, DecimalException)) self.assertTrue(issubclass(Underflow, Inexact)) self.assertTrue(issubclass(Underflow, Rounded)) self.assertTrue(issubclass(Underflow, Subnormal)) self.assertTrue(issubclass(Underflow, DecimalException)) self.assertTrue(issubclass(Subnormal, DecimalException)) self.assertTrue(issubclass(Inexact, DecimalException)) self.assertTrue(issubclass(Rounded, DecimalException)) self.assertTrue(issubclass(Clamped, DecimalException)) self.assertTrue(issubclass(decimal.ConversionSyntax, InvalidOperation)) self.assertTrue(issubclass(decimal.DivisionImpossible, InvalidOperation)) self.assertTrue(issubclass(decimal.DivisionUndefined, InvalidOperation)) self.assertTrue(issubclass(decimal.DivisionUndefined, ZeroDivisionError)) self.assertTrue(issubclass(decimal.InvalidContext, InvalidOperation)) class CPythonAPItests(PythonAPItests): decimal = C class PyPythonAPItests(PythonAPItests): decimal = P class ContextAPItests(unittest.TestCase): def test_none_args(self): Context = self.decimal.Context InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero Overflow = self.decimal.Overflow c1 = Context() c2 = Context(prec=None, rounding=None, Emax=None, Emin=None, capitals=None, clamp=None, flags=None, traps=None) for c in [c1, c2]: self.assertEqual(c.prec, 28) self.assertEqual(c.rounding, ROUND_HALF_EVEN) self.assertEqual(c.Emax, 999999) self.assertEqual(c.Emin, -999999) self.assertEqual(c.capitals, 1) self.assertEqual(c.clamp, 0) assert_signals(self, c, 'flags', []) assert_signals(self, c, 'traps', [InvalidOperation, DivisionByZero, Overflow]) @cpython_only def test_from_legacy_strings(self): import _testcapi c = self.decimal.Context() for rnd in RoundingModes: c.rounding = _testcapi.unicode_legacy_string(rnd) self.assertEqual(c.rounding, rnd) s = _testcapi.unicode_legacy_string('') self.assertRaises(TypeError, setattr, c, 'rounding', s) s = _testcapi.unicode_legacy_string('ROUND_\x00UP') self.assertRaises(TypeError, setattr, c, 'rounding', s) def test_pickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): Context = self.decimal.Context savedecimal = sys.modules['decimal'] # Round trip sys.modules['decimal'] = self.decimal c = Context() e = pickle.loads(pickle.dumps(c, proto)) self.assertEqual(c.prec, e.prec) self.assertEqual(c.Emin, e.Emin) self.assertEqual(c.Emax, e.Emax) self.assertEqual(c.rounding, e.rounding) self.assertEqual(c.capitals, e.capitals) self.assertEqual(c.clamp, e.clamp) self.assertEqual(c.flags, e.flags) self.assertEqual(c.traps, e.traps) # Test interchangeability combinations = [(C, P), (P, C)] if C else [(P, P)] for dumper, loader in combinations: for ri, _ in enumerate(RoundingModes): for fi, _ in enumerate(OrderedSignals[dumper]): for ti, _ in enumerate(OrderedSignals[dumper]): prec = random.randrange(1, 100) emin = random.randrange(-100, 0) emax = random.randrange(1, 100) caps = random.randrange(2) clamp = random.randrange(2) # One module dumps sys.modules['decimal'] = dumper c = dumper.Context( prec=prec, Emin=emin, Emax=emax, rounding=RoundingModes[ri], capitals=caps, clamp=clamp, flags=OrderedSignals[dumper][:fi], traps=OrderedSignals[dumper][:ti] ) s = pickle.dumps(c, proto) # The other module loads sys.modules['decimal'] = loader d = pickle.loads(s) self.assertIsInstance(d, loader.Context) self.assertEqual(d.prec, prec) self.assertEqual(d.Emin, emin) self.assertEqual(d.Emax, emax) self.assertEqual(d.rounding, RoundingModes[ri]) self.assertEqual(d.capitals, caps) self.assertEqual(d.clamp, clamp) assert_signals(self, d, 'flags', OrderedSignals[loader][:fi]) assert_signals(self, d, 'traps', OrderedSignals[loader][:ti]) sys.modules['decimal'] = savedecimal def test_equality_with_other_types(self): Decimal = self.decimal.Decimal self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}]) self.assertNotIn(Decimal(10), ['a', 1.0, (1,2), {}]) def test_copy(self): # All copies should be deep Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.copy() self.assertNotEqual(id(c), id(d)) self.assertNotEqual(id(c.flags), id(d.flags)) self.assertNotEqual(id(c.traps), id(d.traps)) k1 = set(c.flags.keys()) k2 = set(d.flags.keys()) self.assertEqual(k1, k2) self.assertEqual(c.flags, d.flags) def test__clamp(self): # In Python 3.2, the private attribute `_clamp` was made # public (issue 8540), with the old `_clamp` becoming a # property wrapping `clamp`. For the duration of Python 3.2 # only, the attribute should be gettable/settable via both # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be # removed. Context = self.decimal.Context c = Context() self.assertRaises(AttributeError, getattr, c, '_clamp') def test_abs(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.abs(Decimal(-1)) self.assertEqual(c.abs(-1), d) self.assertRaises(TypeError, c.abs, '-1') def test_add(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.add(Decimal(1), Decimal(1)) self.assertEqual(c.add(1, 1), d) self.assertEqual(c.add(Decimal(1), 1), d) self.assertEqual(c.add(1, Decimal(1)), d) self.assertRaises(TypeError, c.add, '1', 1) self.assertRaises(TypeError, c.add, 1, '1') def test_compare(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.compare(Decimal(1), Decimal(1)) self.assertEqual(c.compare(1, 1), d) self.assertEqual(c.compare(Decimal(1), 1), d) self.assertEqual(c.compare(1, Decimal(1)), d) self.assertRaises(TypeError, c.compare, '1', 1) self.assertRaises(TypeError, c.compare, 1, '1') def test_compare_signal(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.compare_signal(Decimal(1), Decimal(1)) self.assertEqual(c.compare_signal(1, 1), d) self.assertEqual(c.compare_signal(Decimal(1), 1), d) self.assertEqual(c.compare_signal(1, Decimal(1)), d) self.assertRaises(TypeError, c.compare_signal, '1', 1) self.assertRaises(TypeError, c.compare_signal, 1, '1') def test_compare_total(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.compare_total(Decimal(1), Decimal(1)) self.assertEqual(c.compare_total(1, 1), d) self.assertEqual(c.compare_total(Decimal(1), 1), d) self.assertEqual(c.compare_total(1, Decimal(1)), d) self.assertRaises(TypeError, c.compare_total, '1', 1) self.assertRaises(TypeError, c.compare_total, 1, '1') def test_compare_total_mag(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.compare_total_mag(Decimal(1), Decimal(1)) self.assertEqual(c.compare_total_mag(1, 1), d) self.assertEqual(c.compare_total_mag(Decimal(1), 1), d) self.assertEqual(c.compare_total_mag(1, Decimal(1)), d) self.assertRaises(TypeError, c.compare_total_mag, '1', 1) self.assertRaises(TypeError, c.compare_total_mag, 1, '1') def test_copy_abs(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.copy_abs(Decimal(-1)) self.assertEqual(c.copy_abs(-1), d) self.assertRaises(TypeError, c.copy_abs, '-1') def test_copy_decimal(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.copy_decimal(Decimal(-1)) self.assertEqual(c.copy_decimal(-1), d) self.assertRaises(TypeError, c.copy_decimal, '-1') def test_copy_negate(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.copy_negate(Decimal(-1)) self.assertEqual(c.copy_negate(-1), d) self.assertRaises(TypeError, c.copy_negate, '-1') def test_copy_sign(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.copy_sign(Decimal(1), Decimal(-2)) self.assertEqual(c.copy_sign(1, -2), d) self.assertEqual(c.copy_sign(Decimal(1), -2), d) self.assertEqual(c.copy_sign(1, Decimal(-2)), d) self.assertRaises(TypeError, c.copy_sign, '1', -2) self.assertRaises(TypeError, c.copy_sign, 1, '-2') def test_divide(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.divide(Decimal(1), Decimal(2)) self.assertEqual(c.divide(1, 2), d) self.assertEqual(c.divide(Decimal(1), 2), d) self.assertEqual(c.divide(1, Decimal(2)), d) self.assertRaises(TypeError, c.divide, '1', 2) self.assertRaises(TypeError, c.divide, 1, '2') def test_divide_int(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.divide_int(Decimal(1), Decimal(2)) self.assertEqual(c.divide_int(1, 2), d) self.assertEqual(c.divide_int(Decimal(1), 2), d) self.assertEqual(c.divide_int(1, Decimal(2)), d) self.assertRaises(TypeError, c.divide_int, '1', 2) self.assertRaises(TypeError, c.divide_int, 1, '2') def test_divmod(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.divmod(Decimal(1), Decimal(2)) self.assertEqual(c.divmod(1, 2), d) self.assertEqual(c.divmod(Decimal(1), 2), d) self.assertEqual(c.divmod(1, Decimal(2)), d) self.assertRaises(TypeError, c.divmod, '1', 2) self.assertRaises(TypeError, c.divmod, 1, '2') def test_exp(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.exp(Decimal(10)) self.assertEqual(c.exp(10), d) self.assertRaises(TypeError, c.exp, '10') def test_fma(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.fma(Decimal(2), Decimal(3), Decimal(4)) self.assertEqual(c.fma(2, 3, 4), d) self.assertEqual(c.fma(Decimal(2), 3, 4), d) self.assertEqual(c.fma(2, Decimal(3), 4), d) self.assertEqual(c.fma(2, 3, Decimal(4)), d) self.assertEqual(c.fma(Decimal(2), Decimal(3), 4), d) self.assertRaises(TypeError, c.fma, '2', 3, 4) self.assertRaises(TypeError, c.fma, 2, '3', 4) self.assertRaises(TypeError, c.fma, 2, 3, '4') # Issue 12079 for Context.fma ... self.assertRaises(TypeError, c.fma, Decimal('Infinity'), Decimal(0), "not a decimal") self.assertRaises(TypeError, c.fma, Decimal(1), Decimal('snan'), 1.222) # ... and for Decimal.fma. self.assertRaises(TypeError, Decimal('Infinity').fma, Decimal(0), "not a decimal") self.assertRaises(TypeError, Decimal(1).fma, Decimal('snan'), 1.222) def test_is_finite(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_finite(Decimal(10)) self.assertEqual(c.is_finite(10), d) self.assertRaises(TypeError, c.is_finite, '10') def test_is_infinite(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_infinite(Decimal(10)) self.assertEqual(c.is_infinite(10), d) self.assertRaises(TypeError, c.is_infinite, '10') def test_is_nan(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_nan(Decimal(10)) self.assertEqual(c.is_nan(10), d) self.assertRaises(TypeError, c.is_nan, '10') def test_is_normal(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_normal(Decimal(10)) self.assertEqual(c.is_normal(10), d) self.assertRaises(TypeError, c.is_normal, '10') def test_is_qnan(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_qnan(Decimal(10)) self.assertEqual(c.is_qnan(10), d) self.assertRaises(TypeError, c.is_qnan, '10') def test_is_signed(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_signed(Decimal(10)) self.assertEqual(c.is_signed(10), d) self.assertRaises(TypeError, c.is_signed, '10') def test_is_snan(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_snan(Decimal(10)) self.assertEqual(c.is_snan(10), d) self.assertRaises(TypeError, c.is_snan, '10') def test_is_subnormal(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_subnormal(Decimal(10)) self.assertEqual(c.is_subnormal(10), d) self.assertRaises(TypeError, c.is_subnormal, '10') def test_is_zero(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.is_zero(Decimal(10)) self.assertEqual(c.is_zero(10), d) self.assertRaises(TypeError, c.is_zero, '10') def test_ln(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.ln(Decimal(10)) self.assertEqual(c.ln(10), d) self.assertRaises(TypeError, c.ln, '10') def test_log10(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.log10(Decimal(10)) self.assertEqual(c.log10(10), d) self.assertRaises(TypeError, c.log10, '10') def test_logb(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.logb(Decimal(10)) self.assertEqual(c.logb(10), d) self.assertRaises(TypeError, c.logb, '10') def test_logical_and(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.logical_and(Decimal(1), Decimal(1)) self.assertEqual(c.logical_and(1, 1), d) self.assertEqual(c.logical_and(Decimal(1), 1), d) self.assertEqual(c.logical_and(1, Decimal(1)), d) self.assertRaises(TypeError, c.logical_and, '1', 1) self.assertRaises(TypeError, c.logical_and, 1, '1') def test_logical_invert(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.logical_invert(Decimal(1000)) self.assertEqual(c.logical_invert(1000), d) self.assertRaises(TypeError, c.logical_invert, '1000') def test_logical_or(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.logical_or(Decimal(1), Decimal(1)) self.assertEqual(c.logical_or(1, 1), d) self.assertEqual(c.logical_or(Decimal(1), 1), d) self.assertEqual(c.logical_or(1, Decimal(1)), d) self.assertRaises(TypeError, c.logical_or, '1', 1) self.assertRaises(TypeError, c.logical_or, 1, '1') def test_logical_xor(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.logical_xor(Decimal(1), Decimal(1)) self.assertEqual(c.logical_xor(1, 1), d) self.assertEqual(c.logical_xor(Decimal(1), 1), d) self.assertEqual(c.logical_xor(1, Decimal(1)), d) self.assertRaises(TypeError, c.logical_xor, '1', 1) self.assertRaises(TypeError, c.logical_xor, 1, '1') def test_max(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.max(Decimal(1), Decimal(2)) self.assertEqual(c.max(1, 2), d) self.assertEqual(c.max(Decimal(1), 2), d) self.assertEqual(c.max(1, Decimal(2)), d) self.assertRaises(TypeError, c.max, '1', 2) self.assertRaises(TypeError, c.max, 1, '2') def test_max_mag(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.max_mag(Decimal(1), Decimal(2)) self.assertEqual(c.max_mag(1, 2), d) self.assertEqual(c.max_mag(Decimal(1), 2), d) self.assertEqual(c.max_mag(1, Decimal(2)), d) self.assertRaises(TypeError, c.max_mag, '1', 2) self.assertRaises(TypeError, c.max_mag, 1, '2') def test_min(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.min(Decimal(1), Decimal(2)) self.assertEqual(c.min(1, 2), d) self.assertEqual(c.min(Decimal(1), 2), d) self.assertEqual(c.min(1, Decimal(2)), d) self.assertRaises(TypeError, c.min, '1', 2) self.assertRaises(TypeError, c.min, 1, '2') def test_min_mag(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.min_mag(Decimal(1), Decimal(2)) self.assertEqual(c.min_mag(1, 2), d) self.assertEqual(c.min_mag(Decimal(1), 2), d) self.assertEqual(c.min_mag(1, Decimal(2)), d) self.assertRaises(TypeError, c.min_mag, '1', 2) self.assertRaises(TypeError, c.min_mag, 1, '2') def test_minus(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.minus(Decimal(10)) self.assertEqual(c.minus(10), d) self.assertRaises(TypeError, c.minus, '10') def test_multiply(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.multiply(Decimal(1), Decimal(2)) self.assertEqual(c.multiply(1, 2), d) self.assertEqual(c.multiply(Decimal(1), 2), d) self.assertEqual(c.multiply(1, Decimal(2)), d) self.assertRaises(TypeError, c.multiply, '1', 2) self.assertRaises(TypeError, c.multiply, 1, '2') def test_next_minus(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.next_minus(Decimal(10)) self.assertEqual(c.next_minus(10), d) self.assertRaises(TypeError, c.next_minus, '10') def test_next_plus(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.next_plus(Decimal(10)) self.assertEqual(c.next_plus(10), d) self.assertRaises(TypeError, c.next_plus, '10') def test_next_toward(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.next_toward(Decimal(1), Decimal(2)) self.assertEqual(c.next_toward(1, 2), d) self.assertEqual(c.next_toward(Decimal(1), 2), d) self.assertEqual(c.next_toward(1, Decimal(2)), d) self.assertRaises(TypeError, c.next_toward, '1', 2) self.assertRaises(TypeError, c.next_toward, 1, '2') def test_normalize(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.normalize(Decimal(10)) self.assertEqual(c.normalize(10), d) self.assertRaises(TypeError, c.normalize, '10') def test_number_class(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() self.assertEqual(c.number_class(123), c.number_class(Decimal(123))) self.assertEqual(c.number_class(0), c.number_class(Decimal(0))) self.assertEqual(c.number_class(-45), c.number_class(Decimal(-45))) def test_plus(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.plus(Decimal(10)) self.assertEqual(c.plus(10), d) self.assertRaises(TypeError, c.plus, '10') def test_power(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.power(Decimal(1), Decimal(4)) self.assertEqual(c.power(1, 4), d) self.assertEqual(c.power(Decimal(1), 4), d) self.assertEqual(c.power(1, Decimal(4)), d) self.assertEqual(c.power(Decimal(1), Decimal(4)), d) self.assertRaises(TypeError, c.power, '1', 4) self.assertRaises(TypeError, c.power, 1, '4') self.assertEqual(c.power(modulo=5, b=8, a=2), 1) def test_quantize(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.quantize(Decimal(1), Decimal(2)) self.assertEqual(c.quantize(1, 2), d) self.assertEqual(c.quantize(Decimal(1), 2), d) self.assertEqual(c.quantize(1, Decimal(2)), d) self.assertRaises(TypeError, c.quantize, '1', 2) self.assertRaises(TypeError, c.quantize, 1, '2') def test_remainder(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.remainder(Decimal(1), Decimal(2)) self.assertEqual(c.remainder(1, 2), d) self.assertEqual(c.remainder(Decimal(1), 2), d) self.assertEqual(c.remainder(1, Decimal(2)), d) self.assertRaises(TypeError, c.remainder, '1', 2) self.assertRaises(TypeError, c.remainder, 1, '2') def test_remainder_near(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.remainder_near(Decimal(1), Decimal(2)) self.assertEqual(c.remainder_near(1, 2), d) self.assertEqual(c.remainder_near(Decimal(1), 2), d) self.assertEqual(c.remainder_near(1, Decimal(2)), d) self.assertRaises(TypeError, c.remainder_near, '1', 2) self.assertRaises(TypeError, c.remainder_near, 1, '2') def test_rotate(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.rotate(Decimal(1), Decimal(2)) self.assertEqual(c.rotate(1, 2), d) self.assertEqual(c.rotate(Decimal(1), 2), d) self.assertEqual(c.rotate(1, Decimal(2)), d) self.assertRaises(TypeError, c.rotate, '1', 2) self.assertRaises(TypeError, c.rotate, 1, '2') def test_sqrt(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.sqrt(Decimal(10)) self.assertEqual(c.sqrt(10), d) self.assertRaises(TypeError, c.sqrt, '10') def test_same_quantum(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.same_quantum(Decimal(1), Decimal(2)) self.assertEqual(c.same_quantum(1, 2), d) self.assertEqual(c.same_quantum(Decimal(1), 2), d) self.assertEqual(c.same_quantum(1, Decimal(2)), d) self.assertRaises(TypeError, c.same_quantum, '1', 2) self.assertRaises(TypeError, c.same_quantum, 1, '2') def test_scaleb(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.scaleb(Decimal(1), Decimal(2)) self.assertEqual(c.scaleb(1, 2), d) self.assertEqual(c.scaleb(Decimal(1), 2), d) self.assertEqual(c.scaleb(1, Decimal(2)), d) self.assertRaises(TypeError, c.scaleb, '1', 2) self.assertRaises(TypeError, c.scaleb, 1, '2') def test_shift(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.shift(Decimal(1), Decimal(2)) self.assertEqual(c.shift(1, 2), d) self.assertEqual(c.shift(Decimal(1), 2), d) self.assertEqual(c.shift(1, Decimal(2)), d) self.assertRaises(TypeError, c.shift, '1', 2) self.assertRaises(TypeError, c.shift, 1, '2') def test_subtract(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.subtract(Decimal(1), Decimal(2)) self.assertEqual(c.subtract(1, 2), d) self.assertEqual(c.subtract(Decimal(1), 2), d) self.assertEqual(c.subtract(1, Decimal(2)), d) self.assertRaises(TypeError, c.subtract, '1', 2) self.assertRaises(TypeError, c.subtract, 1, '2') def test_to_eng_string(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.to_eng_string(Decimal(10)) self.assertEqual(c.to_eng_string(10), d) self.assertRaises(TypeError, c.to_eng_string, '10') def test_to_sci_string(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.to_sci_string(Decimal(10)) self.assertEqual(c.to_sci_string(10), d) self.assertRaises(TypeError, c.to_sci_string, '10') def test_to_integral_exact(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.to_integral_exact(Decimal(10)) self.assertEqual(c.to_integral_exact(10), d) self.assertRaises(TypeError, c.to_integral_exact, '10') def test_to_integral_value(self): Decimal = self.decimal.Decimal Context = self.decimal.Context c = Context() d = c.to_integral_value(Decimal(10)) self.assertEqual(c.to_integral_value(10), d) self.assertRaises(TypeError, c.to_integral_value, '10') self.assertRaises(TypeError, c.to_integral_value, 10, 'x') class CContextAPItests(ContextAPItests): decimal = C class PyContextAPItests(ContextAPItests): decimal = P class ContextWithStatement(unittest.TestCase): # Can't do these as docstrings until Python 2.6 # as doctest can't handle __future__ statements def test_localcontext(self): # Use a copy of the current context in the block getcontext = self.decimal.getcontext localcontext = self.decimal.localcontext orig_ctx = getcontext() with localcontext() as enter_ctx: set_ctx = getcontext() final_ctx = getcontext() self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly') self.assertIsNot(orig_ctx, set_ctx, 'did not copy the context') self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context') def test_localcontextarg(self): # Use a copy of the supplied context in the block Context = self.decimal.Context getcontext = self.decimal.getcontext localcontext = self.decimal.localcontext localcontext = self.decimal.localcontext orig_ctx = getcontext() new_ctx = Context(prec=42) with localcontext(new_ctx) as enter_ctx: set_ctx = getcontext() final_ctx = getcontext() self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly') self.assertEqual(set_ctx.prec, new_ctx.prec, 'did not set correct context') self.assertIsNot(new_ctx, set_ctx, 'did not copy the context') self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context') def test_nested_with_statements(self): # Use a copy of the supplied context in the block Decimal = self.decimal.Decimal Context = self.decimal.Context getcontext = self.decimal.getcontext localcontext = self.decimal.localcontext Clamped = self.decimal.Clamped Overflow = self.decimal.Overflow orig_ctx = getcontext() orig_ctx.clear_flags() new_ctx = Context(Emax=384) with localcontext() as c1: self.assertEqual(c1.flags, orig_ctx.flags) self.assertEqual(c1.traps, orig_ctx.traps) c1.traps[Clamped] = True c1.Emin = -383 self.assertNotEqual(orig_ctx.Emin, -383) self.assertRaises(Clamped, c1.create_decimal, '0e-999') self.assertTrue(c1.flags[Clamped]) with localcontext(new_ctx) as c2: self.assertEqual(c2.flags, new_ctx.flags) self.assertEqual(c2.traps, new_ctx.traps) self.assertRaises(Overflow, c2.power, Decimal('3.4e200'), 2) self.assertFalse(c2.flags[Clamped]) self.assertTrue(c2.flags[Overflow]) del c2 self.assertFalse(c1.flags[Overflow]) del c1 self.assertNotEqual(orig_ctx.Emin, -383) self.assertFalse(orig_ctx.flags[Clamped]) self.assertFalse(orig_ctx.flags[Overflow]) self.assertFalse(new_ctx.flags[Clamped]) self.assertFalse(new_ctx.flags[Overflow]) def test_with_statements_gc1(self): localcontext = self.decimal.localcontext with localcontext() as c1: del c1 with localcontext() as c2: del c2 with localcontext() as c3: del c3 with localcontext() as c4: del c4 def test_with_statements_gc2(self): localcontext = self.decimal.localcontext with localcontext() as c1: with localcontext(c1) as c2: del c1 with localcontext(c2) as c3: del c2 with localcontext(c3) as c4: del c3 del c4 def test_with_statements_gc3(self): Context = self.decimal.Context localcontext = self.decimal.localcontext getcontext = self.decimal.getcontext setcontext = self.decimal.setcontext with localcontext() as c1: del c1 n1 = Context(prec=1) setcontext(n1) with localcontext(n1) as c2: del n1 self.assertEqual(c2.prec, 1) del c2 n2 = Context(prec=2) setcontext(n2) del n2 self.assertEqual(getcontext().prec, 2) n3 = Context(prec=3) setcontext(n3) self.assertEqual(getcontext().prec, 3) with localcontext(n3) as c3: del n3 self.assertEqual(c3.prec, 3) del c3 n4 = Context(prec=4) setcontext(n4) del n4 self.assertEqual(getcontext().prec, 4) with localcontext() as c4: self.assertEqual(c4.prec, 4) del c4 class CContextWithStatement(ContextWithStatement): decimal = C class PyContextWithStatement(ContextWithStatement): decimal = P class ContextFlags(unittest.TestCase): def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags Decimal = self.decimal.Decimal Context = self.decimal.Context Inexact = self.decimal.Inexact Rounded = self.decimal.Rounded Underflow = self.decimal.Underflow Clamped = self.decimal.Clamped Subnormal = self.decimal.Subnormal def raise_error(context, flag): if self.decimal == C: context.flags[flag] = True if context.traps[flag]: raise flag else: context._raise_error(flag) context = Context(prec=9, Emin = -425000000, Emax = 425000000, rounding=ROUND_HALF_EVEN, traps=[], flags=[]) # operations that raise various flags, in the form (function, arglist) operations = [ (context._apply, [Decimal("100E-425000010")]), (context.sqrt, [Decimal(2)]), (context.add, [Decimal("1.23456789"), Decimal("9.87654321")]), (context.multiply, [Decimal("1.23456789"), Decimal("9.87654321")]), (context.subtract, [Decimal("1.23456789"), Decimal("9.87654321")]), ] # try various flags individually, then a whole lot at once flagsets = [[Inexact], [Rounded], [Underflow], [Clamped], [Subnormal], [Inexact, Rounded, Underflow, Clamped, Subnormal]] for fn, args in operations: # find answer and flags raised using a clean context context.clear_flags() ans = fn(*args) flags = [k for k, v in context.flags.items() if v] for extra_flags in flagsets: # set flags, before calling operation context.clear_flags() for flag in extra_flags: raise_error(context, flag) new_ans = fn(*args) # flags that we expect to be set after the operation expected_flags = list(flags) for flag in extra_flags: if flag not in expected_flags: expected_flags.append(flag) expected_flags.sort(key=id) # flags we actually got new_flags = [k for k,v in context.flags.items() if v] new_flags.sort(key=id) self.assertEqual(ans, new_ans, "operation produces different answers depending on flags set: " + "expected %s, got %s." % (ans, new_ans)) self.assertEqual(new_flags, expected_flags, "operation raises different flags depending on flags set: " + "expected %s, got %s" % (expected_flags, new_flags)) def test_flag_comparisons(self): Context = self.decimal.Context Inexact = self.decimal.Inexact Rounded = self.decimal.Rounded c = Context() # Valid SignalDict self.assertNotEqual(c.flags, c.traps) self.assertNotEqual(c.traps, c.flags) c.flags = c.traps self.assertEqual(c.flags, c.traps) self.assertEqual(c.traps, c.flags) c.flags[Rounded] = True c.traps = c.flags self.assertEqual(c.flags, c.traps) self.assertEqual(c.traps, c.flags) d = {} d.update(c.flags) self.assertEqual(d, c.flags) self.assertEqual(c.flags, d) d[Inexact] = True self.assertNotEqual(d, c.flags) self.assertNotEqual(c.flags, d) # Invalid SignalDict d = {Inexact:False} self.assertNotEqual(d, c.flags) self.assertNotEqual(c.flags, d) d = ["xyz"] self.assertNotEqual(d, c.flags) self.assertNotEqual(c.flags, d) @requires_IEEE_754 def test_float_operation(self): Decimal = self.decimal.Decimal FloatOperation = self.decimal.FloatOperation localcontext = self.decimal.localcontext with localcontext() as c: ##### trap is off by default self.assertFalse(c.traps[FloatOperation]) # implicit conversion sets the flag c.clear_flags() self.assertEqual(Decimal(7.5), 7.5) self.assertTrue(c.flags[FloatOperation]) c.clear_flags() self.assertEqual(c.create_decimal(7.5), 7.5) self.assertTrue(c.flags[FloatOperation]) # explicit conversion does not set the flag c.clear_flags() x = Decimal.from_float(7.5) self.assertFalse(c.flags[FloatOperation]) # comparison sets the flag self.assertEqual(x, 7.5) self.assertTrue(c.flags[FloatOperation]) c.clear_flags() x = c.create_decimal_from_float(7.5) self.assertFalse(c.flags[FloatOperation]) self.assertEqual(x, 7.5) self.assertTrue(c.flags[FloatOperation]) ##### set the trap c.traps[FloatOperation] = True # implicit conversion raises c.clear_flags() self.assertRaises(FloatOperation, Decimal, 7.5) self.assertTrue(c.flags[FloatOperation]) c.clear_flags() self.assertRaises(FloatOperation, c.create_decimal, 7.5) self.assertTrue(c.flags[FloatOperation]) # explicit conversion is silent c.clear_flags() x = Decimal.from_float(7.5) self.assertFalse(c.flags[FloatOperation]) c.clear_flags() x = c.create_decimal_from_float(7.5) self.assertFalse(c.flags[FloatOperation]) def test_float_comparison(self): Decimal = self.decimal.Decimal Context = self.decimal.Context FloatOperation = self.decimal.FloatOperation localcontext = self.decimal.localcontext def assert_attr(a, b, attr, context, signal=None): context.clear_flags() f = getattr(a, attr) if signal == FloatOperation: self.assertRaises(signal, f, b) else: self.assertIs(f(b), True) self.assertTrue(context.flags[FloatOperation]) small_d = Decimal('0.25') big_d = Decimal('3.0') small_f = 0.25 big_f = 3.0 zero_d = Decimal('0.0') neg_zero_d = Decimal('-0.0') zero_f = 0.0 neg_zero_f = -0.0 inf_d = Decimal('Infinity') neg_inf_d = Decimal('-Infinity') inf_f = float('inf') neg_inf_f = float('-inf') def doit(c, signal=None): # Order for attr in '__lt__', '__le__': assert_attr(small_d, big_f, attr, c, signal) for attr in '__gt__', '__ge__': assert_attr(big_d, small_f, attr, c, signal) # Equality assert_attr(small_d, small_f, '__eq__', c, None) assert_attr(neg_zero_d, neg_zero_f, '__eq__', c, None) assert_attr(neg_zero_d, zero_f, '__eq__', c, None) assert_attr(zero_d, neg_zero_f, '__eq__', c, None) assert_attr(zero_d, zero_f, '__eq__', c, None) assert_attr(neg_inf_d, neg_inf_f, '__eq__', c, None) assert_attr(inf_d, inf_f, '__eq__', c, None) # Inequality assert_attr(small_d, big_f, '__ne__', c, None) assert_attr(Decimal('0.1'), 0.1, '__ne__', c, None) assert_attr(neg_inf_d, inf_f, '__ne__', c, None) assert_attr(inf_d, neg_inf_f, '__ne__', c, None) assert_attr(Decimal('NaN'), float('nan'), '__ne__', c, None) def test_containers(c, signal=None): c.clear_flags() s = set([100.0, Decimal('100.0')]) self.assertEqual(len(s), 1) self.assertTrue(c.flags[FloatOperation]) c.clear_flags() if signal: self.assertRaises(signal, sorted, [1.0, Decimal('10.0')]) else: s = sorted([10.0, Decimal('10.0')]) self.assertTrue(c.flags[FloatOperation]) c.clear_flags() b = 10.0 in [Decimal('10.0'), 1.0] self.assertTrue(c.flags[FloatOperation]) c.clear_flags() b = 10.0 in {Decimal('10.0'):'a', 1.0:'b'} self.assertTrue(c.flags[FloatOperation]) nc = Context() with localcontext(nc) as c: self.assertFalse(c.traps[FloatOperation]) doit(c, signal=None) test_containers(c, signal=None) c.traps[FloatOperation] = True doit(c, signal=FloatOperation) test_containers(c, signal=FloatOperation) def test_float_operation_default(self): Decimal = self.decimal.Decimal Context = self.decimal.Context Inexact = self.decimal.Inexact FloatOperation= self.decimal.FloatOperation context = Context() self.assertFalse(context.flags[FloatOperation]) self.assertFalse(context.traps[FloatOperation]) context.clear_traps() context.traps[Inexact] = True context.traps[FloatOperation] = True self.assertTrue(context.traps[FloatOperation]) self.assertTrue(context.traps[Inexact]) class CContextFlags(ContextFlags): decimal = C class PyContextFlags(ContextFlags): decimal = P class SpecialContexts(unittest.TestCase): """Test the context templates.""" def test_context_templates(self): BasicContext = self.decimal.BasicContext ExtendedContext = self.decimal.ExtendedContext getcontext = self.decimal.getcontext setcontext = self.decimal.setcontext InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero Overflow = self.decimal.Overflow Underflow = self.decimal.Underflow Clamped = self.decimal.Clamped assert_signals(self, BasicContext, 'traps', [InvalidOperation, DivisionByZero, Overflow, Underflow, Clamped] ) savecontext = getcontext().copy() basic_context_prec = BasicContext.prec extended_context_prec = ExtendedContext.prec ex = None try: BasicContext.prec = ExtendedContext.prec = 441 for template in BasicContext, ExtendedContext: setcontext(template) c = getcontext() self.assertIsNot(c, template) self.assertEqual(c.prec, 441) except Exception as e: ex = e.__class__ finally: BasicContext.prec = basic_context_prec ExtendedContext.prec = extended_context_prec setcontext(savecontext) if ex: raise ex def test_default_context(self): DefaultContext = self.decimal.DefaultContext BasicContext = self.decimal.BasicContext ExtendedContext = self.decimal.ExtendedContext getcontext = self.decimal.getcontext setcontext = self.decimal.setcontext InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero Overflow = self.decimal.Overflow self.assertEqual(BasicContext.prec, 9) self.assertEqual(ExtendedContext.prec, 9) assert_signals(self, DefaultContext, 'traps', [InvalidOperation, DivisionByZero, Overflow] ) savecontext = getcontext().copy() default_context_prec = DefaultContext.prec ex = None try: c = getcontext() saveprec = c.prec DefaultContext.prec = 961 c = getcontext() self.assertEqual(c.prec, saveprec) setcontext(DefaultContext) c = getcontext() self.assertIsNot(c, DefaultContext) self.assertEqual(c.prec, 961) except Exception as e: ex = e.__class__ finally: DefaultContext.prec = default_context_prec setcontext(savecontext) if ex: raise ex class CSpecialContexts(SpecialContexts): decimal = C class PySpecialContexts(SpecialContexts): decimal = P class ContextInputValidation(unittest.TestCase): def test_invalid_context(self): Context = self.decimal.Context DefaultContext = self.decimal.DefaultContext c = DefaultContext.copy() # prec, Emax for attr in ['prec', 'Emax']: setattr(c, attr, 999999) self.assertEqual(getattr(c, attr), 999999) self.assertRaises(ValueError, setattr, c, attr, -1) self.assertRaises(TypeError, setattr, c, attr, 'xyz') # Emin setattr(c, 'Emin', -999999) self.assertEqual(getattr(c, 'Emin'), -999999) self.assertRaises(ValueError, setattr, c, 'Emin', 1) self.assertRaises(TypeError, setattr, c, 'Emin', (1,2,3)) self.assertRaises(TypeError, setattr, c, 'rounding', -1) self.assertRaises(TypeError, setattr, c, 'rounding', 9) self.assertRaises(TypeError, setattr, c, 'rounding', 1.0) self.assertRaises(TypeError, setattr, c, 'rounding', 'xyz') # capitals, clamp for attr in ['capitals', 'clamp']: self.assertRaises(ValueError, setattr, c, attr, -1) self.assertRaises(ValueError, setattr, c, attr, 2) self.assertRaises(TypeError, setattr, c, attr, [1,2,3]) # Invalid attribute self.assertRaises(AttributeError, setattr, c, 'emax', 100) # Invalid signal dict self.assertRaises(TypeError, setattr, c, 'flags', []) self.assertRaises(KeyError, setattr, c, 'flags', {}) self.assertRaises(KeyError, setattr, c, 'traps', {'InvalidOperation':0}) # Attributes cannot be deleted for attr in ['prec', 'Emax', 'Emin', 'rounding', 'capitals', 'clamp', 'flags', 'traps']: self.assertRaises(AttributeError, c.__delattr__, attr) # Invalid attributes self.assertRaises(TypeError, getattr, c, 9) self.assertRaises(TypeError, setattr, c, 9) # Invalid values in constructor self.assertRaises(TypeError, Context, rounding=999999) self.assertRaises(TypeError, Context, rounding='xyz') self.assertRaises(ValueError, Context, clamp=2) self.assertRaises(ValueError, Context, capitals=-1) self.assertRaises(KeyError, Context, flags=["P"]) self.assertRaises(KeyError, Context, traps=["Q"]) # Type error in conversion self.assertRaises(TypeError, Context, flags=(0,1)) self.assertRaises(TypeError, Context, traps=(1,0)) class CContextInputValidation(ContextInputValidation): decimal = C class PyContextInputValidation(ContextInputValidation): decimal = P class ContextSubclassing(unittest.TestCase): def test_context_subclassing(self): decimal = self.decimal Decimal = decimal.Decimal Context = decimal.Context Clamped = decimal.Clamped DivisionByZero = decimal.DivisionByZero Inexact = decimal.Inexact Overflow = decimal.Overflow Rounded = decimal.Rounded Subnormal = decimal.Subnormal Underflow = decimal.Underflow InvalidOperation = decimal.InvalidOperation class MyContext(Context): def __init__(self, prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=None, flags=None, traps=None): Context.__init__(self) if prec is not None: self.prec = prec if rounding is not None: self.rounding = rounding if Emin is not None: self.Emin = Emin if Emax is not None: self.Emax = Emax if capitals is not None: self.capitals = capitals if clamp is not None: self.clamp = clamp if flags is not None: if isinstance(flags, list): flags = {v:(v in flags) for v in OrderedSignals[decimal] + flags} self.flags = flags if traps is not None: if isinstance(traps, list): traps = {v:(v in traps) for v in OrderedSignals[decimal] + traps} self.traps = traps c = Context() d = MyContext() for attr in ('prec', 'rounding', 'Emin', 'Emax', 'capitals', 'clamp', 'flags', 'traps'): self.assertEqual(getattr(c, attr), getattr(d, attr)) # prec self.assertRaises(ValueError, MyContext, **{'prec':-1}) c = MyContext(prec=1) self.assertEqual(c.prec, 1) self.assertRaises(InvalidOperation, c.quantize, Decimal('9e2'), 0) # rounding self.assertRaises(TypeError, MyContext, **{'rounding':'XYZ'}) c = MyContext(rounding=ROUND_DOWN, prec=1) self.assertEqual(c.rounding, ROUND_DOWN) self.assertEqual(c.plus(Decimal('9.9')), 9) # Emin self.assertRaises(ValueError, MyContext, **{'Emin':5}) c = MyContext(Emin=-1, prec=1) self.assertEqual(c.Emin, -1) x = c.add(Decimal('1e-99'), Decimal('2.234e-2000')) self.assertEqual(x, Decimal('0.0')) for signal in (Inexact, Underflow, Subnormal, Rounded, Clamped): self.assertTrue(c.flags[signal]) # Emax self.assertRaises(ValueError, MyContext, **{'Emax':-1}) c = MyContext(Emax=1, prec=1) self.assertEqual(c.Emax, 1) self.assertRaises(Overflow, c.add, Decimal('1e99'), Decimal('2.234e2000')) if self.decimal == C: for signal in (Inexact, Overflow, Rounded): self.assertTrue(c.flags[signal]) # capitals self.assertRaises(ValueError, MyContext, **{'capitals':-1}) c = MyContext(capitals=0) self.assertEqual(c.capitals, 0) x = c.create_decimal('1E222') self.assertEqual(c.to_sci_string(x), '1e+222') # clamp self.assertRaises(ValueError, MyContext, **{'clamp':2}) c = MyContext(clamp=1, Emax=99) self.assertEqual(c.clamp, 1) x = c.plus(Decimal('1e99')) self.assertEqual(str(x), '1.000000000000000000000000000E+99') # flags self.assertRaises(TypeError, MyContext, **{'flags':'XYZ'}) c = MyContext(flags=[Rounded, DivisionByZero]) for signal in (Rounded, DivisionByZero): self.assertTrue(c.flags[signal]) c.clear_flags() for signal in OrderedSignals[decimal]: self.assertFalse(c.flags[signal]) # traps self.assertRaises(TypeError, MyContext, **{'traps':'XYZ'}) c = MyContext(traps=[Rounded, DivisionByZero]) for signal in (Rounded, DivisionByZero): self.assertTrue(c.traps[signal]) c.clear_traps() for signal in OrderedSignals[decimal]: self.assertFalse(c.traps[signal]) class CContextSubclassing(ContextSubclassing): decimal = C class PyContextSubclassing(ContextSubclassing): decimal = P @skip_if_extra_functionality class CheckAttributes(unittest.TestCase): def test_module_attributes(self): # Architecture dependent context limits self.assertEqual(C.MAX_PREC, P.MAX_PREC) self.assertEqual(C.MAX_EMAX, P.MAX_EMAX) self.assertEqual(C.MIN_EMIN, P.MIN_EMIN) self.assertEqual(C.MIN_ETINY, P.MIN_ETINY) self.assertTrue(C.HAVE_THREADS is True or C.HAVE_THREADS is False) self.assertTrue(P.HAVE_THREADS is True or P.HAVE_THREADS is False) self.assertEqual(C.__version__, P.__version__) self.assertEqual(dir(C), dir(P)) def test_context_attributes(self): x = [s for s in dir(C.Context()) if '__' in s or not s.startswith('_')] y = [s for s in dir(P.Context()) if '__' in s or not s.startswith('_')] self.assertEqual(set(x) - set(y), set()) def test_decimal_attributes(self): x = [s for s in dir(C.Decimal(9)) if '__' in s or not s.startswith('_')] y = [s for s in dir(C.Decimal(9)) if '__' in s or not s.startswith('_')] self.assertEqual(set(x) - set(y), set()) class Coverage(unittest.TestCase): def test_adjusted(self): Decimal = self.decimal.Decimal self.assertEqual(Decimal('1234e9999').adjusted(), 10002) # XXX raise? self.assertEqual(Decimal('nan').adjusted(), 0) self.assertEqual(Decimal('inf').adjusted(), 0) def test_canonical(self): Decimal = self.decimal.Decimal getcontext = self.decimal.getcontext x = Decimal(9).canonical() self.assertEqual(x, 9) c = getcontext() x = c.canonical(Decimal(9)) self.assertEqual(x, 9) def test_context_repr(self): c = self.decimal.DefaultContext.copy() c.prec = 425000000 c.Emax = 425000000 c.Emin = -425000000 c.rounding = ROUND_HALF_DOWN c.capitals = 0 c.clamp = 1 for sig in OrderedSignals[self.decimal]: c.flags[sig] = False c.traps[sig] = False s = c.__repr__() t = "Context(prec=425000000, rounding=ROUND_HALF_DOWN, " \ "Emin=-425000000, Emax=425000000, capitals=0, clamp=1, " \ "flags=[], traps=[])" self.assertEqual(s, t) def test_implicit_context(self): Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext with localcontext() as c: c.prec = 1 c.Emax = 1 c.Emin = -1 # abs self.assertEqual(abs(Decimal("-10")), 10) # add self.assertEqual(Decimal("7") + 1, 8) # divide self.assertEqual(Decimal("10") / 5, 2) # divide_int self.assertEqual(Decimal("10") // 7, 1) # fma self.assertEqual(Decimal("1.2").fma(Decimal("0.01"), 1), 1) self.assertIs(Decimal("NaN").fma(7, 1).is_nan(), True) # three arg power self.assertEqual(pow(Decimal(10), 2, 7), 2) # exp self.assertEqual(Decimal("1.01").exp(), 3) # is_normal self.assertIs(Decimal("0.01").is_normal(), False) # is_subnormal self.assertIs(Decimal("0.01").is_subnormal(), True) # ln self.assertEqual(Decimal("20").ln(), 3) # log10 self.assertEqual(Decimal("20").log10(), 1) # logb self.assertEqual(Decimal("580").logb(), 2) # logical_invert self.assertEqual(Decimal("10").logical_invert(), 1) # minus self.assertEqual(-Decimal("-10"), 10) # multiply self.assertEqual(Decimal("2") * 4, 8) # next_minus self.assertEqual(Decimal("10").next_minus(), 9) # next_plus self.assertEqual(Decimal("10").next_plus(), Decimal('2E+1')) # normalize self.assertEqual(Decimal("-10").normalize(), Decimal('-1E+1')) # number_class self.assertEqual(Decimal("10").number_class(), '+Normal') # plus self.assertEqual(+Decimal("-1"), -1) # remainder self.assertEqual(Decimal("10") % 7, 3) # subtract self.assertEqual(Decimal("10") - 7, 3) # to_integral_exact self.assertEqual(Decimal("1.12345").to_integral_exact(), 1) # Boolean functions self.assertTrue(Decimal("1").is_canonical()) self.assertTrue(Decimal("1").is_finite()) self.assertTrue(Decimal("1").is_finite()) self.assertTrue(Decimal("snan").is_snan()) self.assertTrue(Decimal("-1").is_signed()) self.assertTrue(Decimal("0").is_zero()) self.assertTrue(Decimal("0").is_zero()) # Copy with localcontext() as c: c.prec = 10000 x = 1228 ** 1523 y = -Decimal(x) z = y.copy_abs() self.assertEqual(z, x) z = y.copy_negate() self.assertEqual(z, x) z = y.copy_sign(Decimal(1)) self.assertEqual(z, x) def test_divmod(self): Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero with localcontext() as c: q, r = divmod(Decimal("10912837129"), 1001) self.assertEqual(q, Decimal('10901935')) self.assertEqual(r, Decimal('194')) q, r = divmod(Decimal("NaN"), 7) self.assertTrue(q.is_nan() and r.is_nan()) c.traps[InvalidOperation] = False q, r = divmod(Decimal("NaN"), 7) self.assertTrue(q.is_nan() and r.is_nan()) c.traps[InvalidOperation] = False c.clear_flags() q, r = divmod(Decimal("inf"), Decimal("inf")) self.assertTrue(q.is_nan() and r.is_nan()) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() q, r = divmod(Decimal("inf"), 101) self.assertTrue(q.is_infinite() and r.is_nan()) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() q, r = divmod(Decimal(0), 0) self.assertTrue(q.is_nan() and r.is_nan()) self.assertTrue(c.flags[InvalidOperation]) c.traps[DivisionByZero] = False c.clear_flags() q, r = divmod(Decimal(11), 0) self.assertTrue(q.is_infinite() and r.is_nan()) self.assertTrue(c.flags[InvalidOperation] and c.flags[DivisionByZero]) def test_power(self): Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext Overflow = self.decimal.Overflow Rounded = self.decimal.Rounded with localcontext() as c: c.prec = 3 c.clear_flags() self.assertEqual(Decimal("1.0") ** 100, Decimal('1.00')) self.assertTrue(c.flags[Rounded]) c.prec = 1 c.Emax = 1 c.Emin = -1 c.clear_flags() c.traps[Overflow] = False self.assertEqual(Decimal(10000) ** Decimal("0.5"), Decimal('inf')) self.assertTrue(c.flags[Overflow]) def test_quantize(self): Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext InvalidOperation = self.decimal.InvalidOperation with localcontext() as c: c.prec = 1 c.Emax = 1 c.Emin = -1 c.traps[InvalidOperation] = False x = Decimal(99).quantize(Decimal("1e1")) self.assertTrue(x.is_nan()) def test_radix(self): Decimal = self.decimal.Decimal getcontext = self.decimal.getcontext c = getcontext() self.assertEqual(Decimal("1").radix(), 10) self.assertEqual(c.radix(), 10) def test_rop(self): Decimal = self.decimal.Decimal for attr in ('__radd__', '__rsub__', '__rmul__', '__rtruediv__', '__rdivmod__', '__rmod__', '__rfloordiv__', '__rpow__'): self.assertIs(getattr(Decimal("1"), attr)("xyz"), NotImplemented) def test_round(self): # Python3 behavior: round() returns Decimal Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext with localcontext() as c: c.prec = 28 self.assertEqual(str(Decimal("9.99").__round__()), "10") self.assertEqual(str(Decimal("9.99e-5").__round__()), "0") self.assertEqual(str(Decimal("1.23456789").__round__(5)), "1.23457") self.assertEqual(str(Decimal("1.2345").__round__(10)), "1.2345000000") self.assertEqual(str(Decimal("1.2345").__round__(-10)), "0E+10") self.assertRaises(TypeError, Decimal("1.23").__round__, "5") self.assertRaises(TypeError, Decimal("1.23").__round__, 5, 8) def test_create_decimal(self): c = self.decimal.Context() self.assertRaises(ValueError, c.create_decimal, ["%"]) def test_int(self): Decimal = self.decimal.Decimal localcontext = self.decimal.localcontext with localcontext() as c: c.prec = 9999 x = Decimal(1221**1271) / 10**3923 self.assertEqual(int(x), 1) self.assertEqual(x.to_integral(), 2) def test_copy(self): Context = self.decimal.Context c = Context() c.prec = 10000 x = -(1172 ** 1712) y = c.copy_abs(x) self.assertEqual(y, -x) y = c.copy_negate(x) self.assertEqual(y, -x) y = c.copy_sign(x, 1) self.assertEqual(y, -x) class CCoverage(Coverage): decimal = C class PyCoverage(Coverage): decimal = P class PyFunctionality(unittest.TestCase): """Extra functionality in decimal.py""" def test_py_alternate_formatting(self): # triples giving a format, a Decimal, and the expected result Decimal = P.Decimal localcontext = P.localcontext test_values = [ # Issue 7094: Alternate formatting (specified by #) ('.0e', '1.0', '1e+0'), ('#.0e', '1.0', '1.e+0'), ('.0f', '1.0', '1'), ('#.0f', '1.0', '1.'), ('g', '1.1', '1.1'), ('#g', '1.1', '1.1'), ('.0g', '1', '1'), ('#.0g', '1', '1.'), ('.0%', '1.0', '100%'), ('#.0%', '1.0', '100.%'), ] for fmt, d, result in test_values: self.assertEqual(format(Decimal(d), fmt), result) class PyWhitebox(unittest.TestCase): """White box testing for decimal.py""" def test_py_exact_power(self): # Rarely exercised lines in _power_exact. Decimal = P.Decimal localcontext = P.localcontext with localcontext() as c: c.prec = 8 x = Decimal(2**16) ** Decimal("-0.5") self.assertEqual(x, Decimal('0.00390625')) x = Decimal(2**16) ** Decimal("-0.6") self.assertEqual(x, Decimal('0.0012885819')) x = Decimal("256e7") ** Decimal("-0.5") x = Decimal(152587890625) ** Decimal('-0.0625') self.assertEqual(x, Decimal("0.2")) x = Decimal("152587890625e7") ** Decimal('-0.0625') x = Decimal(5**2659) ** Decimal('-0.0625') c.prec = 1 x = Decimal("152587890625") ** Decimal('-0.5') c.prec = 201 x = Decimal(2**578) ** Decimal("-0.5") def test_py_immutability_operations(self): # Do operations and check that it didn't change internal objects. Decimal = P.Decimal DefaultContext = P.DefaultContext setcontext = P.setcontext c = DefaultContext.copy() c.traps = dict((s, 0) for s in OrderedSignals[P]) setcontext(c) d1 = Decimal('-25e55') b1 = Decimal('-25e55') d2 = Decimal('33e+33') b2 = Decimal('33e+33') def checkSameDec(operation, useOther=False): if useOther: eval("d1." + operation + "(d2)") self.assertEqual(d1._sign, b1._sign) self.assertEqual(d1._int, b1._int) self.assertEqual(d1._exp, b1._exp) self.assertEqual(d2._sign, b2._sign) self.assertEqual(d2._int, b2._int) self.assertEqual(d2._exp, b2._exp) else: eval("d1." + operation + "()") self.assertEqual(d1._sign, b1._sign) self.assertEqual(d1._int, b1._int) self.assertEqual(d1._exp, b1._exp) Decimal(d1) self.assertEqual(d1._sign, b1._sign) self.assertEqual(d1._int, b1._int) self.assertEqual(d1._exp, b1._exp) checkSameDec("__abs__") checkSameDec("__add__", True) checkSameDec("__divmod__", True) checkSameDec("__eq__", True) checkSameDec("__ne__", True) checkSameDec("__le__", True) checkSameDec("__lt__", True) checkSameDec("__ge__", True) checkSameDec("__gt__", True) checkSameDec("__float__") checkSameDec("__floordiv__", True) checkSameDec("__hash__") checkSameDec("__int__") checkSameDec("__trunc__") checkSameDec("__mod__", True) checkSameDec("__mul__", True) checkSameDec("__neg__") checkSameDec("__bool__") checkSameDec("__pos__") checkSameDec("__pow__", True) checkSameDec("__radd__", True) checkSameDec("__rdivmod__", True) checkSameDec("__repr__") checkSameDec("__rfloordiv__", True) checkSameDec("__rmod__", True) checkSameDec("__rmul__", True) checkSameDec("__rpow__", True) checkSameDec("__rsub__", True) checkSameDec("__str__") checkSameDec("__sub__", True) checkSameDec("__truediv__", True) checkSameDec("adjusted") checkSameDec("as_tuple") checkSameDec("compare", True) checkSameDec("max", True) checkSameDec("min", True) checkSameDec("normalize") checkSameDec("quantize", True) checkSameDec("remainder_near", True) checkSameDec("same_quantum", True) checkSameDec("sqrt") checkSameDec("to_eng_string") checkSameDec("to_integral") def test_py_decimal_id(self): Decimal = P.Decimal d = Decimal(45) e = Decimal(d) self.assertEqual(str(e), '45') self.assertNotEqual(id(d), id(e)) def test_py_rescale(self): # Coverage Decimal = P.Decimal localcontext = P.localcontext with localcontext() as c: x = Decimal("NaN")._rescale(3, ROUND_UP) self.assertTrue(x.is_nan()) def test_py__round(self): # Coverage Decimal = P.Decimal self.assertRaises(ValueError, Decimal("3.1234")._round, 0, ROUND_UP) class CFunctionality(unittest.TestCase): """Extra functionality in _decimal""" @requires_extra_functionality def test_c_ieee_context(self): # issue 8786: Add support for IEEE 754 contexts to decimal module. IEEEContext = C.IEEEContext DECIMAL32 = C.DECIMAL32 DECIMAL64 = C.DECIMAL64 DECIMAL128 = C.DECIMAL128 def assert_rest(self, context): self.assertEqual(context.clamp, 1) assert_signals(self, context, 'traps', []) assert_signals(self, context, 'flags', []) c = IEEEContext(DECIMAL32) self.assertEqual(c.prec, 7) self.assertEqual(c.Emax, 96) self.assertEqual(c.Emin, -95) assert_rest(self, c) c = IEEEContext(DECIMAL64) self.assertEqual(c.prec, 16) self.assertEqual(c.Emax, 384) self.assertEqual(c.Emin, -383) assert_rest(self, c) c = IEEEContext(DECIMAL128) self.assertEqual(c.prec, 34) self.assertEqual(c.Emax, 6144) self.assertEqual(c.Emin, -6143) assert_rest(self, c) # Invalid values self.assertRaises(OverflowError, IEEEContext, 2**63) self.assertRaises(ValueError, IEEEContext, -1) self.assertRaises(ValueError, IEEEContext, 1024) @requires_extra_functionality def test_c_context(self): Context = C.Context c = Context(flags=C.DecClamped, traps=C.DecRounded) self.assertEqual(c._flags, C.DecClamped) self.assertEqual(c._traps, C.DecRounded) @requires_extra_functionality def test_constants(self): # Condition flags cond = ( C.DecClamped, C.DecConversionSyntax, C.DecDivisionByZero, C.DecDivisionImpossible, C.DecDivisionUndefined, C.DecFpuError, C.DecInexact, C.DecInvalidContext, C.DecInvalidOperation, C.DecMallocError, C.DecFloatOperation, C.DecOverflow, C.DecRounded, C.DecSubnormal, C.DecUnderflow ) # IEEEContext self.assertEqual(C.DECIMAL32, 32) self.assertEqual(C.DECIMAL64, 64) self.assertEqual(C.DECIMAL128, 128) self.assertEqual(C.IEEE_CONTEXT_MAX_BITS, 512) # Conditions for i, v in enumerate(cond): self.assertEqual(v, 1<<i) self.assertEqual(C.DecIEEEInvalidOperation, C.DecConversionSyntax| C.DecDivisionImpossible| C.DecDivisionUndefined| C.DecFpuError| C.DecInvalidContext| C.DecInvalidOperation| C.DecMallocError) self.assertEqual(C.DecErrors, C.DecIEEEInvalidOperation| C.DecDivisionByZero) self.assertEqual(C.DecTraps, C.DecErrors|C.DecOverflow|C.DecUnderflow) class CWhitebox(unittest.TestCase): """Whitebox testing for _decimal""" def test_bignum(self): # Not exactly whitebox, but too slow with pydecimal. Decimal = C.Decimal localcontext = C.localcontext b1 = 10**35 b2 = 10**36 with localcontext() as c: c.prec = 1000000 for i in range(5): a = random.randrange(b1, b2) b = random.randrange(1000, 1200) x = a ** b y = Decimal(a) ** Decimal(b) self.assertEqual(x, y) def test_invalid_construction(self): self.assertRaises(TypeError, C.Decimal, 9, "xyz") def test_c_input_restriction(self): # Too large for _decimal to be converted exactly Decimal = C.Decimal InvalidOperation = C.InvalidOperation Context = C.Context localcontext = C.localcontext with localcontext(Context()): self.assertRaises(InvalidOperation, Decimal, "1e9999999999999999999") def test_c_context_repr(self): # This test is _decimal-only because flags are not printed # in the same order. DefaultContext = C.DefaultContext FloatOperation = C.FloatOperation c = DefaultContext.copy() c.prec = 425000000 c.Emax = 425000000 c.Emin = -425000000 c.rounding = ROUND_HALF_DOWN c.capitals = 0 c.clamp = 1 for sig in OrderedSignals[C]: c.flags[sig] = True c.traps[sig] = True c.flags[FloatOperation] = True c.traps[FloatOperation] = True s = c.__repr__() t = "Context(prec=425000000, rounding=ROUND_HALF_DOWN, " \ "Emin=-425000000, Emax=425000000, capitals=0, clamp=1, " \ "flags=[Clamped, InvalidOperation, DivisionByZero, Inexact, " \ "FloatOperation, Overflow, Rounded, Subnormal, Underflow], " \ "traps=[Clamped, InvalidOperation, DivisionByZero, Inexact, " \ "FloatOperation, Overflow, Rounded, Subnormal, Underflow])" self.assertEqual(s, t) def test_c_context_errors(self): Context = C.Context InvalidOperation = C.InvalidOperation Overflow = C.Overflow FloatOperation = C.FloatOperation localcontext = C.localcontext getcontext = C.getcontext setcontext = C.setcontext HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) c = Context() # SignalDict: input validation self.assertRaises(KeyError, c.flags.__setitem__, 801, 0) self.assertRaises(KeyError, c.traps.__setitem__, 801, 0) self.assertRaises(ValueError, c.flags.__delitem__, Overflow) self.assertRaises(ValueError, c.traps.__delitem__, InvalidOperation) self.assertRaises(TypeError, setattr, c, 'flags', ['x']) self.assertRaises(TypeError, setattr, c,'traps', ['y']) self.assertRaises(KeyError, setattr, c, 'flags', {0:1}) self.assertRaises(KeyError, setattr, c, 'traps', {0:1}) # Test assignment from a signal dict with the correct length but # one invalid key. d = c.flags.copy() del d[FloatOperation] d["XYZ"] = 91283719 self.assertRaises(KeyError, setattr, c, 'flags', d) self.assertRaises(KeyError, setattr, c, 'traps', d) # Input corner cases int_max = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 gt_max_emax = 10**18 if HAVE_CONFIG_64 else 10**9 # prec, Emax, Emin for attr in ['prec', 'Emax']: self.assertRaises(ValueError, setattr, c, attr, gt_max_emax) self.assertRaises(ValueError, setattr, c, 'Emin', -gt_max_emax) # prec, Emax, Emin in context constructor self.assertRaises(ValueError, Context, prec=gt_max_emax) self.assertRaises(ValueError, Context, Emax=gt_max_emax) self.assertRaises(ValueError, Context, Emin=-gt_max_emax) # Overflow in conversion self.assertRaises(OverflowError, Context, prec=int_max+1) self.assertRaises(OverflowError, Context, Emax=int_max+1) self.assertRaises(OverflowError, Context, Emin=-int_max-2) self.assertRaises(OverflowError, Context, clamp=int_max+1) self.assertRaises(OverflowError, Context, capitals=int_max+1) # OverflowError, general ValueError for attr in ('prec', 'Emin', 'Emax', 'capitals', 'clamp'): self.assertRaises(OverflowError, setattr, c, attr, int_max+1) self.assertRaises(OverflowError, setattr, c, attr, -int_max-2) if sys.platform != 'win32': self.assertRaises(ValueError, setattr, c, attr, int_max) self.assertRaises(ValueError, setattr, c, attr, -int_max-1) # OverflowError: _unsafe_setprec, _unsafe_setemin, _unsafe_setemax if C.MAX_PREC == 425000000: self.assertRaises(OverflowError, getattr(c, '_unsafe_setprec'), int_max+1) self.assertRaises(OverflowError, getattr(c, '_unsafe_setemax'), int_max+1) self.assertRaises(OverflowError, getattr(c, '_unsafe_setemin'), -int_max-2) # ValueError: _unsafe_setprec, _unsafe_setemin, _unsafe_setemax if C.MAX_PREC == 425000000: self.assertRaises(ValueError, getattr(c, '_unsafe_setprec'), 0) self.assertRaises(ValueError, getattr(c, '_unsafe_setprec'), 1070000001) self.assertRaises(ValueError, getattr(c, '_unsafe_setemax'), -1) self.assertRaises(ValueError, getattr(c, '_unsafe_setemax'), 1070000001) self.assertRaises(ValueError, getattr(c, '_unsafe_setemin'), -1070000001) self.assertRaises(ValueError, getattr(c, '_unsafe_setemin'), 1) # capitals, clamp for attr in ['capitals', 'clamp']: self.assertRaises(ValueError, setattr, c, attr, -1) self.assertRaises(ValueError, setattr, c, attr, 2) self.assertRaises(TypeError, setattr, c, attr, [1,2,3]) if HAVE_CONFIG_64: self.assertRaises(ValueError, setattr, c, attr, 2**32) self.assertRaises(ValueError, setattr, c, attr, 2**32+1) # Invalid local context self.assertRaises(TypeError, exec, 'with localcontext("xyz"): pass', locals()) self.assertRaises(TypeError, exec, 'with localcontext(context=getcontext()): pass', locals()) # setcontext saved_context = getcontext() self.assertRaises(TypeError, setcontext, "xyz") setcontext(saved_context) def test_rounding_strings_interned(self): self.assertIs(C.ROUND_UP, P.ROUND_UP) self.assertIs(C.ROUND_DOWN, P.ROUND_DOWN) self.assertIs(C.ROUND_CEILING, P.ROUND_CEILING) self.assertIs(C.ROUND_FLOOR, P.ROUND_FLOOR) self.assertIs(C.ROUND_HALF_UP, P.ROUND_HALF_UP) self.assertIs(C.ROUND_HALF_DOWN, P.ROUND_HALF_DOWN) self.assertIs(C.ROUND_HALF_EVEN, P.ROUND_HALF_EVEN) self.assertIs(C.ROUND_05UP, P.ROUND_05UP) @requires_extra_functionality def test_c_context_errors_extra(self): Context = C.Context InvalidOperation = C.InvalidOperation Overflow = C.Overflow localcontext = C.localcontext getcontext = C.getcontext setcontext = C.setcontext HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) c = Context() # Input corner cases int_max = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 # OverflowError, general ValueError self.assertRaises(OverflowError, setattr, c, '_allcr', int_max+1) self.assertRaises(OverflowError, setattr, c, '_allcr', -int_max-2) if sys.platform != 'win32': self.assertRaises(ValueError, setattr, c, '_allcr', int_max) self.assertRaises(ValueError, setattr, c, '_allcr', -int_max-1) # OverflowError, general TypeError for attr in ('_flags', '_traps'): self.assertRaises(OverflowError, setattr, c, attr, int_max+1) self.assertRaises(OverflowError, setattr, c, attr, -int_max-2) if sys.platform != 'win32': self.assertRaises(TypeError, setattr, c, attr, int_max) self.assertRaises(TypeError, setattr, c, attr, -int_max-1) # _allcr self.assertRaises(ValueError, setattr, c, '_allcr', -1) self.assertRaises(ValueError, setattr, c, '_allcr', 2) self.assertRaises(TypeError, setattr, c, '_allcr', [1,2,3]) if HAVE_CONFIG_64: self.assertRaises(ValueError, setattr, c, '_allcr', 2**32) self.assertRaises(ValueError, setattr, c, '_allcr', 2**32+1) # _flags, _traps for attr in ['_flags', '_traps']: self.assertRaises(TypeError, setattr, c, attr, 999999) self.assertRaises(TypeError, setattr, c, attr, 'x') def test_c_valid_context(self): # These tests are for code coverage in _decimal. DefaultContext = C.DefaultContext Clamped = C.Clamped Underflow = C.Underflow Inexact = C.Inexact Rounded = C.Rounded Subnormal = C.Subnormal c = DefaultContext.copy() # Exercise all getters and setters c.prec = 34 c.rounding = ROUND_HALF_UP c.Emax = 3000 c.Emin = -3000 c.capitals = 1 c.clamp = 0 self.assertEqual(c.prec, 34) self.assertEqual(c.rounding, ROUND_HALF_UP) self.assertEqual(c.Emin, -3000) self.assertEqual(c.Emax, 3000) self.assertEqual(c.capitals, 1) self.assertEqual(c.clamp, 0) self.assertEqual(c.Etiny(), -3033) self.assertEqual(c.Etop(), 2967) # Exercise all unsafe setters if C.MAX_PREC == 425000000: c._unsafe_setprec(999999999) c._unsafe_setemax(999999999) c._unsafe_setemin(-999999999) self.assertEqual(c.prec, 999999999) self.assertEqual(c.Emax, 999999999) self.assertEqual(c.Emin, -999999999) @requires_extra_functionality def test_c_valid_context_extra(self): DefaultContext = C.DefaultContext c = DefaultContext.copy() self.assertEqual(c._allcr, 1) c._allcr = 0 self.assertEqual(c._allcr, 0) def test_c_round(self): # Restricted input. Decimal = C.Decimal InvalidOperation = C.InvalidOperation localcontext = C.localcontext MAX_EMAX = C.MAX_EMAX MIN_ETINY = C.MIN_ETINY int_max = 2**63-1 if C.MAX_PREC > 425000000 else 2**31-1 with localcontext() as c: c.traps[InvalidOperation] = True self.assertRaises(InvalidOperation, Decimal("1.23").__round__, -int_max-1) self.assertRaises(InvalidOperation, Decimal("1.23").__round__, int_max) self.assertRaises(InvalidOperation, Decimal("1").__round__, int(MAX_EMAX+1)) self.assertRaises(C.InvalidOperation, Decimal("1").__round__, -int(MIN_ETINY-1)) self.assertRaises(OverflowError, Decimal("1.23").__round__, -int_max-2) self.assertRaises(OverflowError, Decimal("1.23").__round__, int_max+1) def test_c_format(self): # Restricted input Decimal = C.Decimal HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", [], 9) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9) self.assertRaises(TypeError, Decimal(1).__format__, []) self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 self.assertRaises(ValueError, Decimal("1.23456789").__format__, "=%d.1" % maxsize) def test_c_integral(self): Decimal = C.Decimal Inexact = C.Inexact localcontext = C.localcontext x = Decimal(10) self.assertEqual(x.to_integral(), 10) self.assertRaises(TypeError, x.to_integral, '10') self.assertRaises(TypeError, x.to_integral, 10, 'x') self.assertRaises(TypeError, x.to_integral, 10) self.assertEqual(x.to_integral_value(), 10) self.assertRaises(TypeError, x.to_integral_value, '10') self.assertRaises(TypeError, x.to_integral_value, 10, 'x') self.assertRaises(TypeError, x.to_integral_value, 10) self.assertEqual(x.to_integral_exact(), 10) self.assertRaises(TypeError, x.to_integral_exact, '10') self.assertRaises(TypeError, x.to_integral_exact, 10, 'x') self.assertRaises(TypeError, x.to_integral_exact, 10) with localcontext() as c: x = Decimal("99999999999999999999999999.9").to_integral_value(ROUND_UP) self.assertEqual(x, Decimal('100000000000000000000000000')) x = Decimal("99999999999999999999999999.9").to_integral_exact(ROUND_UP) self.assertEqual(x, Decimal('100000000000000000000000000')) c.traps[Inexact] = True self.assertRaises(Inexact, Decimal("999.9").to_integral_exact, ROUND_UP) def test_c_funcs(self): # Invalid arguments Decimal = C.Decimal InvalidOperation = C.InvalidOperation DivisionByZero = C.DivisionByZero getcontext = C.getcontext localcontext = C.localcontext self.assertEqual(Decimal('9.99e10').to_eng_string(), '99.9E+9') self.assertRaises(TypeError, pow, Decimal(1), 2, "3") self.assertRaises(TypeError, Decimal(9).number_class, "x", "y") self.assertRaises(TypeError, Decimal(9).same_quantum, 3, "x", "y") self.assertRaises( TypeError, Decimal("1.23456789").quantize, Decimal('1e-100000'), [] ) self.assertRaises( TypeError, Decimal("1.23456789").quantize, Decimal('1e-100000'), getcontext() ) self.assertRaises( TypeError, Decimal("1.23456789").quantize, Decimal('1e-100000'), 10 ) self.assertRaises( TypeError, Decimal("1.23456789").quantize, Decimal('1e-100000'), ROUND_UP, 1000 ) with localcontext() as c: c.clear_traps() # Invalid arguments self.assertRaises(TypeError, c.copy_sign, Decimal(1), "x", "y") self.assertRaises(TypeError, c.canonical, 200) self.assertRaises(TypeError, c.is_canonical, 200) self.assertRaises(TypeError, c.divmod, 9, 8, "x", "y") self.assertRaises(TypeError, c.same_quantum, 9, 3, "x", "y") self.assertEqual(str(c.canonical(Decimal(200))), '200') self.assertEqual(c.radix(), 10) c.traps[DivisionByZero] = True self.assertRaises(DivisionByZero, Decimal(9).__divmod__, 0) self.assertRaises(DivisionByZero, c.divmod, 9, 0) self.assertTrue(c.flags[InvalidOperation]) c.clear_flags() c.traps[InvalidOperation] = True self.assertRaises(InvalidOperation, Decimal(9).__divmod__, 0) self.assertRaises(InvalidOperation, c.divmod, 9, 0) self.assertTrue(c.flags[DivisionByZero]) c.traps[InvalidOperation] = True c.prec = 2 self.assertRaises(InvalidOperation, pow, Decimal(1000), 1, 501) def test_va_args_exceptions(self): Decimal = C.Decimal Context = C.Context x = Decimal("10001111111") for attr in ['exp', 'is_normal', 'is_subnormal', 'ln', 'log10', 'logb', 'logical_invert', 'next_minus', 'next_plus', 'normalize', 'number_class', 'sqrt', 'to_eng_string']: func = getattr(x, attr) self.assertRaises(TypeError, func, context="x") self.assertRaises(TypeError, func, "x", context=None) for attr in ['compare', 'compare_signal', 'logical_and', 'logical_or', 'max', 'max_mag', 'min', 'min_mag', 'remainder_near', 'rotate', 'scaleb', 'shift']: func = getattr(x, attr) self.assertRaises(TypeError, func, context="x") self.assertRaises(TypeError, func, "x", context=None) self.assertRaises(TypeError, x.to_integral, rounding=None, context=[]) self.assertRaises(TypeError, x.to_integral, rounding={}, context=[]) self.assertRaises(TypeError, x.to_integral, [], []) self.assertRaises(TypeError, x.to_integral_value, rounding=None, context=[]) self.assertRaises(TypeError, x.to_integral_value, rounding={}, context=[]) self.assertRaises(TypeError, x.to_integral_value, [], []) self.assertRaises(TypeError, x.to_integral_exact, rounding=None, context=[]) self.assertRaises(TypeError, x.to_integral_exact, rounding={}, context=[]) self.assertRaises(TypeError, x.to_integral_exact, [], []) self.assertRaises(TypeError, x.fma, 1, 2, context="x") self.assertRaises(TypeError, x.fma, 1, 2, "x", context=None) self.assertRaises(TypeError, x.quantize, 1, [], context=None) self.assertRaises(TypeError, x.quantize, 1, [], rounding=None) self.assertRaises(TypeError, x.quantize, 1, [], []) c = Context() self.assertRaises(TypeError, c.power, 1, 2, mod="x") self.assertRaises(TypeError, c.power, 1, "x", mod=None) self.assertRaises(TypeError, c.power, "x", 2, mod=None) @requires_extra_functionality def test_c_context_templates(self): self.assertEqual( C.BasicContext._traps, C.DecIEEEInvalidOperation|C.DecDivisionByZero|C.DecOverflow| C.DecUnderflow|C.DecClamped ) self.assertEqual( C.DefaultContext._traps, C.DecIEEEInvalidOperation|C.DecDivisionByZero|C.DecOverflow ) @requires_extra_functionality def test_c_signal_dict(self): # SignalDict coverage Context = C.Context DefaultContext = C.DefaultContext InvalidOperation = C.InvalidOperation DivisionByZero = C.DivisionByZero Overflow = C.Overflow Subnormal = C.Subnormal Underflow = C.Underflow Rounded = C.Rounded Inexact = C.Inexact Clamped = C.Clamped DecClamped = C.DecClamped DecInvalidOperation = C.DecInvalidOperation DecIEEEInvalidOperation = C.DecIEEEInvalidOperation def assertIsExclusivelySet(signal, signal_dict): for sig in signal_dict: if sig == signal: self.assertTrue(signal_dict[sig]) else: self.assertFalse(signal_dict[sig]) c = DefaultContext.copy() # Signal dict methods self.assertTrue(Overflow in c.traps) c.clear_traps() for k in c.traps.keys(): c.traps[k] = True for v in c.traps.values(): self.assertTrue(v) c.clear_traps() for k, v in c.traps.items(): self.assertFalse(v) self.assertFalse(c.flags.get(Overflow)) self.assertIs(c.flags.get("x"), None) self.assertEqual(c.flags.get("x", "y"), "y") self.assertRaises(TypeError, c.flags.get, "x", "y", "z") self.assertEqual(len(c.flags), len(c.traps)) s = sys.getsizeof(c.flags) s = sys.getsizeof(c.traps) s = c.flags.__repr__() # Set flags/traps. c.clear_flags() c._flags = DecClamped self.assertTrue(c.flags[Clamped]) c.clear_traps() c._traps = DecInvalidOperation self.assertTrue(c.traps[InvalidOperation]) # Set flags/traps from dictionary. c.clear_flags() d = c.flags.copy() d[DivisionByZero] = True c.flags = d assertIsExclusivelySet(DivisionByZero, c.flags) c.clear_traps() d = c.traps.copy() d[Underflow] = True c.traps = d assertIsExclusivelySet(Underflow, c.traps) # Random constructors IntSignals = { Clamped: C.DecClamped, Rounded: C.DecRounded, Inexact: C.DecInexact, Subnormal: C.DecSubnormal, Underflow: C.DecUnderflow, Overflow: C.DecOverflow, DivisionByZero: C.DecDivisionByZero, InvalidOperation: C.DecIEEEInvalidOperation } IntCond = [ C.DecDivisionImpossible, C.DecDivisionUndefined, C.DecFpuError, C.DecInvalidContext, C.DecInvalidOperation, C.DecMallocError, C.DecConversionSyntax, ] lim = len(OrderedSignals[C]) for r in range(lim): for t in range(lim): for round in RoundingModes: flags = random.sample(OrderedSignals[C], r) traps = random.sample(OrderedSignals[C], t) prec = random.randrange(1, 10000) emin = random.randrange(-10000, 0) emax = random.randrange(0, 10000) clamp = random.randrange(0, 2) caps = random.randrange(0, 2) cr = random.randrange(0, 2) c = Context(prec=prec, rounding=round, Emin=emin, Emax=emax, capitals=caps, clamp=clamp, flags=list(flags), traps=list(traps)) self.assertEqual(c.prec, prec) self.assertEqual(c.rounding, round) self.assertEqual(c.Emin, emin) self.assertEqual(c.Emax, emax) self.assertEqual(c.capitals, caps) self.assertEqual(c.clamp, clamp) f = 0 for x in flags: f |= IntSignals[x] self.assertEqual(c._flags, f) f = 0 for x in traps: f |= IntSignals[x] self.assertEqual(c._traps, f) for cond in IntCond: c._flags = cond self.assertTrue(c._flags&DecIEEEInvalidOperation) assertIsExclusivelySet(InvalidOperation, c.flags) for cond in IntCond: c._traps = cond self.assertTrue(c._traps&DecIEEEInvalidOperation) assertIsExclusivelySet(InvalidOperation, c.traps) def test_invalid_override(self): Decimal = C.Decimal try: from locale import CHAR_MAX except ImportError: self.skipTest('locale.CHAR_MAX not available') def make_grouping(lst): return ''.join([chr(x) for x in lst]) def get_fmt(x, override=None, fmt='n'): return Decimal(x).__format__(fmt, override) invalid_grouping = { 'decimal_point' : ',', 'grouping' : make_grouping([255, 255, 0]), 'thousands_sep' : ',' } invalid_dot = { 'decimal_point' : 'xxxxx', 'grouping' : make_grouping([3, 3, 0]), 'thousands_sep' : ',' } invalid_sep = { 'decimal_point' : '.', 'grouping' : make_grouping([3, 3, 0]), 'thousands_sep' : 'yyyyy' } if CHAR_MAX == 127: # negative grouping in override self.assertRaises(ValueError, get_fmt, 12345, invalid_grouping, 'g') self.assertRaises(ValueError, get_fmt, 12345, invalid_dot, 'g') self.assertRaises(ValueError, get_fmt, 12345, invalid_sep, 'g') def test_exact_conversion(self): Decimal = C.Decimal localcontext = C.localcontext InvalidOperation = C.InvalidOperation with localcontext() as c: c.traps[InvalidOperation] = True # Clamped x = "0e%d" % sys.maxsize self.assertRaises(InvalidOperation, Decimal, x) x = "0e%d" % (-sys.maxsize-1) self.assertRaises(InvalidOperation, Decimal, x) # Overflow x = "1e%d" % sys.maxsize self.assertRaises(InvalidOperation, Decimal, x) # Underflow x = "1e%d" % (-sys.maxsize-1) self.assertRaises(InvalidOperation, Decimal, x) def test_from_tuple(self): Decimal = C.Decimal localcontext = C.localcontext InvalidOperation = C.InvalidOperation Overflow = C.Overflow Underflow = C.Underflow with localcontext() as c: c.traps[InvalidOperation] = True c.traps[Overflow] = True c.traps[Underflow] = True # SSIZE_MAX x = (1, (), sys.maxsize) self.assertEqual(str(c.create_decimal(x)), '-0E+999999') self.assertRaises(InvalidOperation, Decimal, x) x = (1, (0, 1, 2), sys.maxsize) self.assertRaises(Overflow, c.create_decimal, x) self.assertRaises(InvalidOperation, Decimal, x) # SSIZE_MIN x = (1, (), -sys.maxsize-1) self.assertEqual(str(c.create_decimal(x)), '-0E-1000007') self.assertRaises(InvalidOperation, Decimal, x) x = (1, (0, 1, 2), -sys.maxsize-1) self.assertRaises(Underflow, c.create_decimal, x) self.assertRaises(InvalidOperation, Decimal, x) # OverflowError x = (1, (), sys.maxsize+1) self.assertRaises(OverflowError, c.create_decimal, x) self.assertRaises(OverflowError, Decimal, x) x = (1, (), -sys.maxsize-2) self.assertRaises(OverflowError, c.create_decimal, x) self.assertRaises(OverflowError, Decimal, x) # Specials x = (1, (), "N") self.assertEqual(str(Decimal(x)), '-sNaN') x = (1, (0,), "N") self.assertEqual(str(Decimal(x)), '-sNaN') x = (1, (0, 1), "N") self.assertEqual(str(Decimal(x)), '-sNaN1') def test_sizeof(self): Decimal = C.Decimal HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) self.assertGreater(Decimal(0).__sizeof__(), 0) if HAVE_CONFIG_64: x = Decimal(10**(19*24)).__sizeof__() y = Decimal(10**(19*25)).__sizeof__() self.assertEqual(y, x+8) else: x = Decimal(10**(9*24)).__sizeof__() y = Decimal(10**(9*25)).__sizeof__() self.assertEqual(y, x+4) def test_internal_use_of_overridden_methods(self): Decimal = C.Decimal # Unsound subtyping class X(float): def as_integer_ratio(self): return 1 def __abs__(self): return self class Y(float): def __abs__(self): return [1]*200 class I(int): def bit_length(self): return [1]*200 class Z(float): def as_integer_ratio(self): return (I(1), I(1)) def __abs__(self): return self for cls in X, Y, Z: self.assertEqual(Decimal.from_float(cls(101.1)), Decimal.from_float(101.1)) @requires_docstrings @unittest.skipUnless(C, "test requires C version") class SignatureTest(unittest.TestCase): """Function signatures""" def test_inspect_module(self): for attr in dir(P): if attr.startswith('_'): continue p_func = getattr(P, attr) c_func = getattr(C, attr) if (attr == 'Decimal' or attr == 'Context' or inspect.isfunction(p_func)): p_sig = inspect.signature(p_func) c_sig = inspect.signature(c_func) # parameter names: c_names = list(c_sig.parameters.keys()) p_names = [x for x in p_sig.parameters.keys() if not x.startswith('_')] self.assertEqual(c_names, p_names, msg="parameter name mismatch in %s" % p_func) c_kind = [x.kind for x in c_sig.parameters.values()] p_kind = [x[1].kind for x in p_sig.parameters.items() if not x[0].startswith('_')] # parameters: if attr != 'setcontext': self.assertEqual(c_kind, p_kind, msg="parameter kind mismatch in %s" % p_func) def test_inspect_types(self): POS = inspect._ParameterKind.POSITIONAL_ONLY POS_KWD = inspect._ParameterKind.POSITIONAL_OR_KEYWORD # Type heuristic (type annotations would help!): pdict = {C: {'other': C.Decimal(1), 'third': C.Decimal(1), 'x': C.Decimal(1), 'y': C.Decimal(1), 'z': C.Decimal(1), 'a': C.Decimal(1), 'b': C.Decimal(1), 'c': C.Decimal(1), 'exp': C.Decimal(1), 'modulo': C.Decimal(1), 'num': "1", 'f': 1.0, 'rounding': C.ROUND_HALF_UP, 'context': C.getcontext()}, P: {'other': P.Decimal(1), 'third': P.Decimal(1), 'a': P.Decimal(1), 'b': P.Decimal(1), 'c': P.Decimal(1), 'exp': P.Decimal(1), 'modulo': P.Decimal(1), 'num': "1", 'f': 1.0, 'rounding': P.ROUND_HALF_UP, 'context': P.getcontext()}} def mkargs(module, sig): args = [] kwargs = {} for name, param in sig.parameters.items(): if name == 'self': continue if param.kind == POS: args.append(pdict[module][name]) elif param.kind == POS_KWD: kwargs[name] = pdict[module][name] else: raise TestFailed("unexpected parameter kind") return args, kwargs def tr(s): """The C Context docstrings use 'x' in order to prevent confusion with the article 'a' in the descriptions.""" if s == 'x': return 'a' if s == 'y': return 'b' if s == 'z': return 'c' return s def doit(ty): p_type = getattr(P, ty) c_type = getattr(C, ty) for attr in dir(p_type): if attr.startswith('_'): continue p_func = getattr(p_type, attr) c_func = getattr(c_type, attr) if inspect.isfunction(p_func): p_sig = inspect.signature(p_func) c_sig = inspect.signature(c_func) # parameter names: p_names = list(p_sig.parameters.keys()) c_names = [tr(x) for x in c_sig.parameters.keys()] self.assertEqual(c_names, p_names, msg="parameter name mismatch in %s" % p_func) p_kind = [x.kind for x in p_sig.parameters.values()] c_kind = [x.kind for x in c_sig.parameters.values()] # 'self' parameter: self.assertIs(p_kind[0], POS_KWD) self.assertIs(c_kind[0], POS) # remaining parameters: if ty == 'Decimal': self.assertEqual(c_kind[1:], p_kind[1:], msg="parameter kind mismatch in %s" % p_func) else: # Context methods are positional only in the C version. self.assertEqual(len(c_kind), len(p_kind), msg="parameter kind mismatch in %s" % p_func) # Run the function: args, kwds = mkargs(C, c_sig) try: getattr(c_type(9), attr)(*args, **kwds) except Exception as err: raise TestFailed("invalid signature for %s: %s %s" % (c_func, args, kwds)) args, kwds = mkargs(P, p_sig) try: getattr(p_type(9), attr)(*args, **kwds) except Exception as err: raise TestFailed("invalid signature for %s: %s %s" % (p_func, args, kwds)) doit('Decimal') doit('Context') all_tests = [ CExplicitConstructionTest, PyExplicitConstructionTest, CImplicitConstructionTest, PyImplicitConstructionTest, CFormatTest, PyFormatTest, CArithmeticOperatorsTest, PyArithmeticOperatorsTest, CThreadingTest, PyThreadingTest, CUsabilityTest, PyUsabilityTest, CPythonAPItests, PyPythonAPItests, CContextAPItests, PyContextAPItests, CContextWithStatement, PyContextWithStatement, CContextFlags, PyContextFlags, CSpecialContexts, PySpecialContexts, CContextInputValidation, PyContextInputValidation, CContextSubclassing, PyContextSubclassing, CCoverage, PyCoverage, CFunctionality, PyFunctionality, CWhitebox, PyWhitebox, CIBMTestCases, PyIBMTestCases, ] # Delete C tests if _decimal.so is not present. if not C: all_tests = all_tests[1::2] else: all_tests = all_tests[0::2] all_tests.insert(0, CheckAttributes) all_tests.insert(1, SignatureTest) def test_main(arith=None, verbose=None, todo_tests=None, debug=None): """ Execute the tests. Runs all arithmetic tests if arith is True or if the "decimal" resource is enabled in regrtest.py """ init(C) init(P) global TEST_ALL, DEBUG TEST_ALL = arith if arith is not None else is_resource_enabled('decimal') DEBUG = debug if todo_tests is None: test_classes = all_tests else: test_classes = [CIBMTestCases, PyIBMTestCases] # Dynamically build custom test definition for each file in the test # directory and add the definitions to the DecimalTest class. This # procedure insures that new files do not get skipped. for filename in os.listdir(directory): if '.decTest' not in filename or filename.startswith("."): continue head, tail = filename.split('.') if todo_tests is not None and head not in todo_tests: continue tester = lambda self, f=filename: self.eval_file(os.path.join(directory, f)) setattr(CIBMTestCases, 'test_' + head, tester) setattr(PyIBMTestCases, 'test_' + head, tester) del filename, head, tail, tester try: run_unittest(*test_classes) if todo_tests is None: from doctest import IGNORE_EXCEPTION_DETAIL savedecimal = sys.modules['decimal'] if C: sys.modules['decimal'] = C run_doctest(C, verbose, optionflags=IGNORE_EXCEPTION_DETAIL) sys.modules['decimal'] = P run_doctest(P, verbose) sys.modules['decimal'] = savedecimal finally: if C: C.setcontext(ORIGINAL_CONTEXT[C]) P.setcontext(ORIGINAL_CONTEXT[P]) if not C: warnings.warn('C tests skipped: no module named _decimal.', UserWarning) if not orig_sys_decimal is sys.modules['decimal']: raise TestFailed("Internal error: unbalanced number of changes to " "sys.modules['decimal'].") if __name__ == '__main__': import optparse p = optparse.OptionParser("test_decimal.py [--debug] [{--skip | test1 [test2 [...]]}]") p.add_option('--debug', '-d', action='store_true', help='shows the test number and context before each test') p.add_option('--skip', '-s', action='store_true', help='skip over 90% of the arithmetic tests') p.add_option('--verbose', '-v', action='store_true', help='Does nothing') (opt, args) = p.parse_args() if opt.skip: test_main(arith=False, verbose=True) elif args: test_main(arith=True, verbose=True, todo_tests=args, debug=opt.debug) else: test_main(arith=True, verbose=True)
211,531
5,708
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_class.py
"Test the functionality of Python classes implementing operators." import unittest import cosmo testmeths = [ # Binary operations "add", "radd", "sub", "rsub", "mul", "rmul", "matmul", "rmatmul", "truediv", "rtruediv", "floordiv", "rfloordiv", "mod", "rmod", "divmod", "rdivmod", "pow", "rpow", "rshift", "rrshift", "lshift", "rlshift", "and", "rand", "or", "ror", "xor", "rxor", # List/dict operations "contains", "getitem", "setitem", "delitem", # Unary operations "neg", "pos", "abs", # generic operations "init", ] # These need to return something other than None # "hash", # "str", # "repr", # "int", # "float", # These are separate because they can influence the test of other methods. # "getattr", # "setattr", # "delattr", callLst = [] def trackCall(f): def track(*args, **kwargs): callLst.append((f.__name__, args)) return f(*args, **kwargs) return track statictests = """ @trackCall def __hash__(self, *args): return hash(id(self)) @trackCall def __str__(self, *args): return "AllTests" @trackCall def __repr__(self, *args): return "AllTests" @trackCall def __int__(self, *args): return 1 @trackCall def __index__(self, *args): return 1 @trackCall def __float__(self, *args): return 1.0 @trackCall def __eq__(self, *args): return True @trackCall def __ne__(self, *args): return False @trackCall def __lt__(self, *args): return False @trackCall def __le__(self, *args): return True @trackCall def __gt__(self, *args): return False @trackCall def __ge__(self, *args): return True """ # Synthesize all the other AllTests methods from the names in testmeths. method_template = """\ @trackCall def __%s__(self, *args): pass """ d = {} exec(statictests, globals(), d) for method in testmeths: exec(method_template % method, globals(), d) AllTests = type("AllTests", (object,), d) del d, statictests, method, method_template class ClassTests(unittest.TestCase): def setUp(self): callLst[:] = [] def assertCallStack(self, expected_calls): actualCallList = callLst[:] # need to copy because the comparison below will add # additional calls to callLst if expected_calls != actualCallList: self.fail("Expected call list:\n %s\ndoes not match actual call list\n %s" % (expected_calls, actualCallList)) def testInit(self): foo = AllTests() self.assertCallStack([("__init__", (foo,))]) def testBinaryOps(self): testme = AllTests() # Binary operations callLst[:] = [] testme + 1 self.assertCallStack([("__add__", (testme, 1))]) callLst[:] = [] 1 + testme self.assertCallStack([("__radd__", (testme, 1))]) callLst[:] = [] testme - 1 self.assertCallStack([("__sub__", (testme, 1))]) callLst[:] = [] 1 - testme self.assertCallStack([("__rsub__", (testme, 1))]) callLst[:] = [] testme * 1 self.assertCallStack([("__mul__", (testme, 1))]) callLst[:] = [] 1 * testme self.assertCallStack([("__rmul__", (testme, 1))]) callLst[:] = [] testme @ 1 self.assertCallStack([("__matmul__", (testme, 1))]) callLst[:] = [] 1 @ testme self.assertCallStack([("__rmatmul__", (testme, 1))]) callLst[:] = [] testme / 1 self.assertCallStack([("__truediv__", (testme, 1))]) callLst[:] = [] 1 / testme self.assertCallStack([("__rtruediv__", (testme, 1))]) callLst[:] = [] testme // 1 self.assertCallStack([("__floordiv__", (testme, 1))]) callLst[:] = [] 1 // testme self.assertCallStack([("__rfloordiv__", (testme, 1))]) callLst[:] = [] testme % 1 self.assertCallStack([("__mod__", (testme, 1))]) callLst[:] = [] 1 % testme self.assertCallStack([("__rmod__", (testme, 1))]) callLst[:] = [] divmod(testme,1) self.assertCallStack([("__divmod__", (testme, 1))]) callLst[:] = [] divmod(1, testme) self.assertCallStack([("__rdivmod__", (testme, 1))]) callLst[:] = [] testme ** 1 self.assertCallStack([("__pow__", (testme, 1))]) callLst[:] = [] 1 ** testme self.assertCallStack([("__rpow__", (testme, 1))]) callLst[:] = [] testme >> 1 self.assertCallStack([("__rshift__", (testme, 1))]) callLst[:] = [] 1 >> testme self.assertCallStack([("__rrshift__", (testme, 1))]) callLst[:] = [] testme << 1 self.assertCallStack([("__lshift__", (testme, 1))]) callLst[:] = [] 1 << testme self.assertCallStack([("__rlshift__", (testme, 1))]) callLst[:] = [] testme & 1 self.assertCallStack([("__and__", (testme, 1))]) callLst[:] = [] 1 & testme self.assertCallStack([("__rand__", (testme, 1))]) callLst[:] = [] testme | 1 self.assertCallStack([("__or__", (testme, 1))]) callLst[:] = [] 1 | testme self.assertCallStack([("__ror__", (testme, 1))]) callLst[:] = [] testme ^ 1 self.assertCallStack([("__xor__", (testme, 1))]) callLst[:] = [] 1 ^ testme self.assertCallStack([("__rxor__", (testme, 1))]) def testListAndDictOps(self): testme = AllTests() # List/dict operations class Empty: pass try: 1 in Empty() self.fail('failed, should have raised TypeError') except TypeError: pass callLst[:] = [] 1 in testme self.assertCallStack([('__contains__', (testme, 1))]) callLst[:] = [] testme[1] self.assertCallStack([('__getitem__', (testme, 1))]) callLst[:] = [] testme[1] = 1 self.assertCallStack([('__setitem__', (testme, 1, 1))]) callLst[:] = [] del testme[1] self.assertCallStack([('__delitem__', (testme, 1))]) callLst[:] = [] testme[:42] self.assertCallStack([('__getitem__', (testme, slice(None, 42)))]) callLst[:] = [] testme[:42] = "The Answer" self.assertCallStack([('__setitem__', (testme, slice(None, 42), "The Answer"))]) callLst[:] = [] del testme[:42] self.assertCallStack([('__delitem__', (testme, slice(None, 42)))]) callLst[:] = [] testme[2:1024:10] self.assertCallStack([('__getitem__', (testme, slice(2, 1024, 10)))]) callLst[:] = [] testme[2:1024:10] = "A lot" self.assertCallStack([('__setitem__', (testme, slice(2, 1024, 10), "A lot"))]) callLst[:] = [] del testme[2:1024:10] self.assertCallStack([('__delitem__', (testme, slice(2, 1024, 10)))]) callLst[:] = [] testme[:42, ..., :24:, 24, 100] self.assertCallStack([('__getitem__', (testme, (slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100)))]) callLst[:] = [] testme[:42, ..., :24:, 24, 100] = "Strange" self.assertCallStack([('__setitem__', (testme, (slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100), "Strange"))]) callLst[:] = [] del testme[:42, ..., :24:, 24, 100] self.assertCallStack([('__delitem__', (testme, (slice(None, 42, None), Ellipsis, slice(None, 24, None), 24, 100)))]) def testUnaryOps(self): testme = AllTests() callLst[:] = [] -testme self.assertCallStack([('__neg__', (testme,))]) callLst[:] = [] +testme self.assertCallStack([('__pos__', (testme,))]) callLst[:] = [] abs(testme) self.assertCallStack([('__abs__', (testme,))]) callLst[:] = [] int(testme) self.assertCallStack([('__int__', (testme,))]) callLst[:] = [] float(testme) self.assertCallStack([('__float__', (testme,))]) callLst[:] = [] oct(testme) self.assertCallStack([('__index__', (testme,))]) callLst[:] = [] hex(testme) self.assertCallStack([('__index__', (testme,))]) def testMisc(self): testme = AllTests() callLst[:] = [] hash(testme) self.assertCallStack([('__hash__', (testme,))]) callLst[:] = [] repr(testme) self.assertCallStack([('__repr__', (testme,))]) callLst[:] = [] str(testme) self.assertCallStack([('__str__', (testme,))]) callLst[:] = [] testme == 1 self.assertCallStack([('__eq__', (testme, 1))]) callLst[:] = [] testme < 1 self.assertCallStack([('__lt__', (testme, 1))]) callLst[:] = [] testme > 1 self.assertCallStack([('__gt__', (testme, 1))]) callLst[:] = [] testme != 1 self.assertCallStack([('__ne__', (testme, 1))]) callLst[:] = [] 1 == testme self.assertCallStack([('__eq__', (1, testme))]) callLst[:] = [] 1 < testme self.assertCallStack([('__gt__', (1, testme))]) callLst[:] = [] 1 > testme self.assertCallStack([('__lt__', (1, testme))]) callLst[:] = [] 1 != testme self.assertCallStack([('__ne__', (1, testme))]) def testGetSetAndDel(self): # Interfering tests class ExtraTests(AllTests): @trackCall def __getattr__(self, *args): return "SomeVal" @trackCall def __setattr__(self, *args): pass @trackCall def __delattr__(self, *args): pass testme = ExtraTests() callLst[:] = [] testme.spam self.assertCallStack([('__getattr__', (testme, "spam"))]) callLst[:] = [] testme.eggs = "spam, spam, spam and ham" self.assertCallStack([('__setattr__', (testme, "eggs", "spam, spam, spam and ham"))]) callLst[:] = [] del testme.cardinal self.assertCallStack([('__delattr__', (testme, "cardinal"))]) def testDel(self): x = [] class DelTest: def __del__(self): x.append("crab people, crab people") testme = DelTest() del testme import gc gc.collect() self.assertEqual(["crab people, crab people"], x) def testBadTypeReturned(self): # return values of some method are type-checked class BadTypeClass: def __int__(self): return None __float__ = __int__ __complex__ = __int__ __str__ = __int__ __repr__ = __int__ __bytes__ = __int__ __bool__ = __int__ __index__ = __int__ def index(x): return [][x] for f in [float, complex, str, repr, bytes, bin, oct, hex, bool, index]: self.assertRaises(TypeError, f, BadTypeClass()) def testHashStuff(self): # Test correct errors from hash() on objects with comparisons but # no __hash__ class C0: pass hash(C0()) # This should work; the next two should raise TypeError class C2: def __eq__(self, other): return 1 self.assertRaises(TypeError, hash, C2()) @unittest.skipIf(cosmo.MODE.startswith("tiny"), "no stack awareness in tiny mode") def testSFBug532646(self): # Test for SF bug 532646 class A: pass A.__call__ = A() a = A() try: a() # This should not segfault except (RecursionError, MemoryError): pass else: self.fail("Failed to raise RecursionError") def testForExceptionsRaisedInInstanceGetattr2(self): # Tests for exceptions raised in instance_getattr2(). def booh(self): raise AttributeError("booh") class A: a = property(booh) try: A().a # Raised AttributeError: A instance has no attribute 'a' except AttributeError as x: if str(x) != "booh": self.fail("attribute error for A().a got masked: %s" % x) class E: __eq__ = property(booh) E() == E() # In debug mode, caused a C-level assert() to fail class I: __init__ = property(booh) try: # In debug mode, printed XXX undetected error and # raises AttributeError I() except AttributeError as x: pass else: self.fail("attribute error for I.__init__ got masked") def testHashComparisonOfMethods(self): # Test comparison and hash of methods class A: def __init__(self, x): self.x = x def f(self): pass def g(self): pass def __eq__(self, other): return self.x == other.x def __hash__(self): return self.x class B(A): pass a1 = A(1) a2 = A(2) self.assertEqual(a1.f, a1.f) self.assertNotEqual(a1.f, a2.f) self.assertNotEqual(a1.f, a1.g) self.assertEqual(a1.f, A(1).f) self.assertEqual(hash(a1.f), hash(a1.f)) self.assertEqual(hash(a1.f), hash(A(1).f)) self.assertNotEqual(A.f, a1.f) self.assertNotEqual(A.f, A.g) self.assertEqual(B.f, A.f) self.assertEqual(hash(B.f), hash(A.f)) # the following triggers a SystemError in 2.4 a = A(hash(A.f)^(-1)) hash(a.f) def testSetattrWrapperNameIntern(self): # Issue #25794: __setattr__ should intern the attribute name class A: pass def add(self, other): return 'summa' name = str(b'__add__', 'ascii') # shouldn't be optimized self.assertIsNot(name, '__add__') # not interned type.__setattr__(A, name, add) self.assertEqual(A() + 1, 'summa') name2 = str(b'__add__', 'ascii') self.assertIsNot(name2, '__add__') self.assertIsNot(name2, name) type.__delattr__(A, name2) with self.assertRaises(TypeError): A() + 1 def testSetattrNonStringName(self): class A: pass with self.assertRaises(TypeError): type.__setattr__(A, b'x', None) if __name__ == '__main__': unittest.main()
15,576
603
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_long.py
import unittest from test import support import sys import random import math import array # SHIFT should match the value in longintrepr.h for best testing. SHIFT = sys.int_info.bits_per_digit BASE = 2 ** SHIFT MASK = BASE - 1 KARATSUBA_CUTOFF = 70 # from longobject.c # Max number of base BASE digits to use in test cases. Doubling # this will more than double the runtime. MAXDIGITS = 15 # build some special values special = [0, 1, 2, BASE, BASE >> 1, 0x5555555555555555, 0xaaaaaaaaaaaaaaaa] # some solid strings of one bits p2 = 4 # 0 and 1 already added for i in range(2*SHIFT): special.append(p2 - 1) p2 = p2 << 1 del p2 # add complements & negations special += [~x for x in special] + [-x for x in special] DBL_MAX = sys.float_info.max DBL_MAX_EXP = sys.float_info.max_exp DBL_MIN_EXP = sys.float_info.min_exp DBL_MANT_DIG = sys.float_info.mant_dig DBL_MIN_OVERFLOW = 2**DBL_MAX_EXP - 2**(DBL_MAX_EXP - DBL_MANT_DIG - 1) # Pure Python version of correctly-rounded integer-to-float conversion. def int_to_float(n): """ Correctly-rounded integer-to-float conversion. """ # Constants, depending only on the floating-point format in use. # We use an extra 2 bits of precision for rounding purposes. PRECISION = sys.float_info.mant_dig + 2 SHIFT_MAX = sys.float_info.max_exp - PRECISION Q_MAX = 1 << PRECISION ROUND_HALF_TO_EVEN_CORRECTION = [0, -1, -2, 1, 0, -1, 2, 1] # Reduce to the case where n is positive. if n == 0: return 0.0 elif n < 0: return -int_to_float(-n) # Convert n to a 'floating-point' number q * 2**shift, where q is an # integer with 'PRECISION' significant bits. When shifting n to create q, # the least significant bit of q is treated as 'sticky'. That is, the # least significant bit of q is set if either the corresponding bit of n # was already set, or any one of the bits of n lost in the shift was set. shift = n.bit_length() - PRECISION q = n << -shift if shift < 0 else (n >> shift) | bool(n & ~(-1 << shift)) # Round half to even (actually rounds to the nearest multiple of 4, # rounding ties to a multiple of 8). q += ROUND_HALF_TO_EVEN_CORRECTION[q & 7] # Detect overflow. if shift + (q == Q_MAX) > SHIFT_MAX: raise OverflowError("integer too large to convert to float") # Checks: q is exactly representable, and q**2**shift doesn't overflow. assert q % 4 == 0 and q // 4 <= 2**(sys.float_info.mant_dig) assert q * 2**shift <= sys.float_info.max # Some circularity here, since float(q) is doing an int-to-float # conversion. But here q is of bounded size, and is exactly representable # as a float. In a low-level C-like language, this operation would be a # simple cast (e.g., from unsigned long long to double). return math.ldexp(float(q), shift) # pure Python version of correctly-rounded true division def truediv(a, b): """Correctly-rounded true division for integers.""" negative = a^b < 0 a, b = abs(a), abs(b) # exceptions: division by zero, overflow if not b: raise ZeroDivisionError("division by zero") if a >= DBL_MIN_OVERFLOW * b: raise OverflowError("int/int too large to represent as a float") # find integer d satisfying 2**(d - 1) <= a/b < 2**d d = a.bit_length() - b.bit_length() if d >= 0 and a >= 2**d * b or d < 0 and a * 2**-d >= b: d += 1 # compute 2**-exp * a / b for suitable exp exp = max(d, DBL_MIN_EXP) - DBL_MANT_DIG a, b = a << max(-exp, 0), b << max(exp, 0) q, r = divmod(a, b) # round-half-to-even: fractional part is r/b, which is > 0.5 iff # 2*r > b, and == 0.5 iff 2*r == b. if 2*r > b or 2*r == b and q % 2 == 1: q += 1 result = math.ldexp(q, exp) return -result if negative else result class LongTest(unittest.TestCase): # Get quasi-random long consisting of ndigits digits (in base BASE). # quasi == the most-significant digit will not be 0, and the number # is constructed to contain long strings of 0 and 1 bits. These are # more likely than random bits to provoke digit-boundary errors. # The sign of the number is also random. def getran(self, ndigits): self.assertGreater(ndigits, 0) nbits_hi = ndigits * SHIFT nbits_lo = nbits_hi - SHIFT + 1 answer = 0 nbits = 0 r = int(random.random() * (SHIFT * 2)) | 1 # force 1 bits to start while nbits < nbits_lo: bits = (r >> 1) + 1 bits = min(bits, nbits_hi - nbits) self.assertTrue(1 <= bits <= SHIFT) nbits = nbits + bits answer = answer << bits if r & 1: answer = answer | ((1 << bits) - 1) r = int(random.random() * (SHIFT * 2)) self.assertTrue(nbits_lo <= nbits <= nbits_hi) if random.random() < 0.5: answer = -answer return answer # Get random long consisting of ndigits random digits (relative to base # BASE). The sign bit is also random. def getran2(ndigits): answer = 0 for i in range(ndigits): answer = (answer << SHIFT) | random.randint(0, MASK) if random.random() < 0.5: answer = -answer return answer def check_division(self, x, y): eq = self.assertEqual with self.subTest(x=x, y=y): q, r = divmod(x, y) q2, r2 = x//y, x%y pab, pba = x*y, y*x eq(pab, pba, "multiplication does not commute") eq(q, q2, "divmod returns different quotient than /") eq(r, r2, "divmod returns different mod than %") eq(x, q*y + r, "x != q*y + r after divmod") if y > 0: self.assertTrue(0 <= r < y, "bad mod from divmod") else: self.assertTrue(y < r <= 0, "bad mod from divmod") def test_division(self): digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF, KARATSUBA_CUTOFF + 14)) digits.append(KARATSUBA_CUTOFF * 3) for lenx in digits: x = self.getran(lenx) for leny in digits: y = self.getran(leny) or 1 self.check_division(x, y) # specific numbers chosen to exercise corner cases of the # current long division implementation # 30-bit cases involving a quotient digit estimate of BASE+1 self.check_division(1231948412290879395966702881, 1147341367131428698) self.check_division(815427756481275430342312021515587883, 707270836069027745) self.check_division(627976073697012820849443363563599041, 643588798496057020) self.check_division(1115141373653752303710932756325578065, 1038556335171453937726882627) # 30-bit cases that require the post-subtraction correction step self.check_division(922498905405436751940989320930368494, 949985870686786135626943396) self.check_division(768235853328091167204009652174031844, 1091555541180371554426545266) # 15-bit cases involving a quotient digit estimate of BASE+1 self.check_division(20172188947443, 615611397) self.check_division(1020908530270155025, 950795710) self.check_division(128589565723112408, 736393718) self.check_division(609919780285761575, 18613274546784) # 15-bit cases that require the post-subtraction correction step self.check_division(710031681576388032, 26769404391308) self.check_division(1933622614268221, 30212853348836) def test_karatsuba(self): digits = list(range(1, 5)) + list(range(KARATSUBA_CUTOFF, KARATSUBA_CUTOFF + 10)) digits.extend([KARATSUBA_CUTOFF * 10, KARATSUBA_CUTOFF * 100]) bits = [digit * SHIFT for digit in digits] # Test products of long strings of 1 bits -- (2**x-1)*(2**y-1) == # 2**(x+y) - 2**x - 2**y + 1, so the proper result is easy to check. for abits in bits: a = (1 << abits) - 1 for bbits in bits: if bbits < abits: continue with self.subTest(abits=abits, bbits=bbits): b = (1 << bbits) - 1 x = a * b y = ((1 << (abits + bbits)) - (1 << abits) - (1 << bbits) + 1) self.assertEqual(x, y) def check_bitop_identities_1(self, x): eq = self.assertEqual with self.subTest(x=x): eq(x & 0, 0) eq(x | 0, x) eq(x ^ 0, x) eq(x & -1, x) eq(x | -1, -1) eq(x ^ -1, ~x) eq(x, ~~x) eq(x & x, x) eq(x | x, x) eq(x ^ x, 0) eq(x & ~x, 0) eq(x | ~x, -1) eq(x ^ ~x, -1) eq(-x, 1 + ~x) eq(-x, ~(x-1)) for n in range(2*SHIFT): p2 = 2 ** n with self.subTest(x=x, n=n, p2=p2): eq(x << n >> n, x) eq(x // p2, x >> n) eq(x * p2, x << n) eq(x & -p2, x >> n << n) eq(x & -p2, x & ~(p2 - 1)) def check_bitop_identities_2(self, x, y): eq = self.assertEqual with self.subTest(x=x, y=y): eq(x & y, y & x) eq(x | y, y | x) eq(x ^ y, y ^ x) eq(x ^ y ^ x, y) eq(x & y, ~(~x | ~y)) eq(x | y, ~(~x & ~y)) eq(x ^ y, (x | y) & ~(x & y)) eq(x ^ y, (x & ~y) | (~x & y)) eq(x ^ y, (x | y) & (~x | ~y)) def check_bitop_identities_3(self, x, y, z): eq = self.assertEqual with self.subTest(x=x, y=y, z=z): eq((x & y) & z, x & (y & z)) eq((x | y) | z, x | (y | z)) eq((x ^ y) ^ z, x ^ (y ^ z)) eq(x & (y | z), (x & y) | (x & z)) eq(x | (y & z), (x | y) & (x | z)) def test_bitop_identities(self): for x in special: self.check_bitop_identities_1(x) digits = range(1, MAXDIGITS+1) for lenx in digits: x = self.getran(lenx) self.check_bitop_identities_1(x) for leny in digits: y = self.getran(leny) self.check_bitop_identities_2(x, y) self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2)) def slow_format(self, x, base): digits = [] sign = 0 if x < 0: sign, x = 1, -x while x: x, r = divmod(x, base) digits.append(int(r)) digits.reverse() digits = digits or [0] return '-'[:sign] + \ {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \ "".join("0123456789abcdef"[i] for i in digits) def check_format_1(self, x): for base, mapper in (2, bin), (8, oct), (10, str), (10, repr), (16, hex): got = mapper(x) with self.subTest(x=x, mapper=mapper.__name__): expected = self.slow_format(x, base) self.assertEqual(got, expected) with self.subTest(got=got): self.assertEqual(int(got, 0), x) def test_format(self): for x in special: self.check_format_1(x) for i in range(10): for lenx in range(1, MAXDIGITS+1): x = self.getran(lenx) self.check_format_1(x) def test_long(self): # Check conversions from string LL = [ ('1' + '0'*20, 10**20), ('1' + '0'*100, 10**100) ] for s, v in LL: for sign in "", "+", "-": for prefix in "", " ", "\t", " \t\t ": ss = prefix + sign + s vv = v if sign == "-" and v is not ValueError: vv = -v try: self.assertEqual(int(ss), vv) except ValueError: pass # trailing L should no longer be accepted... self.assertRaises(ValueError, int, '123L') self.assertRaises(ValueError, int, '123l') self.assertRaises(ValueError, int, '0L') self.assertRaises(ValueError, int, '-37L') self.assertRaises(ValueError, int, '0x32L', 16) self.assertRaises(ValueError, int, '1L', 21) # ... but it's just a normal digit if base >= 22 self.assertEqual(int('1L', 22), 43) # tests with base 0 self.assertEqual(int('000', 0), 0) self.assertEqual(int('0o123', 0), 83) self.assertEqual(int('0x123', 0), 291) self.assertEqual(int('0b100', 0), 4) self.assertEqual(int(' 0O123 ', 0), 83) self.assertEqual(int(' 0X123 ', 0), 291) self.assertEqual(int(' 0B100 ', 0), 4) self.assertEqual(int('0', 0), 0) self.assertEqual(int('+0', 0), 0) self.assertEqual(int('-0', 0), 0) self.assertEqual(int('00', 0), 0) self.assertRaises(ValueError, int, '08', 0) self.assertRaises(ValueError, int, '-012395', 0) # invalid bases invalid_bases = [-909, 2**31-1, 2**31, -2**31, -2**31-1, 2**63-1, 2**63, -2**63, -2**63-1, 2**100, -2**100, ] for base in invalid_bases: self.assertRaises(ValueError, int, '42', base) # Invalid unicode string # See bpo-34087 self.assertRaises(ValueError, int, '\u3053\u3093\u306b\u3061\u306f') def test_conversion(self): class JustLong: # test that __long__ no longer used in 3.x def __long__(self): return 42 self.assertRaises(TypeError, int, JustLong()) class LongTrunc: # __long__ should be ignored in 3.x def __long__(self): return 42 def __trunc__(self): return 1729 self.assertEqual(int(LongTrunc()), 1729) def check_float_conversion(self, n): # Check that int -> float conversion behaviour matches # that of the pure Python version above. try: actual = float(n) except OverflowError: actual = 'overflow' try: expected = int_to_float(n) except OverflowError: expected = 'overflow' msg = ("Error in conversion of integer {} to float. " "Got {}, expected {}.".format(n, actual, expected)) self.assertEqual(actual, expected, msg) @support.requires_IEEE_754 def test_float_conversion(self): exact_values = [0, 1, 2, 2**53-3, 2**53-2, 2**53-1, 2**53, 2**53+2, 2**54-4, 2**54-2, 2**54, 2**54+4] for x in exact_values: self.assertEqual(float(x), x) self.assertEqual(float(-x), -x) # test round-half-even for x, y in [(1, 0), (2, 2), (3, 4), (4, 4), (5, 4), (6, 6), (7, 8)]: for p in range(15): self.assertEqual(int(float(2**p*(2**53+x))), 2**p*(2**53+y)) for x, y in [(0, 0), (1, 0), (2, 0), (3, 4), (4, 4), (5, 4), (6, 8), (7, 8), (8, 8), (9, 8), (10, 8), (11, 12), (12, 12), (13, 12), (14, 16), (15, 16)]: for p in range(15): self.assertEqual(int(float(2**p*(2**54+x))), 2**p*(2**54+y)) # behaviour near extremes of floating-point range int_dbl_max = int(DBL_MAX) top_power = 2**DBL_MAX_EXP halfway = (int_dbl_max + top_power)//2 self.assertEqual(float(int_dbl_max), DBL_MAX) self.assertEqual(float(int_dbl_max+1), DBL_MAX) self.assertEqual(float(halfway-1), DBL_MAX) self.assertRaises(OverflowError, float, halfway) self.assertEqual(float(1-halfway), -DBL_MAX) self.assertRaises(OverflowError, float, -halfway) self.assertRaises(OverflowError, float, top_power-1) self.assertRaises(OverflowError, float, top_power) self.assertRaises(OverflowError, float, top_power+1) self.assertRaises(OverflowError, float, 2*top_power-1) self.assertRaises(OverflowError, float, 2*top_power) self.assertRaises(OverflowError, float, top_power*top_power) for p in range(100): x = 2**p * (2**53 + 1) + 1 y = 2**p * (2**53 + 2) self.assertEqual(int(float(x)), y) x = 2**p * (2**53 + 1) y = 2**p * 2**53 self.assertEqual(int(float(x)), y) # Compare builtin float conversion with pure Python int_to_float # function above. test_values = [ int_dbl_max-1, int_dbl_max, int_dbl_max+1, halfway-1, halfway, halfway + 1, top_power-1, top_power, top_power+1, 2*top_power-1, 2*top_power, top_power*top_power, ] test_values.extend(exact_values) for p in range(-4, 8): for x in range(-128, 128): test_values.append(2**(p+53) + x) for value in test_values: self.check_float_conversion(value) self.check_float_conversion(-value) def test_float_overflow(self): for x in -2.0, -1.0, 0.0, 1.0, 2.0: self.assertEqual(float(int(x)), x) shuge = '12345' * 120 huge = 1 << 30000 mhuge = -huge namespace = {'huge': huge, 'mhuge': mhuge, 'shuge': shuge, 'math': math} for test in ["float(huge)", "float(mhuge)", "complex(huge)", "complex(mhuge)", "complex(huge, 1)", "complex(mhuge, 1)", "complex(1, huge)", "complex(1, mhuge)", "1. + huge", "huge + 1.", "1. + mhuge", "mhuge + 1.", "1. - huge", "huge - 1.", "1. - mhuge", "mhuge - 1.", "1. * huge", "huge * 1.", "1. * mhuge", "mhuge * 1.", "1. // huge", "huge // 1.", "1. // mhuge", "mhuge // 1.", "1. / huge", "huge / 1.", "1. / mhuge", "mhuge / 1.", "1. ** huge", "huge ** 1.", "1. ** mhuge", "mhuge ** 1.", "math.sin(huge)", "math.sin(mhuge)", "math.sqrt(huge)", "math.sqrt(mhuge)", # should do better # math.floor() of an int returns an int now ##"math.floor(huge)", "math.floor(mhuge)", ]: self.assertRaises(OverflowError, eval, test, namespace) # XXX Perhaps float(shuge) can raise OverflowError on some box? # The comparison should not. self.assertNotEqual(float(shuge), int(shuge), "float(shuge) should not equal int(shuge)") def test_logs(self): LOG10E = math.log10(math.e) for exp in list(range(10)) + [100, 1000, 10000]: value = 10 ** exp log10 = math.log10(value) self.assertAlmostEqual(log10, exp) # log10(value) == exp, so log(value) == log10(value)/log10(e) == # exp/LOG10E expected = exp / LOG10E log = math.log(value) self.assertAlmostEqual(log, expected) for bad in -(1 << 10000), -2, 0: self.assertRaises(ValueError, math.log, bad) self.assertRaises(ValueError, math.log10, bad) def test_mixed_compares(self): eq = self.assertEqual # We're mostly concerned with that mixing floats and ints does the # right stuff, even when ints are too large to fit in a float. # The safest way to check the results is to use an entirely different # method, which we do here via a skeletal rational class (which # represents all Python ints and floats exactly). class Rat: def __init__(self, value): if isinstance(value, int): self.n = value self.d = 1 elif isinstance(value, float): # Convert to exact rational equivalent. f, e = math.frexp(abs(value)) assert f == 0 or 0.5 <= f < 1.0 # |value| = f * 2**e exactly # Suck up CHUNK bits at a time; 28 is enough so that we suck # up all bits in 2 iterations for all known binary double- # precision formats, and small enough to fit in an int. CHUNK = 28 top = 0 # invariant: |value| = (top + f) * 2**e exactly while f: f = math.ldexp(f, CHUNK) digit = int(f) assert digit >> CHUNK == 0 top = (top << CHUNK) | digit f -= digit assert 0.0 <= f < 1.0 e -= CHUNK # Now |value| = top * 2**e exactly. if e >= 0: n = top << e d = 1 else: n = top d = 1 << -e if value < 0: n = -n self.n = n self.d = d assert float(n) / float(d) == value else: raise TypeError("can't deal with %r" % value) def _cmp__(self, other): if not isinstance(other, Rat): other = Rat(other) x, y = self.n * other.d, self.d * other.n return (x > y) - (x < y) def __eq__(self, other): return self._cmp__(other) == 0 def __ge__(self, other): return self._cmp__(other) >= 0 def __gt__(self, other): return self._cmp__(other) > 0 def __le__(self, other): return self._cmp__(other) <= 0 def __lt__(self, other): return self._cmp__(other) < 0 cases = [0, 0.001, 0.99, 1.0, 1.5, 1e20, 1e200] # 2**48 is an important boundary in the internals. 2**53 is an # important boundary for IEEE double precision. for t in 2.0**48, 2.0**50, 2.0**53: cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0, int(t-1), int(t), int(t+1)]) cases.extend([0, 1, 2, sys.maxsize, float(sys.maxsize)]) # 1 << 20000 should exceed all double formats. int(1e200) is to # check that we get equality with 1e200 above. t = int(1e200) cases.extend([0, 1, 2, 1 << 20000, t-1, t, t+1]) cases.extend([-x for x in cases]) for x in cases: Rx = Rat(x) for y in cases: Ry = Rat(y) Rcmp = (Rx > Ry) - (Rx < Ry) with self.subTest(x=x, y=y, Rcmp=Rcmp): xycmp = (x > y) - (x < y) eq(Rcmp, xycmp) eq(x == y, Rcmp == 0) eq(x != y, Rcmp != 0) eq(x < y, Rcmp < 0) eq(x <= y, Rcmp <= 0) eq(x > y, Rcmp > 0) eq(x >= y, Rcmp >= 0) def test__format__(self): self.assertEqual(format(123456789, 'd'), '123456789') self.assertEqual(format(123456789, 'd'), '123456789') self.assertEqual(format(123456789, ','), '123,456,789') self.assertEqual(format(123456789, '_'), '123_456_789') # sign and aligning are interdependent self.assertEqual(format(1, "-"), '1') self.assertEqual(format(-1, "-"), '-1') self.assertEqual(format(1, "-3"), ' 1') self.assertEqual(format(-1, "-3"), ' -1') self.assertEqual(format(1, "+3"), ' +1') self.assertEqual(format(-1, "+3"), ' -1') self.assertEqual(format(1, " 3"), ' 1') self.assertEqual(format(-1, " 3"), ' -1') self.assertEqual(format(1, " "), ' 1') self.assertEqual(format(-1, " "), '-1') # hex self.assertEqual(format(3, "x"), "3") self.assertEqual(format(3, "X"), "3") self.assertEqual(format(1234, "x"), "4d2") self.assertEqual(format(-1234, "x"), "-4d2") self.assertEqual(format(1234, "8x"), " 4d2") self.assertEqual(format(-1234, "8x"), " -4d2") self.assertEqual(format(1234, "x"), "4d2") self.assertEqual(format(-1234, "x"), "-4d2") self.assertEqual(format(-3, "x"), "-3") self.assertEqual(format(-3, "X"), "-3") self.assertEqual(format(int('be', 16), "x"), "be") self.assertEqual(format(int('be', 16), "X"), "BE") self.assertEqual(format(-int('be', 16), "x"), "-be") self.assertEqual(format(-int('be', 16), "X"), "-BE") self.assertRaises(ValueError, format, 1234567890, ',x') self.assertEqual(format(1234567890, '_x'), '4996_02d2') self.assertEqual(format(1234567890, '_X'), '4996_02D2') # octal self.assertEqual(format(3, "o"), "3") self.assertEqual(format(-3, "o"), "-3") self.assertEqual(format(1234, "o"), "2322") self.assertEqual(format(-1234, "o"), "-2322") self.assertEqual(format(1234, "-o"), "2322") self.assertEqual(format(-1234, "-o"), "-2322") self.assertEqual(format(1234, " o"), " 2322") self.assertEqual(format(-1234, " o"), "-2322") self.assertEqual(format(1234, "+o"), "+2322") self.assertEqual(format(-1234, "+o"), "-2322") self.assertRaises(ValueError, format, 1234567890, ',o') self.assertEqual(format(1234567890, '_o'), '111_4540_1322') # binary self.assertEqual(format(3, "b"), "11") self.assertEqual(format(-3, "b"), "-11") self.assertEqual(format(1234, "b"), "10011010010") self.assertEqual(format(-1234, "b"), "-10011010010") self.assertEqual(format(1234, "-b"), "10011010010") self.assertEqual(format(-1234, "-b"), "-10011010010") self.assertEqual(format(1234, " b"), " 10011010010") self.assertEqual(format(-1234, " b"), "-10011010010") self.assertEqual(format(1234, "+b"), "+10011010010") self.assertEqual(format(-1234, "+b"), "-10011010010") self.assertRaises(ValueError, format, 1234567890, ',b') self.assertEqual(format(12345, '_b'), '11_0000_0011_1001') # make sure these are errors self.assertRaises(ValueError, format, 3, "1.3") # precision disallowed self.assertRaises(ValueError, format, 3, "_c") # underscore, self.assertRaises(ValueError, format, 3, ",c") # comma, and self.assertRaises(ValueError, format, 3, "+c") # sign not allowed # with 'c' self.assertRaisesRegex(ValueError, 'Cannot specify both', format, 3, '_,') self.assertRaisesRegex(ValueError, 'Cannot specify both', format, 3, ',_') self.assertRaisesRegex(ValueError, 'Cannot specify both', format, 3, '_,d') self.assertRaisesRegex(ValueError, 'Cannot specify both', format, 3, ',_d') self.assertRaisesRegex(ValueError, "Cannot specify ',' with 's'", format, 3, ',s') self.assertRaisesRegex(ValueError, "Cannot specify '_' with 's'", format, 3, '_s') # ensure that only int and float type specifiers work for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + [chr(x) for x in range(ord('A'), ord('Z')+1)]): if not format_spec in 'bcdoxXeEfFgGn%': self.assertRaises(ValueError, format, 0, format_spec) self.assertRaises(ValueError, format, 1, format_spec) self.assertRaises(ValueError, format, -1, format_spec) self.assertRaises(ValueError, format, 2**100, format_spec) self.assertRaises(ValueError, format, -(2**100), format_spec) # ensure that float type specifiers work; format converts # the int to a float for format_spec in 'eEfFgG%': for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]: self.assertEqual(format(value, format_spec), format(float(value), format_spec)) def test_nan_inf(self): self.assertRaises(OverflowError, int, float('inf')) self.assertRaises(OverflowError, int, float('-inf')) self.assertRaises(ValueError, int, float('nan')) def test_mod_division(self): with self.assertRaises(ZeroDivisionError): _ = 1 % 0 self.assertEqual(13 % 10, 3) self.assertEqual(-13 % 10, 7) self.assertEqual(13 % -10, -7) self.assertEqual(-13 % -10, -3) self.assertEqual(12 % 4, 0) self.assertEqual(-12 % 4, 0) self.assertEqual(12 % -4, 0) self.assertEqual(-12 % -4, 0) def test_true_division(self): huge = 1 << 40000 mhuge = -huge self.assertEqual(huge / huge, 1.0) self.assertEqual(mhuge / mhuge, 1.0) self.assertEqual(huge / mhuge, -1.0) self.assertEqual(mhuge / huge, -1.0) self.assertEqual(1 / huge, 0.0) self.assertEqual(1 / huge, 0.0) self.assertEqual(1 / mhuge, 0.0) self.assertEqual(1 / mhuge, 0.0) self.assertEqual((666 * huge + (huge >> 1)) / huge, 666.5) self.assertEqual((666 * mhuge + (mhuge >> 1)) / mhuge, 666.5) self.assertEqual((666 * huge + (huge >> 1)) / mhuge, -666.5) self.assertEqual((666 * mhuge + (mhuge >> 1)) / huge, -666.5) self.assertEqual(huge / (huge << 1), 0.5) self.assertEqual((1000000 * huge) / huge, 1000000) namespace = {'huge': huge, 'mhuge': mhuge} for overflow in ["float(huge)", "float(mhuge)", "huge / 1", "huge / 2", "huge / -1", "huge / -2", "mhuge / 100", "mhuge / 200"]: self.assertRaises(OverflowError, eval, overflow, namespace) for underflow in ["1 / huge", "2 / huge", "-1 / huge", "-2 / huge", "100 / mhuge", "200 / mhuge"]: result = eval(underflow, namespace) self.assertEqual(result, 0.0, "expected underflow to 0 from %r" % underflow) for zero in ["huge / 0", "mhuge / 0"]: self.assertRaises(ZeroDivisionError, eval, zero, namespace) def test_floordiv(self): with self.assertRaises(ZeroDivisionError): _ = 1 // 0 self.assertEqual(2 // 3, 0) self.assertEqual(2 // -3, -1) self.assertEqual(-2 // 3, -1) self.assertEqual(-2 // -3, 0) self.assertEqual(-11 // -3, 3) self.assertEqual(-11 // 3, -4) self.assertEqual(11 // -3, -4) self.assertEqual(11 // 3, 3) self.assertEqual(-12 // -3, 4) self.assertEqual(-12 // 3, -4) self.assertEqual(12 // -3, -4) self.assertEqual(12 // 3, 4) def check_truediv(self, a, b, skip_small=True): """Verify that the result of a/b is correctly rounded, by comparing it with a pure Python implementation of correctly rounded division. b should be nonzero.""" # skip check for small a and b: in this case, the current # implementation converts the arguments to float directly and # then applies a float division. This can give doubly-rounded # results on x87-using machines (particularly 32-bit Linux). if skip_small and max(abs(a), abs(b)) < 2**DBL_MANT_DIG: return try: # use repr so that we can distinguish between -0.0 and 0.0 expected = repr(truediv(a, b)) except OverflowError: expected = 'overflow' except ZeroDivisionError: expected = 'zerodivision' try: got = repr(a / b) except OverflowError: got = 'overflow' except ZeroDivisionError: got = 'zerodivision' self.assertEqual(expected, got, "Incorrectly rounded division {}/{}: " "expected {}, got {}".format(a, b, expected, got)) @support.requires_IEEE_754 def test_correctly_rounded_true_division(self): # more stringent tests than those above, checking that the # result of true division of ints is always correctly rounded. # This test should probably be considered CPython-specific. # Exercise all the code paths not involving Gb-sized ints. # ... divisions involving zero self.check_truediv(123, 0) self.check_truediv(-456, 0) self.check_truediv(0, 3) self.check_truediv(0, -3) self.check_truediv(0, 0) # ... overflow or underflow by large margin self.check_truediv(671 * 12345 * 2**DBL_MAX_EXP, 12345) self.check_truediv(12345, 345678 * 2**(DBL_MANT_DIG - DBL_MIN_EXP)) # ... a much larger or smaller than b self.check_truediv(12345*2**100, 98765) self.check_truediv(12345*2**30, 98765*7**81) # ... a / b near a boundary: one of 1, 2**DBL_MANT_DIG, 2**DBL_MIN_EXP, # 2**DBL_MAX_EXP, 2**(DBL_MIN_EXP-DBL_MANT_DIG) bases = (0, DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP, DBL_MIN_EXP - DBL_MANT_DIG) for base in bases: for exp in range(base - 15, base + 15): self.check_truediv(75312*2**max(exp, 0), 69187*2**max(-exp, 0)) self.check_truediv(69187*2**max(exp, 0), 75312*2**max(-exp, 0)) # overflow corner case for m in [1, 2, 7, 17, 12345, 7**100, -1, -2, -5, -23, -67891, -41**50]: for n in range(-10, 10): self.check_truediv(m*DBL_MIN_OVERFLOW + n, m) self.check_truediv(m*DBL_MIN_OVERFLOW + n, -m) # check detection of inexactness in shifting stage for n in range(250): # (2**DBL_MANT_DIG+1)/(2**DBL_MANT_DIG) lies halfway # between two representable floats, and would usually be # rounded down under round-half-to-even. The tiniest of # additions to the numerator should cause it to be rounded # up instead. self.check_truediv((2**DBL_MANT_DIG + 1)*12345*2**200 + 2**n, 2**DBL_MANT_DIG*12345) # 1/2731 is one of the smallest division cases that's subject # to double rounding on IEEE 754 machines working internally with # 64-bit precision. On such machines, the next check would fail, # were it not explicitly skipped in check_truediv. self.check_truediv(1, 2731) # a particularly bad case for the old algorithm: gives an # error of close to 3.5 ulps. self.check_truediv(295147931372582273023, 295147932265116303360) for i in range(1000): self.check_truediv(10**(i+1), 10**i) self.check_truediv(10**i, 10**(i+1)) # test round-half-to-even behaviour, normal result for m in [1, 2, 4, 7, 8, 16, 17, 32, 12345, 7**100, -1, -2, -5, -23, -67891, -41**50]: for n in range(-10, 10): self.check_truediv(2**DBL_MANT_DIG*m + n, m) # test round-half-to-even, subnormal result for n in range(-20, 20): self.check_truediv(n, 2**1076) # largeish random divisions: a/b where |a| <= |b| <= # 2*|a|; |ans| is between 0.5 and 1.0, so error should # always be bounded by 2**-54 with equality possible only # if the least significant bit of q=ans*2**53 is zero. for M in [10**10, 10**100, 10**1000]: for i in range(1000): a = random.randrange(1, M) b = random.randrange(a, 2*a+1) self.check_truediv(a, b) self.check_truediv(-a, b) self.check_truediv(a, -b) self.check_truediv(-a, -b) # and some (genuinely) random tests for _ in range(10000): a_bits = random.randrange(1000) b_bits = random.randrange(1, 1000) x = random.randrange(2**a_bits) y = random.randrange(1, 2**b_bits) self.check_truediv(x, y) self.check_truediv(x, -y) self.check_truediv(-x, y) self.check_truediv(-x, -y) def test_lshift_of_zero(self): self.assertEqual(0 << 0, 0) self.assertEqual(0 << 10, 0) with self.assertRaises(ValueError): 0 << -1 @support.cpython_only def test_huge_lshift_of_zero(self): # Shouldn't try to allocate memory for a huge shift. See issue #27870. # Other implementations may have a different boundary for overflow, # or not raise at all. self.assertEqual(0 << sys.maxsize, 0) with self.assertRaises(OverflowError): 0 << (sys.maxsize + 1) def test_small_ints(self): for i in range(-5, 257): self.assertIs(i, i + 0) self.assertIs(i, i * 1) self.assertIs(i, i - 0) self.assertIs(i, i // 1) self.assertIs(i, i & -1) self.assertIs(i, i | 0) self.assertIs(i, i ^ 0) self.assertIs(i, ~~i) self.assertIs(i, i**1) self.assertIs(i, int(str(i))) self.assertIs(i, i<<2>>2, str(i)) # corner cases i = 1 << 70 self.assertIs(i - i, 0) self.assertIs(0 * i, 0) def test_bit_length(self): tiny = 1e-10 for x in range(-65000, 65000): k = x.bit_length() # Check equivalence with Python version self.assertEqual(k, len(bin(x).lstrip('-0b'))) # Behaviour as specified in the docs if x != 0: self.assertTrue(2**(k-1) <= abs(x) < 2**k) else: self.assertEqual(k, 0) # Alternative definition: x.bit_length() == 1 + floor(log_2(x)) if x != 0: # When x is an exact power of 2, numeric errors can # cause floor(log(x)/log(2)) to be one too small; for # small x this can be fixed by adding a small quantity # to the quotient before taking the floor. self.assertEqual(k, 1 + math.floor( math.log(abs(x))/math.log(2) + tiny)) self.assertEqual((0).bit_length(), 0) self.assertEqual((1).bit_length(), 1) self.assertEqual((-1).bit_length(), 1) self.assertEqual((2).bit_length(), 2) self.assertEqual((-2).bit_length(), 2) for i in [2, 3, 15, 16, 17, 31, 32, 33, 63, 64, 234]: a = 2**i self.assertEqual((a-1).bit_length(), i) self.assertEqual((1-a).bit_length(), i) self.assertEqual((a).bit_length(), i+1) self.assertEqual((-a).bit_length(), i+1) self.assertEqual((a+1).bit_length(), i+1) self.assertEqual((-a-1).bit_length(), i+1) def test_round(self): # check round-half-even algorithm. For round to nearest ten; # rounding map is invariant under adding multiples of 20 test_dict = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:10, 7:10, 8:10, 9:10, 10:10, 11:10, 12:10, 13:10, 14:10, 15:20, 16:20, 17:20, 18:20, 19:20} for offset in range(-520, 520, 20): for k, v in test_dict.items(): got = round(k+offset, -1) expected = v+offset self.assertEqual(got, expected) self.assertIs(type(got), int) # larger second argument self.assertEqual(round(-150, -2), -200) self.assertEqual(round(-149, -2), -100) self.assertEqual(round(-51, -2), -100) self.assertEqual(round(-50, -2), 0) self.assertEqual(round(-49, -2), 0) self.assertEqual(round(-1, -2), 0) self.assertEqual(round(0, -2), 0) self.assertEqual(round(1, -2), 0) self.assertEqual(round(49, -2), 0) self.assertEqual(round(50, -2), 0) self.assertEqual(round(51, -2), 100) self.assertEqual(round(149, -2), 100) self.assertEqual(round(150, -2), 200) self.assertEqual(round(250, -2), 200) self.assertEqual(round(251, -2), 300) self.assertEqual(round(172500, -3), 172000) self.assertEqual(round(173500, -3), 174000) self.assertEqual(round(31415926535, -1), 31415926540) self.assertEqual(round(31415926535, -2), 31415926500) self.assertEqual(round(31415926535, -3), 31415927000) self.assertEqual(round(31415926535, -4), 31415930000) self.assertEqual(round(31415926535, -5), 31415900000) self.assertEqual(round(31415926535, -6), 31416000000) self.assertEqual(round(31415926535, -7), 31420000000) self.assertEqual(round(31415926535, -8), 31400000000) self.assertEqual(round(31415926535, -9), 31000000000) self.assertEqual(round(31415926535, -10), 30000000000) self.assertEqual(round(31415926535, -11), 0) self.assertEqual(round(31415926535, -12), 0) self.assertEqual(round(31415926535, -999), 0) # should get correct results even for huge inputs for k in range(10, 100): got = round(10**k + 324678, -3) expect = 10**k + 325000 self.assertEqual(got, expect) self.assertIs(type(got), int) # nonnegative second argument: round(x, n) should just return x for n in range(5): for i in range(100): x = random.randrange(-10000, 10000) got = round(x, n) self.assertEqual(got, x) self.assertIs(type(got), int) for huge_n in 2**31-1, 2**31, 2**63-1, 2**63, 2**100, 10**100: self.assertEqual(round(8979323, huge_n), 8979323) # omitted second argument for i in range(100): x = random.randrange(-10000, 10000) got = round(x) self.assertEqual(got, x) self.assertIs(type(got), int) # bad second argument bad_exponents = ('brian', 2.0, 0j) for e in bad_exponents: self.assertRaises(TypeError, round, 3, e) def test_to_bytes(self): def check(tests, byteorder, signed=False): for test, expected in tests.items(): try: self.assertEqual( test.to_bytes(len(expected), byteorder, signed=signed), expected) except Exception as err: raise AssertionError( "failed to convert {0} with byteorder={1} and signed={2}" .format(test, byteorder, signed)) from err # Convert integers to signed big-endian byte arrays. tests1 = { 0: b'\x00', 1: b'\x01', -1: b'\xff', -127: b'\x81', -128: b'\x80', -129: b'\xff\x7f', 127: b'\x7f', 129: b'\x00\x81', -255: b'\xff\x01', -256: b'\xff\x00', 255: b'\x00\xff', 256: b'\x01\x00', 32767: b'\x7f\xff', -32768: b'\xff\x80\x00', 65535: b'\x00\xff\xff', -65536: b'\xff\x00\x00', -8388608: b'\x80\x00\x00' } check(tests1, 'big', signed=True) # Convert integers to signed little-endian byte arrays. tests2 = { 0: b'\x00', 1: b'\x01', -1: b'\xff', -127: b'\x81', -128: b'\x80', -129: b'\x7f\xff', 127: b'\x7f', 129: b'\x81\x00', -255: b'\x01\xff', -256: b'\x00\xff', 255: b'\xff\x00', 256: b'\x00\x01', 32767: b'\xff\x7f', -32768: b'\x00\x80', 65535: b'\xff\xff\x00', -65536: b'\x00\x00\xff', -8388608: b'\x00\x00\x80' } check(tests2, 'little', signed=True) # Convert integers to unsigned big-endian byte arrays. tests3 = { 0: b'\x00', 1: b'\x01', 127: b'\x7f', 128: b'\x80', 255: b'\xff', 256: b'\x01\x00', 32767: b'\x7f\xff', 32768: b'\x80\x00', 65535: b'\xff\xff', 65536: b'\x01\x00\x00' } check(tests3, 'big', signed=False) # Convert integers to unsigned little-endian byte arrays. tests4 = { 0: b'\x00', 1: b'\x01', 127: b'\x7f', 128: b'\x80', 255: b'\xff', 256: b'\x00\x01', 32767: b'\xff\x7f', 32768: b'\x00\x80', 65535: b'\xff\xff', 65536: b'\x00\x00\x01' } check(tests4, 'little', signed=False) self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=False) self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=True) self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=False) self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=True) self.assertRaises(OverflowError, (-1).to_bytes, 2, 'big', signed=False) self.assertRaises(OverflowError, (-1).to_bytes, 2, 'little', signed=False) self.assertEqual((0).to_bytes(0, 'big'), b'') self.assertEqual((1).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x01') self.assertEqual((0).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x00') self.assertEqual((-1).to_bytes(5, 'big', signed=True), b'\xff\xff\xff\xff\xff') self.assertRaises(OverflowError, (1).to_bytes, 0, 'big') def test_from_bytes(self): def check(tests, byteorder, signed=False): for test, expected in tests.items(): try: self.assertEqual( int.from_bytes(test, byteorder, signed=signed), expected) except Exception as err: raise AssertionError( "failed to convert {0} with byteorder={1!r} and signed={2}" .format(test, byteorder, signed)) from err # Convert signed big-endian byte arrays to integers. tests1 = { b'': 0, b'\x00': 0, b'\x00\x00': 0, b'\x01': 1, b'\x00\x01': 1, b'\xff': -1, b'\xff\xff': -1, b'\x81': -127, b'\x80': -128, b'\xff\x7f': -129, b'\x7f': 127, b'\x00\x81': 129, b'\xff\x01': -255, b'\xff\x00': -256, b'\x00\xff': 255, b'\x01\x00': 256, b'\x7f\xff': 32767, b'\x80\x00': -32768, b'\x00\xff\xff': 65535, b'\xff\x00\x00': -65536, b'\x80\x00\x00': -8388608 } check(tests1, 'big', signed=True) # Convert signed little-endian byte arrays to integers. tests2 = { b'': 0, b'\x00': 0, b'\x00\x00': 0, b'\x01': 1, b'\x00\x01': 256, b'\xff': -1, b'\xff\xff': -1, b'\x81': -127, b'\x80': -128, b'\x7f\xff': -129, b'\x7f': 127, b'\x81\x00': 129, b'\x01\xff': -255, b'\x00\xff': -256, b'\xff\x00': 255, b'\x00\x01': 256, b'\xff\x7f': 32767, b'\x00\x80': -32768, b'\xff\xff\x00': 65535, b'\x00\x00\xff': -65536, b'\x00\x00\x80': -8388608 } check(tests2, 'little', signed=True) # Convert unsigned big-endian byte arrays to integers. tests3 = { b'': 0, b'\x00': 0, b'\x01': 1, b'\x7f': 127, b'\x80': 128, b'\xff': 255, b'\x01\x00': 256, b'\x7f\xff': 32767, b'\x80\x00': 32768, b'\xff\xff': 65535, b'\x01\x00\x00': 65536, } check(tests3, 'big', signed=False) # Convert integers to unsigned little-endian byte arrays. tests4 = { b'': 0, b'\x00': 0, b'\x01': 1, b'\x7f': 127, b'\x80': 128, b'\xff': 255, b'\x00\x01': 256, b'\xff\x7f': 32767, b'\x00\x80': 32768, b'\xff\xff': 65535, b'\x00\x00\x01': 65536, } check(tests4, 'little', signed=False) class myint(int): pass self.assertIs(type(myint.from_bytes(b'\x00', 'big')), myint) self.assertEqual(myint.from_bytes(b'\x01', 'big'), 1) self.assertIs( type(myint.from_bytes(b'\x00', 'big', signed=False)), myint) self.assertEqual(myint.from_bytes(b'\x01', 'big', signed=False), 1) self.assertIs(type(myint.from_bytes(b'\x00', 'little')), myint) self.assertEqual(myint.from_bytes(b'\x01', 'little'), 1) self.assertIs(type(myint.from_bytes( b'\x00', 'little', signed=False)), myint) self.assertEqual(myint.from_bytes(b'\x01', 'little', signed=False), 1) self.assertEqual( int.from_bytes([255, 0, 0], 'big', signed=True), -65536) self.assertEqual( int.from_bytes((255, 0, 0), 'big', signed=True), -65536) self.assertEqual(int.from_bytes( bytearray(b'\xff\x00\x00'), 'big', signed=True), -65536) self.assertEqual(int.from_bytes( bytearray(b'\xff\x00\x00'), 'big', signed=True), -65536) self.assertEqual(int.from_bytes( array.array('B', b'\xff\x00\x00'), 'big', signed=True), -65536) self.assertEqual(int.from_bytes( memoryview(b'\xff\x00\x00'), 'big', signed=True), -65536) self.assertRaises(ValueError, int.from_bytes, [256], 'big') self.assertRaises(ValueError, int.from_bytes, [0], 'big\x00') self.assertRaises(ValueError, int.from_bytes, [0], 'little\x00') self.assertRaises(TypeError, int.from_bytes, "", 'big') self.assertRaises(TypeError, int.from_bytes, "\x00", 'big') self.assertRaises(TypeError, int.from_bytes, 0, 'big') self.assertRaises(TypeError, int.from_bytes, 0, 'big', True) self.assertRaises(TypeError, myint.from_bytes, "", 'big') self.assertRaises(TypeError, myint.from_bytes, "\x00", 'big') self.assertRaises(TypeError, myint.from_bytes, 0, 'big') self.assertRaises(TypeError, int.from_bytes, 0, 'big', True) class myint2(int): def __new__(cls, value): return int.__new__(cls, value + 1) i = myint2.from_bytes(b'\x01', 'big') self.assertIs(type(i), myint2) self.assertEqual(i, 2) class myint3(int): def __init__(self, value): self.foo = 'bar' i = myint3.from_bytes(b'\x01', 'big') self.assertIs(type(i), myint3) self.assertEqual(i, 1) self.assertEqual(getattr(i, 'foo', 'none'), 'bar') def test_access_to_nonexistent_digit_0(self): # http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that # ob_digit[0] was being incorrectly accessed for instances of a # subclass of int, with value 0. class Integer(int): def __new__(cls, value=0): self = int.__new__(cls, value) self.foo = 'foo' return self integers = [Integer(0) for i in range(1000)] for n in map(int, integers): self.assertEqual(n, 0) def test_shift_bool(self): # Issue #21422: ensure that bool << int and bool >> int return int for value in (True, False): for shift in (0, 2): self.assertEqual(type(value << shift), int) self.assertEqual(type(value >> shift), int) if __name__ == "__main__": unittest.main()
52,992
1,330
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_ftplib.py
"""Test script for ftplib module.""" # Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS # environment import ftplib import asyncore import asynchat import socket import io import errno import os import time try: import ssl except ImportError: ssl = None from unittest import TestCase, skipUnless from test import support from test.support import HOST, HOSTv6 threading = support.import_module('threading') TIMEOUT = 3 # the dummy data returned by server over the data channel when # RETR, LIST, NLST, MLSD commands are issued RETR_DATA = 'abcde12345\r\n' * 1000 LIST_DATA = 'foo\r\nbar\r\n' NLST_DATA = 'foo\r\nbar\r\n' MLSD_DATA = ("type=cdir;perm=el;unique==keVO1+ZF4; test\r\n" "type=pdir;perm=e;unique==keVO1+d?3; ..\r\n" "type=OS.unix=slink:/foobar;perm=;unique==keVO1+4G4; foobar\r\n" "type=OS.unix=chr-13/29;perm=;unique==keVO1+5G4; device\r\n" "type=OS.unix=blk-11/108;perm=;unique==keVO1+6G4; block\r\n" "type=file;perm=awr;unique==keVO1+8G4; writable\r\n" "type=dir;perm=cpmel;unique==keVO1+7G4; promiscuous\r\n" "type=dir;perm=;unique==keVO1+1t2; no-exec\r\n" "type=file;perm=r;unique==keVO1+EG4; two words\r\n" "type=file;perm=r;unique==keVO1+IH4; leading space\r\n" "type=file;perm=r;unique==keVO1+1G4; file1\r\n" "type=dir;perm=cpmel;unique==keVO1+7G4; incoming\r\n" "type=file;perm=r;unique==keVO1+1G4; file2\r\n" "type=file;perm=r;unique==keVO1+1G4; file3\r\n" "type=file;perm=r;unique==keVO1+1G4; file4\r\n") class DummyDTPHandler(asynchat.async_chat): dtp_conn_closed = False def __init__(self, conn, baseclass): asynchat.async_chat.__init__(self, conn) self.baseclass = baseclass self.baseclass.last_received_data = '' def handle_read(self): self.baseclass.last_received_data += self.recv(1024).decode('ascii') def handle_close(self): # XXX: this method can be called many times in a row for a single # connection, including in clear-text (non-TLS) mode. # (behaviour witnessed with test_data_connection) if not self.dtp_conn_closed: self.baseclass.push('226 transfer complete') self.close() self.dtp_conn_closed = True def push(self, what): if self.baseclass.next_data is not None: what = self.baseclass.next_data self.baseclass.next_data = None if not what: return self.close_when_done() super(DummyDTPHandler, self).push(what.encode('ascii')) def handle_error(self): raise Exception class DummyFTPHandler(asynchat.async_chat): dtp_handler = DummyDTPHandler def __init__(self, conn): asynchat.async_chat.__init__(self, conn) # tells the socket to handle urgent data inline (ABOR command) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_OOBINLINE, 1) self.set_terminator(b"\r\n") self.in_buffer = [] self.dtp = None self.last_received_cmd = None self.last_received_data = '' self.next_response = '' self.next_data = None self.rest = None self.next_retr_data = RETR_DATA self.push('220 welcome') # We use this as the string IPv4 address to direct the client # to in response to a PASV command. To test security behavior. # https://bugs.python.org/issue43285/. self.fake_pasv_server_ip = '252.253.254.255' def collect_incoming_data(self, data): self.in_buffer.append(data) def found_terminator(self): line = b''.join(self.in_buffer).decode('ascii') self.in_buffer = [] if self.next_response: self.push(self.next_response) self.next_response = '' cmd = line.split(' ')[0].lower() self.last_received_cmd = cmd space = line.find(' ') if space != -1: arg = line[space + 1:] else: arg = "" if hasattr(self, 'cmd_' + cmd): method = getattr(self, 'cmd_' + cmd) method(arg) else: self.push('550 command "%s" not understood.' %cmd) def handle_error(self): raise Exception def push(self, data): asynchat.async_chat.push(self, data.encode('ascii') + b'\r\n') def cmd_port(self, arg): addr = list(map(int, arg.split(','))) ip = '%d.%d.%d.%d' %tuple(addr[:4]) port = (addr[4] * 256) + addr[5] s = socket.create_connection((ip, port), timeout=TIMEOUT) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_pasv(self, arg): with socket.socket() as sock: sock.bind((self.socket.getsockname()[0], 0)) sock.listen() sock.settimeout(TIMEOUT) port = sock.getsockname()[1] ip = self.fake_pasv_server_ip ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256 self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2)) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_eprt(self, arg): af, ip, port = arg.split(arg[0])[1:-1] port = int(port) s = socket.create_connection((ip, port), timeout=TIMEOUT) self.dtp = self.dtp_handler(s, baseclass=self) self.push('200 active data connection established') def cmd_epsv(self, arg): with socket.socket(socket.AF_INET6) as sock: sock.bind((self.socket.getsockname()[0], 0)) sock.listen() sock.settimeout(TIMEOUT) port = sock.getsockname()[1] self.push('229 entering extended passive mode (|||%d|)' %port) conn, addr = sock.accept() self.dtp = self.dtp_handler(conn, baseclass=self) def cmd_echo(self, arg): # sends back the received string (used by the test suite) self.push(arg) def cmd_noop(self, arg): self.push('200 noop ok') def cmd_user(self, arg): self.push('331 username ok') def cmd_pass(self, arg): self.push('230 password ok') def cmd_acct(self, arg): self.push('230 acct ok') def cmd_rnfr(self, arg): self.push('350 rnfr ok') def cmd_rnto(self, arg): self.push('250 rnto ok') def cmd_dele(self, arg): self.push('250 dele ok') def cmd_cwd(self, arg): self.push('250 cwd ok') def cmd_size(self, arg): self.push('250 1000') def cmd_mkd(self, arg): self.push('257 "%s"' %arg) def cmd_rmd(self, arg): self.push('250 rmd ok') def cmd_pwd(self, arg): self.push('257 "pwd ok"') def cmd_type(self, arg): self.push('200 type ok') def cmd_quit(self, arg): self.push('221 quit ok') self.close() def cmd_abor(self, arg): self.push('226 abor ok') def cmd_stor(self, arg): self.push('125 stor ok') def cmd_rest(self, arg): self.rest = arg self.push('350 rest ok') def cmd_retr(self, arg): self.push('125 retr ok') if self.rest is not None: offset = int(self.rest) else: offset = 0 self.dtp.push(self.next_retr_data[offset:]) self.dtp.close_when_done() self.rest = None def cmd_list(self, arg): self.push('125 list ok') self.dtp.push(LIST_DATA) self.dtp.close_when_done() def cmd_nlst(self, arg): self.push('125 nlst ok') self.dtp.push(NLST_DATA) self.dtp.close_when_done() def cmd_opts(self, arg): self.push('200 opts ok') def cmd_mlsd(self, arg): self.push('125 mlsd ok') self.dtp.push(MLSD_DATA) self.dtp.close_when_done() def cmd_setlongretr(self, arg): # For testing. Next RETR will return long line. self.next_retr_data = 'x' * int(arg) self.push('125 setlongretr ok') class DummyFTPServer(asyncore.dispatcher, threading.Thread): handler = DummyFTPHandler def __init__(self, address, af=socket.AF_INET): threading.Thread.__init__(self) asyncore.dispatcher.__init__(self) self.create_socket(af, socket.SOCK_STREAM) self.bind(address) self.listen(5) self.active = False self.active_lock = threading.Lock() self.host, self.port = self.socket.getsockname()[:2] self.handler_instance = None def start(self): assert not self.active self.__flag = threading.Event() threading.Thread.start(self) self.__flag.wait() def run(self): self.active = True self.__flag.set() while self.active and asyncore.socket_map: self.active_lock.acquire() asyncore.loop(timeout=0.1, count=1) self.active_lock.release() asyncore.close_all(ignore_all=True) def stop(self): assert self.active self.active = False self.join() def handle_accepted(self, conn, addr): self.handler_instance = self.handler(conn) def handle_connect(self): self.close() handle_read = handle_connect def writable(self): return 0 def handle_error(self): raise Exception if ssl is not None: CERTFILE = os.path.join(os.path.dirname(__file__), "keycert3.pem") CAFILE = os.path.join(os.path.dirname(__file__), "pycacert.pem") class SSLConnection(asyncore.dispatcher): """An asyncore.dispatcher subclass supporting TLS/SSL.""" _ssl_accepting = False _ssl_closing = False def secure_connection(self): context = ssl.SSLContext() context.load_cert_chain(CERTFILE) socket = context.wrap_socket(self.socket, suppress_ragged_eofs=False, server_side=True, do_handshake_on_connect=False) self.del_channel() self.set_socket(socket) self._ssl_accepting = True def _do_ssl_handshake(self): try: self.socket.do_handshake() except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return elif err.args[0] == ssl.SSL_ERROR_EOF: return self.handle_close() raise except OSError as err: if err.args[0] == errno.ECONNABORTED: return self.handle_close() else: self._ssl_accepting = False def _do_ssl_shutdown(self): self._ssl_closing = True try: self.socket = self.socket.unwrap() except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return except OSError as err: # Any "socket error" corresponds to a SSL_ERROR_SYSCALL return # from OpenSSL's SSL_shutdown(), corresponding to a # closed socket condition. See also: # http://www.mail-archive.com/[email protected]/msg60710.html pass self._ssl_closing = False if getattr(self, '_ccc', False) is False: super(SSLConnection, self).close() else: pass def handle_read_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_read_event() def handle_write_event(self): if self._ssl_accepting: self._do_ssl_handshake() elif self._ssl_closing: self._do_ssl_shutdown() else: super(SSLConnection, self).handle_write_event() def send(self, data): try: return super(SSLConnection, self).send(data) except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN, ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return 0 raise def recv(self, buffer_size): try: return super(SSLConnection, self).recv(buffer_size) except ssl.SSLError as err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return b'' if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): self.handle_close() return b'' raise def handle_error(self): raise Exception def close(self): if (isinstance(self.socket, ssl.SSLSocket) and self.socket._sslobj is not None): self._do_ssl_shutdown() else: super(SSLConnection, self).close() class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler): """A DummyDTPHandler subclass supporting TLS/SSL.""" def __init__(self, conn, baseclass): DummyDTPHandler.__init__(self, conn, baseclass) if self.baseclass.secure_data_channel: self.secure_connection() class DummyTLS_FTPHandler(SSLConnection, DummyFTPHandler): """A DummyFTPHandler subclass supporting TLS/SSL.""" dtp_handler = DummyTLS_DTPHandler def __init__(self, conn): DummyFTPHandler.__init__(self, conn) self.secure_data_channel = False self._ccc = False def cmd_auth(self, line): """Set up secure control channel.""" self.push('234 AUTH TLS successful') self.secure_connection() def cmd_ccc(self, line): self.push('220 Reverting back to clear-text') self._ccc = True self._do_ssl_shutdown() def cmd_pbsz(self, line): """Negotiate size of buffer for secure data transfer. For TLS/SSL the only valid value for the parameter is '0'. Any other value is accepted but ignored. """ self.push('200 PBSZ=0 successful.') def cmd_prot(self, line): """Setup un/secure data channel.""" arg = line.upper() if arg == 'C': self.push('200 Protection set to Clear') self.secure_data_channel = False elif arg == 'P': self.push('200 Protection set to Private') self.secure_data_channel = True else: self.push("502 Unrecognized PROT type (use C or P).") class DummyTLS_FTPServer(DummyFTPServer): handler = DummyTLS_FTPHandler class TestFTPClass(TestCase): def setUp(self): self.server = DummyFTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() # Explicitly clear the attribute to prevent dangling thread self.server = None asyncore.close_all(ignore_all=True) def check_data(self, received, expected): self.assertEqual(len(received), len(expected)) self.assertEqual(received, expected) def test_getwelcome(self): self.assertEqual(self.client.getwelcome(), '220 welcome') def test_sanitize(self): self.assertEqual(self.client.sanitize('foo'), repr('foo')) self.assertEqual(self.client.sanitize('pass 12345'), repr('pass *****')) self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****')) def test_exceptions(self): self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r\n0') self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\n0') self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r0') self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400') self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500') self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 599') self.assertRaises(ftplib.error_proto, self.client.sendcmd, 'echo 999') def test_all_errors(self): exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm, ftplib.error_proto, ftplib.Error, OSError, EOFError) for x in exceptions: try: raise x('exception not included in all_errors set') except ftplib.all_errors: pass def test_set_pasv(self): # passive mode is supposed to be enabled by default self.assertTrue(self.client.passiveserver) self.client.set_pasv(True) self.assertTrue(self.client.passiveserver) self.client.set_pasv(False) self.assertFalse(self.client.passiveserver) def test_voidcmd(self): self.client.voidcmd('echo 200') self.client.voidcmd('echo 299') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 199') self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 300') def test_login(self): self.client.login() def test_acct(self): self.client.acct('passwd') def test_rename(self): self.client.rename('a', 'b') self.server.handler_instance.next_response = '200' self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b') def test_delete(self): self.client.delete('foo') self.server.handler_instance.next_response = '199' self.assertRaises(ftplib.error_reply, self.client.delete, 'foo') def test_size(self): self.client.size('foo') def test_mkd(self): dir = self.client.mkd('/foo') self.assertEqual(dir, '/foo') def test_rmd(self): self.client.rmd('foo') def test_cwd(self): dir = self.client.cwd('/foo') self.assertEqual(dir, '250 cwd ok') def test_pwd(self): dir = self.client.pwd() self.assertEqual(dir, 'pwd ok') def test_quit(self): self.assertEqual(self.client.quit(), '221 quit ok') # Ensure the connection gets closed; sock attribute should be None self.assertEqual(self.client.sock, None) def test_abort(self): self.client.abort() def test_retrbinary(self): def callback(data): received.append(data.decode('ascii')) received = [] self.client.retrbinary('retr', callback) self.check_data(''.join(received), RETR_DATA) def test_retrbinary_rest(self): def callback(data): received.append(data.decode('ascii')) for rest in (0, 10, 20): received = [] self.client.retrbinary('retr', callback, rest=rest) self.check_data(''.join(received), RETR_DATA[rest:]) def test_retrlines(self): received = [] self.client.retrlines('retr', received.append) self.check_data(''.join(received), RETR_DATA.replace('\r\n', '')) def test_storbinary(self): f = io.BytesIO(RETR_DATA.encode('ascii')) self.client.storbinary('stor', f) self.check_data(self.server.handler_instance.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storbinary('stor', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) def test_storbinary_rest(self): f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii')) for r in (30, '30'): f.seek(0) self.client.storbinary('stor', f, rest=r) self.assertEqual(self.server.handler_instance.rest, str(r)) def test_storlines(self): f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii')) self.client.storlines('stor', f) self.check_data(self.server.handler_instance.last_received_data, RETR_DATA) # test new callback arg flag = [] f.seek(0) self.client.storlines('stor foo', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) f = io.StringIO(RETR_DATA.replace('\r\n', '\n')) # storlines() expects a binary file, not a text file with support.check_warnings(('', BytesWarning), quiet=True): self.assertRaises(TypeError, self.client.storlines, 'stor foo', f) def test_nlst(self): self.client.nlst() self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1]) def test_dir(self): l = [] self.client.dir(lambda x: l.append(x)) self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', '')) def test_mlsd(self): list(self.client.mlsd()) list(self.client.mlsd(path='/')) list(self.client.mlsd(path='/', facts=['size', 'type'])) ls = list(self.client.mlsd()) for name, facts in ls: self.assertIsInstance(name, str) self.assertIsInstance(facts, dict) self.assertTrue(name) self.assertIn('type', facts) self.assertIn('perm', facts) self.assertIn('unique', facts) def set_data(data): self.server.handler_instance.next_data = data def test_entry(line, type=None, perm=None, unique=None, name=None): type = 'type' if type is None else type perm = 'perm' if perm is None else perm unique = 'unique' if unique is None else unique name = 'name' if name is None else name set_data(line) _name, facts = next(self.client.mlsd()) self.assertEqual(_name, name) self.assertEqual(facts['type'], type) self.assertEqual(facts['perm'], perm) self.assertEqual(facts['unique'], unique) # plain test_entry('type=type;perm=perm;unique=unique; name\r\n') # "=" in fact value test_entry('type=ty=pe;perm=perm;unique=unique; name\r\n', type="ty=pe") test_entry('type==type;perm=perm;unique=unique; name\r\n', type="=type") test_entry('type=t=y=pe;perm=perm;unique=unique; name\r\n', type="t=y=pe") test_entry('type=====;perm=perm;unique=unique; name\r\n', type="====") # spaces in name test_entry('type=type;perm=perm;unique=unique; na me\r\n', name="na me") test_entry('type=type;perm=perm;unique=unique; name \r\n', name="name ") test_entry('type=type;perm=perm;unique=unique; name\r\n', name=" name") test_entry('type=type;perm=perm;unique=unique; n am e\r\n', name="n am e") # ";" in name test_entry('type=type;perm=perm;unique=unique; na;me\r\n', name="na;me") test_entry('type=type;perm=perm;unique=unique; ;name\r\n', name=";name") test_entry('type=type;perm=perm;unique=unique; ;name;\r\n', name=";name;") test_entry('type=type;perm=perm;unique=unique; ;;;;\r\n', name=";;;;") # case sensitiveness set_data('Type=type;TyPe=perm;UNIQUE=unique; name\r\n') _name, facts = next(self.client.mlsd()) for x in facts: self.assertTrue(x.islower()) # no data (directory empty) set_data('') self.assertRaises(StopIteration, next, self.client.mlsd()) set_data('') for x in self.client.mlsd(): self.fail("unexpected data %s" % x) def test_makeport(self): with self.client.makeport(): # IPv4 is in use, just make sure send_eprt has not been used self.assertEqual(self.server.handler_instance.last_received_cmd, 'port') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), timeout=TIMEOUT) conn.close() # IPv4 is in use, just make sure send_epsv has not been used self.assertEqual(self.server.handler_instance.last_received_cmd, 'pasv') def test_makepasv_issue43285_security_disabled(self): """Test the opt-in to the old vulnerable behavior.""" self.client.trust_server_pasv_ipv4_address = True bad_host, port = self.client.makepasv() self.assertEqual( bad_host, self.server.handler_instance.fake_pasv_server_ip) # Opening and closing a connection keeps the dummy server happy # instead of timing out on accept. socket.create_connection((self.client.sock.getpeername()[0], port), timeout=TIMEOUT).close() def test_makepasv_issue43285_security_enabled_default(self): self.assertFalse(self.client.trust_server_pasv_ipv4_address) trusted_host, port = self.client.makepasv() self.assertNotEqual( trusted_host, self.server.handler_instance.fake_pasv_server_ip) # Opening and closing a connection keeps the dummy server happy # instead of timing out on accept. socket.create_connection((trusted_host, port), timeout=TIMEOUT).close() def test_with_statement(self): self.client.quit() def is_client_connected(): if self.client.sock is None: return False try: self.client.sendcmd('noop') except (OSError, EOFError): return False return True # base test with ftplib.FTP(timeout=TIMEOUT) as self.client: self.client.connect(self.server.host, self.server.port) self.client.sendcmd('noop') self.assertTrue(is_client_connected()) self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) # QUIT sent inside the with block with ftplib.FTP(timeout=TIMEOUT) as self.client: self.client.connect(self.server.host, self.server.port) self.client.sendcmd('noop') self.client.quit() self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) # force a wrong response code to be sent on QUIT: error_perm # is expected and the connection is supposed to be closed try: with ftplib.FTP(timeout=TIMEOUT) as self.client: self.client.connect(self.server.host, self.server.port) self.client.sendcmd('noop') self.server.handler_instance.next_response = '550 error on quit' except ftplib.error_perm as err: self.assertEqual(str(err), '550 error on quit') else: self.fail('Exception not raised') # needed to give the threaded server some time to set the attribute # which otherwise would still be == 'noop' time.sleep(0.1) self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) def test_source_address(self): self.client.quit() port = support.find_unused_port() try: self.client.connect(self.server.host, self.server.port, source_address=(HOST, port)) self.assertEqual(self.client.sock.getsockname()[1], port) self.client.quit() except OSError as e: if e.errno == errno.EADDRINUSE: self.skipTest("couldn't bind to port %d" % port) raise def test_source_address_passive_connection(self): port = support.find_unused_port() self.client.source_address = (HOST, port) try: with self.client.transfercmd('list') as sock: self.assertEqual(sock.getsockname()[1], port) except OSError as e: if e.errno == errno.EADDRINUSE: self.skipTest("couldn't bind to port %d" % port) raise def test_parse257(self): self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar') self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar') self.assertEqual(ftplib.parse257('257 ""'), '') self.assertEqual(ftplib.parse257('257 "" created'), '') self.assertRaises(ftplib.error_reply, ftplib.parse257, '250 "/foo/bar"') # The 257 response is supposed to include the directory # name and in case it contains embedded double-quotes # they must be doubled (see RFC-959, chapter 7, appendix 2). self.assertEqual(ftplib.parse257('257 "/foo/b""ar"'), '/foo/b"ar') self.assertEqual(ftplib.parse257('257 "/foo/b""ar" created'), '/foo/b"ar') def test_line_too_long(self): self.assertRaises(ftplib.Error, self.client.sendcmd, 'x' * self.client.maxline * 2) def test_retrlines_too_long(self): self.client.sendcmd('SETLONGRETR %d' % (self.client.maxline * 2)) received = [] self.assertRaises(ftplib.Error, self.client.retrlines, 'retr', received.append) def test_storlines_too_long(self): f = io.BytesIO(b'x' * self.client.maxline * 2) self.assertRaises(ftplib.Error, self.client.storlines, 'stor', f) @skipUnless(support.IPV6_ENABLED, "IPv6 not enabled") class TestIPv6Environment(TestCase): def setUp(self): self.server = DummyFTPServer((HOSTv6, 0), af=socket.AF_INET6) self.server.start() self.client = ftplib.FTP(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() # Explicitly clear the attribute to prevent dangling thread self.server = None asyncore.close_all(ignore_all=True) def test_af(self): self.assertEqual(self.client.af, socket.AF_INET6) def test_makeport(self): with self.client.makeport(): self.assertEqual(self.server.handler_instance.last_received_cmd, 'eprt') def test_makepasv(self): host, port = self.client.makepasv() conn = socket.create_connection((host, port), timeout=TIMEOUT) conn.close() self.assertEqual(self.server.handler_instance.last_received_cmd, 'epsv') def test_transfer(self): def retr(): def callback(data): received.append(data.decode('ascii')) received = [] self.client.retrbinary('retr', callback) self.assertEqual(len(''.join(received)), len(RETR_DATA)) self.assertEqual(''.join(received), RETR_DATA) self.client.set_pasv(True) retr() self.client.set_pasv(False) retr() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClassMixin(TestFTPClass): """Repeat TestFTPClass tests starting the TLS layer for both control and data connections first. """ def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) # enable TLS self.client.auth() self.client.prot_p() @skipUnless(ssl, "SSL not available") class TestTLS_FTPClass(TestCase): """Specific TLS_FTP class tests.""" def setUp(self): self.server = DummyTLS_FTPServer((HOST, 0)) self.server.start() self.client = ftplib.FTP_TLS(timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) def tearDown(self): self.client.close() self.server.stop() # Explicitly clear the attribute to prevent dangling thread self.server = None asyncore.close_all(ignore_all=True) def test_control_connection(self): self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIsInstance(self.client.sock, ssl.SSLSocket) def test_data_connection(self): # clear text with self.client.transfercmd('list') as sock: self.assertNotIsInstance(sock, ssl.SSLSocket) self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii')) self.assertEqual(self.client.voidresp(), "226 transfer complete") # secured, after PROT P self.client.prot_p() with self.client.transfercmd('list') as sock: self.assertIsInstance(sock, ssl.SSLSocket) # consume from SSL socket to finalize handshake and avoid # "SSLError [SSL] shutdown while in init" self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii')) self.assertEqual(self.client.voidresp(), "226 transfer complete") # PROT C is issued, the connection must be in cleartext again self.client.prot_c() with self.client.transfercmd('list') as sock: self.assertNotIsInstance(sock, ssl.SSLSocket) self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii')) self.assertEqual(self.client.voidresp(), "226 transfer complete") def test_login(self): # login() is supposed to implicitly secure the control connection self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.login() self.assertIsInstance(self.client.sock, ssl.SSLSocket) # make sure that AUTH TLS doesn't get issued again self.client.login() def test_auth_issued_twice(self): self.client.auth() self.assertRaises(ValueError, self.client.auth) def test_auth_ssl(self): try: self.client.ssl_version = ssl.PROTOCOL_SSLv23 self.client.auth() self.assertRaises(ValueError, self.client.auth) finally: self.client.ssl_version = ssl.PROTOCOL_TLS def test_context(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, keyfile=CERTFILE, context=ctx) self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT) self.client.connect(self.server.host, self.server.port) self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) self.client.auth() self.assertIs(self.client.sock.context, ctx) self.assertIsInstance(self.client.sock, ssl.SSLSocket) self.client.prot_p() with self.client.transfercmd('list') as sock: self.assertIs(sock.context, ctx) self.assertIsInstance(sock, ssl.SSLSocket) def test_ccc(self): self.assertRaises(ValueError, self.client.ccc) self.client.login(secure=True) self.assertIsInstance(self.client.sock, ssl.SSLSocket) self.client.ccc() self.assertRaises(ValueError, self.client.sock.unwrap) def test_check_hostname(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) ctx.verify_mode = ssl.CERT_REQUIRED ctx.check_hostname = True ctx.load_verify_locations(CAFILE) self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT) # 127.0.0.1 doesn't match SAN self.client.connect(self.server.host, self.server.port) with self.assertRaises(ssl.CertificateError): self.client.auth() # exception quits connection self.client.connect(self.server.host, self.server.port) self.client.prot_p() with self.assertRaises(ssl.CertificateError): with self.client.transfercmd("list") as sock: pass self.client.quit() self.client.connect("localhost", self.server.port) self.client.auth() self.client.quit() self.client.connect("localhost", self.server.port) self.client.prot_p() with self.client.transfercmd("list") as sock: pass class TestTimeouts(TestCase): def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(20) self.port = support.bind_port(self.sock) self.server_thread = threading.Thread(target=self.server) self.server_thread.start() # Wait for the server to be ready. self.evt.wait() self.evt.clear() self.old_port = ftplib.FTP.port ftplib.FTP.port = self.port def tearDown(self): ftplib.FTP.port = self.old_port self.server_thread.join() # Explicitly clear the attribute to prevent dangling thread self.server_thread = None def server(self): # This method sets the evt 3 times: # 1) when the connection is ready to be accepted. # 2) when it is safe for the caller to close the connection # 3) when we have closed the socket self.sock.listen() # (1) Signal the caller that we are ready to accept the connection. self.evt.set() try: conn, addr = self.sock.accept() except socket.timeout: pass else: conn.sendall(b"1 Hola mundo\n") conn.shutdown(socket.SHUT_WR) # (2) Signal the caller that it is safe to close the socket. self.evt.set() conn.close() finally: self.sock.close() def testTimeoutDefault(self): # default -- use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST) finally: socket.setdefaulttimeout(None) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutNone(self): # no timeout -- do not use global socket timeout self.assertIsNone(socket.getdefaulttimeout()) socket.setdefaulttimeout(30) try: ftp = ftplib.FTP(HOST, timeout=None) finally: socket.setdefaulttimeout(None) self.assertIsNone(ftp.sock.gettimeout()) self.evt.wait() ftp.close() def testTimeoutValue(self): # a value ftp = ftplib.FTP(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutConnect(self): ftp = ftplib.FTP() ftp.connect(HOST, timeout=30) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDifferentOrder(self): ftp = ftplib.FTP(timeout=30) ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() def testTimeoutDirectAccess(self): ftp = ftplib.FTP() ftp.timeout = 30 ftp.connect(HOST) self.assertEqual(ftp.sock.gettimeout(), 30) self.evt.wait() ftp.close() class MiscTestCase(TestCase): def test__all__(self): blacklist = {'MSG_OOB', 'FTP_PORT', 'MAXLINE', 'CRLF', 'B_CRLF', 'Error', 'parse150', 'parse227', 'parse229', 'parse257', 'print_line', 'ftpcp', 'test'} support.check__all__(self, ftplib, blacklist=blacklist) def test_main(): tests = [TestFTPClass, TestTimeouts, TestIPv6Environment, TestTLS_FTPClassMixin, TestTLS_FTPClass, MiscTestCase] thread_info = support.threading_setup() try: support.run_unittest(*tests) finally: support.threading_cleanup(*thread_info) if __name__ == '__main__': test_main()
40,578
1,122
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_ipaddress.py
# Copyright 2007 Google Inc. # Licensed to PSF under a Contributor Agreement. """Unittest for ipaddress module.""" import unittest import re import contextlib import functools import operator import pickle import ipaddress import weakref class BaseTestCase(unittest.TestCase): # One big change in ipaddress over the original ipaddr module is # error reporting that tries to assume users *don't know the rules* # for what constitutes an RFC compliant IP address # Ensuring these errors are emitted correctly in all relevant cases # meant moving to a more systematic test structure that allows the # test structure to map more directly to the module structure # Note that if the constructors are refactored so that addresses with # multiple problems get classified differently, that's OK - just # move the affected examples to the newly appropriate test case. # There is some duplication between the original relatively ad hoc # test suite and the new systematic tests. While some redundancy in # testing is considered preferable to accidentally deleting a valid # test, the original test suite will likely be reduced over time as # redundant tests are identified. @property def factory(self): raise NotImplementedError @contextlib.contextmanager def assertCleanError(self, exc_type, details, *args): """ Ensure exception does not display a context by default Wraps unittest.TestCase.assertRaisesRegex """ if args: details = details % args cm = self.assertRaisesRegex(exc_type, details) with cm as exc: yield exc # Ensure we produce clean tracebacks on failure if exc.exception.__context__ is not None: self.assertTrue(exc.exception.__suppress_context__) def assertAddressError(self, details, *args): """Ensure a clean AddressValueError""" return self.assertCleanError(ipaddress.AddressValueError, details, *args) def assertNetmaskError(self, details, *args): """Ensure a clean NetmaskValueError""" return self.assertCleanError(ipaddress.NetmaskValueError, details, *args) def assertInstancesEqual(self, lhs, rhs): """Check constructor arguments produce equivalent instances""" self.assertEqual(self.factory(lhs), self.factory(rhs)) class CommonTestMixin: def test_empty_address(self): with self.assertAddressError("Address cannot be empty"): self.factory("") def test_floats_rejected(self): with self.assertAddressError(re.escape(repr("1.0"))): self.factory(1.0) def test_not_an_index_issue15559(self): # Implementing __index__ makes for a very nasty interaction with the # bytes constructor. Thus, we disallow implicit use as an integer self.assertRaises(TypeError, operator.index, self.factory(1)) self.assertRaises(TypeError, hex, self.factory(1)) self.assertRaises(TypeError, bytes, self.factory(1)) def pickle_test(self, addr): for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.subTest(proto=proto): x = self.factory(addr) y = pickle.loads(pickle.dumps(x, proto)) self.assertEqual(y, x) class CommonTestMixin_v4(CommonTestMixin): def test_leading_zeros(self): self.assertInstancesEqual("000.000.000.000", "0.0.0.0") self.assertInstancesEqual("192.168.000.001", "192.168.0.1") def test_int(self): self.assertInstancesEqual(0, "0.0.0.0") self.assertInstancesEqual(3232235521, "192.168.0.1") def test_packed(self): self.assertInstancesEqual(bytes.fromhex("00000000"), "0.0.0.0") self.assertInstancesEqual(bytes.fromhex("c0a80001"), "192.168.0.1") def test_negative_ints_rejected(self): msg = "-1 (< 0) is not permitted as an IPv4 address" with self.assertAddressError(re.escape(msg)): self.factory(-1) def test_large_ints_rejected(self): msg = "%d (>= 2**32) is not permitted as an IPv4 address" with self.assertAddressError(re.escape(msg % 2**32)): self.factory(2**32) def test_bad_packed_length(self): def assertBadLength(length): addr = b'\0' * length msg = "%r (len %d != 4) is not permitted as an IPv4 address" with self.assertAddressError(re.escape(msg % (addr, length))): self.factory(addr) assertBadLength(3) assertBadLength(5) class CommonTestMixin_v6(CommonTestMixin): def test_leading_zeros(self): self.assertInstancesEqual("0000::0000", "::") self.assertInstancesEqual("000::c0a8:0001", "::c0a8:1") def test_int(self): self.assertInstancesEqual(0, "::") self.assertInstancesEqual(3232235521, "::c0a8:1") def test_packed(self): addr = b'\0'*12 + bytes.fromhex("00000000") self.assertInstancesEqual(addr, "::") addr = b'\0'*12 + bytes.fromhex("c0a80001") self.assertInstancesEqual(addr, "::c0a8:1") addr = bytes.fromhex("c0a80001") + b'\0'*12 self.assertInstancesEqual(addr, "c0a8:1::") def test_negative_ints_rejected(self): msg = "-1 (< 0) is not permitted as an IPv6 address" with self.assertAddressError(re.escape(msg)): self.factory(-1) def test_large_ints_rejected(self): msg = "%d (>= 2**128) is not permitted as an IPv6 address" with self.assertAddressError(re.escape(msg % 2**128)): self.factory(2**128) def test_bad_packed_length(self): def assertBadLength(length): addr = b'\0' * length msg = "%r (len %d != 16) is not permitted as an IPv6 address" with self.assertAddressError(re.escape(msg % (addr, length))): self.factory(addr) self.factory(addr) assertBadLength(15) assertBadLength(17) class AddressTestCase_v4(BaseTestCase, CommonTestMixin_v4): factory = ipaddress.IPv4Address def test_network_passed_as_address(self): addr = "127.0.0.1/24" with self.assertAddressError("Unexpected '/' in %r", addr): ipaddress.IPv4Address(addr) def test_bad_address_split(self): def assertBadSplit(addr): with self.assertAddressError("Expected 4 octets in %r", addr): ipaddress.IPv4Address(addr) assertBadSplit("127.0.1") assertBadSplit("42.42.42.42.42") assertBadSplit("42.42.42") assertBadSplit("42.42") assertBadSplit("42") assertBadSplit("42..42.42.42") assertBadSplit("42.42.42.42.") assertBadSplit("42.42.42.42...") assertBadSplit(".42.42.42.42") assertBadSplit("...42.42.42.42") assertBadSplit("016.016.016") assertBadSplit("016.016") assertBadSplit("016") assertBadSplit("000") assertBadSplit("0x0a.0x0a.0x0a") assertBadSplit("0x0a.0x0a") assertBadSplit("0x0a") assertBadSplit(".") assertBadSplit("bogus") assertBadSplit("bogus.com") assertBadSplit("1000") assertBadSplit("1000000000000000") assertBadSplit("192.168.0.1.com") def test_empty_octet(self): def assertBadOctet(addr): with self.assertAddressError("Empty octet not permitted in %r", addr): ipaddress.IPv4Address(addr) assertBadOctet("42..42.42") assertBadOctet("...") def test_invalid_characters(self): def assertBadOctet(addr, octet): msg = "Only decimal digits permitted in %r in %r" % (octet, addr) with self.assertAddressError(re.escape(msg)): ipaddress.IPv4Address(addr) assertBadOctet("0x0a.0x0a.0x0a.0x0a", "0x0a") assertBadOctet("0xa.0x0a.0x0a.0x0a", "0xa") assertBadOctet("42.42.42.-0", "-0") assertBadOctet("42.42.42.+0", "+0") assertBadOctet("42.42.42.-42", "-42") assertBadOctet("+1.+2.+3.4", "+1") assertBadOctet("1.2.3.4e0", "4e0") assertBadOctet("1.2.3.4::", "4::") assertBadOctet("1.a.2.3", "a") def test_octal_decimal_ambiguity(self): def assertBadOctet(addr, octet): msg = "Ambiguous (octal/decimal) value in %r not permitted in %r" with self.assertAddressError(re.escape(msg % (octet, addr))): ipaddress.IPv4Address(addr) assertBadOctet("016.016.016.016", "016") assertBadOctet("001.000.008.016", "008") def test_octet_length(self): def assertBadOctet(addr, octet): msg = "At most 3 characters permitted in %r in %r" with self.assertAddressError(re.escape(msg % (octet, addr))): ipaddress.IPv4Address(addr) assertBadOctet("0000.000.000.000", "0000") assertBadOctet("12345.67899.-54321.-98765", "12345") def test_octet_limit(self): def assertBadOctet(addr, octet): msg = "Octet %d (> 255) not permitted in %r" % (octet, addr) with self.assertAddressError(re.escape(msg)): ipaddress.IPv4Address(addr) assertBadOctet("257.0.0.0", 257) assertBadOctet("192.168.0.999", 999) def test_pickle(self): self.pickle_test('192.0.2.1') def test_weakref(self): weakref.ref(self.factory('192.0.2.1')) class AddressTestCase_v6(BaseTestCase, CommonTestMixin_v6): factory = ipaddress.IPv6Address def test_network_passed_as_address(self): addr = "::1/24" with self.assertAddressError("Unexpected '/' in %r", addr): ipaddress.IPv6Address(addr) def test_bad_address_split_v6_not_enough_parts(self): def assertBadSplit(addr): msg = "At least 3 parts expected in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit(":") assertBadSplit(":1") assertBadSplit("FEDC:9878") def test_bad_address_split_v6_too_many_colons(self): def assertBadSplit(addr): msg = "At most 8 colons permitted in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit("9:8:7:6:5:4:3::2:1") assertBadSplit("10:9:8:7:6:5:4:3:2:1") assertBadSplit("::8:7:6:5:4:3:2:1") assertBadSplit("8:7:6:5:4:3:2:1::") # A trailing IPv4 address is two parts assertBadSplit("10:9:8:7:6:5:4:3:42.42.42.42") def test_bad_address_split_v6_too_many_parts(self): def assertBadSplit(addr): msg = "Exactly 8 parts expected without '::' in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit("3ffe:0:0:0:0:0:0:0:1") assertBadSplit("9:8:7:6:5:4:3:2:1") assertBadSplit("7:6:5:4:3:2:1") # A trailing IPv4 address is two parts assertBadSplit("9:8:7:6:5:4:3:42.42.42.42") assertBadSplit("7:6:5:4:3:42.42.42.42") def test_bad_address_split_v6_too_many_parts_with_double_colon(self): def assertBadSplit(addr): msg = "Expected at most 7 other parts with '::' in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit("1:2:3:4::5:6:7:8") def test_bad_address_split_v6_repeated_double_colon(self): def assertBadSplit(addr): msg = "At most one '::' permitted in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit("3ffe::1::1") assertBadSplit("1::2::3::4:5") assertBadSplit("2001::db:::1") assertBadSplit("3ffe::1::") assertBadSplit("::3ffe::1") assertBadSplit(":3ffe::1::1") assertBadSplit("3ffe::1::1:") assertBadSplit(":3ffe::1::1:") assertBadSplit(":::") assertBadSplit('2001:db8:::1') def test_bad_address_split_v6_leading_colon(self): def assertBadSplit(addr): msg = "Leading ':' only permitted as part of '::' in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit(":2001:db8::1") assertBadSplit(":1:2:3:4:5:6:7") assertBadSplit(":1:2:3:4:5:6:") assertBadSplit(":6:5:4:3:2:1::") def test_bad_address_split_v6_trailing_colon(self): def assertBadSplit(addr): msg = "Trailing ':' only permitted as part of '::' in %r" with self.assertAddressError(msg, addr): ipaddress.IPv6Address(addr) assertBadSplit("2001:db8::1:") assertBadSplit("1:2:3:4:5:6:7:") assertBadSplit("::1.2.3.4:") assertBadSplit("::7:6:5:4:3:2:") def test_bad_v4_part_in(self): def assertBadAddressPart(addr, v4_error): with self.assertAddressError("%s in %r", v4_error, addr): ipaddress.IPv6Address(addr) assertBadAddressPart("3ffe::1.net", "Expected 4 octets in '1.net'") assertBadAddressPart("3ffe::127.0.1", "Expected 4 octets in '127.0.1'") assertBadAddressPart("::1.2.3", "Expected 4 octets in '1.2.3'") assertBadAddressPart("::1.2.3.4.5", "Expected 4 octets in '1.2.3.4.5'") assertBadAddressPart("3ffe::1.1.1.net", "Only decimal digits permitted in 'net' " "in '1.1.1.net'") def test_invalid_characters(self): def assertBadPart(addr, part): msg = "Only hex digits permitted in %r in %r" % (part, addr) with self.assertAddressError(re.escape(msg)): ipaddress.IPv6Address(addr) assertBadPart("3ffe::goog", "goog") assertBadPart("3ffe::-0", "-0") assertBadPart("3ffe::+0", "+0") assertBadPart("3ffe::-1", "-1") assertBadPart("1.2.3.4::", "1.2.3.4") assertBadPart('1234:axy::b', "axy") def test_part_length(self): def assertBadPart(addr, part): msg = "At most 4 characters permitted in %r in %r" with self.assertAddressError(msg, part, addr): ipaddress.IPv6Address(addr) assertBadPart("::00000", "00000") assertBadPart("3ffe::10000", "10000") assertBadPart("02001:db8::", "02001") assertBadPart('2001:888888::1', "888888") def test_pickle(self): self.pickle_test('2001:db8::') def test_weakref(self): weakref.ref(self.factory('2001:db8::')) class NetmaskTestMixin_v4(CommonTestMixin_v4): """Input validation on interfaces and networks is very similar""" def test_no_mask(self): self.assertEqual(str(self.factory('1.2.3.4')), '1.2.3.4/32') def test_split_netmask(self): addr = "1.2.3.4/32/24" with self.assertAddressError("Only one '/' permitted in %r" % addr): self.factory(addr) def test_address_errors(self): def assertBadAddress(addr, details): with self.assertAddressError(details): self.factory(addr) assertBadAddress("/", "Address cannot be empty") assertBadAddress("/8", "Address cannot be empty") assertBadAddress("bogus", "Expected 4 octets") assertBadAddress("google.com", "Expected 4 octets") assertBadAddress("10/8", "Expected 4 octets") assertBadAddress("::1.2.3.4", "Only decimal digits") assertBadAddress("1.2.3.256", re.escape("256 (> 255)")) def test_valid_netmask(self): self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')), '192.0.2.0/24') for i in range(0, 33): # Generate and re-parse the CIDR format (trivial). net_str = '0.0.0.0/%d' % i net = self.factory(net_str) self.assertEqual(str(net), net_str) # Generate and re-parse the expanded netmask. self.assertEqual( str(self.factory('0.0.0.0/%s' % net.netmask)), net_str) # Zero prefix is treated as decimal. self.assertEqual(str(self.factory('0.0.0.0/0%d' % i)), net_str) # Generate and re-parse the expanded hostmask. The ambiguous # cases (/0 and /32) are treated as netmasks. if i in (32, 0): net_str = '0.0.0.0/%d' % (32 - i) self.assertEqual( str(self.factory('0.0.0.0/%s' % net.hostmask)), net_str) def test_netmask_errors(self): def assertBadNetmask(addr, netmask): msg = "%r is not a valid netmask" % netmask with self.assertNetmaskError(re.escape(msg)): self.factory("%s/%s" % (addr, netmask)) assertBadNetmask("1.2.3.4", "") assertBadNetmask("1.2.3.4", "-1") assertBadNetmask("1.2.3.4", "+1") assertBadNetmask("1.2.3.4", " 1 ") assertBadNetmask("1.2.3.4", "0x1") assertBadNetmask("1.2.3.4", "33") assertBadNetmask("1.2.3.4", "254.254.255.256") assertBadNetmask("1.2.3.4", "1.a.2.3") assertBadNetmask("1.1.1.1", "254.xyz.2.3") assertBadNetmask("1.1.1.1", "240.255.0.0") assertBadNetmask("1.1.1.1", "255.254.128.0") assertBadNetmask("1.1.1.1", "0.1.127.255") assertBadNetmask("1.1.1.1", "pudding") assertBadNetmask("1.1.1.1", "::") def test_pickle(self): self.pickle_test('192.0.2.0/27') self.pickle_test('192.0.2.0/31') # IPV4LENGTH - 1 self.pickle_test('192.0.2.0') # IPV4LENGTH class InterfaceTestCase_v4(BaseTestCase, NetmaskTestMixin_v4): factory = ipaddress.IPv4Interface class NetworkTestCase_v4(BaseTestCase, NetmaskTestMixin_v4): factory = ipaddress.IPv4Network class NetmaskTestMixin_v6(CommonTestMixin_v6): """Input validation on interfaces and networks is very similar""" def test_split_netmask(self): addr = "cafe:cafe::/128/190" with self.assertAddressError("Only one '/' permitted in %r" % addr): self.factory(addr) def test_address_errors(self): def assertBadAddress(addr, details): with self.assertAddressError(details): self.factory(addr) assertBadAddress("/", "Address cannot be empty") assertBadAddress("/8", "Address cannot be empty") assertBadAddress("google.com", "At least 3 parts") assertBadAddress("1.2.3.4", "At least 3 parts") assertBadAddress("10/8", "At least 3 parts") assertBadAddress("1234:axy::b", "Only hex digits") def test_valid_netmask(self): # We only support CIDR for IPv6, because expanded netmasks are not # standard notation. self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32') for i in range(0, 129): # Generate and re-parse the CIDR format (trivial). net_str = '::/%d' % i self.assertEqual(str(self.factory(net_str)), net_str) # Zero prefix is treated as decimal. self.assertEqual(str(self.factory('::/0%d' % i)), net_str) def test_netmask_errors(self): def assertBadNetmask(addr, netmask): msg = "%r is not a valid netmask" % netmask with self.assertNetmaskError(re.escape(msg)): self.factory("%s/%s" % (addr, netmask)) assertBadNetmask("::1", "") assertBadNetmask("::1", "::1") assertBadNetmask("::1", "1::") assertBadNetmask("::1", "-1") assertBadNetmask("::1", "+1") assertBadNetmask("::1", " 1 ") assertBadNetmask("::1", "0x1") assertBadNetmask("::1", "129") assertBadNetmask("::1", "1.2.3.4") assertBadNetmask("::1", "pudding") assertBadNetmask("::", "::") def test_pickle(self): self.pickle_test('2001:db8::1000/124') self.pickle_test('2001:db8::1000/127') # IPV6LENGTH - 1 self.pickle_test('2001:db8::1000') # IPV6LENGTH class InterfaceTestCase_v6(BaseTestCase, NetmaskTestMixin_v6): factory = ipaddress.IPv6Interface class NetworkTestCase_v6(BaseTestCase, NetmaskTestMixin_v6): factory = ipaddress.IPv6Network class FactoryFunctionErrors(BaseTestCase): def assertFactoryError(self, factory, kind): """Ensure a clean ValueError with the expected message""" addr = "camelot" msg = '%r does not appear to be an IPv4 or IPv6 %s' with self.assertCleanError(ValueError, msg, addr, kind): factory(addr) def test_ip_address(self): self.assertFactoryError(ipaddress.ip_address, "address") def test_ip_interface(self): self.assertFactoryError(ipaddress.ip_interface, "interface") def test_ip_network(self): self.assertFactoryError(ipaddress.ip_network, "network") @functools.total_ordering class LargestObject: def __eq__(self, other): return isinstance(other, LargestObject) def __lt__(self, other): return False @functools.total_ordering class SmallestObject: def __eq__(self, other): return isinstance(other, SmallestObject) def __gt__(self, other): return False class ComparisonTests(unittest.TestCase): v4addr = ipaddress.IPv4Address(1) v4net = ipaddress.IPv4Network(1) v4intf = ipaddress.IPv4Interface(1) v6addr = ipaddress.IPv6Address(1) v6net = ipaddress.IPv6Network(1) v6intf = ipaddress.IPv6Interface(1) v4_addresses = [v4addr, v4intf] v4_objects = v4_addresses + [v4net] v6_addresses = [v6addr, v6intf] v6_objects = v6_addresses + [v6net] objects = v4_objects + v6_objects v4addr2 = ipaddress.IPv4Address(2) v4net2 = ipaddress.IPv4Network(2) v4intf2 = ipaddress.IPv4Interface(2) v6addr2 = ipaddress.IPv6Address(2) v6net2 = ipaddress.IPv6Network(2) v6intf2 = ipaddress.IPv6Interface(2) def test_foreign_type_equality(self): # __eq__ should never raise TypeError directly other = object() for obj in self.objects: self.assertNotEqual(obj, other) self.assertFalse(obj == other) self.assertEqual(obj.__eq__(other), NotImplemented) self.assertEqual(obj.__ne__(other), NotImplemented) def test_mixed_type_equality(self): # Ensure none of the internal objects accidentally # expose the right set of attributes to become "equal" for lhs in self.objects: for rhs in self.objects: if lhs is rhs: continue self.assertNotEqual(lhs, rhs) def test_same_type_equality(self): for obj in self.objects: self.assertEqual(obj, obj) self.assertLessEqual(obj, obj) self.assertGreaterEqual(obj, obj) def test_same_type_ordering(self): for lhs, rhs in ( (self.v4addr, self.v4addr2), (self.v4net, self.v4net2), (self.v4intf, self.v4intf2), (self.v6addr, self.v6addr2), (self.v6net, self.v6net2), (self.v6intf, self.v6intf2), ): self.assertNotEqual(lhs, rhs) self.assertLess(lhs, rhs) self.assertLessEqual(lhs, rhs) self.assertGreater(rhs, lhs) self.assertGreaterEqual(rhs, lhs) self.assertFalse(lhs > rhs) self.assertFalse(rhs < lhs) self.assertFalse(lhs >= rhs) self.assertFalse(rhs <= lhs) def test_containment(self): for obj in self.v4_addresses: self.assertIn(obj, self.v4net) for obj in self.v6_addresses: self.assertIn(obj, self.v6net) for obj in self.v4_objects + [self.v6net]: self.assertNotIn(obj, self.v6net) for obj in self.v6_objects + [self.v4net]: self.assertNotIn(obj, self.v4net) def test_mixed_type_ordering(self): for lhs in self.objects: for rhs in self.objects: if isinstance(lhs, type(rhs)) or isinstance(rhs, type(lhs)): continue self.assertRaises(TypeError, lambda: lhs < rhs) self.assertRaises(TypeError, lambda: lhs > rhs) self.assertRaises(TypeError, lambda: lhs <= rhs) self.assertRaises(TypeError, lambda: lhs >= rhs) def test_foreign_type_ordering(self): other = object() smallest = SmallestObject() largest = LargestObject() for obj in self.objects: with self.assertRaises(TypeError): obj < other with self.assertRaises(TypeError): obj > other with self.assertRaises(TypeError): obj <= other with self.assertRaises(TypeError): obj >= other self.assertTrue(obj < largest) self.assertFalse(obj > largest) self.assertTrue(obj <= largest) self.assertFalse(obj >= largest) self.assertFalse(obj < smallest) self.assertTrue(obj > smallest) self.assertFalse(obj <= smallest) self.assertTrue(obj >= smallest) def test_mixed_type_key(self): # with get_mixed_type_key, you can sort addresses and network. v4_ordered = [self.v4addr, self.v4net, self.v4intf] v6_ordered = [self.v6addr, self.v6net, self.v6intf] self.assertEqual(v4_ordered, sorted(self.v4_objects, key=ipaddress.get_mixed_type_key)) self.assertEqual(v6_ordered, sorted(self.v6_objects, key=ipaddress.get_mixed_type_key)) self.assertEqual(v4_ordered + v6_ordered, sorted(self.objects, key=ipaddress.get_mixed_type_key)) self.assertEqual(NotImplemented, ipaddress.get_mixed_type_key(object)) def test_incompatible_versions(self): # These should always raise TypeError v4addr = ipaddress.ip_address('1.1.1.1') v4net = ipaddress.ip_network('1.1.1.1') v6addr = ipaddress.ip_address('::1') v6net = ipaddress.ip_network('::1') self.assertRaises(TypeError, v4addr.__lt__, v6addr) self.assertRaises(TypeError, v4addr.__gt__, v6addr) self.assertRaises(TypeError, v4net.__lt__, v6net) self.assertRaises(TypeError, v4net.__gt__, v6net) self.assertRaises(TypeError, v6addr.__lt__, v4addr) self.assertRaises(TypeError, v6addr.__gt__, v4addr) self.assertRaises(TypeError, v6net.__lt__, v4net) self.assertRaises(TypeError, v6net.__gt__, v4net) class IpaddrUnitTest(unittest.TestCase): def setUp(self): self.ipv4_address = ipaddress.IPv4Address('1.2.3.4') self.ipv4_interface = ipaddress.IPv4Interface('1.2.3.4/24') self.ipv4_network = ipaddress.IPv4Network('1.2.3.0/24') #self.ipv4_hostmask = ipaddress.IPv4Interface('10.0.0.1/0.255.255.255') self.ipv6_address = ipaddress.IPv6Interface( '2001:658:22a:cafe:200:0:0:1') self.ipv6_interface = ipaddress.IPv6Interface( '2001:658:22a:cafe:200:0:0:1/64') self.ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/64') def testRepr(self): self.assertEqual("IPv4Interface('1.2.3.4/32')", repr(ipaddress.IPv4Interface('1.2.3.4'))) self.assertEqual("IPv6Interface('::1/128')", repr(ipaddress.IPv6Interface('::1'))) # issue #16531: constructing IPv4Network from an (address, mask) tuple def testIPv4Tuple(self): # /32 ip = ipaddress.IPv4Address('192.0.2.1') net = ipaddress.IPv4Network('192.0.2.1/32') self.assertEqual(ipaddress.IPv4Network(('192.0.2.1', 32)), net) self.assertEqual(ipaddress.IPv4Network((ip, 32)), net) self.assertEqual(ipaddress.IPv4Network((3221225985, 32)), net) self.assertEqual(ipaddress.IPv4Network(('192.0.2.1', '255.255.255.255')), net) self.assertEqual(ipaddress.IPv4Network((ip, '255.255.255.255')), net) self.assertEqual(ipaddress.IPv4Network((3221225985, '255.255.255.255')), net) # strict=True and host bits set with self.assertRaises(ValueError): ipaddress.IPv4Network(('192.0.2.1', 24)) with self.assertRaises(ValueError): ipaddress.IPv4Network((ip, 24)) with self.assertRaises(ValueError): ipaddress.IPv4Network((3221225985, 24)) with self.assertRaises(ValueError): ipaddress.IPv4Network(('192.0.2.1', '255.255.255.0')) with self.assertRaises(ValueError): ipaddress.IPv4Network((ip, '255.255.255.0')) with self.assertRaises(ValueError): ipaddress.IPv4Network((3221225985, '255.255.255.0')) # strict=False and host bits set net = ipaddress.IPv4Network('192.0.2.0/24') self.assertEqual(ipaddress.IPv4Network(('192.0.2.1', 24), strict=False), net) self.assertEqual(ipaddress.IPv4Network((ip, 24), strict=False), net) self.assertEqual(ipaddress.IPv4Network((3221225985, 24), strict=False), net) self.assertEqual(ipaddress.IPv4Network(('192.0.2.1', '255.255.255.0'), strict=False), net) self.assertEqual(ipaddress.IPv4Network((ip, '255.255.255.0'), strict=False), net) self.assertEqual(ipaddress.IPv4Network((3221225985, '255.255.255.0'), strict=False), net) # /24 ip = ipaddress.IPv4Address('192.0.2.0') net = ipaddress.IPv4Network('192.0.2.0/24') self.assertEqual(ipaddress.IPv4Network(('192.0.2.0', '255.255.255.0')), net) self.assertEqual(ipaddress.IPv4Network((ip, '255.255.255.0')), net) self.assertEqual(ipaddress.IPv4Network((3221225984, '255.255.255.0')), net) self.assertEqual(ipaddress.IPv4Network(('192.0.2.0', 24)), net) self.assertEqual(ipaddress.IPv4Network((ip, 24)), net) self.assertEqual(ipaddress.IPv4Network((3221225984, 24)), net) self.assertEqual(ipaddress.IPv4Interface(('192.0.2.1', 24)), ipaddress.IPv4Interface('192.0.2.1/24')) self.assertEqual(ipaddress.IPv4Interface((3221225985, 24)), ipaddress.IPv4Interface('192.0.2.1/24')) # issue #16531: constructing IPv6Network from an (address, mask) tuple def testIPv6Tuple(self): # /128 ip = ipaddress.IPv6Address('2001:db8::') net = ipaddress.IPv6Network('2001:db8::/128') self.assertEqual(ipaddress.IPv6Network(('2001:db8::', '128')), net) self.assertEqual(ipaddress.IPv6Network( (42540766411282592856903984951653826560, 128)), net) self.assertEqual(ipaddress.IPv6Network((ip, '128')), net) ip = ipaddress.IPv6Address('2001:db8::') net = ipaddress.IPv6Network('2001:db8::/96') self.assertEqual(ipaddress.IPv6Network(('2001:db8::', '96')), net) self.assertEqual(ipaddress.IPv6Network( (42540766411282592856903984951653826560, 96)), net) self.assertEqual(ipaddress.IPv6Network((ip, '96')), net) # strict=True and host bits set ip = ipaddress.IPv6Address('2001:db8::1') with self.assertRaises(ValueError): ipaddress.IPv6Network(('2001:db8::1', 96)) with self.assertRaises(ValueError): ipaddress.IPv6Network(( 42540766411282592856903984951653826561, 96)) with self.assertRaises(ValueError): ipaddress.IPv6Network((ip, 96)) # strict=False and host bits set net = ipaddress.IPv6Network('2001:db8::/96') self.assertEqual(ipaddress.IPv6Network(('2001:db8::1', 96), strict=False), net) self.assertEqual(ipaddress.IPv6Network( (42540766411282592856903984951653826561, 96), strict=False), net) self.assertEqual(ipaddress.IPv6Network((ip, 96), strict=False), net) # /96 self.assertEqual(ipaddress.IPv6Interface(('2001:db8::1', '96')), ipaddress.IPv6Interface('2001:db8::1/96')) self.assertEqual(ipaddress.IPv6Interface( (42540766411282592856903984951653826561, '96')), ipaddress.IPv6Interface('2001:db8::1/96')) # issue57 def testAddressIntMath(self): self.assertEqual(ipaddress.IPv4Address('1.1.1.1') + 255, ipaddress.IPv4Address('1.1.2.0')) self.assertEqual(ipaddress.IPv4Address('1.1.1.1') - 256, ipaddress.IPv4Address('1.1.0.1')) self.assertEqual(ipaddress.IPv6Address('::1') + (2**16 - 2), ipaddress.IPv6Address('::ffff')) self.assertEqual(ipaddress.IPv6Address('::ffff') - (2**16 - 2), ipaddress.IPv6Address('::1')) def testInvalidIntToBytes(self): self.assertRaises(ValueError, ipaddress.v4_int_to_packed, -1) self.assertRaises(ValueError, ipaddress.v4_int_to_packed, 2 ** ipaddress.IPV4LENGTH) self.assertRaises(ValueError, ipaddress.v6_int_to_packed, -1) self.assertRaises(ValueError, ipaddress.v6_int_to_packed, 2 ** ipaddress.IPV6LENGTH) def testInternals(self): ip1 = ipaddress.IPv4Address('10.10.10.10') ip2 = ipaddress.IPv4Address('10.10.10.11') ip3 = ipaddress.IPv4Address('10.10.10.12') self.assertEqual(list(ipaddress._find_address_range([ip1])), [(ip1, ip1)]) self.assertEqual(list(ipaddress._find_address_range([ip1, ip3])), [(ip1, ip1), (ip3, ip3)]) self.assertEqual(list(ipaddress._find_address_range([ip1, ip2, ip3])), [(ip1, ip3)]) self.assertEqual(128, ipaddress._count_righthand_zero_bits(0, 128)) self.assertEqual("IPv4Network('1.2.3.0/24')", repr(self.ipv4_network)) def testMissingNetworkVersion(self): class Broken(ipaddress._BaseNetwork): pass broken = Broken('127.0.0.1') with self.assertRaisesRegex(NotImplementedError, "Broken.*version"): broken.version def testMissingAddressClass(self): class Broken(ipaddress._BaseNetwork): pass broken = Broken('127.0.0.1') with self.assertRaisesRegex(NotImplementedError, "Broken.*address"): broken._address_class def testGetNetwork(self): self.assertEqual(int(self.ipv4_network.network_address), 16909056) self.assertEqual(str(self.ipv4_network.network_address), '1.2.3.0') self.assertEqual(int(self.ipv6_network.network_address), 42540616829182469433403647294022090752) self.assertEqual(str(self.ipv6_network.network_address), '2001:658:22a:cafe::') self.assertEqual(str(self.ipv6_network.hostmask), '::ffff:ffff:ffff:ffff') def testIpFromInt(self): self.assertEqual(self.ipv4_interface._ip, ipaddress.IPv4Interface(16909060)._ip) ipv4 = ipaddress.ip_network('1.2.3.4') ipv6 = ipaddress.ip_network('2001:658:22a:cafe:200:0:0:1') self.assertEqual(ipv4, ipaddress.ip_network(int(ipv4.network_address))) self.assertEqual(ipv6, ipaddress.ip_network(int(ipv6.network_address))) v6_int = 42540616829182469433547762482097946625 self.assertEqual(self.ipv6_interface._ip, ipaddress.IPv6Interface(v6_int)._ip) self.assertEqual(ipaddress.ip_network(self.ipv4_address._ip).version, 4) self.assertEqual(ipaddress.ip_network(self.ipv6_address._ip).version, 6) def testIpFromPacked(self): address = ipaddress.ip_address self.assertEqual(self.ipv4_interface._ip, ipaddress.ip_interface(b'\x01\x02\x03\x04')._ip) self.assertEqual(address('255.254.253.252'), address(b'\xff\xfe\xfd\xfc')) self.assertEqual(self.ipv6_interface.ip, ipaddress.ip_interface( b'\x20\x01\x06\x58\x02\x2a\xca\xfe' b'\x02\x00\x00\x00\x00\x00\x00\x01').ip) self.assertEqual(address('ffff:2:3:4:ffff::'), address(b'\xff\xff\x00\x02\x00\x03\x00\x04' + b'\xff\xff' + b'\x00' * 6)) self.assertEqual(address('::'), address(b'\x00' * 16)) def testGetIp(self): self.assertEqual(int(self.ipv4_interface.ip), 16909060) self.assertEqual(str(self.ipv4_interface.ip), '1.2.3.4') self.assertEqual(int(self.ipv6_interface.ip), 42540616829182469433547762482097946625) self.assertEqual(str(self.ipv6_interface.ip), '2001:658:22a:cafe:200::1') def testGetNetmask(self): self.assertEqual(int(self.ipv4_network.netmask), 4294967040) self.assertEqual(str(self.ipv4_network.netmask), '255.255.255.0') self.assertEqual(int(self.ipv6_network.netmask), 340282366920938463444927863358058659840) self.assertEqual(self.ipv6_network.prefixlen, 64) def testZeroNetmask(self): ipv4_zero_netmask = ipaddress.IPv4Interface('1.2.3.4/0') self.assertEqual(int(ipv4_zero_netmask.network.netmask), 0) self.assertEqual(ipv4_zero_netmask._prefix_from_prefix_string('0'), 0) self.assertTrue(ipv4_zero_netmask._is_valid_netmask('0')) self.assertTrue(ipv4_zero_netmask._is_valid_netmask('0.0.0.0')) self.assertFalse(ipv4_zero_netmask._is_valid_netmask('invalid')) ipv6_zero_netmask = ipaddress.IPv6Interface('::1/0') self.assertEqual(int(ipv6_zero_netmask.network.netmask), 0) self.assertEqual(ipv6_zero_netmask._prefix_from_prefix_string('0'), 0) def testIPv4NetAndHostmasks(self): net = self.ipv4_network self.assertFalse(net._is_valid_netmask('invalid')) self.assertTrue(net._is_valid_netmask('128.128.128.128')) self.assertFalse(net._is_valid_netmask('128.128.128.127')) self.assertFalse(net._is_valid_netmask('128.128.128.255')) self.assertTrue(net._is_valid_netmask('255.128.128.128')) self.assertFalse(net._is_hostmask('invalid')) self.assertTrue(net._is_hostmask('128.255.255.255')) self.assertFalse(net._is_hostmask('255.255.255.255')) self.assertFalse(net._is_hostmask('1.2.3.4')) net = ipaddress.IPv4Network('127.0.0.0/0.0.0.255') self.assertEqual(net.prefixlen, 24) def testGetBroadcast(self): self.assertEqual(int(self.ipv4_network.broadcast_address), 16909311) self.assertEqual(str(self.ipv4_network.broadcast_address), '1.2.3.255') self.assertEqual(int(self.ipv6_network.broadcast_address), 42540616829182469451850391367731642367) self.assertEqual(str(self.ipv6_network.broadcast_address), '2001:658:22a:cafe:ffff:ffff:ffff:ffff') def testGetPrefixlen(self): self.assertEqual(self.ipv4_interface.network.prefixlen, 24) self.assertEqual(self.ipv6_interface.network.prefixlen, 64) def testGetSupernet(self): self.assertEqual(self.ipv4_network.supernet().prefixlen, 23) self.assertEqual(str(self.ipv4_network.supernet().network_address), '1.2.2.0') self.assertEqual( ipaddress.IPv4Interface('0.0.0.0/0').network.supernet(), ipaddress.IPv4Network('0.0.0.0/0')) self.assertEqual(self.ipv6_network.supernet().prefixlen, 63) self.assertEqual(str(self.ipv6_network.supernet().network_address), '2001:658:22a:cafe::') self.assertEqual(ipaddress.IPv6Interface('::0/0').network.supernet(), ipaddress.IPv6Network('::0/0')) def testGetSupernet3(self): self.assertEqual(self.ipv4_network.supernet(3).prefixlen, 21) self.assertEqual(str(self.ipv4_network.supernet(3).network_address), '1.2.0.0') self.assertEqual(self.ipv6_network.supernet(3).prefixlen, 61) self.assertEqual(str(self.ipv6_network.supernet(3).network_address), '2001:658:22a:caf8::') def testGetSupernet4(self): self.assertRaises(ValueError, self.ipv4_network.supernet, prefixlen_diff=2, new_prefix=1) self.assertRaises(ValueError, self.ipv4_network.supernet, new_prefix=25) self.assertEqual(self.ipv4_network.supernet(prefixlen_diff=2), self.ipv4_network.supernet(new_prefix=22)) self.assertRaises(ValueError, self.ipv6_network.supernet, prefixlen_diff=2, new_prefix=1) self.assertRaises(ValueError, self.ipv6_network.supernet, new_prefix=65) self.assertEqual(self.ipv6_network.supernet(prefixlen_diff=2), self.ipv6_network.supernet(new_prefix=62)) def testHosts(self): hosts = list(self.ipv4_network.hosts()) self.assertEqual(254, len(hosts)) self.assertEqual(ipaddress.IPv4Address('1.2.3.1'), hosts[0]) self.assertEqual(ipaddress.IPv4Address('1.2.3.254'), hosts[-1]) ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/120') hosts = list(ipv6_network.hosts()) self.assertEqual(255, len(hosts)) self.assertEqual(ipaddress.IPv6Address('2001:658:22a:cafe::1'), hosts[0]) self.assertEqual(ipaddress.IPv6Address('2001:658:22a:cafe::ff'), hosts[-1]) # special case where only 1 bit is left for address addrs = [ipaddress.IPv4Address('2.0.0.0'), ipaddress.IPv4Address('2.0.0.1')] str_args = '2.0.0.0/31' tpl_args = ('2.0.0.0', 31) self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts())) self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts())) self.assertEqual(list(ipaddress.ip_network(str_args).hosts()), list(ipaddress.ip_network(tpl_args).hosts())) addrs = [ipaddress.IPv6Address('2001:658:22a:cafe::'), ipaddress.IPv6Address('2001:658:22a:cafe::1')] str_args = '2001:658:22a:cafe::/127' tpl_args = ('2001:658:22a:cafe::', 127) self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts())) self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts())) self.assertEqual(list(ipaddress.ip_network(str_args).hosts()), list(ipaddress.ip_network(tpl_args).hosts())) def testFancySubnetting(self): self.assertEqual(sorted(self.ipv4_network.subnets(prefixlen_diff=3)), sorted(self.ipv4_network.subnets(new_prefix=27))) self.assertRaises(ValueError, list, self.ipv4_network.subnets(new_prefix=23)) self.assertRaises(ValueError, list, self.ipv4_network.subnets(prefixlen_diff=3, new_prefix=27)) self.assertEqual(sorted(self.ipv6_network.subnets(prefixlen_diff=4)), sorted(self.ipv6_network.subnets(new_prefix=68))) self.assertRaises(ValueError, list, self.ipv6_network.subnets(new_prefix=63)) self.assertRaises(ValueError, list, self.ipv6_network.subnets(prefixlen_diff=4, new_prefix=68)) def testGetSubnets(self): self.assertEqual(list(self.ipv4_network.subnets())[0].prefixlen, 25) self.assertEqual(str(list( self.ipv4_network.subnets())[0].network_address), '1.2.3.0') self.assertEqual(str(list( self.ipv4_network.subnets())[1].network_address), '1.2.3.128') self.assertEqual(list(self.ipv6_network.subnets())[0].prefixlen, 65) def testGetSubnetForSingle32(self): ip = ipaddress.IPv4Network('1.2.3.4/32') subnets1 = [str(x) for x in ip.subnets()] subnets2 = [str(x) for x in ip.subnets(2)] self.assertEqual(subnets1, ['1.2.3.4/32']) self.assertEqual(subnets1, subnets2) def testGetSubnetForSingle128(self): ip = ipaddress.IPv6Network('::1/128') subnets1 = [str(x) for x in ip.subnets()] subnets2 = [str(x) for x in ip.subnets(2)] self.assertEqual(subnets1, ['::1/128']) self.assertEqual(subnets1, subnets2) def testSubnet2(self): ips = [str(x) for x in self.ipv4_network.subnets(2)] self.assertEqual( ips, ['1.2.3.0/26', '1.2.3.64/26', '1.2.3.128/26', '1.2.3.192/26']) ipsv6 = [str(x) for x in self.ipv6_network.subnets(2)] self.assertEqual( ipsv6, ['2001:658:22a:cafe::/66', '2001:658:22a:cafe:4000::/66', '2001:658:22a:cafe:8000::/66', '2001:658:22a:cafe:c000::/66']) def testGetSubnets3(self): subnets = [str(x) for x in self.ipv4_network.subnets(8)] self.assertEqual(subnets[:3], ['1.2.3.0/32', '1.2.3.1/32', '1.2.3.2/32']) self.assertEqual(subnets[-3:], ['1.2.3.253/32', '1.2.3.254/32', '1.2.3.255/32']) self.assertEqual(len(subnets), 256) ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/120') subnets = [str(x) for x in ipv6_network.subnets(8)] self.assertEqual(subnets[:3], ['2001:658:22a:cafe::/128', '2001:658:22a:cafe::1/128', '2001:658:22a:cafe::2/128']) self.assertEqual(subnets[-3:], ['2001:658:22a:cafe::fd/128', '2001:658:22a:cafe::fe/128', '2001:658:22a:cafe::ff/128']) self.assertEqual(len(subnets), 256) def testSubnetFailsForLargeCidrDiff(self): self.assertRaises(ValueError, list, self.ipv4_interface.network.subnets(9)) self.assertRaises(ValueError, list, self.ipv4_network.subnets(9)) self.assertRaises(ValueError, list, self.ipv6_interface.network.subnets(65)) self.assertRaises(ValueError, list, self.ipv6_network.subnets(65)) def testSupernetFailsForLargeCidrDiff(self): self.assertRaises(ValueError, self.ipv4_interface.network.supernet, 25) self.assertRaises(ValueError, self.ipv6_interface.network.supernet, 65) def testSubnetFailsForNegativeCidrDiff(self): self.assertRaises(ValueError, list, self.ipv4_interface.network.subnets(-1)) self.assertRaises(ValueError, list, self.ipv4_network.subnets(-1)) self.assertRaises(ValueError, list, self.ipv6_interface.network.subnets(-1)) self.assertRaises(ValueError, list, self.ipv6_network.subnets(-1)) def testGetNum_Addresses(self): self.assertEqual(self.ipv4_network.num_addresses, 256) self.assertEqual(list(self.ipv4_network.subnets())[0].num_addresses, 128) self.assertEqual(self.ipv4_network.supernet().num_addresses, 512) self.assertEqual(self.ipv6_network.num_addresses, 18446744073709551616) self.assertEqual(list(self.ipv6_network.subnets())[0].num_addresses, 9223372036854775808) self.assertEqual(self.ipv6_network.supernet().num_addresses, 36893488147419103232) def testContains(self): self.assertIn(ipaddress.IPv4Interface('1.2.3.128/25'), self.ipv4_network) self.assertNotIn(ipaddress.IPv4Interface('1.2.4.1/24'), self.ipv4_network) # We can test addresses and string as well. addr1 = ipaddress.IPv4Address('1.2.3.37') self.assertIn(addr1, self.ipv4_network) # issue 61, bad network comparison on like-ip'd network objects # with identical broadcast addresses. self.assertFalse(ipaddress.IPv4Network('1.1.0.0/16').__contains__( ipaddress.IPv4Network('1.0.0.0/15'))) def testNth(self): self.assertEqual(str(self.ipv4_network[5]), '1.2.3.5') self.assertRaises(IndexError, self.ipv4_network.__getitem__, 256) self.assertEqual(str(self.ipv6_network[5]), '2001:658:22a:cafe::5') self.assertRaises(IndexError, self.ipv6_network.__getitem__, 1 << 64) def testGetitem(self): # http://code.google.com/p/ipaddr-py/issues/detail?id=15 addr = ipaddress.IPv4Network('172.31.255.128/255.255.255.240') self.assertEqual(28, addr.prefixlen) addr_list = list(addr) self.assertEqual('172.31.255.128', str(addr_list[0])) self.assertEqual('172.31.255.128', str(addr[0])) self.assertEqual('172.31.255.143', str(addr_list[-1])) self.assertEqual('172.31.255.143', str(addr[-1])) self.assertEqual(addr_list[-1], addr[-1]) def testEqual(self): self.assertTrue(self.ipv4_interface == ipaddress.IPv4Interface('1.2.3.4/24')) self.assertFalse(self.ipv4_interface == ipaddress.IPv4Interface('1.2.3.4/23')) self.assertFalse(self.ipv4_interface == ipaddress.IPv6Interface('::1.2.3.4/24')) self.assertFalse(self.ipv4_interface == '') self.assertFalse(self.ipv4_interface == []) self.assertFalse(self.ipv4_interface == 2) self.assertTrue(self.ipv6_interface == ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/64')) self.assertFalse(self.ipv6_interface == ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/63')) self.assertFalse(self.ipv6_interface == ipaddress.IPv4Interface('1.2.3.4/23')) self.assertFalse(self.ipv6_interface == '') self.assertFalse(self.ipv6_interface == []) self.assertFalse(self.ipv6_interface == 2) def testNotEqual(self): self.assertFalse(self.ipv4_interface != ipaddress.IPv4Interface('1.2.3.4/24')) self.assertTrue(self.ipv4_interface != ipaddress.IPv4Interface('1.2.3.4/23')) self.assertTrue(self.ipv4_interface != ipaddress.IPv6Interface('::1.2.3.4/24')) self.assertTrue(self.ipv4_interface != '') self.assertTrue(self.ipv4_interface != []) self.assertTrue(self.ipv4_interface != 2) self.assertTrue(self.ipv4_address != ipaddress.IPv4Address('1.2.3.5')) self.assertTrue(self.ipv4_address != '') self.assertTrue(self.ipv4_address != []) self.assertTrue(self.ipv4_address != 2) self.assertFalse(self.ipv6_interface != ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/64')) self.assertTrue(self.ipv6_interface != ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/63')) self.assertTrue(self.ipv6_interface != ipaddress.IPv4Interface('1.2.3.4/23')) self.assertTrue(self.ipv6_interface != '') self.assertTrue(self.ipv6_interface != []) self.assertTrue(self.ipv6_interface != 2) self.assertTrue(self.ipv6_address != ipaddress.IPv4Address('1.2.3.4')) self.assertTrue(self.ipv6_address != '') self.assertTrue(self.ipv6_address != []) self.assertTrue(self.ipv6_address != 2) def testSlash32Constructor(self): self.assertEqual(str(ipaddress.IPv4Interface( '1.2.3.4/255.255.255.255')), '1.2.3.4/32') def testSlash128Constructor(self): self.assertEqual(str(ipaddress.IPv6Interface('::1/128')), '::1/128') def testSlash0Constructor(self): self.assertEqual(str(ipaddress.IPv4Interface('1.2.3.4/0.0.0.0')), '1.2.3.4/0') def testCollapsing(self): # test only IP addresses including some duplicates ip1 = ipaddress.IPv4Address('1.1.1.0') ip2 = ipaddress.IPv4Address('1.1.1.1') ip3 = ipaddress.IPv4Address('1.1.1.2') ip4 = ipaddress.IPv4Address('1.1.1.3') ip5 = ipaddress.IPv4Address('1.1.1.4') ip6 = ipaddress.IPv4Address('1.1.1.0') # check that addresses are subsumed properly. collapsed = ipaddress.collapse_addresses( [ip1, ip2, ip3, ip4, ip5, ip6]) self.assertEqual(list(collapsed), [ipaddress.IPv4Network('1.1.1.0/30'), ipaddress.IPv4Network('1.1.1.4/32')]) # test a mix of IP addresses and networks including some duplicates ip1 = ipaddress.IPv4Address('1.1.1.0') ip2 = ipaddress.IPv4Address('1.1.1.1') ip3 = ipaddress.IPv4Address('1.1.1.2') ip4 = ipaddress.IPv4Address('1.1.1.3') #ip5 = ipaddress.IPv4Interface('1.1.1.4/30') #ip6 = ipaddress.IPv4Interface('1.1.1.4/30') # check that addresses are subsumed properly. collapsed = ipaddress.collapse_addresses([ip1, ip2, ip3, ip4]) self.assertEqual(list(collapsed), [ipaddress.IPv4Network('1.1.1.0/30')]) # test only IP networks ip1 = ipaddress.IPv4Network('1.1.0.0/24') ip2 = ipaddress.IPv4Network('1.1.1.0/24') ip3 = ipaddress.IPv4Network('1.1.2.0/24') ip4 = ipaddress.IPv4Network('1.1.3.0/24') ip5 = ipaddress.IPv4Network('1.1.4.0/24') # stored in no particular order b/c we want CollapseAddr to call # [].sort ip6 = ipaddress.IPv4Network('1.1.0.0/22') # check that addresses are subsumed properly. collapsed = ipaddress.collapse_addresses([ip1, ip2, ip3, ip4, ip5, ip6]) self.assertEqual(list(collapsed), [ipaddress.IPv4Network('1.1.0.0/22'), ipaddress.IPv4Network('1.1.4.0/24')]) # test that two addresses are supernet'ed properly collapsed = ipaddress.collapse_addresses([ip1, ip2]) self.assertEqual(list(collapsed), [ipaddress.IPv4Network('1.1.0.0/23')]) # test same IP networks ip_same1 = ip_same2 = ipaddress.IPv4Network('1.1.1.1/32') self.assertEqual(list(ipaddress.collapse_addresses( [ip_same1, ip_same2])), [ip_same1]) # test same IP addresses ip_same1 = ip_same2 = ipaddress.IPv4Address('1.1.1.1') self.assertEqual(list(ipaddress.collapse_addresses( [ip_same1, ip_same2])), [ipaddress.ip_network('1.1.1.1/32')]) ip1 = ipaddress.IPv6Network('2001::/100') ip2 = ipaddress.IPv6Network('2001::/120') ip3 = ipaddress.IPv6Network('2001::/96') # test that ipv6 addresses are subsumed properly. collapsed = ipaddress.collapse_addresses([ip1, ip2, ip3]) self.assertEqual(list(collapsed), [ip3]) # the toejam test addr_tuples = [ (ipaddress.ip_address('1.1.1.1'), ipaddress.ip_address('::1')), (ipaddress.IPv4Network('1.1.0.0/24'), ipaddress.IPv6Network('2001::/120')), (ipaddress.IPv4Network('1.1.0.0/32'), ipaddress.IPv6Network('2001::/128')), ] for ip1, ip2 in addr_tuples: self.assertRaises(TypeError, ipaddress.collapse_addresses, [ip1, ip2]) def testSummarizing(self): #ip = ipaddress.ip_address #ipnet = ipaddress.ip_network summarize = ipaddress.summarize_address_range ip1 = ipaddress.ip_address('1.1.1.0') ip2 = ipaddress.ip_address('1.1.1.255') # summarize works only for IPv4 & IPv6 class IPv7Address(ipaddress.IPv6Address): @property def version(self): return 7 ip_invalid1 = IPv7Address('::1') ip_invalid2 = IPv7Address('::1') self.assertRaises(ValueError, list, summarize(ip_invalid1, ip_invalid2)) # test that a summary over ip4 & ip6 fails self.assertRaises(TypeError, list, summarize(ip1, ipaddress.IPv6Address('::1'))) # test a /24 is summarized properly self.assertEqual(list(summarize(ip1, ip2))[0], ipaddress.ip_network('1.1.1.0/24')) # test an IPv4 range that isn't on a network byte boundary ip2 = ipaddress.ip_address('1.1.1.8') self.assertEqual(list(summarize(ip1, ip2)), [ipaddress.ip_network('1.1.1.0/29'), ipaddress.ip_network('1.1.1.8')]) # all! ip1 = ipaddress.IPv4Address(0) ip2 = ipaddress.IPv4Address(ipaddress.IPv4Address._ALL_ONES) self.assertEqual([ipaddress.IPv4Network('0.0.0.0/0')], list(summarize(ip1, ip2))) ip1 = ipaddress.ip_address('1::') ip2 = ipaddress.ip_address('1:ffff:ffff:ffff:ffff:ffff:ffff:ffff') # test an IPv6 is summarized properly self.assertEqual(list(summarize(ip1, ip2))[0], ipaddress.ip_network('1::/16')) # test an IPv6 range that isn't on a network byte boundary ip2 = ipaddress.ip_address('2::') self.assertEqual(list(summarize(ip1, ip2)), [ipaddress.ip_network('1::/16'), ipaddress.ip_network('2::/128')]) # test exception raised when first is greater than last self.assertRaises(ValueError, list, summarize(ipaddress.ip_address('1.1.1.0'), ipaddress.ip_address('1.1.0.0'))) # test exception raised when first and last aren't IP addresses self.assertRaises(TypeError, list, summarize(ipaddress.ip_network('1.1.1.0'), ipaddress.ip_network('1.1.0.0'))) self.assertRaises(TypeError, list, summarize(ipaddress.ip_network('1.1.1.0'), ipaddress.ip_network('1.1.0.0'))) # test exception raised when first and last are not same version self.assertRaises(TypeError, list, summarize(ipaddress.ip_address('::'), ipaddress.ip_network('1.1.0.0'))) def testAddressComparison(self): self.assertTrue(ipaddress.ip_address('1.1.1.1') <= ipaddress.ip_address('1.1.1.1')) self.assertTrue(ipaddress.ip_address('1.1.1.1') <= ipaddress.ip_address('1.1.1.2')) self.assertTrue(ipaddress.ip_address('::1') <= ipaddress.ip_address('::1')) self.assertTrue(ipaddress.ip_address('::1') <= ipaddress.ip_address('::2')) def testInterfaceComparison(self): self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') == ipaddress.ip_interface('1.1.1.1/24')) self.assertTrue(ipaddress.ip_interface('1.1.1.1/16') < ipaddress.ip_interface('1.1.1.1/24')) self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') < ipaddress.ip_interface('1.1.1.2/24')) self.assertTrue(ipaddress.ip_interface('1.1.1.2/16') < ipaddress.ip_interface('1.1.1.1/24')) self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') > ipaddress.ip_interface('1.1.1.1/16')) self.assertTrue(ipaddress.ip_interface('1.1.1.2/24') > ipaddress.ip_interface('1.1.1.1/24')) self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') > ipaddress.ip_interface('1.1.1.2/16')) self.assertTrue(ipaddress.ip_interface('::1/64') == ipaddress.ip_interface('::1/64')) self.assertTrue(ipaddress.ip_interface('::1/64') < ipaddress.ip_interface('::1/80')) self.assertTrue(ipaddress.ip_interface('::1/64') < ipaddress.ip_interface('::2/64')) self.assertTrue(ipaddress.ip_interface('::2/48') < ipaddress.ip_interface('::1/64')) self.assertTrue(ipaddress.ip_interface('::1/80') > ipaddress.ip_interface('::1/64')) self.assertTrue(ipaddress.ip_interface('::2/64') > ipaddress.ip_interface('::1/64')) self.assertTrue(ipaddress.ip_interface('::1/64') > ipaddress.ip_interface('::2/48')) def testNetworkComparison(self): # ip1 and ip2 have the same network address ip1 = ipaddress.IPv4Network('1.1.1.0/24') ip2 = ipaddress.IPv4Network('1.1.1.0/32') ip3 = ipaddress.IPv4Network('1.1.2.0/24') self.assertTrue(ip1 < ip3) self.assertTrue(ip3 > ip2) self.assertEqual(ip1.compare_networks(ip1), 0) # if addresses are the same, sort by netmask self.assertEqual(ip1.compare_networks(ip2), -1) self.assertEqual(ip2.compare_networks(ip1), 1) self.assertEqual(ip1.compare_networks(ip3), -1) self.assertEqual(ip3.compare_networks(ip1), 1) self.assertTrue(ip1._get_networks_key() < ip3._get_networks_key()) ip1 = ipaddress.IPv6Network('2001:2000::/96') ip2 = ipaddress.IPv6Network('2001:2001::/96') ip3 = ipaddress.IPv6Network('2001:ffff:2000::/96') self.assertTrue(ip1 < ip3) self.assertTrue(ip3 > ip2) self.assertEqual(ip1.compare_networks(ip3), -1) self.assertTrue(ip1._get_networks_key() < ip3._get_networks_key()) # Test comparing different protocols. # Should always raise a TypeError. self.assertRaises(TypeError, self.ipv4_network.compare_networks, self.ipv6_network) ipv6 = ipaddress.IPv6Interface('::/0') ipv4 = ipaddress.IPv4Interface('0.0.0.0/0') self.assertRaises(TypeError, ipv4.__lt__, ipv6) self.assertRaises(TypeError, ipv4.__gt__, ipv6) self.assertRaises(TypeError, ipv6.__lt__, ipv4) self.assertRaises(TypeError, ipv6.__gt__, ipv4) # Regression test for issue 19. ip1 = ipaddress.ip_network('10.1.2.128/25') self.assertFalse(ip1 < ip1) self.assertFalse(ip1 > ip1) ip2 = ipaddress.ip_network('10.1.3.0/24') self.assertTrue(ip1 < ip2) self.assertFalse(ip2 < ip1) self.assertFalse(ip1 > ip2) self.assertTrue(ip2 > ip1) ip3 = ipaddress.ip_network('10.1.3.0/25') self.assertTrue(ip2 < ip3) self.assertFalse(ip3 < ip2) self.assertFalse(ip2 > ip3) self.assertTrue(ip3 > ip2) # Regression test for issue 28. ip1 = ipaddress.ip_network('10.10.10.0/31') ip2 = ipaddress.ip_network('10.10.10.0') ip3 = ipaddress.ip_network('10.10.10.2/31') ip4 = ipaddress.ip_network('10.10.10.2') sorted = [ip1, ip2, ip3, ip4] unsorted = [ip2, ip4, ip1, ip3] unsorted.sort() self.assertEqual(sorted, unsorted) unsorted = [ip4, ip1, ip3, ip2] unsorted.sort() self.assertEqual(sorted, unsorted) self.assertIs(ip1.__lt__(ipaddress.ip_address('10.10.10.0')), NotImplemented) self.assertIs(ip2.__lt__(ipaddress.ip_address('10.10.10.0')), NotImplemented) # <=, >= self.assertTrue(ipaddress.ip_network('1.1.1.1') <= ipaddress.ip_network('1.1.1.1')) self.assertTrue(ipaddress.ip_network('1.1.1.1') <= ipaddress.ip_network('1.1.1.2')) self.assertFalse(ipaddress.ip_network('1.1.1.2') <= ipaddress.ip_network('1.1.1.1')) self.assertTrue(ipaddress.ip_network('::1') <= ipaddress.ip_network('::1')) self.assertTrue(ipaddress.ip_network('::1') <= ipaddress.ip_network('::2')) self.assertFalse(ipaddress.ip_network('::2') <= ipaddress.ip_network('::1')) def testStrictNetworks(self): self.assertRaises(ValueError, ipaddress.ip_network, '192.168.1.1/24') self.assertRaises(ValueError, ipaddress.ip_network, '::1/120') def testOverlaps(self): other = ipaddress.IPv4Network('1.2.3.0/30') other2 = ipaddress.IPv4Network('1.2.2.0/24') other3 = ipaddress.IPv4Network('1.2.2.64/26') self.assertTrue(self.ipv4_network.overlaps(other)) self.assertFalse(self.ipv4_network.overlaps(other2)) self.assertTrue(other2.overlaps(other3)) def testEmbeddedIpv4(self): ipv4_string = '192.168.0.1' ipv4 = ipaddress.IPv4Interface(ipv4_string) v4compat_ipv6 = ipaddress.IPv6Interface('::%s' % ipv4_string) self.assertEqual(int(v4compat_ipv6.ip), int(ipv4.ip)) v4mapped_ipv6 = ipaddress.IPv6Interface('::ffff:%s' % ipv4_string) self.assertNotEqual(v4mapped_ipv6.ip, ipv4.ip) self.assertRaises(ipaddress.AddressValueError, ipaddress.IPv6Interface, '2001:1.1.1.1:1.1.1.1') # Issue 67: IPv6 with embedded IPv4 address not recognized. def testIPv6AddressTooLarge(self): # RFC4291 2.5.5.2 self.assertEqual(ipaddress.ip_address('::FFFF:192.0.2.1'), ipaddress.ip_address('::FFFF:c000:201')) # RFC4291 2.2 (part 3) x::d.d.d.d self.assertEqual(ipaddress.ip_address('FFFF::192.0.2.1'), ipaddress.ip_address('FFFF::c000:201')) def testIPVersion(self): self.assertEqual(self.ipv4_address.version, 4) self.assertEqual(self.ipv6_address.version, 6) def testMaxPrefixLength(self): self.assertEqual(self.ipv4_interface.max_prefixlen, 32) self.assertEqual(self.ipv6_interface.max_prefixlen, 128) def testPacked(self): self.assertEqual(self.ipv4_address.packed, b'\x01\x02\x03\x04') self.assertEqual(ipaddress.IPv4Interface('255.254.253.252').packed, b'\xff\xfe\xfd\xfc') self.assertEqual(self.ipv6_address.packed, b'\x20\x01\x06\x58\x02\x2a\xca\xfe' b'\x02\x00\x00\x00\x00\x00\x00\x01') self.assertEqual(ipaddress.IPv6Interface('ffff:2:3:4:ffff::').packed, b'\xff\xff\x00\x02\x00\x03\x00\x04\xff\xff' + b'\x00' * 6) self.assertEqual(ipaddress.IPv6Interface('::1:0:0:0:0').packed, b'\x00' * 6 + b'\x00\x01' + b'\x00' * 8) def testIpType(self): ipv4net = ipaddress.ip_network('1.2.3.4') ipv4addr = ipaddress.ip_address('1.2.3.4') ipv6net = ipaddress.ip_network('::1.2.3.4') ipv6addr = ipaddress.ip_address('::1.2.3.4') self.assertEqual(ipaddress.IPv4Network, type(ipv4net)) self.assertEqual(ipaddress.IPv4Address, type(ipv4addr)) self.assertEqual(ipaddress.IPv6Network, type(ipv6net)) self.assertEqual(ipaddress.IPv6Address, type(ipv6addr)) def testReservedIpv4(self): # test networks self.assertEqual(True, ipaddress.ip_interface( '224.1.1.1/31').is_multicast) self.assertEqual(False, ipaddress.ip_network('240.0.0.0').is_multicast) self.assertEqual(True, ipaddress.ip_network('240.0.0.0').is_reserved) self.assertEqual(True, ipaddress.ip_interface( '192.168.1.1/17').is_private) self.assertEqual(False, ipaddress.ip_network('192.169.0.0').is_private) self.assertEqual(True, ipaddress.ip_network( '10.255.255.255').is_private) self.assertEqual(False, ipaddress.ip_network('11.0.0.0').is_private) self.assertEqual(False, ipaddress.ip_network('11.0.0.0').is_reserved) self.assertEqual(True, ipaddress.ip_network( '172.31.255.255').is_private) self.assertEqual(False, ipaddress.ip_network('172.32.0.0').is_private) self.assertEqual(True, ipaddress.ip_network('169.254.1.0/24').is_link_local) self.assertEqual(True, ipaddress.ip_interface( '169.254.100.200/24').is_link_local) self.assertEqual(False, ipaddress.ip_interface( '169.255.100.200/24').is_link_local) self.assertEqual(True, ipaddress.ip_network( '127.100.200.254/32').is_loopback) self.assertEqual(True, ipaddress.ip_network( '127.42.0.0/16').is_loopback) self.assertEqual(False, ipaddress.ip_network('128.0.0.0').is_loopback) self.assertEqual(False, ipaddress.ip_network('100.64.0.0/10').is_private) self.assertEqual(False, ipaddress.ip_network('100.64.0.0/10').is_global) self.assertEqual(True, ipaddress.ip_network('192.0.2.128/25').is_private) self.assertEqual(True, ipaddress.ip_network('192.0.3.0/24').is_global) # test addresses self.assertEqual(True, ipaddress.ip_address('0.0.0.0').is_unspecified) self.assertEqual(True, ipaddress.ip_address('224.1.1.1').is_multicast) self.assertEqual(False, ipaddress.ip_address('240.0.0.0').is_multicast) self.assertEqual(True, ipaddress.ip_address('240.0.0.1').is_reserved) self.assertEqual(False, ipaddress.ip_address('239.255.255.255').is_reserved) self.assertEqual(True, ipaddress.ip_address('192.168.1.1').is_private) self.assertEqual(False, ipaddress.ip_address('192.169.0.0').is_private) self.assertEqual(True, ipaddress.ip_address( '10.255.255.255').is_private) self.assertEqual(False, ipaddress.ip_address('11.0.0.0').is_private) self.assertEqual(True, ipaddress.ip_address( '172.31.255.255').is_private) self.assertEqual(False, ipaddress.ip_address('172.32.0.0').is_private) self.assertEqual(True, ipaddress.ip_address('169.254.100.200').is_link_local) self.assertEqual(False, ipaddress.ip_address('169.255.100.200').is_link_local) self.assertTrue(ipaddress.ip_address('192.0.7.1').is_global) self.assertFalse(ipaddress.ip_address('203.0.113.1').is_global) self.assertEqual(True, ipaddress.ip_address('127.100.200.254').is_loopback) self.assertEqual(True, ipaddress.ip_address('127.42.0.0').is_loopback) self.assertEqual(False, ipaddress.ip_address('128.0.0.0').is_loopback) self.assertEqual(True, ipaddress.ip_network('0.0.0.0').is_unspecified) def testReservedIpv6(self): self.assertEqual(True, ipaddress.ip_network('ffff::').is_multicast) self.assertEqual(True, ipaddress.ip_network(2**128 - 1).is_multicast) self.assertEqual(True, ipaddress.ip_network('ff00::').is_multicast) self.assertEqual(False, ipaddress.ip_network('fdff::').is_multicast) self.assertEqual(True, ipaddress.ip_network('fecf::').is_site_local) self.assertEqual(True, ipaddress.ip_network( 'feff:ffff:ffff:ffff::').is_site_local) self.assertEqual(False, ipaddress.ip_network( 'fbf:ffff::').is_site_local) self.assertEqual(False, ipaddress.ip_network('ff00::').is_site_local) self.assertEqual(True, ipaddress.ip_network('fc00::').is_private) self.assertEqual(True, ipaddress.ip_network( 'fc00:ffff:ffff:ffff::').is_private) self.assertEqual(False, ipaddress.ip_network('fbff:ffff::').is_private) self.assertEqual(False, ipaddress.ip_network('fe00::').is_private) self.assertEqual(True, ipaddress.ip_network('fea0::').is_link_local) self.assertEqual(True, ipaddress.ip_network( 'febf:ffff::').is_link_local) self.assertEqual(False, ipaddress.ip_network( 'fe7f:ffff::').is_link_local) self.assertEqual(False, ipaddress.ip_network('fec0::').is_link_local) self.assertEqual(True, ipaddress.ip_interface('0:0::0:01').is_loopback) self.assertEqual(False, ipaddress.ip_interface('::1/127').is_loopback) self.assertEqual(False, ipaddress.ip_network('::').is_loopback) self.assertEqual(False, ipaddress.ip_network('::2').is_loopback) self.assertEqual(True, ipaddress.ip_network('0::0').is_unspecified) self.assertEqual(False, ipaddress.ip_network('::1').is_unspecified) self.assertEqual(False, ipaddress.ip_network('::/127').is_unspecified) self.assertEqual(True, ipaddress.ip_network('2001::1/128').is_private) self.assertEqual(True, ipaddress.ip_network('200::1/128').is_global) # test addresses self.assertEqual(True, ipaddress.ip_address('ffff::').is_multicast) self.assertEqual(True, ipaddress.ip_address(2**128 - 1).is_multicast) self.assertEqual(True, ipaddress.ip_address('ff00::').is_multicast) self.assertEqual(False, ipaddress.ip_address('fdff::').is_multicast) self.assertEqual(True, ipaddress.ip_address('fecf::').is_site_local) self.assertEqual(True, ipaddress.ip_address( 'feff:ffff:ffff:ffff::').is_site_local) self.assertEqual(False, ipaddress.ip_address( 'fbf:ffff::').is_site_local) self.assertEqual(False, ipaddress.ip_address('ff00::').is_site_local) self.assertEqual(True, ipaddress.ip_address('fc00::').is_private) self.assertEqual(True, ipaddress.ip_address( 'fc00:ffff:ffff:ffff::').is_private) self.assertEqual(False, ipaddress.ip_address('fbff:ffff::').is_private) self.assertEqual(False, ipaddress.ip_address('fe00::').is_private) self.assertEqual(True, ipaddress.ip_address('fea0::').is_link_local) self.assertEqual(True, ipaddress.ip_address( 'febf:ffff::').is_link_local) self.assertEqual(False, ipaddress.ip_address( 'fe7f:ffff::').is_link_local) self.assertEqual(False, ipaddress.ip_address('fec0::').is_link_local) self.assertEqual(True, ipaddress.ip_address('0:0::0:01').is_loopback) self.assertEqual(True, ipaddress.ip_address('::1').is_loopback) self.assertEqual(False, ipaddress.ip_address('::2').is_loopback) self.assertEqual(True, ipaddress.ip_address('0::0').is_unspecified) self.assertEqual(False, ipaddress.ip_address('::1').is_unspecified) # some generic IETF reserved addresses self.assertEqual(True, ipaddress.ip_address('100::').is_reserved) self.assertEqual(True, ipaddress.ip_network('4000::1/128').is_reserved) def testIpv4Mapped(self): self.assertEqual( ipaddress.ip_address('::ffff:192.168.1.1').ipv4_mapped, ipaddress.ip_address('192.168.1.1')) self.assertEqual(ipaddress.ip_address('::c0a8:101').ipv4_mapped, None) self.assertEqual(ipaddress.ip_address('::ffff:c0a8:101').ipv4_mapped, ipaddress.ip_address('192.168.1.1')) def testAddrExclude(self): addr1 = ipaddress.ip_network('10.1.1.0/24') addr2 = ipaddress.ip_network('10.1.1.0/26') addr3 = ipaddress.ip_network('10.2.1.0/24') addr4 = ipaddress.ip_address('10.1.1.0') addr5 = ipaddress.ip_network('2001:db8::0/32') addr6 = ipaddress.ip_network('10.1.1.5/32') self.assertEqual(sorted(list(addr1.address_exclude(addr2))), [ipaddress.ip_network('10.1.1.64/26'), ipaddress.ip_network('10.1.1.128/25')]) self.assertRaises(ValueError, list, addr1.address_exclude(addr3)) self.assertRaises(TypeError, list, addr1.address_exclude(addr4)) self.assertRaises(TypeError, list, addr1.address_exclude(addr5)) self.assertEqual(list(addr1.address_exclude(addr1)), []) self.assertEqual(sorted(list(addr1.address_exclude(addr6))), [ipaddress.ip_network('10.1.1.0/30'), ipaddress.ip_network('10.1.1.4/32'), ipaddress.ip_network('10.1.1.6/31'), ipaddress.ip_network('10.1.1.8/29'), ipaddress.ip_network('10.1.1.16/28'), ipaddress.ip_network('10.1.1.32/27'), ipaddress.ip_network('10.1.1.64/26'), ipaddress.ip_network('10.1.1.128/25')]) def testHash(self): self.assertEqual(hash(ipaddress.ip_interface('10.1.1.0/24')), hash(ipaddress.ip_interface('10.1.1.0/24'))) self.assertEqual(hash(ipaddress.ip_network('10.1.1.0/24')), hash(ipaddress.ip_network('10.1.1.0/24'))) self.assertEqual(hash(ipaddress.ip_address('10.1.1.0')), hash(ipaddress.ip_address('10.1.1.0'))) # i70 self.assertEqual(hash(ipaddress.ip_address('1.2.3.4')), hash(ipaddress.ip_address( int(ipaddress.ip_address('1.2.3.4')._ip)))) ip1 = ipaddress.ip_address('10.1.1.0') ip2 = ipaddress.ip_address('1::') dummy = {} dummy[self.ipv4_address] = None dummy[self.ipv6_address] = None dummy[ip1] = None dummy[ip2] = None self.assertIn(self.ipv4_address, dummy) self.assertIn(ip2, dummy) def testIPBases(self): net = self.ipv4_network self.assertEqual('1.2.3.0/24', net.compressed) net = self.ipv6_network self.assertRaises(ValueError, net._string_from_ip_int, 2**128 + 1) def testIPv6NetworkHelpers(self): net = self.ipv6_network self.assertEqual('2001:658:22a:cafe::/64', net.with_prefixlen) self.assertEqual('2001:658:22a:cafe::/ffff:ffff:ffff:ffff::', net.with_netmask) self.assertEqual('2001:658:22a:cafe::/::ffff:ffff:ffff:ffff', net.with_hostmask) self.assertEqual('2001:658:22a:cafe::/64', str(net)) def testIPv4NetworkHelpers(self): net = self.ipv4_network self.assertEqual('1.2.3.0/24', net.with_prefixlen) self.assertEqual('1.2.3.0/255.255.255.0', net.with_netmask) self.assertEqual('1.2.3.0/0.0.0.255', net.with_hostmask) self.assertEqual('1.2.3.0/24', str(net)) def testCopyConstructor(self): addr1 = ipaddress.ip_network('10.1.1.0/24') addr2 = ipaddress.ip_network(addr1) addr3 = ipaddress.ip_interface('2001:658:22a:cafe:200::1/64') addr4 = ipaddress.ip_interface(addr3) addr5 = ipaddress.IPv4Address('1.1.1.1') addr6 = ipaddress.IPv6Address('2001:658:22a:cafe:200::1') self.assertEqual(addr1, addr2) self.assertEqual(addr3, addr4) self.assertEqual(addr5, ipaddress.IPv4Address(addr5)) self.assertEqual(addr6, ipaddress.IPv6Address(addr6)) def testCompressIPv6Address(self): test_addresses = { '1:2:3:4:5:6:7:8': '1:2:3:4:5:6:7:8/128', '2001:0:0:4:0:0:0:8': '2001:0:0:4::8/128', '2001:0:0:4:5:6:7:8': '2001::4:5:6:7:8/128', '2001:0:3:4:5:6:7:8': '2001:0:3:4:5:6:7:8/128', '0:0:3:0:0:0:0:ffff': '0:0:3::ffff/128', '0:0:0:4:0:0:0:ffff': '::4:0:0:0:ffff/128', '0:0:0:0:5:0:0:ffff': '::5:0:0:ffff/128', '1:0:0:4:0:0:7:8': '1::4:0:0:7:8/128', '0:0:0:0:0:0:0:0': '::/128', '0:0:0:0:0:0:0:0/0': '::/0', '0:0:0:0:0:0:0:1': '::1/128', '2001:0658:022a:cafe:0000:0000:0000:0000/66': '2001:658:22a:cafe::/66', '::1.2.3.4': '::102:304/128', '1:2:3:4:5:ffff:1.2.3.4': '1:2:3:4:5:ffff:102:304/128', '::7:6:5:4:3:2:1': '0:7:6:5:4:3:2:1/128', '::7:6:5:4:3:2:0': '0:7:6:5:4:3:2:0/128', '7:6:5:4:3:2:1::': '7:6:5:4:3:2:1:0/128', '0:6:5:4:3:2:1::': '0:6:5:4:3:2:1:0/128', } for uncompressed, compressed in list(test_addresses.items()): self.assertEqual(compressed, str(ipaddress.IPv6Interface( uncompressed))) def testExplodeShortHandIpStr(self): addr1 = ipaddress.IPv6Interface('2001::1') addr2 = ipaddress.IPv6Address('2001:0:5ef5:79fd:0:59d:a0e5:ba1') addr3 = ipaddress.IPv6Network('2001::/96') addr4 = ipaddress.IPv4Address('192.168.178.1') self.assertEqual('2001:0000:0000:0000:0000:0000:0000:0001/128', addr1.exploded) self.assertEqual('0000:0000:0000:0000:0000:0000:0000:0001/128', ipaddress.IPv6Interface('::1/128').exploded) # issue 77 self.assertEqual('2001:0000:5ef5:79fd:0000:059d:a0e5:0ba1', addr2.exploded) self.assertEqual('2001:0000:0000:0000:0000:0000:0000:0000/96', addr3.exploded) self.assertEqual('192.168.178.1', addr4.exploded) def testReversePointer(self): addr1 = ipaddress.IPv4Address('127.0.0.1') addr2 = ipaddress.IPv6Address('2001:db8::1') self.assertEqual('1.0.0.127.in-addr.arpa', addr1.reverse_pointer) self.assertEqual('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.' + 'b.d.0.1.0.0.2.ip6.arpa', addr2.reverse_pointer) def testIntRepresentation(self): self.assertEqual(16909060, int(self.ipv4_address)) self.assertEqual(42540616829182469433547762482097946625, int(self.ipv6_address)) def testForceVersion(self): self.assertEqual(ipaddress.ip_network(1).version, 4) self.assertEqual(ipaddress.IPv6Network(1).version, 6) def testWithStar(self): self.assertEqual(self.ipv4_interface.with_prefixlen, "1.2.3.4/24") self.assertEqual(self.ipv4_interface.with_netmask, "1.2.3.4/255.255.255.0") self.assertEqual(self.ipv4_interface.with_hostmask, "1.2.3.4/0.0.0.255") self.assertEqual(self.ipv6_interface.with_prefixlen, '2001:658:22a:cafe:200::1/64') self.assertEqual(self.ipv6_interface.with_netmask, '2001:658:22a:cafe:200::1/ffff:ffff:ffff:ffff::') # this probably don't make much sense, but it's included for # compatibility with ipv4 self.assertEqual(self.ipv6_interface.with_hostmask, '2001:658:22a:cafe:200::1/::ffff:ffff:ffff:ffff') def testNetworkElementCaching(self): # V4 - make sure we're empty self.assertNotIn('network_address', self.ipv4_network._cache) self.assertNotIn('broadcast_address', self.ipv4_network._cache) self.assertNotIn('hostmask', self.ipv4_network._cache) # V4 - populate and test self.assertEqual(self.ipv4_network.network_address, ipaddress.IPv4Address('1.2.3.0')) self.assertEqual(self.ipv4_network.broadcast_address, ipaddress.IPv4Address('1.2.3.255')) self.assertEqual(self.ipv4_network.hostmask, ipaddress.IPv4Address('0.0.0.255')) # V4 - check we're cached self.assertIn('broadcast_address', self.ipv4_network._cache) self.assertIn('hostmask', self.ipv4_network._cache) # V6 - make sure we're empty self.assertNotIn('broadcast_address', self.ipv6_network._cache) self.assertNotIn('hostmask', self.ipv6_network._cache) # V6 - populate and test self.assertEqual(self.ipv6_network.network_address, ipaddress.IPv6Address('2001:658:22a:cafe::')) self.assertEqual(self.ipv6_interface.network.network_address, ipaddress.IPv6Address('2001:658:22a:cafe::')) self.assertEqual( self.ipv6_network.broadcast_address, ipaddress.IPv6Address('2001:658:22a:cafe:ffff:ffff:ffff:ffff')) self.assertEqual(self.ipv6_network.hostmask, ipaddress.IPv6Address('::ffff:ffff:ffff:ffff')) self.assertEqual( self.ipv6_interface.network.broadcast_address, ipaddress.IPv6Address('2001:658:22a:cafe:ffff:ffff:ffff:ffff')) self.assertEqual(self.ipv6_interface.network.hostmask, ipaddress.IPv6Address('::ffff:ffff:ffff:ffff')) # V6 - check we're cached self.assertIn('broadcast_address', self.ipv6_network._cache) self.assertIn('hostmask', self.ipv6_network._cache) self.assertIn('broadcast_address', self.ipv6_interface.network._cache) self.assertIn('hostmask', self.ipv6_interface.network._cache) def testTeredo(self): # stolen from wikipedia server = ipaddress.IPv4Address('65.54.227.120') client = ipaddress.IPv4Address('192.0.2.45') teredo_addr = '2001:0000:4136:e378:8000:63bf:3fff:fdd2' self.assertEqual((server, client), ipaddress.ip_address(teredo_addr).teredo) bad_addr = '2000::4136:e378:8000:63bf:3fff:fdd2' self.assertFalse(ipaddress.ip_address(bad_addr).teredo) bad_addr = '2001:0001:4136:e378:8000:63bf:3fff:fdd2' self.assertFalse(ipaddress.ip_address(bad_addr).teredo) # i77 teredo_addr = ipaddress.IPv6Address('2001:0:5ef5:79fd:0:59d:a0e5:ba1') self.assertEqual((ipaddress.IPv4Address('94.245.121.253'), ipaddress.IPv4Address('95.26.244.94')), teredo_addr.teredo) def testsixtofour(self): sixtofouraddr = ipaddress.ip_address('2002:ac1d:2d64::1') bad_addr = ipaddress.ip_address('2000:ac1d:2d64::1') self.assertEqual(ipaddress.IPv4Address('172.29.45.100'), sixtofouraddr.sixtofour) self.assertFalse(bad_addr.sixtofour) # issue41004 Hash collisions in IPv4Interface and IPv6Interface def testV4HashIsNotConstant(self): ipv4_address1 = ipaddress.IPv4Interface("1.2.3.4") ipv4_address2 = ipaddress.IPv4Interface("2.3.4.5") self.assertNotEqual(ipv4_address1.__hash__(), ipv4_address2.__hash__()) # issue41004 Hash collisions in IPv4Interface and IPv6Interface def testV6HashIsNotConstant(self): ipv6_address1 = ipaddress.IPv6Interface("2001:658:22a:cafe:200:0:0:1") ipv6_address2 = ipaddress.IPv6Interface("2001:658:22a:cafe:200:0:0:2") self.assertNotEqual(ipv6_address1.__hash__(), ipv6_address2.__hash__()) if __name__ == '__main__': unittest.main()
89,128
2,007
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_code_module.py
"Test InteractiveConsole and InteractiveInterpreter from code module" import sys import unittest from textwrap import dedent from contextlib import ExitStack from unittest import mock from test import support code = support.import_module('code') class TestInteractiveConsole(unittest.TestCase): def setUp(self): self.console = code.InteractiveConsole() self.mock_sys() def mock_sys(self): "Mock system environment for InteractiveConsole" # use exit stack to match patch context managers to addCleanup stack = ExitStack() self.addCleanup(stack.close) self.infunc = stack.enter_context(mock.patch('code.input', create=True)) self.stdout = stack.enter_context(mock.patch('code.sys.stdout')) self.stderr = stack.enter_context(mock.patch('code.sys.stderr')) prepatch = mock.patch('code.sys', wraps=code.sys, spec=code.sys) self.sysmod = stack.enter_context(prepatch) if sys.excepthook is sys.__excepthook__: self.sysmod.excepthook = self.sysmod.__excepthook__ del self.sysmod.ps1 del self.sysmod.ps2 def test_ps1(self): self.infunc.side_effect = EOFError('Finished') self.console.interact() self.assertEqual(self.sysmod.ps1, '>>> ') self.sysmod.ps1 = 'custom1> ' self.console.interact() self.assertEqual(self.sysmod.ps1, 'custom1> ') def test_ps2(self): self.infunc.side_effect = EOFError('Finished') self.console.interact() self.assertEqual(self.sysmod.ps2, '... ') self.sysmod.ps1 = 'custom2> ' self.console.interact() self.assertEqual(self.sysmod.ps1, 'custom2> ') def test_console_stderr(self): self.infunc.side_effect = ["'antioch'", "", EOFError('Finished')] self.console.interact() for call in list(self.stdout.method_calls): if 'antioch' in ''.join(call[1]): break else: raise AssertionError("no console stdout") def test_syntax_error(self): self.infunc.side_effect = ["undefined", EOFError('Finished')] self.console.interact() for call in self.stderr.method_calls: if 'NameError' in ''.join(call[1]): break else: raise AssertionError("No syntax error from console") def test_sysexcepthook(self): self.infunc.side_effect = ["raise ValueError('')", EOFError('Finished')] hook = mock.Mock() self.sysmod.excepthook = hook self.console.interact() self.assertTrue(hook.called) def test_banner(self): # with banner self.infunc.side_effect = EOFError('Finished') self.console.interact(banner='Foo') self.assertEqual(len(self.stderr.method_calls), 3) banner_call = self.stderr.method_calls[0] self.assertEqual(banner_call, ['write', ('Foo\n',), {}]) # no banner self.stderr.reset_mock() self.infunc.side_effect = EOFError('Finished') self.console.interact(banner='') self.assertEqual(len(self.stderr.method_calls), 2) def test_exit_msg(self): # default exit message self.infunc.side_effect = EOFError('Finished') self.console.interact(banner='') self.assertEqual(len(self.stderr.method_calls), 2) err_msg = self.stderr.method_calls[1] expected = 'now exiting InteractiveConsole...\n' self.assertEqual(err_msg, ['write', (expected,), {}]) # no exit message self.stderr.reset_mock() self.infunc.side_effect = EOFError('Finished') self.console.interact(banner='', exitmsg='') self.assertEqual(len(self.stderr.method_calls), 1) # custom exit message self.stderr.reset_mock() message = ( 'bye! \N{GREEK SMALL LETTER ZETA}\N{CYRILLIC SMALL LETTER ZHE}' ) self.infunc.side_effect = EOFError('Finished') self.console.interact(banner='', exitmsg=message) self.assertEqual(len(self.stderr.method_calls), 2) err_msg = self.stderr.method_calls[1] expected = message + '\n' self.assertEqual(err_msg, ['write', (expected,), {}]) def test_cause_tb(self): self.infunc.side_effect = ["raise ValueError('') from AttributeError", EOFError('Finished')] self.console.interact() output = ''.join(''.join(call[1]) for call in self.stderr.method_calls) expected = dedent(""" AttributeError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<console>", line 1, in <module> ValueError """) self.assertIn(expected, output) def test_context_tb(self): self.infunc.side_effect = ["try: ham\nexcept: eggs\n", EOFError('Finished')] self.console.interact() output = ''.join(''.join(call[1]) for call in self.stderr.method_calls) expected = dedent(""" Traceback (most recent call last): File "<console>", line 1, in <module> NameError: name 'ham' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<console>", line 2, in <module> NameError: name 'eggs' is not defined """) self.assertIn(expected, output) if __name__ == "__main__": unittest.main()
5,646
155
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_argparse.py
# Author: Steven J. Bethard <[email protected]>. import codecs import inspect import os import shutil import stat import sys import textwrap import tempfile import unittest import argparse from io import StringIO from test import support from unittest import mock class StdIOBuffer(StringIO): pass class TestCase(unittest.TestCase): def setUp(self): # The tests assume that line wrapping occurs at 80 columns, but this # behaviour can be overridden by setting the COLUMNS environment # variable. To ensure that this assumption is true, unset COLUMNS. env = support.EnvironmentVarGuard() env.unset("COLUMNS") self.addCleanup(env.__exit__) class TempDirMixin(object): def setUp(self): self.temp_dir = tempfile.mkdtemp() self.old_dir = os.getcwd() os.chdir(self.temp_dir) def tearDown(self): os.chdir(self.old_dir) for root, dirs, files in os.walk(self.temp_dir, topdown=False): for name in files: os.chmod(os.path.join(self.temp_dir, name), stat.S_IWRITE) shutil.rmtree(self.temp_dir, True) def create_readonly_file(self, filename): file_path = os.path.join(self.temp_dir, filename) with open(file_path, 'w') as file: file.write(filename) os.chmod(file_path, stat.S_IREAD) class Sig(object): def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs class NS(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __repr__(self): sorted_items = sorted(self.__dict__.items()) kwarg_str = ', '.join(['%s=%r' % tup for tup in sorted_items]) return '%s(%s)' % (type(self).__name__, kwarg_str) def __eq__(self, other): return vars(self) == vars(other) class ArgumentParserError(Exception): def __init__(self, message, stdout=None, stderr=None, error_code=None): Exception.__init__(self, message, stdout, stderr) self.message = message self.stdout = stdout self.stderr = stderr self.error_code = error_code def stderr_to_parser_error(parse_args, *args, **kwargs): # if this is being called recursively and stderr or stdout is already being # redirected, simply call the function and let the enclosing function # catch the exception if isinstance(sys.stderr, StdIOBuffer) or isinstance(sys.stdout, StdIOBuffer): return parse_args(*args, **kwargs) # if this is not being called recursively, redirect stderr and # use it as the ArgumentParserError message old_stdout = sys.stdout old_stderr = sys.stderr sys.stdout = StdIOBuffer() sys.stderr = StdIOBuffer() try: try: result = parse_args(*args, **kwargs) for key in list(vars(result)): if getattr(result, key) is sys.stdout: setattr(result, key, old_stdout) if getattr(result, key) is sys.stderr: setattr(result, key, old_stderr) return result except SystemExit: code = sys.exc_info()[1].code stdout = sys.stdout.getvalue() stderr = sys.stderr.getvalue() raise ArgumentParserError("SystemExit", stdout, stderr, code) finally: sys.stdout = old_stdout sys.stderr = old_stderr class ErrorRaisingArgumentParser(argparse.ArgumentParser): def parse_args(self, *args, **kwargs): parse_args = super(ErrorRaisingArgumentParser, self).parse_args return stderr_to_parser_error(parse_args, *args, **kwargs) def exit(self, *args, **kwargs): exit = super(ErrorRaisingArgumentParser, self).exit return stderr_to_parser_error(exit, *args, **kwargs) def error(self, *args, **kwargs): error = super(ErrorRaisingArgumentParser, self).error return stderr_to_parser_error(error, *args, **kwargs) class ParserTesterMetaclass(type): """Adds parser tests using the class attributes. Classes of this type should specify the following attributes: argument_signatures -- a list of Sig objects which specify the signatures of Argument objects to be created failures -- a list of args lists that should cause the parser to fail successes -- a list of (initial_args, options, remaining_args) tuples where initial_args specifies the string args to be parsed, options is a dict that should match the vars() of the options parsed out of initial_args, and remaining_args should be any remaining unparsed arguments """ def __init__(cls, name, bases, bodydict): if name == 'ParserTestCase': return # default parser signature is empty if not hasattr(cls, 'parser_signature'): cls.parser_signature = Sig() if not hasattr(cls, 'parser_class'): cls.parser_class = ErrorRaisingArgumentParser # --------------------------------------- # functions for adding optional arguments # --------------------------------------- def no_groups(parser, argument_signatures): """Add all arguments directly to the parser""" for sig in argument_signatures: parser.add_argument(*sig.args, **sig.kwargs) def one_group(parser, argument_signatures): """Add all arguments under a single group in the parser""" group = parser.add_argument_group('foo') for sig in argument_signatures: group.add_argument(*sig.args, **sig.kwargs) def many_groups(parser, argument_signatures): """Add each argument in its own group to the parser""" for i, sig in enumerate(argument_signatures): group = parser.add_argument_group('foo:%i' % i) group.add_argument(*sig.args, **sig.kwargs) # -------------------------- # functions for parsing args # -------------------------- def listargs(parser, args): """Parse the args by passing in a list""" return parser.parse_args(args) def sysargs(parser, args): """Parse the args by defaulting to sys.argv""" old_sys_argv = sys.argv sys.argv = [old_sys_argv[0]] + args try: return parser.parse_args() finally: sys.argv = old_sys_argv # class that holds the combination of one optional argument # addition method and one arg parsing method class AddTests(object): def __init__(self, tester_cls, add_arguments, parse_args): self._add_arguments = add_arguments self._parse_args = parse_args add_arguments_name = self._add_arguments.__name__ parse_args_name = self._parse_args.__name__ for test_func in [self.test_failures, self.test_successes]: func_name = test_func.__name__ names = func_name, add_arguments_name, parse_args_name test_name = '_'.join(names) def wrapper(self, test_func=test_func): test_func(self) try: wrapper.__name__ = test_name except TypeError: pass setattr(tester_cls, test_name, wrapper) def _get_parser(self, tester): args = tester.parser_signature.args kwargs = tester.parser_signature.kwargs parser = tester.parser_class(*args, **kwargs) self._add_arguments(parser, tester.argument_signatures) return parser def test_failures(self, tester): parser = self._get_parser(tester) for args_str in tester.failures: args = args_str.split() with tester.assertRaises(ArgumentParserError, msg=args): parser.parse_args(args) def test_successes(self, tester): parser = self._get_parser(tester) for args, expected_ns in tester.successes: if isinstance(args, str): args = args.split() result_ns = self._parse_args(parser, args) tester.assertEqual(expected_ns, result_ns) # add tests for each combination of an optionals adding method # and an arg parsing method for add_arguments in [no_groups, one_group, many_groups]: for parse_args in [listargs, sysargs]: AddTests(cls, add_arguments, parse_args) bases = TestCase, ParserTestCase = ParserTesterMetaclass('ParserTestCase', bases, {}) # =============== # Optionals tests # =============== class TestOptionalsSingleDash(ParserTestCase): """Test an Optional with a single-dash option string""" argument_signatures = [Sig('-x')] failures = ['-x', 'a', '--foo', '-x --foo', '-x -y'] successes = [ ('', NS(x=None)), ('-x a', NS(x='a')), ('-xa', NS(x='a')), ('-x -1', NS(x='-1')), ('-x-1', NS(x='-1')), ] class TestOptionalsSingleDashCombined(ParserTestCase): """Test an Optional with a single-dash option string""" argument_signatures = [ Sig('-x', action='store_true'), Sig('-yyy', action='store_const', const=42), Sig('-z'), ] failures = ['a', '--foo', '-xa', '-x --foo', '-x -z', '-z -x', '-yx', '-yz a', '-yyyx', '-yyyza', '-xyza'] successes = [ ('', NS(x=False, yyy=None, z=None)), ('-x', NS(x=True, yyy=None, z=None)), ('-za', NS(x=False, yyy=None, z='a')), ('-z a', NS(x=False, yyy=None, z='a')), ('-xza', NS(x=True, yyy=None, z='a')), ('-xz a', NS(x=True, yyy=None, z='a')), ('-x -za', NS(x=True, yyy=None, z='a')), ('-x -z a', NS(x=True, yyy=None, z='a')), ('-y', NS(x=False, yyy=42, z=None)), ('-yyy', NS(x=False, yyy=42, z=None)), ('-x -yyy -za', NS(x=True, yyy=42, z='a')), ('-x -yyy -z a', NS(x=True, yyy=42, z='a')), ] class TestOptionalsSingleDashLong(ParserTestCase): """Test an Optional with a multi-character single-dash option string""" argument_signatures = [Sig('-foo')] failures = ['-foo', 'a', '--foo', '-foo --foo', '-foo -y', '-fooa'] successes = [ ('', NS(foo=None)), ('-foo a', NS(foo='a')), ('-foo -1', NS(foo='-1')), ('-fo a', NS(foo='a')), ('-f a', NS(foo='a')), ] class TestOptionalsSingleDashSubsetAmbiguous(ParserTestCase): """Test Optionals where option strings are subsets of each other""" argument_signatures = [Sig('-f'), Sig('-foobar'), Sig('-foorab')] failures = ['-f', '-foo', '-fo', '-foo b', '-foob', '-fooba', '-foora'] successes = [ ('', NS(f=None, foobar=None, foorab=None)), ('-f a', NS(f='a', foobar=None, foorab=None)), ('-fa', NS(f='a', foobar=None, foorab=None)), ('-foa', NS(f='oa', foobar=None, foorab=None)), ('-fooa', NS(f='ooa', foobar=None, foorab=None)), ('-foobar a', NS(f=None, foobar='a', foorab=None)), ('-foorab a', NS(f=None, foobar=None, foorab='a')), ] class TestOptionalsSingleDashAmbiguous(ParserTestCase): """Test Optionals that partially match but are not subsets""" argument_signatures = [Sig('-foobar'), Sig('-foorab')] failures = ['-f', '-f a', '-fa', '-foa', '-foo', '-fo', '-foo b'] successes = [ ('', NS(foobar=None, foorab=None)), ('-foob a', NS(foobar='a', foorab=None)), ('-foor a', NS(foobar=None, foorab='a')), ('-fooba a', NS(foobar='a', foorab=None)), ('-foora a', NS(foobar=None, foorab='a')), ('-foobar a', NS(foobar='a', foorab=None)), ('-foorab a', NS(foobar=None, foorab='a')), ] class TestOptionalsNumeric(ParserTestCase): """Test an Optional with a short opt string""" argument_signatures = [Sig('-1', dest='one')] failures = ['-1', 'a', '-1 --foo', '-1 -y', '-1 -1', '-1 -2'] successes = [ ('', NS(one=None)), ('-1 a', NS(one='a')), ('-1a', NS(one='a')), ('-1-2', NS(one='-2')), ] class TestOptionalsDoubleDash(ParserTestCase): """Test an Optional with a double-dash option string""" argument_signatures = [Sig('--foo')] failures = ['--foo', '-f', '-f a', 'a', '--foo -x', '--foo --bar'] successes = [ ('', NS(foo=None)), ('--foo a', NS(foo='a')), ('--foo=a', NS(foo='a')), ('--foo -2.5', NS(foo='-2.5')), ('--foo=-2.5', NS(foo='-2.5')), ] class TestOptionalsDoubleDashPartialMatch(ParserTestCase): """Tests partial matching with a double-dash option string""" argument_signatures = [ Sig('--badger', action='store_true'), Sig('--bat'), ] failures = ['--bar', '--b', '--ba', '--b=2', '--ba=4', '--badge 5'] successes = [ ('', NS(badger=False, bat=None)), ('--bat X', NS(badger=False, bat='X')), ('--bad', NS(badger=True, bat=None)), ('--badg', NS(badger=True, bat=None)), ('--badge', NS(badger=True, bat=None)), ('--badger', NS(badger=True, bat=None)), ] class TestOptionalsDoubleDashPrefixMatch(ParserTestCase): """Tests when one double-dash option string is a prefix of another""" argument_signatures = [ Sig('--badger', action='store_true'), Sig('--ba'), ] failures = ['--bar', '--b', '--ba', '--b=2', '--badge 5'] successes = [ ('', NS(badger=False, ba=None)), ('--ba X', NS(badger=False, ba='X')), ('--ba=X', NS(badger=False, ba='X')), ('--bad', NS(badger=True, ba=None)), ('--badg', NS(badger=True, ba=None)), ('--badge', NS(badger=True, ba=None)), ('--badger', NS(badger=True, ba=None)), ] class TestOptionalsSingleDoubleDash(ParserTestCase): """Test an Optional with single- and double-dash option strings""" argument_signatures = [ Sig('-f', action='store_true'), Sig('--bar'), Sig('-baz', action='store_const', const=42), ] failures = ['--bar', '-fbar', '-fbaz', '-bazf', '-b B', 'B'] successes = [ ('', NS(f=False, bar=None, baz=None)), ('-f', NS(f=True, bar=None, baz=None)), ('--ba B', NS(f=False, bar='B', baz=None)), ('-f --bar B', NS(f=True, bar='B', baz=None)), ('-f -b', NS(f=True, bar=None, baz=42)), ('-ba -f', NS(f=True, bar=None, baz=42)), ] class TestOptionalsAlternatePrefixChars(ParserTestCase): """Test an Optional with option strings with custom prefixes""" parser_signature = Sig(prefix_chars='+:/', add_help=False) argument_signatures = [ Sig('+f', action='store_true'), Sig('::bar'), Sig('/baz', action='store_const', const=42), ] failures = ['--bar', '-fbar', '-b B', 'B', '-f', '--bar B', '-baz', '-h', '--help', '+h', '::help', '/help'] successes = [ ('', NS(f=False, bar=None, baz=None)), ('+f', NS(f=True, bar=None, baz=None)), ('::ba B', NS(f=False, bar='B', baz=None)), ('+f ::bar B', NS(f=True, bar='B', baz=None)), ('+f /b', NS(f=True, bar=None, baz=42)), ('/ba +f', NS(f=True, bar=None, baz=42)), ] class TestOptionalsAlternatePrefixCharsAddedHelp(ParserTestCase): """When ``-`` not in prefix_chars, default operators created for help should use the prefix_chars in use rather than - or -- http://bugs.python.org/issue9444""" parser_signature = Sig(prefix_chars='+:/', add_help=True) argument_signatures = [ Sig('+f', action='store_true'), Sig('::bar'), Sig('/baz', action='store_const', const=42), ] failures = ['--bar', '-fbar', '-b B', 'B', '-f', '--bar B', '-baz'] successes = [ ('', NS(f=False, bar=None, baz=None)), ('+f', NS(f=True, bar=None, baz=None)), ('::ba B', NS(f=False, bar='B', baz=None)), ('+f ::bar B', NS(f=True, bar='B', baz=None)), ('+f /b', NS(f=True, bar=None, baz=42)), ('/ba +f', NS(f=True, bar=None, baz=42)) ] class TestOptionalsAlternatePrefixCharsMultipleShortArgs(ParserTestCase): """Verify that Optionals must be called with their defined prefixes""" parser_signature = Sig(prefix_chars='+-', add_help=False) argument_signatures = [ Sig('-x', action='store_true'), Sig('+y', action='store_true'), Sig('+z', action='store_true'), ] failures = ['-w', '-xyz', '+x', '-y', '+xyz', ] successes = [ ('', NS(x=False, y=False, z=False)), ('-x', NS(x=True, y=False, z=False)), ('+y -x', NS(x=True, y=True, z=False)), ('+yz -x', NS(x=True, y=True, z=True)), ] class TestOptionalsShortLong(ParserTestCase): """Test a combination of single- and double-dash option strings""" argument_signatures = [ Sig('-v', '--verbose', '-n', '--noisy', action='store_true'), ] failures = ['--x --verbose', '-N', 'a', '-v x'] successes = [ ('', NS(verbose=False)), ('-v', NS(verbose=True)), ('--verbose', NS(verbose=True)), ('-n', NS(verbose=True)), ('--noisy', NS(verbose=True)), ] class TestOptionalsDest(ParserTestCase): """Tests various means of setting destination""" argument_signatures = [Sig('--foo-bar'), Sig('--baz', dest='zabbaz')] failures = ['a'] successes = [ ('--foo-bar f', NS(foo_bar='f', zabbaz=None)), ('--baz g', NS(foo_bar=None, zabbaz='g')), ('--foo-bar h --baz i', NS(foo_bar='h', zabbaz='i')), ('--baz j --foo-bar k', NS(foo_bar='k', zabbaz='j')), ] class TestOptionalsDefault(ParserTestCase): """Tests specifying a default for an Optional""" argument_signatures = [Sig('-x'), Sig('-y', default=42)] failures = ['a'] successes = [ ('', NS(x=None, y=42)), ('-xx', NS(x='x', y=42)), ('-yy', NS(x=None, y='y')), ] class TestOptionalsNargsDefault(ParserTestCase): """Tests not specifying the number of args for an Optional""" argument_signatures = [Sig('-x')] failures = ['a', '-x'] successes = [ ('', NS(x=None)), ('-x a', NS(x='a')), ] class TestOptionalsNargs1(ParserTestCase): """Tests specifying 1 arg for an Optional""" argument_signatures = [Sig('-x', nargs=1)] failures = ['a', '-x'] successes = [ ('', NS(x=None)), ('-x a', NS(x=['a'])), ] class TestOptionalsNargs3(ParserTestCase): """Tests specifying 3 args for an Optional""" argument_signatures = [Sig('-x', nargs=3)] failures = ['a', '-x', '-x a', '-x a b', 'a -x', 'a -x b'] successes = [ ('', NS(x=None)), ('-x a b c', NS(x=['a', 'b', 'c'])), ] class TestOptionalsNargsOptional(ParserTestCase): """Tests specifying an Optional arg for an Optional""" argument_signatures = [ Sig('-w', nargs='?'), Sig('-x', nargs='?', const=42), Sig('-y', nargs='?', default='spam'), Sig('-z', nargs='?', type=int, const='42', default='84'), ] failures = ['2'] successes = [ ('', NS(w=None, x=None, y='spam', z=84)), ('-w', NS(w=None, x=None, y='spam', z=84)), ('-w 2', NS(w='2', x=None, y='spam', z=84)), ('-x', NS(w=None, x=42, y='spam', z=84)), ('-x 2', NS(w=None, x='2', y='spam', z=84)), ('-y', NS(w=None, x=None, y=None, z=84)), ('-y 2', NS(w=None, x=None, y='2', z=84)), ('-z', NS(w=None, x=None, y='spam', z=42)), ('-z 2', NS(w=None, x=None, y='spam', z=2)), ] class TestOptionalsNargsZeroOrMore(ParserTestCase): """Tests specifying args for an Optional that accepts zero or more""" argument_signatures = [ Sig('-x', nargs='*'), Sig('-y', nargs='*', default='spam'), ] failures = ['a'] successes = [ ('', NS(x=None, y='spam')), ('-x', NS(x=[], y='spam')), ('-x a', NS(x=['a'], y='spam')), ('-x a b', NS(x=['a', 'b'], y='spam')), ('-y', NS(x=None, y=[])), ('-y a', NS(x=None, y=['a'])), ('-y a b', NS(x=None, y=['a', 'b'])), ] class TestOptionalsNargsOneOrMore(ParserTestCase): """Tests specifying args for an Optional that accepts one or more""" argument_signatures = [ Sig('-x', nargs='+'), Sig('-y', nargs='+', default='spam'), ] failures = ['a', '-x', '-y', 'a -x', 'a -y b'] successes = [ ('', NS(x=None, y='spam')), ('-x a', NS(x=['a'], y='spam')), ('-x a b', NS(x=['a', 'b'], y='spam')), ('-y a', NS(x=None, y=['a'])), ('-y a b', NS(x=None, y=['a', 'b'])), ] class TestOptionalsChoices(ParserTestCase): """Tests specifying the choices for an Optional""" argument_signatures = [ Sig('-f', choices='abc'), Sig('-g', type=int, choices=range(5))] failures = ['a', '-f d', '-fad', '-ga', '-g 6'] successes = [ ('', NS(f=None, g=None)), ('-f a', NS(f='a', g=None)), ('-f c', NS(f='c', g=None)), ('-g 0', NS(f=None, g=0)), ('-g 03', NS(f=None, g=3)), ('-fb -g4', NS(f='b', g=4)), ] class TestOptionalsRequired(ParserTestCase): """Tests an optional action that is required""" argument_signatures = [ Sig('-x', type=int, required=True), ] failures = ['a', ''] successes = [ ('-x 1', NS(x=1)), ('-x42', NS(x=42)), ] class TestOptionalsActionStore(ParserTestCase): """Tests the store action for an Optional""" argument_signatures = [Sig('-x', action='store')] failures = ['a', 'a -x'] successes = [ ('', NS(x=None)), ('-xfoo', NS(x='foo')), ] class TestOptionalsActionStoreConst(ParserTestCase): """Tests the store_const action for an Optional""" argument_signatures = [Sig('-y', action='store_const', const=object)] failures = ['a'] successes = [ ('', NS(y=None)), ('-y', NS(y=object)), ] class TestOptionalsActionStoreFalse(ParserTestCase): """Tests the store_false action for an Optional""" argument_signatures = [Sig('-z', action='store_false')] failures = ['a', '-za', '-z a'] successes = [ ('', NS(z=True)), ('-z', NS(z=False)), ] class TestOptionalsActionStoreTrue(ParserTestCase): """Tests the store_true action for an Optional""" argument_signatures = [Sig('--apple', action='store_true')] failures = ['a', '--apple=b', '--apple b'] successes = [ ('', NS(apple=False)), ('--apple', NS(apple=True)), ] class TestOptionalsActionAppend(ParserTestCase): """Tests the append action for an Optional""" argument_signatures = [Sig('--baz', action='append')] failures = ['a', '--baz', 'a --baz', '--baz a b'] successes = [ ('', NS(baz=None)), ('--baz a', NS(baz=['a'])), ('--baz a --baz b', NS(baz=['a', 'b'])), ] class TestOptionalsActionAppendWithDefault(ParserTestCase): """Tests the append action for an Optional""" argument_signatures = [Sig('--baz', action='append', default=['X'])] failures = ['a', '--baz', 'a --baz', '--baz a b'] successes = [ ('', NS(baz=['X'])), ('--baz a', NS(baz=['X', 'a'])), ('--baz a --baz b', NS(baz=['X', 'a', 'b'])), ] class TestOptionalsActionAppendConst(ParserTestCase): """Tests the append_const action for an Optional""" argument_signatures = [ Sig('-b', action='append_const', const=Exception), Sig('-c', action='append', dest='b'), ] failures = ['a', '-c', 'a -c', '-bx', '-b x'] successes = [ ('', NS(b=None)), ('-b', NS(b=[Exception])), ('-b -cx -b -cyz', NS(b=[Exception, 'x', Exception, 'yz'])), ] class TestOptionalsActionAppendConstWithDefault(ParserTestCase): """Tests the append_const action for an Optional""" argument_signatures = [ Sig('-b', action='append_const', const=Exception, default=['X']), Sig('-c', action='append', dest='b'), ] failures = ['a', '-c', 'a -c', '-bx', '-b x'] successes = [ ('', NS(b=['X'])), ('-b', NS(b=['X', Exception])), ('-b -cx -b -cyz', NS(b=['X', Exception, 'x', Exception, 'yz'])), ] class TestOptionalsActionCount(ParserTestCase): """Tests the count action for an Optional""" argument_signatures = [Sig('-x', action='count')] failures = ['a', '-x a', '-x b', '-x a -x b'] successes = [ ('', NS(x=None)), ('-x', NS(x=1)), ] class TestOptionalsAllowLongAbbreviation(ParserTestCase): """Allow long options to be abbreviated unambiguously""" argument_signatures = [ Sig('--foo'), Sig('--foobaz'), Sig('--fooble', action='store_true'), ] failures = ['--foob 5', '--foob'] successes = [ ('', NS(foo=None, foobaz=None, fooble=False)), ('--foo 7', NS(foo='7', foobaz=None, fooble=False)), ('--fooba a', NS(foo=None, foobaz='a', fooble=False)), ('--foobl --foo g', NS(foo='g', foobaz=None, fooble=True)), ] class TestOptionalsDisallowLongAbbreviation(ParserTestCase): """Do not allow abbreviations of long options at all""" parser_signature = Sig(allow_abbrev=False) argument_signatures = [ Sig('--foo'), Sig('--foodle', action='store_true'), Sig('--foonly'), ] failures = ['-foon 3', '--foon 3', '--food', '--food --foo 2'] successes = [ ('', NS(foo=None, foodle=False, foonly=None)), ('--foo 3', NS(foo='3', foodle=False, foonly=None)), ('--foonly 7 --foodle --foo 2', NS(foo='2', foodle=True, foonly='7')), ] # ================ # Positional tests # ================ class TestPositionalsNargsNone(ParserTestCase): """Test a Positional that doesn't specify nargs""" argument_signatures = [Sig('foo')] failures = ['', '-x', 'a b'] successes = [ ('a', NS(foo='a')), ] class TestPositionalsNargs1(ParserTestCase): """Test a Positional that specifies an nargs of 1""" argument_signatures = [Sig('foo', nargs=1)] failures = ['', '-x', 'a b'] successes = [ ('a', NS(foo=['a'])), ] class TestPositionalsNargs2(ParserTestCase): """Test a Positional that specifies an nargs of 2""" argument_signatures = [Sig('foo', nargs=2)] failures = ['', 'a', '-x', 'a b c'] successes = [ ('a b', NS(foo=['a', 'b'])), ] class TestPositionalsNargsZeroOrMore(ParserTestCase): """Test a Positional that specifies unlimited nargs""" argument_signatures = [Sig('foo', nargs='*')] failures = ['-x'] successes = [ ('', NS(foo=[])), ('a', NS(foo=['a'])), ('a b', NS(foo=['a', 'b'])), ] class TestPositionalsNargsZeroOrMoreDefault(ParserTestCase): """Test a Positional that specifies unlimited nargs and a default""" argument_signatures = [Sig('foo', nargs='*', default='bar')] failures = ['-x'] successes = [ ('', NS(foo='bar')), ('a', NS(foo=['a'])), ('a b', NS(foo=['a', 'b'])), ] class TestPositionalsNargsOneOrMore(ParserTestCase): """Test a Positional that specifies one or more nargs""" argument_signatures = [Sig('foo', nargs='+')] failures = ['', '-x'] successes = [ ('a', NS(foo=['a'])), ('a b', NS(foo=['a', 'b'])), ] class TestPositionalsNargsOptional(ParserTestCase): """Tests an Optional Positional""" argument_signatures = [Sig('foo', nargs='?')] failures = ['-x', 'a b'] successes = [ ('', NS(foo=None)), ('a', NS(foo='a')), ] class TestPositionalsNargsOptionalDefault(ParserTestCase): """Tests an Optional Positional with a default value""" argument_signatures = [Sig('foo', nargs='?', default=42)] failures = ['-x', 'a b'] successes = [ ('', NS(foo=42)), ('a', NS(foo='a')), ] class TestPositionalsNargsOptionalConvertedDefault(ParserTestCase): """Tests an Optional Positional with a default value that needs to be converted to the appropriate type. """ argument_signatures = [ Sig('foo', nargs='?', type=int, default='42'), ] failures = ['-x', 'a b', '1 2'] successes = [ ('', NS(foo=42)), ('1', NS(foo=1)), ] class TestPositionalsNargsNoneNone(ParserTestCase): """Test two Positionals that don't specify nargs""" argument_signatures = [Sig('foo'), Sig('bar')] failures = ['', '-x', 'a', 'a b c'] successes = [ ('a b', NS(foo='a', bar='b')), ] class TestPositionalsNargsNone1(ParserTestCase): """Test a Positional with no nargs followed by one with 1""" argument_signatures = [Sig('foo'), Sig('bar', nargs=1)] failures = ['', '--foo', 'a', 'a b c'] successes = [ ('a b', NS(foo='a', bar=['b'])), ] class TestPositionalsNargs2None(ParserTestCase): """Test a Positional with 2 nargs followed by one with none""" argument_signatures = [Sig('foo', nargs=2), Sig('bar')] failures = ['', '--foo', 'a', 'a b', 'a b c d'] successes = [ ('a b c', NS(foo=['a', 'b'], bar='c')), ] class TestPositionalsNargsNoneZeroOrMore(ParserTestCase): """Test a Positional with no nargs followed by one with unlimited""" argument_signatures = [Sig('foo'), Sig('bar', nargs='*')] failures = ['', '--foo'] successes = [ ('a', NS(foo='a', bar=[])), ('a b', NS(foo='a', bar=['b'])), ('a b c', NS(foo='a', bar=['b', 'c'])), ] class TestPositionalsNargsNoneOneOrMore(ParserTestCase): """Test a Positional with no nargs followed by one with one or more""" argument_signatures = [Sig('foo'), Sig('bar', nargs='+')] failures = ['', '--foo', 'a'] successes = [ ('a b', NS(foo='a', bar=['b'])), ('a b c', NS(foo='a', bar=['b', 'c'])), ] class TestPositionalsNargsNoneOptional(ParserTestCase): """Test a Positional with no nargs followed by one with an Optional""" argument_signatures = [Sig('foo'), Sig('bar', nargs='?')] failures = ['', '--foo', 'a b c'] successes = [ ('a', NS(foo='a', bar=None)), ('a b', NS(foo='a', bar='b')), ] class TestPositionalsNargsZeroOrMoreNone(ParserTestCase): """Test a Positional with unlimited nargs followed by one with none""" argument_signatures = [Sig('foo', nargs='*'), Sig('bar')] failures = ['', '--foo'] successes = [ ('a', NS(foo=[], bar='a')), ('a b', NS(foo=['a'], bar='b')), ('a b c', NS(foo=['a', 'b'], bar='c')), ] class TestPositionalsNargsOneOrMoreNone(ParserTestCase): """Test a Positional with one or more nargs followed by one with none""" argument_signatures = [Sig('foo', nargs='+'), Sig('bar')] failures = ['', '--foo', 'a'] successes = [ ('a b', NS(foo=['a'], bar='b')), ('a b c', NS(foo=['a', 'b'], bar='c')), ] class TestPositionalsNargsOptionalNone(ParserTestCase): """Test a Positional with an Optional nargs followed by one with none""" argument_signatures = [Sig('foo', nargs='?', default=42), Sig('bar')] failures = ['', '--foo', 'a b c'] successes = [ ('a', NS(foo=42, bar='a')), ('a b', NS(foo='a', bar='b')), ] class TestPositionalsNargs2ZeroOrMore(ParserTestCase): """Test a Positional with 2 nargs followed by one with unlimited""" argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='*')] failures = ['', '--foo', 'a'] successes = [ ('a b', NS(foo=['a', 'b'], bar=[])), ('a b c', NS(foo=['a', 'b'], bar=['c'])), ] class TestPositionalsNargs2OneOrMore(ParserTestCase): """Test a Positional with 2 nargs followed by one with one or more""" argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='+')] failures = ['', '--foo', 'a', 'a b'] successes = [ ('a b c', NS(foo=['a', 'b'], bar=['c'])), ] class TestPositionalsNargs2Optional(ParserTestCase): """Test a Positional with 2 nargs followed by one optional""" argument_signatures = [Sig('foo', nargs=2), Sig('bar', nargs='?')] failures = ['', '--foo', 'a', 'a b c d'] successes = [ ('a b', NS(foo=['a', 'b'], bar=None)), ('a b c', NS(foo=['a', 'b'], bar='c')), ] class TestPositionalsNargsZeroOrMore1(ParserTestCase): """Test a Positional with unlimited nargs followed by one with 1""" argument_signatures = [Sig('foo', nargs='*'), Sig('bar', nargs=1)] failures = ['', '--foo', ] successes = [ ('a', NS(foo=[], bar=['a'])), ('a b', NS(foo=['a'], bar=['b'])), ('a b c', NS(foo=['a', 'b'], bar=['c'])), ] class TestPositionalsNargsOneOrMore1(ParserTestCase): """Test a Positional with one or more nargs followed by one with 1""" argument_signatures = [Sig('foo', nargs='+'), Sig('bar', nargs=1)] failures = ['', '--foo', 'a'] successes = [ ('a b', NS(foo=['a'], bar=['b'])), ('a b c', NS(foo=['a', 'b'], bar=['c'])), ] class TestPositionalsNargsOptional1(ParserTestCase): """Test a Positional with an Optional nargs followed by one with 1""" argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs=1)] failures = ['', '--foo', 'a b c'] successes = [ ('a', NS(foo=None, bar=['a'])), ('a b', NS(foo='a', bar=['b'])), ] class TestPositionalsNargsNoneZeroOrMore1(ParserTestCase): """Test three Positionals: no nargs, unlimited nargs and 1 nargs""" argument_signatures = [ Sig('foo'), Sig('bar', nargs='*'), Sig('baz', nargs=1), ] failures = ['', '--foo', 'a'] successes = [ ('a b', NS(foo='a', bar=[], baz=['b'])), ('a b c', NS(foo='a', bar=['b'], baz=['c'])), ] class TestPositionalsNargsNoneOneOrMore1(ParserTestCase): """Test three Positionals: no nargs, one or more nargs and 1 nargs""" argument_signatures = [ Sig('foo'), Sig('bar', nargs='+'), Sig('baz', nargs=1), ] failures = ['', '--foo', 'a', 'b'] successes = [ ('a b c', NS(foo='a', bar=['b'], baz=['c'])), ('a b c d', NS(foo='a', bar=['b', 'c'], baz=['d'])), ] class TestPositionalsNargsNoneOptional1(ParserTestCase): """Test three Positionals: no nargs, optional narg and 1 nargs""" argument_signatures = [ Sig('foo'), Sig('bar', nargs='?', default=0.625), Sig('baz', nargs=1), ] failures = ['', '--foo', 'a'] successes = [ ('a b', NS(foo='a', bar=0.625, baz=['b'])), ('a b c', NS(foo='a', bar='b', baz=['c'])), ] class TestPositionalsNargsOptionalOptional(ParserTestCase): """Test two optional nargs""" argument_signatures = [ Sig('foo', nargs='?'), Sig('bar', nargs='?', default=42), ] failures = ['--foo', 'a b c'] successes = [ ('', NS(foo=None, bar=42)), ('a', NS(foo='a', bar=42)), ('a b', NS(foo='a', bar='b')), ] class TestPositionalsNargsOptionalZeroOrMore(ParserTestCase): """Test an Optional narg followed by unlimited nargs""" argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs='*')] failures = ['--foo'] successes = [ ('', NS(foo=None, bar=[])), ('a', NS(foo='a', bar=[])), ('a b', NS(foo='a', bar=['b'])), ('a b c', NS(foo='a', bar=['b', 'c'])), ] class TestPositionalsNargsOptionalOneOrMore(ParserTestCase): """Test an Optional narg followed by one or more nargs""" argument_signatures = [Sig('foo', nargs='?'), Sig('bar', nargs='+')] failures = ['', '--foo'] successes = [ ('a', NS(foo=None, bar=['a'])), ('a b', NS(foo='a', bar=['b'])), ('a b c', NS(foo='a', bar=['b', 'c'])), ] class TestPositionalsChoicesString(ParserTestCase): """Test a set of single-character choices""" argument_signatures = [Sig('spam', choices=set('abcdefg'))] failures = ['', '--foo', 'h', '42', 'ef'] successes = [ ('a', NS(spam='a')), ('g', NS(spam='g')), ] class TestPositionalsChoicesInt(ParserTestCase): """Test a set of integer choices""" argument_signatures = [Sig('spam', type=int, choices=range(20))] failures = ['', '--foo', 'h', '42', 'ef'] successes = [ ('4', NS(spam=4)), ('15', NS(spam=15)), ] class TestPositionalsActionAppend(ParserTestCase): """Test the 'append' action""" argument_signatures = [ Sig('spam', action='append'), Sig('spam', action='append', nargs=2), ] failures = ['', '--foo', 'a', 'a b', 'a b c d'] successes = [ ('a b c', NS(spam=['a', ['b', 'c']])), ] # ======================================== # Combined optionals and positionals tests # ======================================== class TestOptionalsNumericAndPositionals(ParserTestCase): """Tests negative number args when numeric options are present""" argument_signatures = [ Sig('x', nargs='?'), Sig('-4', dest='y', action='store_true'), ] failures = ['-2', '-315'] successes = [ ('', NS(x=None, y=False)), ('a', NS(x='a', y=False)), ('-4', NS(x=None, y=True)), ('-4 a', NS(x='a', y=True)), ] class TestOptionalsAlmostNumericAndPositionals(ParserTestCase): """Tests negative number args when almost numeric options are present""" argument_signatures = [ Sig('x', nargs='?'), Sig('-k4', dest='y', action='store_true'), ] failures = ['-k3'] successes = [ ('', NS(x=None, y=False)), ('-2', NS(x='-2', y=False)), ('a', NS(x='a', y=False)), ('-k4', NS(x=None, y=True)), ('-k4 a', NS(x='a', y=True)), ] class TestEmptyAndSpaceContainingArguments(ParserTestCase): argument_signatures = [ Sig('x', nargs='?'), Sig('-y', '--yyy', dest='y'), ] failures = ['-y'] successes = [ ([''], NS(x='', y=None)), (['a badger'], NS(x='a badger', y=None)), (['-a badger'], NS(x='-a badger', y=None)), (['-y', ''], NS(x=None, y='')), (['-y', 'a badger'], NS(x=None, y='a badger')), (['-y', '-a badger'], NS(x=None, y='-a badger')), (['--yyy=a badger'], NS(x=None, y='a badger')), (['--yyy=-a badger'], NS(x=None, y='-a badger')), ] class TestPrefixCharacterOnlyArguments(ParserTestCase): parser_signature = Sig(prefix_chars='-+') argument_signatures = [ Sig('-', dest='x', nargs='?', const='badger'), Sig('+', dest='y', type=int, default=42), Sig('-+-', dest='z', action='store_true'), ] failures = ['-y', '+ -'] successes = [ ('', NS(x=None, y=42, z=False)), ('-', NS(x='badger', y=42, z=False)), ('- X', NS(x='X', y=42, z=False)), ('+ -3', NS(x=None, y=-3, z=False)), ('-+-', NS(x=None, y=42, z=True)), ('- ===', NS(x='===', y=42, z=False)), ] class TestNargsZeroOrMore(ParserTestCase): """Tests specifying args for an Optional that accepts zero or more""" argument_signatures = [Sig('-x', nargs='*'), Sig('y', nargs='*')] failures = [] successes = [ ('', NS(x=None, y=[])), ('-x', NS(x=[], y=[])), ('-x a', NS(x=['a'], y=[])), ('-x a -- b', NS(x=['a'], y=['b'])), ('a', NS(x=None, y=['a'])), ('a -x', NS(x=[], y=['a'])), ('a -x b', NS(x=['b'], y=['a'])), ] class TestNargsRemainder(ParserTestCase): """Tests specifying a positional with nargs=REMAINDER""" argument_signatures = [Sig('x'), Sig('y', nargs='...'), Sig('-z')] failures = ['', '-z', '-z Z'] successes = [ ('X', NS(x='X', y=[], z=None)), ('-z Z X', NS(x='X', y=[], z='Z')), ('X A B -z Z', NS(x='X', y=['A', 'B', '-z', 'Z'], z=None)), ('X Y --foo', NS(x='X', y=['Y', '--foo'], z=None)), ] class TestOptionLike(ParserTestCase): """Tests options that may or may not be arguments""" argument_signatures = [ Sig('-x', type=float), Sig('-3', type=float, dest='y'), Sig('z', nargs='*'), ] failures = ['-x', '-y2.5', '-xa', '-x -a', '-x -3', '-x -3.5', '-3 -3.5', '-x -2.5', '-x -2.5 a', '-3 -.5', 'a x -1', '-x -1 a', '-3 -1 a'] successes = [ ('', NS(x=None, y=None, z=[])), ('-x 2.5', NS(x=2.5, y=None, z=[])), ('-x 2.5 a', NS(x=2.5, y=None, z=['a'])), ('-3.5', NS(x=None, y=0.5, z=[])), ('-3-.5', NS(x=None, y=-0.5, z=[])), ('-3 .5', NS(x=None, y=0.5, z=[])), ('a -3.5', NS(x=None, y=0.5, z=['a'])), ('a', NS(x=None, y=None, z=['a'])), ('a -x 1', NS(x=1.0, y=None, z=['a'])), ('-x 1 a', NS(x=1.0, y=None, z=['a'])), ('-3 1 a', NS(x=None, y=1.0, z=['a'])), ] class TestDefaultSuppress(ParserTestCase): """Test actions with suppressed defaults""" argument_signatures = [ Sig('foo', nargs='?', default=argparse.SUPPRESS), Sig('bar', nargs='*', default=argparse.SUPPRESS), Sig('--baz', action='store_true', default=argparse.SUPPRESS), ] failures = ['-x'] successes = [ ('', NS()), ('a', NS(foo='a')), ('a b', NS(foo='a', bar=['b'])), ('--baz', NS(baz=True)), ('a --baz', NS(foo='a', baz=True)), ('--baz a b', NS(foo='a', bar=['b'], baz=True)), ] class TestParserDefaultSuppress(ParserTestCase): """Test actions with a parser-level default of SUPPRESS""" parser_signature = Sig(argument_default=argparse.SUPPRESS) argument_signatures = [ Sig('foo', nargs='?'), Sig('bar', nargs='*'), Sig('--baz', action='store_true'), ] failures = ['-x'] successes = [ ('', NS()), ('a', NS(foo='a')), ('a b', NS(foo='a', bar=['b'])), ('--baz', NS(baz=True)), ('a --baz', NS(foo='a', baz=True)), ('--baz a b', NS(foo='a', bar=['b'], baz=True)), ] class TestParserDefault42(ParserTestCase): """Test actions with a parser-level default of 42""" parser_signature = Sig(argument_default=42) argument_signatures = [ Sig('--version', action='version', version='1.0'), Sig('foo', nargs='?'), Sig('bar', nargs='*'), Sig('--baz', action='store_true'), ] failures = ['-x'] successes = [ ('', NS(foo=42, bar=42, baz=42, version=42)), ('a', NS(foo='a', bar=42, baz=42, version=42)), ('a b', NS(foo='a', bar=['b'], baz=42, version=42)), ('--baz', NS(foo=42, bar=42, baz=True, version=42)), ('a --baz', NS(foo='a', bar=42, baz=True, version=42)), ('--baz a b', NS(foo='a', bar=['b'], baz=True, version=42)), ] class TestArgumentsFromFile(TempDirMixin, ParserTestCase): """Test reading arguments from a file""" def setUp(self): super(TestArgumentsFromFile, self).setUp() file_texts = [ ('hello', 'hello world!\n'), ('recursive', '-a\n' 'A\n' '@hello'), ('invalid', '@no-such-path\n'), ] for path, text in file_texts: file = open(path, 'w') file.write(text) file.close() parser_signature = Sig(fromfile_prefix_chars='@') argument_signatures = [ Sig('-a'), Sig('x'), Sig('y', nargs='+'), ] failures = ['', '-b', 'X', '@invalid', '@missing'] successes = [ ('X Y', NS(a=None, x='X', y=['Y'])), ('X -a A Y Z', NS(a='A', x='X', y=['Y', 'Z'])), ('@hello X', NS(a=None, x='hello world!', y=['X'])), ('X @hello', NS(a=None, x='X', y=['hello world!'])), ('-a B @recursive Y Z', NS(a='A', x='hello world!', y=['Y', 'Z'])), ('X @recursive Z -a B', NS(a='B', x='X', y=['hello world!', 'Z'])), (["-a", "", "X", "Y"], NS(a='', x='X', y=['Y'])), ] class TestArgumentsFromFileConverter(TempDirMixin, ParserTestCase): """Test reading arguments from a file""" def setUp(self): super(TestArgumentsFromFileConverter, self).setUp() file_texts = [ ('hello', 'hello world!\n'), ] for path, text in file_texts: file = open(path, 'w') file.write(text) file.close() class FromFileConverterArgumentParser(ErrorRaisingArgumentParser): def convert_arg_line_to_args(self, arg_line): for arg in arg_line.split(): if not arg.strip(): continue yield arg parser_class = FromFileConverterArgumentParser parser_signature = Sig(fromfile_prefix_chars='@') argument_signatures = [ Sig('y', nargs='+'), ] failures = [] successes = [ ('@hello X', NS(y=['hello', 'world!', 'X'])), ] # ===================== # Type conversion tests # ===================== class TestFileTypeRepr(TestCase): def test_r(self): type = argparse.FileType('r') self.assertEqual("FileType('r')", repr(type)) def test_wb_1(self): type = argparse.FileType('wb', 1) self.assertEqual("FileType('wb', 1)", repr(type)) def test_r_latin(self): type = argparse.FileType('r', encoding='latin_1') self.assertEqual("FileType('r', encoding='latin_1')", repr(type)) def test_w_big5_ignore(self): type = argparse.FileType('w', encoding='big5', errors='ignore') self.assertEqual("FileType('w', encoding='big5', errors='ignore')", repr(type)) def test_r_1_replace(self): type = argparse.FileType('r', 1, errors='replace') self.assertEqual("FileType('r', 1, errors='replace')", repr(type)) class StdStreamComparer: def __init__(self, attr): self.attr = attr def __eq__(self, other): return other == getattr(sys, self.attr) eq_stdin = StdStreamComparer('stdin') eq_stdout = StdStreamComparer('stdout') eq_stderr = StdStreamComparer('stderr') class RFile(object): seen = {} def __init__(self, name): self.name = name def __eq__(self, other): if other in self.seen: text = self.seen[other] else: text = self.seen[other] = other.read() other.close() if not isinstance(text, str): text = text.decode('ascii') return self.name == other.name == text class TestFileTypeR(TempDirMixin, ParserTestCase): """Test the FileType option/argument type for reading files""" def setUp(self): super(TestFileTypeR, self).setUp() for file_name in ['foo', 'bar']: file = open(os.path.join(self.temp_dir, file_name), 'w') file.write(file_name) file.close() self.create_readonly_file('readonly') argument_signatures = [ Sig('-x', type=argparse.FileType()), Sig('spam', type=argparse.FileType('r')), ] failures = ['-x', '', 'non-existent-file.txt'] successes = [ ('foo', NS(x=None, spam=RFile('foo'))), ('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))), ('bar -x foo', NS(x=RFile('foo'), spam=RFile('bar'))), ('-x - -', NS(x=eq_stdin, spam=eq_stdin)), ('readonly', NS(x=None, spam=RFile('readonly'))), ] class TestFileTypeDefaults(TempDirMixin, ParserTestCase): """Test that a file is not created unless the default is needed""" def setUp(self): super(TestFileTypeDefaults, self).setUp() file = open(os.path.join(self.temp_dir, 'good'), 'w') file.write('good') file.close() argument_signatures = [ Sig('-c', type=argparse.FileType('r'), default='no-file.txt'), ] # should provoke no such file error failures = [''] # should not provoke error because default file is created successes = [('-c good', NS(c=RFile('good')))] class TestFileTypeRB(TempDirMixin, ParserTestCase): """Test the FileType option/argument type for reading files""" def setUp(self): super(TestFileTypeRB, self).setUp() for file_name in ['foo', 'bar']: file = open(os.path.join(self.temp_dir, file_name), 'w') file.write(file_name) file.close() argument_signatures = [ Sig('-x', type=argparse.FileType('rb')), Sig('spam', type=argparse.FileType('rb')), ] failures = ['-x', ''] successes = [ ('foo', NS(x=None, spam=RFile('foo'))), ('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))), ('bar -x foo', NS(x=RFile('foo'), spam=RFile('bar'))), ('-x - -', NS(x=eq_stdin, spam=eq_stdin)), ] class WFile(object): seen = set() def __init__(self, name): self.name = name def __eq__(self, other): if other not in self.seen: text = 'Check that file is writable.' if 'b' in other.mode: text = text.encode('ascii') other.write(text) other.close() self.seen.add(other) return self.name == other.name @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, "non-root user required") class TestFileTypeW(TempDirMixin, ParserTestCase): """Test the FileType option/argument type for writing files""" def setUp(self): super(TestFileTypeW, self).setUp() self.create_readonly_file('readonly') argument_signatures = [ Sig('-x', type=argparse.FileType('w')), Sig('spam', type=argparse.FileType('w')), ] failures = ['-x', '', 'readonly'] successes = [ ('foo', NS(x=None, spam=WFile('foo'))), ('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))), ('bar -x foo', NS(x=WFile('foo'), spam=WFile('bar'))), ('-x - -', NS(x=eq_stdout, spam=eq_stdout)), ] class TestFileTypeWB(TempDirMixin, ParserTestCase): argument_signatures = [ Sig('-x', type=argparse.FileType('wb')), Sig('spam', type=argparse.FileType('wb')), ] failures = ['-x', ''] successes = [ ('foo', NS(x=None, spam=WFile('foo'))), ('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))), ('bar -x foo', NS(x=WFile('foo'), spam=WFile('bar'))), ('-x - -', NS(x=eq_stdout, spam=eq_stdout)), ] class TestFileTypeOpenArgs(TestCase): """Test that open (the builtin) is correctly called""" def test_open_args(self): FT = argparse.FileType cases = [ (FT('rb'), ('rb', -1, None, None)), (FT('w', 1), ('w', 1, None, None)), (FT('w', errors='replace'), ('w', -1, None, 'replace')), (FT('wb', encoding='big5'), ('wb', -1, 'big5', None)), (FT('w', 0, 'l1', 'strict'), ('w', 0, 'l1', 'strict')), ] with mock.patch('builtins.open') as m: for type, args in cases: type('foo') m.assert_called_with('foo', *args) class TestTypeCallable(ParserTestCase): """Test some callables as option/argument types""" argument_signatures = [ Sig('--eggs', type=complex), Sig('spam', type=float), ] failures = ['a', '42j', '--eggs a', '--eggs 2i'] successes = [ ('--eggs=42 42', NS(eggs=42, spam=42.0)), ('--eggs 2j -- -1.5', NS(eggs=2j, spam=-1.5)), ('1024.675', NS(eggs=None, spam=1024.675)), ] class TestTypeUserDefined(ParserTestCase): """Test a user-defined option/argument type""" class MyType(TestCase): def __init__(self, value): self.value = value def __eq__(self, other): return (type(self), self.value) == (type(other), other.value) argument_signatures = [ Sig('-x', type=MyType), Sig('spam', type=MyType), ] failures = [] successes = [ ('a -x b', NS(x=MyType('b'), spam=MyType('a'))), ('-xf g', NS(x=MyType('f'), spam=MyType('g'))), ] class TestTypeClassicClass(ParserTestCase): """Test a classic class type""" class C: def __init__(self, value): self.value = value def __eq__(self, other): return (type(self), self.value) == (type(other), other.value) argument_signatures = [ Sig('-x', type=C), Sig('spam', type=C), ] failures = [] successes = [ ('a -x b', NS(x=C('b'), spam=C('a'))), ('-xf g', NS(x=C('f'), spam=C('g'))), ] class TestTypeRegistration(TestCase): """Test a user-defined type by registering it""" def test(self): def get_my_type(string): return 'my_type{%s}' % string parser = argparse.ArgumentParser() parser.register('type', 'my_type', get_my_type) parser.add_argument('-x', type='my_type') parser.add_argument('y', type='my_type') self.assertEqual(parser.parse_args('1'.split()), NS(x=None, y='my_type{1}')) self.assertEqual(parser.parse_args('-x 1 42'.split()), NS(x='my_type{1}', y='my_type{42}')) # ============ # Action tests # ============ class TestActionUserDefined(ParserTestCase): """Test a user-defined option/argument action""" class OptionalAction(argparse.Action): def __call__(self, parser, namespace, value, option_string=None): try: # check destination and option string assert self.dest == 'spam', 'dest: %s' % self.dest assert option_string == '-s', 'flag: %s' % option_string # when option is before argument, badger=2, and when # option is after argument, badger=<whatever was set> expected_ns = NS(spam=0.25) if value in [0.125, 0.625]: expected_ns.badger = 2 elif value in [2.0]: expected_ns.badger = 84 else: raise AssertionError('value: %s' % value) assert expected_ns == namespace, ('expected %s, got %s' % (expected_ns, namespace)) except AssertionError: e = sys.exc_info()[1] raise ArgumentParserError('opt_action failed: %s' % e) setattr(namespace, 'spam', value) class PositionalAction(argparse.Action): def __call__(self, parser, namespace, value, option_string=None): try: assert option_string is None, ('option_string: %s' % option_string) # check destination assert self.dest == 'badger', 'dest: %s' % self.dest # when argument is before option, spam=0.25, and when # option is after argument, spam=<whatever was set> expected_ns = NS(badger=2) if value in [42, 84]: expected_ns.spam = 0.25 elif value in [1]: expected_ns.spam = 0.625 elif value in [2]: expected_ns.spam = 0.125 else: raise AssertionError('value: %s' % value) assert expected_ns == namespace, ('expected %s, got %s' % (expected_ns, namespace)) except AssertionError: e = sys.exc_info()[1] raise ArgumentParserError('arg_action failed: %s' % e) setattr(namespace, 'badger', value) argument_signatures = [ Sig('-s', dest='spam', action=OptionalAction, type=float, default=0.25), Sig('badger', action=PositionalAction, type=int, nargs='?', default=2), ] failures = [] successes = [ ('-s0.125', NS(spam=0.125, badger=2)), ('42', NS(spam=0.25, badger=42)), ('-s 0.625 1', NS(spam=0.625, badger=1)), ('84 -s2', NS(spam=2.0, badger=84)), ] class TestActionRegistration(TestCase): """Test a user-defined action supplied by registering it""" class MyAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, 'foo[%s]' % values) def test(self): parser = argparse.ArgumentParser() parser.register('action', 'my_action', self.MyAction) parser.add_argument('badger', action='my_action') self.assertEqual(parser.parse_args(['1']), NS(badger='foo[1]')) self.assertEqual(parser.parse_args(['42']), NS(badger='foo[42]')) # ================ # Subparsers tests # ================ class TestAddSubparsers(TestCase): """Test the add_subparsers method""" def assertArgumentParserError(self, *args, **kwargs): self.assertRaises(ArgumentParserError, *args, **kwargs) def _get_parser(self, subparser_help=False, prefix_chars=None, aliases=False): # create a parser with a subparsers argument if prefix_chars: parser = ErrorRaisingArgumentParser( prog='PROG', description='main description', prefix_chars=prefix_chars) parser.add_argument( prefix_chars[0] * 2 + 'foo', action='store_true', help='foo help') else: parser = ErrorRaisingArgumentParser( prog='PROG', description='main description') parser.add_argument( '--foo', action='store_true', help='foo help') parser.add_argument( 'bar', type=float, help='bar help') # check that only one subparsers argument can be added subparsers_kwargs = {} if aliases: subparsers_kwargs['metavar'] = 'COMMAND' subparsers_kwargs['title'] = 'commands' else: subparsers_kwargs['help'] = 'command help' subparsers = parser.add_subparsers(**subparsers_kwargs) self.assertArgumentParserError(parser.add_subparsers) # add first sub-parser parser1_kwargs = dict(description='1 description') if subparser_help: parser1_kwargs['help'] = '1 help' if aliases: parser1_kwargs['aliases'] = ['1alias1', '1alias2'] parser1 = subparsers.add_parser('1', **parser1_kwargs) parser1.add_argument('-w', type=int, help='w help') parser1.add_argument('x', choices='abc', help='x help') # add second sub-parser parser2_kwargs = dict(description='2 description') if subparser_help: parser2_kwargs['help'] = '2 help' parser2 = subparsers.add_parser('2', **parser2_kwargs) parser2.add_argument('-y', choices='123', help='y help') parser2.add_argument('z', type=complex, nargs='*', help='z help') # add third sub-parser parser3_kwargs = dict(description='3 description') if subparser_help: parser3_kwargs['help'] = '3 help' parser3 = subparsers.add_parser('3', **parser3_kwargs) parser3.add_argument('t', type=int, help='t help') parser3.add_argument('u', nargs='...', help='u help') # return the main parser return parser def setUp(self): super().setUp() self.parser = self._get_parser() self.command_help_parser = self._get_parser(subparser_help=True) def test_parse_args_failures(self): # check some failure cases: for args_str in ['', 'a', 'a a', '0.5 a', '0.5 1', '0.5 1 -y', '0.5 2 -w']: args = args_str.split() self.assertArgumentParserError(self.parser.parse_args, args) def test_parse_args(self): # check some non-failure cases: self.assertEqual( self.parser.parse_args('0.5 1 b -w 7'.split()), NS(foo=False, bar=0.5, w=7, x='b'), ) self.assertEqual( self.parser.parse_args('0.25 --foo 2 -y 2 3j -- -1j'.split()), NS(foo=True, bar=0.25, y='2', z=[3j, -1j]), ) self.assertEqual( self.parser.parse_args('--foo 0.125 1 c'.split()), NS(foo=True, bar=0.125, w=None, x='c'), ) self.assertEqual( self.parser.parse_args('-1.5 3 11 -- a --foo 7 -- b'.split()), NS(foo=False, bar=-1.5, t=11, u=['a', '--foo', '7', '--', 'b']), ) def test_parse_known_args(self): self.assertEqual( self.parser.parse_known_args('0.5 1 b -w 7'.split()), (NS(foo=False, bar=0.5, w=7, x='b'), []), ) self.assertEqual( self.parser.parse_known_args('0.5 -p 1 b -w 7'.split()), (NS(foo=False, bar=0.5, w=7, x='b'), ['-p']), ) self.assertEqual( self.parser.parse_known_args('0.5 1 b -w 7 -p'.split()), (NS(foo=False, bar=0.5, w=7, x='b'), ['-p']), ) self.assertEqual( self.parser.parse_known_args('0.5 1 b -q -rs -w 7'.split()), (NS(foo=False, bar=0.5, w=7, x='b'), ['-q', '-rs']), ) self.assertEqual( self.parser.parse_known_args('0.5 -W 1 b -X Y -w 7 Z'.split()), (NS(foo=False, bar=0.5, w=7, x='b'), ['-W', '-X', 'Y', 'Z']), ) def test_dest(self): parser = ErrorRaisingArgumentParser() parser.add_argument('--foo', action='store_true') subparsers = parser.add_subparsers(dest='bar') parser1 = subparsers.add_parser('1') parser1.add_argument('baz') self.assertEqual(NS(foo=False, bar='1', baz='2'), parser.parse_args('1 2'.split())) def test_help(self): self.assertEqual(self.parser.format_usage(), 'usage: PROG [-h] [--foo] bar {1,2,3} ...\n') self.assertEqual(self.parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [--foo] bar {1,2,3} ... main description positional arguments: bar bar help {1,2,3} command help optional arguments: -h, --help show this help message and exit --foo foo help ''')) def test_help_extra_prefix_chars(self): # Make sure - is still used for help if it is a non-first prefix char parser = self._get_parser(prefix_chars='+:-') self.assertEqual(parser.format_usage(), 'usage: PROG [-h] [++foo] bar {1,2,3} ...\n') self.assertEqual(parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [++foo] bar {1,2,3} ... main description positional arguments: bar bar help {1,2,3} command help optional arguments: -h, --help show this help message and exit ++foo foo help ''')) def test_help_non_breaking_spaces(self): parser = ErrorRaisingArgumentParser( prog='PROG', description='main description') parser.add_argument( "--non-breaking", action='store_false', help='help message containing non-breaking spaces shall not ' 'wrap\N{NO-BREAK SPACE}at non-breaking spaces') self.assertEqual(parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [--non-breaking] main description optional arguments: -h, --help show this help message and exit --non-breaking help message containing non-breaking spaces shall not wrap\N{NO-BREAK SPACE}at non-breaking spaces ''')) def test_help_alternate_prefix_chars(self): parser = self._get_parser(prefix_chars='+:/') self.assertEqual(parser.format_usage(), 'usage: PROG [+h] [++foo] bar {1,2,3} ...\n') self.assertEqual(parser.format_help(), textwrap.dedent('''\ usage: PROG [+h] [++foo] bar {1,2,3} ... main description positional arguments: bar bar help {1,2,3} command help optional arguments: +h, ++help show this help message and exit ++foo foo help ''')) def test_parser_command_help(self): self.assertEqual(self.command_help_parser.format_usage(), 'usage: PROG [-h] [--foo] bar {1,2,3} ...\n') self.assertEqual(self.command_help_parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [--foo] bar {1,2,3} ... main description positional arguments: bar bar help {1,2,3} command help 1 1 help 2 2 help 3 3 help optional arguments: -h, --help show this help message and exit --foo foo help ''')) def test_subparser_title_help(self): parser = ErrorRaisingArgumentParser(prog='PROG', description='main description') parser.add_argument('--foo', action='store_true', help='foo help') parser.add_argument('bar', help='bar help') subparsers = parser.add_subparsers(title='subcommands', description='command help', help='additional text') parser1 = subparsers.add_parser('1') parser2 = subparsers.add_parser('2') self.assertEqual(parser.format_usage(), 'usage: PROG [-h] [--foo] bar {1,2} ...\n') self.assertEqual(parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [--foo] bar {1,2} ... main description positional arguments: bar bar help optional arguments: -h, --help show this help message and exit --foo foo help subcommands: command help {1,2} additional text ''')) def _test_subparser_help(self, args_str, expected_help): with self.assertRaises(ArgumentParserError) as cm: self.parser.parse_args(args_str.split()) self.assertEqual(expected_help, cm.exception.stdout) def test_subparser1_help(self): self._test_subparser_help('5.0 1 -h', textwrap.dedent('''\ usage: PROG bar 1 [-h] [-w W] {a,b,c} 1 description positional arguments: {a,b,c} x help optional arguments: -h, --help show this help message and exit -w W w help ''')) def test_subparser2_help(self): self._test_subparser_help('5.0 2 -h', textwrap.dedent('''\ usage: PROG bar 2 [-h] [-y {1,2,3}] [z [z ...]] 2 description positional arguments: z z help optional arguments: -h, --help show this help message and exit -y {1,2,3} y help ''')) def test_alias_invocation(self): parser = self._get_parser(aliases=True) self.assertEqual( parser.parse_known_args('0.5 1alias1 b'.split()), (NS(foo=False, bar=0.5, w=None, x='b'), []), ) self.assertEqual( parser.parse_known_args('0.5 1alias2 b'.split()), (NS(foo=False, bar=0.5, w=None, x='b'), []), ) def test_error_alias_invocation(self): parser = self._get_parser(aliases=True) self.assertArgumentParserError(parser.parse_args, '0.5 1alias3 b'.split()) def test_alias_help(self): parser = self._get_parser(aliases=True, subparser_help=True) self.maxDiff = None self.assertEqual(parser.format_help(), textwrap.dedent("""\ usage: PROG [-h] [--foo] bar COMMAND ... main description positional arguments: bar bar help optional arguments: -h, --help show this help message and exit --foo foo help commands: COMMAND 1 (1alias1, 1alias2) 1 help 2 2 help 3 3 help """)) # ============ # Groups tests # ============ class TestPositionalsGroups(TestCase): """Tests that order of group positionals matches construction order""" def test_nongroup_first(self): parser = ErrorRaisingArgumentParser() parser.add_argument('foo') group = parser.add_argument_group('g') group.add_argument('bar') parser.add_argument('baz') expected = NS(foo='1', bar='2', baz='3') result = parser.parse_args('1 2 3'.split()) self.assertEqual(expected, result) def test_group_first(self): parser = ErrorRaisingArgumentParser() group = parser.add_argument_group('xxx') group.add_argument('foo') parser.add_argument('bar') parser.add_argument('baz') expected = NS(foo='1', bar='2', baz='3') result = parser.parse_args('1 2 3'.split()) self.assertEqual(expected, result) def test_interleaved_groups(self): parser = ErrorRaisingArgumentParser() group = parser.add_argument_group('xxx') parser.add_argument('foo') group.add_argument('bar') parser.add_argument('baz') group = parser.add_argument_group('yyy') group.add_argument('frell') expected = NS(foo='1', bar='2', baz='3', frell='4') result = parser.parse_args('1 2 3 4'.split()) self.assertEqual(expected, result) # =================== # Parent parser tests # =================== class TestParentParsers(TestCase): """Tests that parsers can be created with parent parsers""" def assertArgumentParserError(self, *args, **kwargs): self.assertRaises(ArgumentParserError, *args, **kwargs) def setUp(self): super().setUp() self.wxyz_parent = ErrorRaisingArgumentParser(add_help=False) self.wxyz_parent.add_argument('--w') x_group = self.wxyz_parent.add_argument_group('x') x_group.add_argument('-y') self.wxyz_parent.add_argument('z') self.abcd_parent = ErrorRaisingArgumentParser(add_help=False) self.abcd_parent.add_argument('a') self.abcd_parent.add_argument('-b') c_group = self.abcd_parent.add_argument_group('c') c_group.add_argument('--d') self.w_parent = ErrorRaisingArgumentParser(add_help=False) self.w_parent.add_argument('--w') self.z_parent = ErrorRaisingArgumentParser(add_help=False) self.z_parent.add_argument('z') # parents with mutually exclusive groups self.ab_mutex_parent = ErrorRaisingArgumentParser(add_help=False) group = self.ab_mutex_parent.add_mutually_exclusive_group() group.add_argument('-a', action='store_true') group.add_argument('-b', action='store_true') self.main_program = os.path.basename(sys.argv[0]) def test_single_parent(self): parser = ErrorRaisingArgumentParser(parents=[self.wxyz_parent]) self.assertEqual(parser.parse_args('-y 1 2 --w 3'.split()), NS(w='3', y='1', z='2')) def test_single_parent_mutex(self): self._test_mutex_ab(self.ab_mutex_parent.parse_args) parser = ErrorRaisingArgumentParser(parents=[self.ab_mutex_parent]) self._test_mutex_ab(parser.parse_args) def test_single_granparent_mutex(self): parents = [self.ab_mutex_parent] parser = ErrorRaisingArgumentParser(add_help=False, parents=parents) parser = ErrorRaisingArgumentParser(parents=[parser]) self._test_mutex_ab(parser.parse_args) def _test_mutex_ab(self, parse_args): self.assertEqual(parse_args([]), NS(a=False, b=False)) self.assertEqual(parse_args(['-a']), NS(a=True, b=False)) self.assertEqual(parse_args(['-b']), NS(a=False, b=True)) self.assertArgumentParserError(parse_args, ['-a', '-b']) self.assertArgumentParserError(parse_args, ['-b', '-a']) self.assertArgumentParserError(parse_args, ['-c']) self.assertArgumentParserError(parse_args, ['-a', '-c']) self.assertArgumentParserError(parse_args, ['-b', '-c']) def test_multiple_parents(self): parents = [self.abcd_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) self.assertEqual(parser.parse_args('--d 1 --w 2 3 4'.split()), NS(a='3', b=None, d='1', w='2', y=None, z='4')) def test_multiple_parents_mutex(self): parents = [self.ab_mutex_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) self.assertEqual(parser.parse_args('-a --w 2 3'.split()), NS(a=True, b=False, w='2', y=None, z='3')) self.assertArgumentParserError( parser.parse_args, '-a --w 2 3 -b'.split()) self.assertArgumentParserError( parser.parse_args, '-a -b --w 2 3'.split()) def test_conflicting_parents(self): self.assertRaises( argparse.ArgumentError, argparse.ArgumentParser, parents=[self.w_parent, self.wxyz_parent]) def test_conflicting_parents_mutex(self): self.assertRaises( argparse.ArgumentError, argparse.ArgumentParser, parents=[self.abcd_parent, self.ab_mutex_parent]) def test_same_argument_name_parents(self): parents = [self.wxyz_parent, self.z_parent] parser = ErrorRaisingArgumentParser(parents=parents) self.assertEqual(parser.parse_args('1 2'.split()), NS(w=None, y=None, z='2')) def test_subparser_parents(self): parser = ErrorRaisingArgumentParser() subparsers = parser.add_subparsers() abcde_parser = subparsers.add_parser('bar', parents=[self.abcd_parent]) abcde_parser.add_argument('e') self.assertEqual(parser.parse_args('bar -b 1 --d 2 3 4'.split()), NS(a='3', b='1', d='2', e='4')) def test_subparser_parents_mutex(self): parser = ErrorRaisingArgumentParser() subparsers = parser.add_subparsers() parents = [self.ab_mutex_parent] abc_parser = subparsers.add_parser('foo', parents=parents) c_group = abc_parser.add_argument_group('c_group') c_group.add_argument('c') parents = [self.wxyz_parent, self.ab_mutex_parent] wxyzabe_parser = subparsers.add_parser('bar', parents=parents) wxyzabe_parser.add_argument('e') self.assertEqual(parser.parse_args('foo -a 4'.split()), NS(a=True, b=False, c='4')) self.assertEqual(parser.parse_args('bar -b --w 2 3 4'.split()), NS(a=False, b=True, w='2', y=None, z='3', e='4')) self.assertArgumentParserError( parser.parse_args, 'foo -a -b 4'.split()) self.assertArgumentParserError( parser.parse_args, 'bar -b -a 4'.split()) def test_parent_help(self): parents = [self.abcd_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) parser_help = parser.format_help() progname = self.main_program self.assertEqual(parser_help, textwrap.dedent('''\ usage: {}{}[-h] [-b B] [--d D] [--w W] [-y Y] a z positional arguments: a z optional arguments: -h, --help show this help message and exit -b B --w W c: --d D x: -y Y '''.format(progname, ' ' if progname else '' ))) def test_groups_parents(self): parent = ErrorRaisingArgumentParser(add_help=False) g = parent.add_argument_group(title='g', description='gd') g.add_argument('-w') g.add_argument('-x') m = parent.add_mutually_exclusive_group() m.add_argument('-y') m.add_argument('-z') parser = ErrorRaisingArgumentParser(parents=[parent]) self.assertRaises(ArgumentParserError, parser.parse_args, ['-y', 'Y', '-z', 'Z']) parser_help = parser.format_help() progname = self.main_program self.assertEqual(parser_help, textwrap.dedent('''\ usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z] optional arguments: -h, --help show this help message and exit -y Y -z Z g: gd -w W -x X '''.format(progname, ' ' if progname else '' ))) # ============================== # Mutually exclusive group tests # ============================== class TestMutuallyExclusiveGroupErrors(TestCase): def test_invalid_add_argument_group(self): parser = ErrorRaisingArgumentParser() raises = self.assertRaises raises(TypeError, parser.add_mutually_exclusive_group, title='foo') def test_invalid_add_argument(self): parser = ErrorRaisingArgumentParser() group = parser.add_mutually_exclusive_group() add_argument = group.add_argument raises = self.assertRaises raises(ValueError, add_argument, '--foo', required=True) raises(ValueError, add_argument, 'bar') raises(ValueError, add_argument, 'bar', nargs='+') raises(ValueError, add_argument, 'bar', nargs=1) raises(ValueError, add_argument, 'bar', nargs=argparse.PARSER) def test_help(self): parser = ErrorRaisingArgumentParser(prog='PROG') group1 = parser.add_mutually_exclusive_group() group1.add_argument('--foo', action='store_true') group1.add_argument('--bar', action='store_false') group2 = parser.add_mutually_exclusive_group() group2.add_argument('--soup', action='store_true') group2.add_argument('--nuts', action='store_false') expected = '''\ usage: PROG [-h] [--foo | --bar] [--soup | --nuts] optional arguments: -h, --help show this help message and exit --foo --bar --soup --nuts ''' self.assertEqual(parser.format_help(), textwrap.dedent(expected)) class MEMixin(object): def test_failures_when_not_required(self): parse_args = self.get_parser(required=False).parse_args error = ArgumentParserError for args_string in self.failures: self.assertRaises(error, parse_args, args_string.split()) def test_failures_when_required(self): parse_args = self.get_parser(required=True).parse_args error = ArgumentParserError for args_string in self.failures + ['']: self.assertRaises(error, parse_args, args_string.split()) def test_successes_when_not_required(self): parse_args = self.get_parser(required=False).parse_args successes = self.successes + self.successes_when_not_required for args_string, expected_ns in successes: actual_ns = parse_args(args_string.split()) self.assertEqual(actual_ns, expected_ns) def test_successes_when_required(self): parse_args = self.get_parser(required=True).parse_args for args_string, expected_ns in self.successes: actual_ns = parse_args(args_string.split()) self.assertEqual(actual_ns, expected_ns) def test_usage_when_not_required(self): format_usage = self.get_parser(required=False).format_usage expected_usage = self.usage_when_not_required self.assertEqual(format_usage(), textwrap.dedent(expected_usage)) def test_usage_when_required(self): format_usage = self.get_parser(required=True).format_usage expected_usage = self.usage_when_required self.assertEqual(format_usage(), textwrap.dedent(expected_usage)) def test_help_when_not_required(self): format_help = self.get_parser(required=False).format_help help = self.usage_when_not_required + self.help self.assertEqual(format_help(), textwrap.dedent(help)) def test_help_when_required(self): format_help = self.get_parser(required=True).format_help help = self.usage_when_required + self.help self.assertEqual(format_help(), textwrap.dedent(help)) class TestMutuallyExclusiveSimple(MEMixin, TestCase): def get_parser(self, required=None): parser = ErrorRaisingArgumentParser(prog='PROG') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('--bar', help='bar help') group.add_argument('--baz', nargs='?', const='Z', help='baz help') return parser failures = ['--bar X --baz Y', '--bar X --baz'] successes = [ ('--bar X', NS(bar='X', baz=None)), ('--bar X --bar Z', NS(bar='Z', baz=None)), ('--baz Y', NS(bar=None, baz='Y')), ('--baz', NS(bar=None, baz='Z')), ] successes_when_not_required = [ ('', NS(bar=None, baz=None)), ] usage_when_not_required = '''\ usage: PROG [-h] [--bar BAR | --baz [BAZ]] ''' usage_when_required = '''\ usage: PROG [-h] (--bar BAR | --baz [BAZ]) ''' help = '''\ optional arguments: -h, --help show this help message and exit --bar BAR bar help --baz [BAZ] baz help ''' class TestMutuallyExclusiveLong(MEMixin, TestCase): def get_parser(self, required=None): parser = ErrorRaisingArgumentParser(prog='PROG') parser.add_argument('--abcde', help='abcde help') parser.add_argument('--fghij', help='fghij help') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('--klmno', help='klmno help') group.add_argument('--pqrst', help='pqrst help') return parser failures = ['--klmno X --pqrst Y'] successes = [ ('--klmno X', NS(abcde=None, fghij=None, klmno='X', pqrst=None)), ('--abcde Y --klmno X', NS(abcde='Y', fghij=None, klmno='X', pqrst=None)), ('--pqrst X', NS(abcde=None, fghij=None, klmno=None, pqrst='X')), ('--pqrst X --fghij Y', NS(abcde=None, fghij='Y', klmno=None, pqrst='X')), ] successes_when_not_required = [ ('', NS(abcde=None, fghij=None, klmno=None, pqrst=None)), ] usage_when_not_required = '''\ usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ] [--klmno KLMNO | --pqrst PQRST] ''' usage_when_required = '''\ usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ] (--klmno KLMNO | --pqrst PQRST) ''' help = '''\ optional arguments: -h, --help show this help message and exit --abcde ABCDE abcde help --fghij FGHIJ fghij help --klmno KLMNO klmno help --pqrst PQRST pqrst help ''' class TestMutuallyExclusiveFirstSuppressed(MEMixin, TestCase): def get_parser(self, required): parser = ErrorRaisingArgumentParser(prog='PROG') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('-x', help=argparse.SUPPRESS) group.add_argument('-y', action='store_false', help='y help') return parser failures = ['-x X -y'] successes = [ ('-x X', NS(x='X', y=True)), ('-x X -x Y', NS(x='Y', y=True)), ('-y', NS(x=None, y=False)), ] successes_when_not_required = [ ('', NS(x=None, y=True)), ] usage_when_not_required = '''\ usage: PROG [-h] [-y] ''' usage_when_required = '''\ usage: PROG [-h] -y ''' help = '''\ optional arguments: -h, --help show this help message and exit -y y help ''' class TestMutuallyExclusiveManySuppressed(MEMixin, TestCase): def get_parser(self, required): parser = ErrorRaisingArgumentParser(prog='PROG') group = parser.add_mutually_exclusive_group(required=required) add = group.add_argument add('--spam', action='store_true', help=argparse.SUPPRESS) add('--badger', action='store_false', help=argparse.SUPPRESS) add('--bladder', help=argparse.SUPPRESS) return parser failures = [ '--spam --badger', '--badger --bladder B', '--bladder B --spam', ] successes = [ ('--spam', NS(spam=True, badger=True, bladder=None)), ('--badger', NS(spam=False, badger=False, bladder=None)), ('--bladder B', NS(spam=False, badger=True, bladder='B')), ('--spam --spam', NS(spam=True, badger=True, bladder=None)), ] successes_when_not_required = [ ('', NS(spam=False, badger=True, bladder=None)), ] usage_when_required = usage_when_not_required = '''\ usage: PROG [-h] ''' help = '''\ optional arguments: -h, --help show this help message and exit ''' class TestMutuallyExclusiveOptionalAndPositional(MEMixin, TestCase): def get_parser(self, required): parser = ErrorRaisingArgumentParser(prog='PROG') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('--foo', action='store_true', help='FOO') group.add_argument('--spam', help='SPAM') group.add_argument('badger', nargs='*', default='X', help='BADGER') return parser failures = [ '--foo --spam S', '--spam S X', 'X --foo', 'X Y Z --spam S', '--foo X Y', ] successes = [ ('--foo', NS(foo=True, spam=None, badger='X')), ('--spam S', NS(foo=False, spam='S', badger='X')), ('X', NS(foo=False, spam=None, badger=['X'])), ('X Y Z', NS(foo=False, spam=None, badger=['X', 'Y', 'Z'])), ] successes_when_not_required = [ ('', NS(foo=False, spam=None, badger='X')), ] usage_when_not_required = '''\ usage: PROG [-h] [--foo | --spam SPAM | badger [badger ...]] ''' usage_when_required = '''\ usage: PROG [-h] (--foo | --spam SPAM | badger [badger ...]) ''' help = '''\ positional arguments: badger BADGER optional arguments: -h, --help show this help message and exit --foo FOO --spam SPAM SPAM ''' class TestMutuallyExclusiveOptionalsMixed(MEMixin, TestCase): def get_parser(self, required): parser = ErrorRaisingArgumentParser(prog='PROG') parser.add_argument('-x', action='store_true', help='x help') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('-a', action='store_true', help='a help') group.add_argument('-b', action='store_true', help='b help') parser.add_argument('-y', action='store_true', help='y help') group.add_argument('-c', action='store_true', help='c help') return parser failures = ['-a -b', '-b -c', '-a -c', '-a -b -c'] successes = [ ('-a', NS(a=True, b=False, c=False, x=False, y=False)), ('-b', NS(a=False, b=True, c=False, x=False, y=False)), ('-c', NS(a=False, b=False, c=True, x=False, y=False)), ('-a -x', NS(a=True, b=False, c=False, x=True, y=False)), ('-y -b', NS(a=False, b=True, c=False, x=False, y=True)), ('-x -y -c', NS(a=False, b=False, c=True, x=True, y=True)), ] successes_when_not_required = [ ('', NS(a=False, b=False, c=False, x=False, y=False)), ('-x', NS(a=False, b=False, c=False, x=True, y=False)), ('-y', NS(a=False, b=False, c=False, x=False, y=True)), ] usage_when_required = usage_when_not_required = '''\ usage: PROG [-h] [-x] [-a] [-b] [-y] [-c] ''' help = '''\ optional arguments: -h, --help show this help message and exit -x x help -a a help -b b help -y y help -c c help ''' class TestMutuallyExclusiveInGroup(MEMixin, TestCase): def get_parser(self, required=None): parser = ErrorRaisingArgumentParser(prog='PROG') titled_group = parser.add_argument_group( title='Titled group', description='Group description') mutex_group = \ titled_group.add_mutually_exclusive_group(required=required) mutex_group.add_argument('--bar', help='bar help') mutex_group.add_argument('--baz', help='baz help') return parser failures = ['--bar X --baz Y', '--baz X --bar Y'] successes = [ ('--bar X', NS(bar='X', baz=None)), ('--baz Y', NS(bar=None, baz='Y')), ] successes_when_not_required = [ ('', NS(bar=None, baz=None)), ] usage_when_not_required = '''\ usage: PROG [-h] [--bar BAR | --baz BAZ] ''' usage_when_required = '''\ usage: PROG [-h] (--bar BAR | --baz BAZ) ''' help = '''\ optional arguments: -h, --help show this help message and exit Titled group: Group description --bar BAR bar help --baz BAZ baz help ''' class TestMutuallyExclusiveOptionalsAndPositionalsMixed(MEMixin, TestCase): def get_parser(self, required): parser = ErrorRaisingArgumentParser(prog='PROG') parser.add_argument('x', help='x help') parser.add_argument('-y', action='store_true', help='y help') group = parser.add_mutually_exclusive_group(required=required) group.add_argument('a', nargs='?', help='a help') group.add_argument('-b', action='store_true', help='b help') group.add_argument('-c', action='store_true', help='c help') return parser failures = ['X A -b', '-b -c', '-c X A'] successes = [ ('X A', NS(a='A', b=False, c=False, x='X', y=False)), ('X -b', NS(a=None, b=True, c=False, x='X', y=False)), ('X -c', NS(a=None, b=False, c=True, x='X', y=False)), ('X A -y', NS(a='A', b=False, c=False, x='X', y=True)), ('X -y -b', NS(a=None, b=True, c=False, x='X', y=True)), ] successes_when_not_required = [ ('X', NS(a=None, b=False, c=False, x='X', y=False)), ('X -y', NS(a=None, b=False, c=False, x='X', y=True)), ] usage_when_required = usage_when_not_required = '''\ usage: PROG [-h] [-y] [-b] [-c] x [a] ''' help = '''\ positional arguments: x x help a a help optional arguments: -h, --help show this help message and exit -y y help -b b help -c c help ''' # ================================================= # Mutually exclusive group in parent parser tests # ================================================= class MEPBase(object): def get_parser(self, required=None): parent = super(MEPBase, self).get_parser(required=required) parser = ErrorRaisingArgumentParser( prog=parent.prog, add_help=False, parents=[parent]) return parser class TestMutuallyExclusiveGroupErrorsParent( MEPBase, TestMutuallyExclusiveGroupErrors): pass class TestMutuallyExclusiveSimpleParent( MEPBase, TestMutuallyExclusiveSimple): pass class TestMutuallyExclusiveLongParent( MEPBase, TestMutuallyExclusiveLong): pass class TestMutuallyExclusiveFirstSuppressedParent( MEPBase, TestMutuallyExclusiveFirstSuppressed): pass class TestMutuallyExclusiveManySuppressedParent( MEPBase, TestMutuallyExclusiveManySuppressed): pass class TestMutuallyExclusiveOptionalAndPositionalParent( MEPBase, TestMutuallyExclusiveOptionalAndPositional): pass class TestMutuallyExclusiveOptionalsMixedParent( MEPBase, TestMutuallyExclusiveOptionalsMixed): pass class TestMutuallyExclusiveOptionalsAndPositionalsMixedParent( MEPBase, TestMutuallyExclusiveOptionalsAndPositionalsMixed): pass # ================= # Set default tests # ================= class TestSetDefaults(TestCase): def test_set_defaults_no_args(self): parser = ErrorRaisingArgumentParser() parser.set_defaults(x='foo') parser.set_defaults(y='bar', z=1) self.assertEqual(NS(x='foo', y='bar', z=1), parser.parse_args([])) self.assertEqual(NS(x='foo', y='bar', z=1), parser.parse_args([], NS())) self.assertEqual(NS(x='baz', y='bar', z=1), parser.parse_args([], NS(x='baz'))) self.assertEqual(NS(x='baz', y='bar', z=2), parser.parse_args([], NS(x='baz', z=2))) def test_set_defaults_with_args(self): parser = ErrorRaisingArgumentParser() parser.set_defaults(x='foo', y='bar') parser.add_argument('-x', default='xfoox') self.assertEqual(NS(x='xfoox', y='bar'), parser.parse_args([])) self.assertEqual(NS(x='xfoox', y='bar'), parser.parse_args([], NS())) self.assertEqual(NS(x='baz', y='bar'), parser.parse_args([], NS(x='baz'))) self.assertEqual(NS(x='1', y='bar'), parser.parse_args('-x 1'.split())) self.assertEqual(NS(x='1', y='bar'), parser.parse_args('-x 1'.split(), NS())) self.assertEqual(NS(x='1', y='bar'), parser.parse_args('-x 1'.split(), NS(x='baz'))) def test_set_defaults_subparsers(self): parser = ErrorRaisingArgumentParser() parser.set_defaults(x='foo') subparsers = parser.add_subparsers() parser_a = subparsers.add_parser('a') parser_a.set_defaults(y='bar') self.assertEqual(NS(x='foo', y='bar'), parser.parse_args('a'.split())) def test_set_defaults_parents(self): parent = ErrorRaisingArgumentParser(add_help=False) parent.set_defaults(x='foo') parser = ErrorRaisingArgumentParser(parents=[parent]) self.assertEqual(NS(x='foo'), parser.parse_args([])) def test_set_defaults_on_parent_and_subparser(self): parser = argparse.ArgumentParser() xparser = parser.add_subparsers().add_parser('X') parser.set_defaults(foo=1) xparser.set_defaults(foo=2) self.assertEqual(NS(foo=2), parser.parse_args(['X'])) def test_set_defaults_same_as_add_argument(self): parser = ErrorRaisingArgumentParser() parser.set_defaults(w='W', x='X', y='Y', z='Z') parser.add_argument('-w') parser.add_argument('-x', default='XX') parser.add_argument('y', nargs='?') parser.add_argument('z', nargs='?', default='ZZ') # defaults set previously self.assertEqual(NS(w='W', x='XX', y='Y', z='ZZ'), parser.parse_args([])) # reset defaults parser.set_defaults(w='WW', x='X', y='YY', z='Z') self.assertEqual(NS(w='WW', x='X', y='YY', z='Z'), parser.parse_args([])) def test_set_defaults_same_as_add_argument_group(self): parser = ErrorRaisingArgumentParser() parser.set_defaults(w='W', x='X', y='Y', z='Z') group = parser.add_argument_group('foo') group.add_argument('-w') group.add_argument('-x', default='XX') group.add_argument('y', nargs='?') group.add_argument('z', nargs='?', default='ZZ') # defaults set previously self.assertEqual(NS(w='W', x='XX', y='Y', z='ZZ'), parser.parse_args([])) # reset defaults parser.set_defaults(w='WW', x='X', y='YY', z='Z') self.assertEqual(NS(w='WW', x='X', y='YY', z='Z'), parser.parse_args([])) # ================= # Get default tests # ================= class TestGetDefault(TestCase): def test_get_default(self): parser = ErrorRaisingArgumentParser() self.assertIsNone(parser.get_default("foo")) self.assertIsNone(parser.get_default("bar")) parser.add_argument("--foo") self.assertIsNone(parser.get_default("foo")) self.assertIsNone(parser.get_default("bar")) parser.add_argument("--bar", type=int, default=42) self.assertIsNone(parser.get_default("foo")) self.assertEqual(42, parser.get_default("bar")) parser.set_defaults(foo="badger") self.assertEqual("badger", parser.get_default("foo")) self.assertEqual(42, parser.get_default("bar")) # ========================== # Namespace 'contains' tests # ========================== class TestNamespaceContainsSimple(TestCase): def test_empty(self): ns = argparse.Namespace() self.assertNotIn('', ns) self.assertNotIn('x', ns) def test_non_empty(self): ns = argparse.Namespace(x=1, y=2) self.assertNotIn('', ns) self.assertIn('x', ns) self.assertIn('y', ns) self.assertNotIn('xx', ns) self.assertNotIn('z', ns) # ===================== # Help formatting tests # ===================== class TestHelpFormattingMetaclass(type): def __init__(cls, name, bases, bodydict): if name == 'HelpTestCase': return class AddTests(object): def __init__(self, test_class, func_suffix, std_name): self.func_suffix = func_suffix self.std_name = std_name for test_func in [self.test_format, self.test_print, self.test_print_file]: test_name = '%s_%s' % (test_func.__name__, func_suffix) def test_wrapper(self, test_func=test_func): test_func(self) try: test_wrapper.__name__ = test_name except TypeError: pass setattr(test_class, test_name, test_wrapper) def _get_parser(self, tester): parser = argparse.ArgumentParser( *tester.parser_signature.args, **tester.parser_signature.kwargs) for argument_sig in getattr(tester, 'argument_signatures', []): parser.add_argument(*argument_sig.args, **argument_sig.kwargs) group_sigs = getattr(tester, 'argument_group_signatures', []) for group_sig, argument_sigs in group_sigs: group = parser.add_argument_group(*group_sig.args, **group_sig.kwargs) for argument_sig in argument_sigs: group.add_argument(*argument_sig.args, **argument_sig.kwargs) subparsers_sigs = getattr(tester, 'subparsers_signatures', []) if subparsers_sigs: subparsers = parser.add_subparsers() for subparser_sig in subparsers_sigs: subparsers.add_parser(*subparser_sig.args, **subparser_sig.kwargs) return parser def _test(self, tester, parser_text): expected_text = getattr(tester, self.func_suffix) expected_text = textwrap.dedent(expected_text) tester.assertEqual(expected_text, parser_text) def test_format(self, tester): parser = self._get_parser(tester) format = getattr(parser, 'format_%s' % self.func_suffix) self._test(tester, format()) def test_print(self, tester): parser = self._get_parser(tester) print_ = getattr(parser, 'print_%s' % self.func_suffix) old_stream = getattr(sys, self.std_name) setattr(sys, self.std_name, StdIOBuffer()) try: print_() parser_text = getattr(sys, self.std_name).getvalue() finally: setattr(sys, self.std_name, old_stream) self._test(tester, parser_text) def test_print_file(self, tester): parser = self._get_parser(tester) print_ = getattr(parser, 'print_%s' % self.func_suffix) sfile = StdIOBuffer() print_(sfile) parser_text = sfile.getvalue() self._test(tester, parser_text) # add tests for {format,print}_{usage,help} for func_suffix, std_name in [('usage', 'stdout'), ('help', 'stdout')]: AddTests(cls, func_suffix, std_name) bases = TestCase, HelpTestCase = TestHelpFormattingMetaclass('HelpTestCase', bases, {}) class TestHelpBiggerOptionals(HelpTestCase): """Make sure that argument help aligns when options are longer""" parser_signature = Sig(prog='PROG', description='DESCRIPTION', epilog='EPILOG') argument_signatures = [ Sig('-v', '--version', action='version', version='0.1'), Sig('-x', action='store_true', help='X HELP'), Sig('--y', help='Y HELP'), Sig('foo', help='FOO HELP'), Sig('bar', help='BAR HELP'), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-v] [-x] [--y Y] foo bar ''' help = usage + '''\ DESCRIPTION positional arguments: foo FOO HELP bar BAR HELP optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -x X HELP --y Y Y HELP EPILOG ''' version = '''\ 0.1 ''' class TestShortColumns(HelpTestCase): '''Test extremely small number of columns. TestCase prevents "COLUMNS" from being too small in the tests themselves, but we don't want any exceptions thrown in such cases. Only ugly representation. ''' def setUp(self): env = support.EnvironmentVarGuard() env.set("COLUMNS", '15') self.addCleanup(env.__exit__) parser_signature = TestHelpBiggerOptionals.parser_signature argument_signatures = TestHelpBiggerOptionals.argument_signatures argument_group_signatures = TestHelpBiggerOptionals.argument_group_signatures usage = '''\ usage: PROG [-h] [-v] [-x] [--y Y] foo bar ''' help = usage + '''\ DESCRIPTION positional arguments: foo FOO HELP bar BAR HELP optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -x X HELP --y Y Y HELP EPILOG ''' version = TestHelpBiggerOptionals.version class TestHelpBiggerOptionalGroups(HelpTestCase): """Make sure that argument help aligns when options are longer""" parser_signature = Sig(prog='PROG', description='DESCRIPTION', epilog='EPILOG') argument_signatures = [ Sig('-v', '--version', action='version', version='0.1'), Sig('-x', action='store_true', help='X HELP'), Sig('--y', help='Y HELP'), Sig('foo', help='FOO HELP'), Sig('bar', help='BAR HELP'), ] argument_group_signatures = [ (Sig('GROUP TITLE', description='GROUP DESCRIPTION'), [ Sig('baz', help='BAZ HELP'), Sig('-z', nargs='+', help='Z HELP')]), ] usage = '''\ usage: PROG [-h] [-v] [-x] [--y Y] [-z Z [Z ...]] foo bar baz ''' help = usage + '''\ DESCRIPTION positional arguments: foo FOO HELP bar BAR HELP optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -x X HELP --y Y Y HELP GROUP TITLE: GROUP DESCRIPTION baz BAZ HELP -z Z [Z ...] Z HELP EPILOG ''' version = '''\ 0.1 ''' class TestHelpBiggerPositionals(HelpTestCase): """Make sure that help aligns when arguments are longer""" parser_signature = Sig(usage='USAGE', description='DESCRIPTION') argument_signatures = [ Sig('-x', action='store_true', help='X HELP'), Sig('--y', help='Y HELP'), Sig('ekiekiekifekang', help='EKI HELP'), Sig('bar', help='BAR HELP'), ] argument_group_signatures = [] usage = '''\ usage: USAGE ''' help = usage + '''\ DESCRIPTION positional arguments: ekiekiekifekang EKI HELP bar BAR HELP optional arguments: -h, --help show this help message and exit -x X HELP --y Y Y HELP ''' version = '' class TestHelpReformatting(HelpTestCase): """Make sure that text after short names starts on the first line""" parser_signature = Sig( prog='PROG', description=' oddly formatted\n' 'description\n' '\n' 'that is so long that it should go onto multiple ' 'lines when wrapped') argument_signatures = [ Sig('-x', metavar='XX', help='oddly\n' ' formatted -x help'), Sig('y', metavar='yyy', help='normal y help'), ] argument_group_signatures = [ (Sig('title', description='\n' ' oddly formatted group\n' '\n' 'description'), [Sig('-a', action='store_true', help=' oddly \n' 'formatted -a help \n' ' again, so long that it should be wrapped over ' 'multiple lines')]), ] usage = '''\ usage: PROG [-h] [-x XX] [-a] yyy ''' help = usage + '''\ oddly formatted description that is so long that it should go onto \ multiple lines when wrapped positional arguments: yyy normal y help optional arguments: -h, --help show this help message and exit -x XX oddly formatted -x help title: oddly formatted group description -a oddly formatted -a help again, so long that it should \ be wrapped over multiple lines ''' version = '' class TestHelpWrappingShortNames(HelpTestCase): """Make sure that text after short names starts on the first line""" parser_signature = Sig(prog='PROG', description= 'D\nD' * 30) argument_signatures = [ Sig('-x', metavar='XX', help='XHH HX' * 20), Sig('y', metavar='yyy', help='YH YH' * 20), ] argument_group_signatures = [ (Sig('ALPHAS'), [ Sig('-a', action='store_true', help='AHHH HHA' * 10)]), ] usage = '''\ usage: PROG [-h] [-x XX] [-a] yyy ''' help = usage + '''\ D DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD \ DD DD DD DD DD DD DD D positional arguments: yyy YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH \ YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH optional arguments: -h, --help show this help message and exit -x XX XHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH \ HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HX ALPHAS: -a AHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH \ HHAAHHH HHAAHHH HHAAHHH HHA ''' version = '' class TestHelpWrappingLongNames(HelpTestCase): """Make sure that text after long names starts on the next line""" parser_signature = Sig(usage='USAGE', description= 'D D' * 30) argument_signatures = [ Sig('-v', '--version', action='version', version='V V' * 30), Sig('-x', metavar='X' * 25, help='XH XH' * 20), Sig('y', metavar='y' * 25, help='YH YH' * 20), ] argument_group_signatures = [ (Sig('ALPHAS'), [ Sig('-a', metavar='A' * 25, help='AH AH' * 20), Sig('z', metavar='z' * 25, help='ZH ZH' * 20)]), ] usage = '''\ usage: USAGE ''' help = usage + '''\ D DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD \ DD DD DD DD DD DD DD D positional arguments: yyyyyyyyyyyyyyyyyyyyyyyyy YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH \ YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -x XXXXXXXXXXXXXXXXXXXXXXXXX XH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH \ XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XH ALPHAS: -a AAAAAAAAAAAAAAAAAAAAAAAAA AH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH \ AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AH zzzzzzzzzzzzzzzzzzzzzzzzz ZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH \ ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZH ''' version = '''\ V VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV \ VV VV VV VV VV VV VV V ''' class TestHelpUsage(HelpTestCase): """Test basic usage messages""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-w', nargs='+', help='w'), Sig('-x', nargs='*', help='x'), Sig('a', help='a'), Sig('b', help='b', nargs=2), Sig('c', help='c', nargs='?'), ] argument_group_signatures = [ (Sig('group'), [ Sig('-y', nargs='?', help='y'), Sig('-z', nargs=3, help='z'), Sig('d', help='d', nargs='*'), Sig('e', help='e', nargs='+'), ]) ] usage = '''\ usage: PROG [-h] [-w W [W ...]] [-x [X [X ...]]] [-y [Y]] [-z Z Z Z] a b b [c] [d [d ...]] e [e ...] ''' help = usage + '''\ positional arguments: a a b b c c optional arguments: -h, --help show this help message and exit -w W [W ...] w -x [X [X ...]] x group: -y [Y] y -z Z Z Z z d d e e ''' version = '' class TestHelpOnlyUserGroups(HelpTestCase): """Test basic usage messages""" parser_signature = Sig(prog='PROG', add_help=False) argument_signatures = [] argument_group_signatures = [ (Sig('xxxx'), [ Sig('-x', help='x'), Sig('a', help='a'), ]), (Sig('yyyy'), [ Sig('b', help='b'), Sig('-y', help='y'), ]), ] usage = '''\ usage: PROG [-x X] [-y Y] a b ''' help = usage + '''\ xxxx: -x X x a a yyyy: b b -y Y y ''' version = '' class TestHelpUsageLongProg(HelpTestCase): """Test usage messages where the prog is long""" parser_signature = Sig(prog='P' * 60) argument_signatures = [ Sig('-w', metavar='W'), Sig('-x', metavar='X'), Sig('a'), Sig('b'), ] argument_group_signatures = [] usage = '''\ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP [-h] [-w W] [-x X] a b ''' help = usage + '''\ positional arguments: a b optional arguments: -h, --help show this help message and exit -w W -x X ''' version = '' class TestHelpUsageLongProgOptionsWrap(HelpTestCase): """Test usage messages where the prog is long and the optionals wrap""" parser_signature = Sig(prog='P' * 60) argument_signatures = [ Sig('-w', metavar='W' * 25), Sig('-x', metavar='X' * 25), Sig('-y', metavar='Y' * 25), Sig('-z', metavar='Z' * 25), Sig('a'), Sig('b'), ] argument_group_signatures = [] usage = '''\ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] \ [-x XXXXXXXXXXXXXXXXXXXXXXXXX] [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ] a b ''' help = usage + '''\ positional arguments: a b optional arguments: -h, --help show this help message and exit -w WWWWWWWWWWWWWWWWWWWWWWWWW -x XXXXXXXXXXXXXXXXXXXXXXXXX -y YYYYYYYYYYYYYYYYYYYYYYYYY -z ZZZZZZZZZZZZZZZZZZZZZZZZZ ''' version = '' class TestHelpUsageLongProgPositionalsWrap(HelpTestCase): """Test usage messages where the prog is long and the positionals wrap""" parser_signature = Sig(prog='P' * 60, add_help=False) argument_signatures = [ Sig('a' * 25), Sig('b' * 25), Sig('c' * 25), ] argument_group_signatures = [] usage = '''\ usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc ''' help = usage + '''\ positional arguments: aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc ''' version = '' class TestHelpUsageOptionalsWrap(HelpTestCase): """Test usage messages where the optionals wrap""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-w', metavar='W' * 25), Sig('-x', metavar='X' * 25), Sig('-y', metavar='Y' * 25), Sig('-z', metavar='Z' * 25), Sig('a'), Sig('b'), Sig('c'), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] \ [-x XXXXXXXXXXXXXXXXXXXXXXXXX] [-y YYYYYYYYYYYYYYYYYYYYYYYYY] \ [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ] a b c ''' help = usage + '''\ positional arguments: a b c optional arguments: -h, --help show this help message and exit -w WWWWWWWWWWWWWWWWWWWWWWWWW -x XXXXXXXXXXXXXXXXXXXXXXXXX -y YYYYYYYYYYYYYYYYYYYYYYYYY -z ZZZZZZZZZZZZZZZZZZZZZZZZZ ''' version = '' class TestHelpUsagePositionalsWrap(HelpTestCase): """Test usage messages where the positionals wrap""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-x'), Sig('-y'), Sig('-z'), Sig('a' * 25), Sig('b' * 25), Sig('c' * 25), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-x X] [-y Y] [-z Z] aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc ''' help = usage + '''\ positional arguments: aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc optional arguments: -h, --help show this help message and exit -x X -y Y -z Z ''' version = '' class TestHelpUsageOptionalsPositionalsWrap(HelpTestCase): """Test usage messages where the optionals and positionals wrap""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-x', metavar='X' * 25), Sig('-y', metavar='Y' * 25), Sig('-z', metavar='Z' * 25), Sig('a' * 25), Sig('b' * 25), Sig('c' * 25), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-x XXXXXXXXXXXXXXXXXXXXXXXXX] \ [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ] aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc ''' help = usage + '''\ positional arguments: aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc optional arguments: -h, --help show this help message and exit -x XXXXXXXXXXXXXXXXXXXXXXXXX -y YYYYYYYYYYYYYYYYYYYYYYYYY -z ZZZZZZZZZZZZZZZZZZZZZZZZZ ''' version = '' class TestHelpUsageOptionalsOnlyWrap(HelpTestCase): """Test usage messages where there are only optionals and they wrap""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-x', metavar='X' * 25), Sig('-y', metavar='Y' * 25), Sig('-z', metavar='Z' * 25), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-x XXXXXXXXXXXXXXXXXXXXXXXXX] \ [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ] ''' help = usage + '''\ optional arguments: -h, --help show this help message and exit -x XXXXXXXXXXXXXXXXXXXXXXXXX -y YYYYYYYYYYYYYYYYYYYYYYYYY -z ZZZZZZZZZZZZZZZZZZZZZZZZZ ''' version = '' class TestHelpUsagePositionalsOnlyWrap(HelpTestCase): """Test usage messages where there are only positionals and they wrap""" parser_signature = Sig(prog='PROG', add_help=False) argument_signatures = [ Sig('a' * 25), Sig('b' * 25), Sig('c' * 25), ] argument_group_signatures = [] usage = '''\ usage: PROG aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc ''' help = usage + '''\ positional arguments: aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccccc ''' version = '' class TestHelpVariableExpansion(HelpTestCase): """Test that variables are expanded properly in help messages""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-x', type=int, help='x %(prog)s %(default)s %(type)s %%'), Sig('-y', action='store_const', default=42, const='XXX', help='y %(prog)s %(default)s %(const)s'), Sig('--foo', choices='abc', help='foo %(prog)s %(default)s %(choices)s'), Sig('--bar', default='baz', choices=[1, 2], metavar='BBB', help='bar %(prog)s %(default)s %(dest)s'), Sig('spam', help='spam %(prog)s %(default)s'), Sig('badger', default=0.5, help='badger %(prog)s %(default)s'), ] argument_group_signatures = [ (Sig('group'), [ Sig('-a', help='a %(prog)s %(default)s'), Sig('-b', default=-1, help='b %(prog)s %(default)s'), ]) ] usage = ('''\ usage: PROG [-h] [-x X] [-y] [--foo {a,b,c}] [--bar BBB] [-a A] [-b B] spam badger ''') help = usage + '''\ positional arguments: spam spam PROG None badger badger PROG 0.5 optional arguments: -h, --help show this help message and exit -x X x PROG None int % -y y PROG 42 XXX --foo {a,b,c} foo PROG None a, b, c --bar BBB bar PROG baz bar group: -a A a PROG None -b B b PROG -1 ''' version = '' class TestHelpVariableExpansionUsageSupplied(HelpTestCase): """Test that variables are expanded properly when usage= is present""" parser_signature = Sig(prog='PROG', usage='%(prog)s FOO') argument_signatures = [] argument_group_signatures = [] usage = ('''\ usage: PROG FOO ''') help = usage + '''\ optional arguments: -h, --help show this help message and exit ''' version = '' class TestHelpVariableExpansionNoArguments(HelpTestCase): """Test that variables are expanded properly with no arguments""" parser_signature = Sig(prog='PROG', add_help=False) argument_signatures = [] argument_group_signatures = [] usage = ('''\ usage: PROG ''') help = usage version = '' class TestHelpSuppressUsage(HelpTestCase): """Test that items can be suppressed in usage messages""" parser_signature = Sig(prog='PROG', usage=argparse.SUPPRESS) argument_signatures = [ Sig('--foo', help='foo help'), Sig('spam', help='spam help'), ] argument_group_signatures = [] help = '''\ positional arguments: spam spam help optional arguments: -h, --help show this help message and exit --foo FOO foo help ''' usage = '' version = '' class TestHelpSuppressOptional(HelpTestCase): """Test that optional arguments can be suppressed in help messages""" parser_signature = Sig(prog='PROG', add_help=False) argument_signatures = [ Sig('--foo', help=argparse.SUPPRESS), Sig('spam', help='spam help'), ] argument_group_signatures = [] usage = '''\ usage: PROG spam ''' help = usage + '''\ positional arguments: spam spam help ''' version = '' class TestHelpSuppressOptionalGroup(HelpTestCase): """Test that optional groups can be suppressed in help messages""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('--foo', help='foo help'), Sig('spam', help='spam help'), ] argument_group_signatures = [ (Sig('group'), [Sig('--bar', help=argparse.SUPPRESS)]), ] usage = '''\ usage: PROG [-h] [--foo FOO] spam ''' help = usage + '''\ positional arguments: spam spam help optional arguments: -h, --help show this help message and exit --foo FOO foo help ''' version = '' class TestHelpSuppressPositional(HelpTestCase): """Test that positional arguments can be suppressed in help messages""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('--foo', help='foo help'), Sig('spam', help=argparse.SUPPRESS), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [--foo FOO] ''' help = usage + '''\ optional arguments: -h, --help show this help message and exit --foo FOO foo help ''' version = '' class TestHelpRequiredOptional(HelpTestCase): """Test that required options don't look optional""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('--foo', required=True, help='foo help'), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] --foo FOO ''' help = usage + '''\ optional arguments: -h, --help show this help message and exit --foo FOO foo help ''' version = '' class TestHelpAlternatePrefixChars(HelpTestCase): """Test that options display with different prefix characters""" parser_signature = Sig(prog='PROG', prefix_chars='^;', add_help=False) argument_signatures = [ Sig('^^foo', action='store_true', help='foo help'), Sig(';b', ';;bar', help='bar help'), ] argument_group_signatures = [] usage = '''\ usage: PROG [^^foo] [;b BAR] ''' help = usage + '''\ optional arguments: ^^foo foo help ;b BAR, ;;bar BAR bar help ''' version = '' class TestHelpNoHelpOptional(HelpTestCase): """Test that the --help argument can be suppressed help messages""" parser_signature = Sig(prog='PROG', add_help=False) argument_signatures = [ Sig('--foo', help='foo help'), Sig('spam', help='spam help'), ] argument_group_signatures = [] usage = '''\ usage: PROG [--foo FOO] spam ''' help = usage + '''\ positional arguments: spam spam help optional arguments: --foo FOO foo help ''' version = '' class TestHelpNone(HelpTestCase): """Test that no errors occur if no help is specified""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('--foo'), Sig('spam'), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [--foo FOO] spam ''' help = usage + '''\ positional arguments: spam optional arguments: -h, --help show this help message and exit --foo FOO ''' version = '' class TestHelpTupleMetavar(HelpTestCase): """Test specifying metavar as a tuple""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-w', help='w', nargs='+', metavar=('W1', 'W2')), Sig('-x', help='x', nargs='*', metavar=('X1', 'X2')), Sig('-y', help='y', nargs=3, metavar=('Y1', 'Y2', 'Y3')), Sig('-z', help='z', nargs='?', metavar=('Z1', )), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] \ [-z [Z1]] ''' help = usage + '''\ optional arguments: -h, --help show this help message and exit -w W1 [W2 ...] w -x [X1 [X2 ...]] x -y Y1 Y2 Y3 y -z [Z1] z ''' version = '' class TestHelpRawText(HelpTestCase): """Test the RawTextHelpFormatter""" parser_signature = Sig( prog='PROG', formatter_class=argparse.RawTextHelpFormatter, description='Keep the formatting\n' ' exactly as it is written\n' '\n' 'here\n') argument_signatures = [ Sig('--foo', help=' foo help should also\n' 'appear as given here'), Sig('spam', help='spam help'), ] argument_group_signatures = [ (Sig('title', description=' This text\n' ' should be indented\n' ' exactly like it is here\n'), [Sig('--bar', help='bar help')]), ] usage = '''\ usage: PROG [-h] [--foo FOO] [--bar BAR] spam ''' help = usage + '''\ Keep the formatting exactly as it is written here positional arguments: spam spam help optional arguments: -h, --help show this help message and exit --foo FOO foo help should also appear as given here title: This text should be indented exactly like it is here --bar BAR bar help ''' version = '' class TestHelpRawDescription(HelpTestCase): """Test the RawTextHelpFormatter""" parser_signature = Sig( prog='PROG', formatter_class=argparse.RawDescriptionHelpFormatter, description='Keep the formatting\n' ' exactly as it is written\n' '\n' 'here\n') argument_signatures = [ Sig('--foo', help=' foo help should not\n' ' retain this odd formatting'), Sig('spam', help='spam help'), ] argument_group_signatures = [ (Sig('title', description=' This text\n' ' should be indented\n' ' exactly like it is here\n'), [Sig('--bar', help='bar help')]), ] usage = '''\ usage: PROG [-h] [--foo FOO] [--bar BAR] spam ''' help = usage + '''\ Keep the formatting exactly as it is written here positional arguments: spam spam help optional arguments: -h, --help show this help message and exit --foo FOO foo help should not retain this odd formatting title: This text should be indented exactly like it is here --bar BAR bar help ''' version = '' class TestHelpArgumentDefaults(HelpTestCase): """Test the ArgumentDefaultsHelpFormatter""" parser_signature = Sig( prog='PROG', formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='description') argument_signatures = [ Sig('--foo', help='foo help - oh and by the way, %(default)s'), Sig('--bar', action='store_true', help='bar help'), Sig('spam', help='spam help'), Sig('badger', nargs='?', default='wooden', help='badger help'), ] argument_group_signatures = [ (Sig('title', description='description'), [Sig('--baz', type=int, default=42, help='baz help')]), ] usage = '''\ usage: PROG [-h] [--foo FOO] [--bar] [--baz BAZ] spam [badger] ''' help = usage + '''\ description positional arguments: spam spam help badger badger help (default: wooden) optional arguments: -h, --help show this help message and exit --foo FOO foo help - oh and by the way, None --bar bar help (default: False) title: description --baz BAZ baz help (default: 42) ''' version = '' class TestHelpVersionAction(HelpTestCase): """Test the default help for the version action""" parser_signature = Sig(prog='PROG', description='description') argument_signatures = [Sig('-V', '--version', action='version', version='3.6')] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-V] ''' help = usage + '''\ description optional arguments: -h, --help show this help message and exit -V, --version show program's version number and exit ''' version = '' class TestHelpVersionActionSuppress(HelpTestCase): """Test that the --version argument can be suppressed in help messages""" parser_signature = Sig(prog='PROG') argument_signatures = [ Sig('-v', '--version', action='version', version='1.0', help=argparse.SUPPRESS), Sig('--foo', help='foo help'), Sig('spam', help='spam help'), ] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [--foo FOO] spam ''' help = usage + '''\ positional arguments: spam spam help optional arguments: -h, --help show this help message and exit --foo FOO foo help ''' class TestHelpSubparsersOrdering(HelpTestCase): """Test ordering of subcommands in help matches the code""" parser_signature = Sig(prog='PROG', description='display some subcommands') argument_signatures = [Sig('-v', '--version', action='version', version='0.1')] subparsers_signatures = [Sig(name=name) for name in ('a', 'b', 'c', 'd', 'e')] usage = '''\ usage: PROG [-h] [-v] {a,b,c,d,e} ... ''' help = usage + '''\ display some subcommands positional arguments: {a,b,c,d,e} optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit ''' version = '''\ 0.1 ''' class TestHelpSubparsersWithHelpOrdering(HelpTestCase): """Test ordering of subcommands in help matches the code""" parser_signature = Sig(prog='PROG', description='display some subcommands') argument_signatures = [Sig('-v', '--version', action='version', version='0.1')] subcommand_data = (('a', 'a subcommand help'), ('b', 'b subcommand help'), ('c', 'c subcommand help'), ('d', 'd subcommand help'), ('e', 'e subcommand help'), ) subparsers_signatures = [Sig(name=name, help=help) for name, help in subcommand_data] usage = '''\ usage: PROG [-h] [-v] {a,b,c,d,e} ... ''' help = usage + '''\ display some subcommands positional arguments: {a,b,c,d,e} a a subcommand help b b subcommand help c c subcommand help d d subcommand help e e subcommand help optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit ''' version = '''\ 0.1 ''' class TestHelpMetavarTypeFormatter(HelpTestCase): """""" def custom_type(string): return string parser_signature = Sig(prog='PROG', description='description', formatter_class=argparse.MetavarTypeHelpFormatter) argument_signatures = [Sig('a', type=int), Sig('-b', type=custom_type), Sig('-c', type=float, metavar='SOME FLOAT')] argument_group_signatures = [] usage = '''\ usage: PROG [-h] [-b custom_type] [-c SOME FLOAT] int ''' help = usage + '''\ description positional arguments: int optional arguments: -h, --help show this help message and exit -b custom_type -c SOME FLOAT ''' version = '' # ===================================== # Optional/Positional constructor tests # ===================================== class TestInvalidArgumentConstructors(TestCase): """Test a bunch of invalid Argument constructors""" def assertTypeError(self, *args, **kwargs): parser = argparse.ArgumentParser() self.assertRaises(TypeError, parser.add_argument, *args, **kwargs) def assertValueError(self, *args, **kwargs): parser = argparse.ArgumentParser() self.assertRaises(ValueError, parser.add_argument, *args, **kwargs) def test_invalid_keyword_arguments(self): self.assertTypeError('-x', bar=None) self.assertTypeError('-y', callback='foo') self.assertTypeError('-y', callback_args=()) self.assertTypeError('-y', callback_kwargs={}) def test_missing_destination(self): self.assertTypeError() for action in ['append', 'store']: self.assertTypeError(action=action) def test_invalid_option_strings(self): self.assertValueError('--') self.assertValueError('---') def test_invalid_type(self): self.assertValueError('--foo', type='int') self.assertValueError('--foo', type=(int, float)) def test_invalid_action(self): self.assertValueError('-x', action='foo') self.assertValueError('foo', action='baz') self.assertValueError('--foo', action=('store', 'append')) parser = argparse.ArgumentParser() with self.assertRaises(ValueError) as cm: parser.add_argument("--foo", action="store-true") self.assertIn('unknown action', str(cm.exception)) def test_multiple_dest(self): parser = argparse.ArgumentParser() parser.add_argument(dest='foo') with self.assertRaises(ValueError) as cm: parser.add_argument('bar', dest='baz') self.assertIn('dest supplied twice for positional argument', str(cm.exception)) def test_no_argument_actions(self): for action in ['store_const', 'store_true', 'store_false', 'append_const', 'count']: for attrs in [dict(type=int), dict(nargs='+'), dict(choices='ab')]: self.assertTypeError('-x', action=action, **attrs) def test_no_argument_no_const_actions(self): # options with zero arguments for action in ['store_true', 'store_false', 'count']: # const is always disallowed self.assertTypeError('-x', const='foo', action=action) # nargs is always disallowed self.assertTypeError('-x', nargs='*', action=action) def test_more_than_one_argument_actions(self): for action in ['store', 'append']: # nargs=0 is disallowed self.assertValueError('-x', nargs=0, action=action) self.assertValueError('spam', nargs=0, action=action) # const is disallowed with non-optional arguments for nargs in [1, '*', '+']: self.assertValueError('-x', const='foo', nargs=nargs, action=action) self.assertValueError('spam', const='foo', nargs=nargs, action=action) def test_required_const_actions(self): for action in ['store_const', 'append_const']: # nargs is always disallowed self.assertTypeError('-x', nargs='+', action=action) def test_parsers_action_missing_params(self): self.assertTypeError('command', action='parsers') self.assertTypeError('command', action='parsers', prog='PROG') self.assertTypeError('command', action='parsers', parser_class=argparse.ArgumentParser) def test_required_positional(self): self.assertTypeError('foo', required=True) def test_user_defined_action(self): class Success(Exception): pass class Action(object): def __init__(self, option_strings, dest, const, default, required=False): if dest == 'spam': if const is Success: if default is Success: raise Success() def __call__(self, *args, **kwargs): pass parser = argparse.ArgumentParser() self.assertRaises(Success, parser.add_argument, '--spam', action=Action, default=Success, const=Success) self.assertRaises(Success, parser.add_argument, 'spam', action=Action, default=Success, const=Success) # ================================ # Actions returned by add_argument # ================================ class TestActionsReturned(TestCase): def test_dest(self): parser = argparse.ArgumentParser() action = parser.add_argument('--foo') self.assertEqual(action.dest, 'foo') action = parser.add_argument('-b', '--bar') self.assertEqual(action.dest, 'bar') action = parser.add_argument('-x', '-y') self.assertEqual(action.dest, 'x') def test_misc(self): parser = argparse.ArgumentParser() action = parser.add_argument('--foo', nargs='?', const=42, default=84, type=int, choices=[1, 2], help='FOO', metavar='BAR', dest='baz') self.assertEqual(action.nargs, '?') self.assertEqual(action.const, 42) self.assertEqual(action.default, 84) self.assertEqual(action.type, int) self.assertEqual(action.choices, [1, 2]) self.assertEqual(action.help, 'FOO') self.assertEqual(action.metavar, 'BAR') self.assertEqual(action.dest, 'baz') # ================================ # Argument conflict handling tests # ================================ class TestConflictHandling(TestCase): def test_bad_type(self): self.assertRaises(ValueError, argparse.ArgumentParser, conflict_handler='foo') def test_conflict_error(self): parser = argparse.ArgumentParser() parser.add_argument('-x') self.assertRaises(argparse.ArgumentError, parser.add_argument, '-x') parser.add_argument('--spam') self.assertRaises(argparse.ArgumentError, parser.add_argument, '--spam') def test_resolve_error(self): get_parser = argparse.ArgumentParser parser = get_parser(prog='PROG', conflict_handler='resolve') parser.add_argument('-x', help='OLD X') parser.add_argument('-x', help='NEW X') self.assertEqual(parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [-x X] optional arguments: -h, --help show this help message and exit -x X NEW X ''')) parser.add_argument('--spam', metavar='OLD_SPAM') parser.add_argument('--spam', metavar='NEW_SPAM') self.assertEqual(parser.format_help(), textwrap.dedent('''\ usage: PROG [-h] [-x X] [--spam NEW_SPAM] optional arguments: -h, --help show this help message and exit -x X NEW X --spam NEW_SPAM ''')) # ============================= # Help and Version option tests # ============================= class TestOptionalsHelpVersionActions(TestCase): """Test the help and version actions""" def assertPrintHelpExit(self, parser, args_str): with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(args_str.split()) self.assertEqual(parser.format_help(), cm.exception.stdout) def assertArgumentParserError(self, parser, *args): self.assertRaises(ArgumentParserError, parser.parse_args, args) def test_version(self): parser = ErrorRaisingArgumentParser() parser.add_argument('-v', '--version', action='version', version='1.0') self.assertPrintHelpExit(parser, '-h') self.assertPrintHelpExit(parser, '--help') self.assertRaises(AttributeError, getattr, parser, 'format_version') def test_version_format(self): parser = ErrorRaisingArgumentParser(prog='PPP') parser.add_argument('-v', '--version', action='version', version='%(prog)s 3.5') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(['-v']) self.assertEqual('PPP 3.5\n', cm.exception.stdout) def test_version_no_help(self): parser = ErrorRaisingArgumentParser(add_help=False) parser.add_argument('-v', '--version', action='version', version='1.0') self.assertArgumentParserError(parser, '-h') self.assertArgumentParserError(parser, '--help') self.assertRaises(AttributeError, getattr, parser, 'format_version') def test_version_action(self): parser = ErrorRaisingArgumentParser(prog='XXX') parser.add_argument('-V', action='version', version='%(prog)s 3.7') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(['-V']) self.assertEqual('XXX 3.7\n', cm.exception.stdout) def test_no_help(self): parser = ErrorRaisingArgumentParser(add_help=False) self.assertArgumentParserError(parser, '-h') self.assertArgumentParserError(parser, '--help') self.assertArgumentParserError(parser, '-v') self.assertArgumentParserError(parser, '--version') def test_alternate_help_version(self): parser = ErrorRaisingArgumentParser() parser.add_argument('-x', action='help') parser.add_argument('-y', action='version') self.assertPrintHelpExit(parser, '-x') self.assertArgumentParserError(parser, '-v') self.assertArgumentParserError(parser, '--version') self.assertRaises(AttributeError, getattr, parser, 'format_version') def test_help_version_extra_arguments(self): parser = ErrorRaisingArgumentParser() parser.add_argument('--version', action='version', version='1.0') parser.add_argument('-x', action='store_true') parser.add_argument('y') # try all combinations of valid prefixes and suffixes valid_prefixes = ['', '-x', 'foo', '-x bar', 'baz -x'] valid_suffixes = valid_prefixes + ['--bad-option', 'foo bar baz'] for prefix in valid_prefixes: for suffix in valid_suffixes: format = '%s %%s %s' % (prefix, suffix) self.assertPrintHelpExit(parser, format % '-h') self.assertPrintHelpExit(parser, format % '--help') self.assertRaises(AttributeError, getattr, parser, 'format_version') # ====================== # str() and repr() tests # ====================== class TestStrings(TestCase): """Test str() and repr() on Optionals and Positionals""" def assertStringEqual(self, obj, result_string): for func in [str, repr]: self.assertEqual(func(obj), result_string) def test_optional(self): option = argparse.Action( option_strings=['--foo', '-a', '-b'], dest='b', type='int', nargs='+', default=42, choices=[1, 2, 3], help='HELP', metavar='METAVAR') string = ( "Action(option_strings=['--foo', '-a', '-b'], dest='b', " "nargs='+', const=None, default=42, type='int', " "choices=[1, 2, 3], help='HELP', metavar='METAVAR')") self.assertStringEqual(option, string) def test_argument(self): argument = argparse.Action( option_strings=[], dest='x', type=float, nargs='?', default=2.5, choices=[0.5, 1.5, 2.5], help='H HH H', metavar='MV MV MV') string = ( "Action(option_strings=[], dest='x', nargs='?', " "const=None, default=2.5, type=%r, choices=[0.5, 1.5, 2.5], " "help='H HH H', metavar='MV MV MV')" % float) self.assertStringEqual(argument, string) def test_namespace(self): ns = argparse.Namespace(foo=42, bar='spam') string = "Namespace(bar='spam', foo=42)" self.assertStringEqual(ns, string) def test_namespace_starkwargs_notidentifier(self): ns = argparse.Namespace(**{'"': 'quote'}) string = """Namespace(**{'"': 'quote'})""" self.assertStringEqual(ns, string) def test_namespace_kwargs_and_starkwargs_notidentifier(self): ns = argparse.Namespace(a=1, **{'"': 'quote'}) string = """Namespace(a=1, **{'"': 'quote'})""" self.assertStringEqual(ns, string) def test_namespace_starkwargs_identifier(self): ns = argparse.Namespace(**{'valid': True}) string = "Namespace(valid=True)" self.assertStringEqual(ns, string) def test_parser(self): parser = argparse.ArgumentParser(prog='PROG') string = ( "ArgumentParser(prog='PROG', usage=None, description=None, " "formatter_class=%r, conflict_handler='error', " "add_help=True)" % argparse.HelpFormatter) self.assertStringEqual(parser, string) # =============== # Namespace tests # =============== class TestNamespace(TestCase): def test_constructor(self): ns = argparse.Namespace() self.assertRaises(AttributeError, getattr, ns, 'x') ns = argparse.Namespace(a=42, b='spam') self.assertEqual(ns.a, 42) self.assertEqual(ns.b, 'spam') def test_equality(self): ns1 = argparse.Namespace(a=1, b=2) ns2 = argparse.Namespace(b=2, a=1) ns3 = argparse.Namespace(a=1) ns4 = argparse.Namespace(b=2) self.assertEqual(ns1, ns2) self.assertNotEqual(ns1, ns3) self.assertNotEqual(ns1, ns4) self.assertNotEqual(ns2, ns3) self.assertNotEqual(ns2, ns4) self.assertTrue(ns1 != ns3) self.assertTrue(ns1 != ns4) self.assertTrue(ns2 != ns3) self.assertTrue(ns2 != ns4) def test_equality_returns_notimplemented(self): # See issue 21481 ns = argparse.Namespace(a=1, b=2) self.assertIs(ns.__eq__(None), NotImplemented) self.assertIs(ns.__ne__(None), NotImplemented) # =================== # File encoding tests # =================== class TestEncoding(TestCase): def _test_module_encoding(self, path): path, _ = os.path.splitext(path) path += ".py" with codecs.open(path, 'r', 'utf-8') as f: f.read() def test_argparse_module_encoding(self): self._test_module_encoding(argparse.__file__) def test_test_argparse_module_encoding(self): self._test_module_encoding(__file__) # =================== # ArgumentError tests # =================== class TestArgumentError(TestCase): def test_argument_error(self): msg = "my error here" error = argparse.ArgumentError(None, msg) self.assertEqual(str(error), msg) # ======================= # ArgumentTypeError tests # ======================= class TestArgumentTypeError(TestCase): def test_argument_type_error(self): def spam(string): raise argparse.ArgumentTypeError('spam!') parser = ErrorRaisingArgumentParser(prog='PROG', add_help=False) parser.add_argument('x', type=spam) with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(['XXX']) self.assertEqual('usage: PROG x\nPROG: error: argument x: spam!\n', cm.exception.stderr) # ========================= # MessageContentError tests # ========================= class TestMessageContentError(TestCase): def test_missing_argument_name_in_message(self): parser = ErrorRaisingArgumentParser(prog='PROG', usage='') parser.add_argument('req_pos', type=str) parser.add_argument('-req_opt', type=int, required=True) parser.add_argument('need_one', type=str, nargs='+') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args([]) msg = str(cm.exception) self.assertRegex(msg, 'req_pos') self.assertRegex(msg, 'req_opt') self.assertRegex(msg, 'need_one') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(['myXargument']) msg = str(cm.exception) self.assertNotIn(msg, 'req_pos') self.assertRegex(msg, 'req_opt') self.assertRegex(msg, 'need_one') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(['myXargument', '-req_opt=1']) msg = str(cm.exception) self.assertNotIn(msg, 'req_pos') self.assertNotIn(msg, 'req_opt') self.assertRegex(msg, 'need_one') def test_optional_optional_not_in_message(self): parser = ErrorRaisingArgumentParser(prog='PROG', usage='') parser.add_argument('req_pos', type=str) parser.add_argument('--req_opt', type=int, required=True) parser.add_argument('--opt_opt', type=bool, nargs='?', default=True) with self.assertRaises(ArgumentParserError) as cm: parser.parse_args([]) msg = str(cm.exception) self.assertRegex(msg, 'req_pos') self.assertRegex(msg, 'req_opt') self.assertNotIn(msg, 'opt_opt') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args(['--req_opt=1']) msg = str(cm.exception) self.assertRegex(msg, 'req_pos') self.assertNotIn(msg, 'req_opt') self.assertNotIn(msg, 'opt_opt') def test_optional_positional_not_in_message(self): parser = ErrorRaisingArgumentParser(prog='PROG', usage='') parser.add_argument('req_pos') parser.add_argument('optional_positional', nargs='?', default='eggs') with self.assertRaises(ArgumentParserError) as cm: parser.parse_args([]) msg = str(cm.exception) self.assertRegex(msg, 'req_pos') self.assertNotIn(msg, 'optional_positional') # ================================================ # Check that the type function is called only once # ================================================ class TestTypeFunctionCallOnlyOnce(TestCase): def test_type_function_call_only_once(self): def spam(string_to_convert): self.assertEqual(string_to_convert, 'spam!') return 'foo_converted' parser = argparse.ArgumentParser() parser.add_argument('--foo', type=spam, default='bar') args = parser.parse_args('--foo spam!'.split()) self.assertEqual(NS(foo='foo_converted'), args) # ================================================================== # Check semantics regarding the default argument and type conversion # ================================================================== class TestTypeFunctionCalledOnDefault(TestCase): def test_type_function_call_with_non_string_default(self): def spam(int_to_convert): self.assertEqual(int_to_convert, 0) return 'foo_converted' parser = argparse.ArgumentParser() parser.add_argument('--foo', type=spam, default=0) args = parser.parse_args([]) # foo should *not* be converted because its default is not a string. self.assertEqual(NS(foo=0), args) def test_type_function_call_with_string_default(self): def spam(int_to_convert): return 'foo_converted' parser = argparse.ArgumentParser() parser.add_argument('--foo', type=spam, default='0') args = parser.parse_args([]) # foo is converted because its default is a string. self.assertEqual(NS(foo='foo_converted'), args) def test_no_double_type_conversion_of_default(self): def extend(str_to_convert): return str_to_convert + '*' parser = argparse.ArgumentParser() parser.add_argument('--test', type=extend, default='*') args = parser.parse_args([]) # The test argument will be two stars, one coming from the default # value and one coming from the type conversion being called exactly # once. self.assertEqual(NS(test='**'), args) def test_issue_15906(self): # Issue #15906: When action='append', type=str, default=[] are # providing, the dest value was the string representation "[]" when it # should have been an empty list. parser = argparse.ArgumentParser() parser.add_argument('--test', dest='test', type=str, default=[], action='append') args = parser.parse_args([]) self.assertEqual(args.test, []) # ====================== # parse_known_args tests # ====================== class TestParseKnownArgs(TestCase): def test_arguments_tuple(self): parser = argparse.ArgumentParser() parser.parse_args(()) def test_arguments_list(self): parser = argparse.ArgumentParser() parser.parse_args([]) def test_arguments_tuple_positional(self): parser = argparse.ArgumentParser() parser.add_argument('x') parser.parse_args(('x',)) def test_arguments_list_positional(self): parser = argparse.ArgumentParser() parser.add_argument('x') parser.parse_args(['x']) def test_optionals(self): parser = argparse.ArgumentParser() parser.add_argument('--foo') args, extras = parser.parse_known_args('--foo F --bar --baz'.split()) self.assertEqual(NS(foo='F'), args) self.assertEqual(['--bar', '--baz'], extras) def test_mixed(self): parser = argparse.ArgumentParser() parser.add_argument('-v', nargs='?', const=1, type=int) parser.add_argument('--spam', action='store_false') parser.add_argument('badger') argv = ["B", "C", "--foo", "-v", "3", "4"] args, extras = parser.parse_known_args(argv) self.assertEqual(NS(v=3, spam=True, badger="B"), args) self.assertEqual(["C", "--foo", "4"], extras) # ========================== # add_argument metavar tests # ========================== class TestAddArgumentMetavar(TestCase): EXPECTED_MESSAGE = "length of metavar tuple does not match nargs" def do_test_no_exception(self, nargs, metavar): parser = argparse.ArgumentParser() parser.add_argument("--foo", nargs=nargs, metavar=metavar) def do_test_exception(self, nargs, metavar): parser = argparse.ArgumentParser() with self.assertRaises(ValueError) as cm: parser.add_argument("--foo", nargs=nargs, metavar=metavar) self.assertEqual(cm.exception.args[0], self.EXPECTED_MESSAGE) # Unit tests for different values of metavar when nargs=None def test_nargs_None_metavar_string(self): self.do_test_no_exception(nargs=None, metavar="1") def test_nargs_None_metavar_length0(self): self.do_test_exception(nargs=None, metavar=tuple()) def test_nargs_None_metavar_length1(self): self.do_test_no_exception(nargs=None, metavar=("1",)) def test_nargs_None_metavar_length2(self): self.do_test_exception(nargs=None, metavar=("1", "2")) def test_nargs_None_metavar_length3(self): self.do_test_exception(nargs=None, metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=? def test_nargs_optional_metavar_string(self): self.do_test_no_exception(nargs="?", metavar="1") def test_nargs_optional_metavar_length0(self): self.do_test_exception(nargs="?", metavar=tuple()) def test_nargs_optional_metavar_length1(self): self.do_test_no_exception(nargs="?", metavar=("1",)) def test_nargs_optional_metavar_length2(self): self.do_test_exception(nargs="?", metavar=("1", "2")) def test_nargs_optional_metavar_length3(self): self.do_test_exception(nargs="?", metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=* def test_nargs_zeroormore_metavar_string(self): self.do_test_no_exception(nargs="*", metavar="1") def test_nargs_zeroormore_metavar_length0(self): self.do_test_exception(nargs="*", metavar=tuple()) def test_nargs_zeroormore_metavar_length1(self): self.do_test_exception(nargs="*", metavar=("1",)) def test_nargs_zeroormore_metavar_length2(self): self.do_test_no_exception(nargs="*", metavar=("1", "2")) def test_nargs_zeroormore_metavar_length3(self): self.do_test_exception(nargs="*", metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=+ def test_nargs_oneormore_metavar_string(self): self.do_test_no_exception(nargs="+", metavar="1") def test_nargs_oneormore_metavar_length0(self): self.do_test_exception(nargs="+", metavar=tuple()) def test_nargs_oneormore_metavar_length1(self): self.do_test_exception(nargs="+", metavar=("1",)) def test_nargs_oneormore_metavar_length2(self): self.do_test_no_exception(nargs="+", metavar=("1", "2")) def test_nargs_oneormore_metavar_length3(self): self.do_test_exception(nargs="+", metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=... def test_nargs_remainder_metavar_string(self): self.do_test_no_exception(nargs="...", metavar="1") def test_nargs_remainder_metavar_length0(self): self.do_test_no_exception(nargs="...", metavar=tuple()) def test_nargs_remainder_metavar_length1(self): self.do_test_no_exception(nargs="...", metavar=("1",)) def test_nargs_remainder_metavar_length2(self): self.do_test_no_exception(nargs="...", metavar=("1", "2")) def test_nargs_remainder_metavar_length3(self): self.do_test_no_exception(nargs="...", metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=A... def test_nargs_parser_metavar_string(self): self.do_test_no_exception(nargs="A...", metavar="1") def test_nargs_parser_metavar_length0(self): self.do_test_exception(nargs="A...", metavar=tuple()) def test_nargs_parser_metavar_length1(self): self.do_test_no_exception(nargs="A...", metavar=("1",)) def test_nargs_parser_metavar_length2(self): self.do_test_exception(nargs="A...", metavar=("1", "2")) def test_nargs_parser_metavar_length3(self): self.do_test_exception(nargs="A...", metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=1 def test_nargs_1_metavar_string(self): self.do_test_no_exception(nargs=1, metavar="1") def test_nargs_1_metavar_length0(self): self.do_test_exception(nargs=1, metavar=tuple()) def test_nargs_1_metavar_length1(self): self.do_test_no_exception(nargs=1, metavar=("1",)) def test_nargs_1_metavar_length2(self): self.do_test_exception(nargs=1, metavar=("1", "2")) def test_nargs_1_metavar_length3(self): self.do_test_exception(nargs=1, metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=2 def test_nargs_2_metavar_string(self): self.do_test_no_exception(nargs=2, metavar="1") def test_nargs_2_metavar_length0(self): self.do_test_exception(nargs=2, metavar=tuple()) def test_nargs_2_metavar_length1(self): self.do_test_exception(nargs=2, metavar=("1",)) def test_nargs_2_metavar_length2(self): self.do_test_no_exception(nargs=2, metavar=("1", "2")) def test_nargs_2_metavar_length3(self): self.do_test_exception(nargs=2, metavar=("1", "2", "3")) # Unit tests for different values of metavar when nargs=3 def test_nargs_3_metavar_string(self): self.do_test_no_exception(nargs=3, metavar="1") def test_nargs_3_metavar_length0(self): self.do_test_exception(nargs=3, metavar=tuple()) def test_nargs_3_metavar_length1(self): self.do_test_exception(nargs=3, metavar=("1",)) def test_nargs_3_metavar_length2(self): self.do_test_exception(nargs=3, metavar=("1", "2")) def test_nargs_3_metavar_length3(self): self.do_test_no_exception(nargs=3, metavar=("1", "2", "3")) # ============================ # from argparse import * tests # ============================ class TestImportStar(TestCase): def test(self): for name in argparse.__all__: self.assertTrue(hasattr(argparse, name)) def test_all_exports_everything_but_modules(self): items = [ name for name, value in vars(argparse).items() if not (name.startswith("_") or name == 'ngettext') if not inspect.ismodule(value) ] self.assertEqual(sorted(items), sorted(argparse.__all__)) class TestWrappingMetavar(TestCase): def setUp(self): self.parser = ErrorRaisingArgumentParser( 'this_is_spammy_prog_with_a_long_name_sorry_about_the_name' ) # this metavar was triggering library assertion errors due to usage # message formatting incorrectly splitting on the ] chars within metavar = '<http[s]://example:1234>' self.parser.add_argument('--proxy', metavar=metavar) def test_help_with_metavar(self): help_text = self.parser.format_help() self.assertEqual(help_text, textwrap.dedent('''\ usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name [-h] [--proxy <http[s]://example:1234>] optional arguments: -h, --help show this help message and exit --proxy <http[s]://example:1234> ''')) def test_main(): support.run_unittest(__name__) # Remove global references to avoid looking like we have refleaks. RFile.seen = {} WFile.seen = set() if __name__ == '__main__': test_main()
166,515
5,039
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_float.py
import fractions import operator import os import random import sys import struct import time import unittest from test import support from test.test_grammar import (VALID_UNDERSCORE_LITERALS, INVALID_UNDERSCORE_LITERALS) from math import isinf, isnan, copysign, ldexp INF = float("inf") NAN = float("nan") have_getformat = hasattr(float, "__getformat__") requires_getformat = unittest.skipUnless(have_getformat, "requires __getformat__") requires_setformat = unittest.skipUnless(hasattr(float, "__setformat__"), "requires __setformat__") #locate file with float format test values test_dir = os.path.dirname(__file__) or os.curdir format_testfile = os.path.join(test_dir, 'formatfloat_testcases.txt') class FloatSubclass(float): pass class OtherFloatSubclass(float): pass class GeneralFloatCases(unittest.TestCase): def test_float(self): self.assertEqual(float(3.14), 3.14) self.assertEqual(float(314), 314.0) self.assertEqual(float(" 3.14 "), 3.14) self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertRaises(ValueError, float, "++3.14") self.assertRaises(ValueError, float, "+-3.14") self.assertRaises(ValueError, float, "-+3.14") self.assertRaises(ValueError, float, "--3.14") self.assertRaises(ValueError, float, ".nan") self.assertRaises(ValueError, float, "+.inf") self.assertRaises(ValueError, float, ".") self.assertRaises(ValueError, float, "-.") self.assertRaises(TypeError, float, {}) self.assertRaisesRegex(TypeError, "not 'dict'", float, {}) # Lone surrogate self.assertRaises(UnicodeEncodeError, float, '\uD8F0') # check that we don't accept alternate exponent markers self.assertRaises(ValueError, float, "-1.7d29") self.assertRaises(ValueError, float, "3D-14") self.assertEqual(float(" \u0663.\u0661\u0664 "), 3.14) # TODO(jart): Need \N in pycomp.com self.assertEqual(float("\N{EM SPACE}3.14\N{EN SPACE}"), 3.14) # extra long strings should not be a problem float(b'.' + b'1'*1000) float('.' + '1'*1000) # Invalid unicode string # See bpo-34087 self.assertRaises(ValueError, float, '\u3053\u3093\u306b\u3061\u306f') def test_underscores(self): for lit in VALID_UNDERSCORE_LITERALS: if not any(ch in lit for ch in 'jJxXoObB'): self.assertEqual(float(lit), eval(lit)) self.assertEqual(float(lit), float(lit.replace('_', ''))) for lit in INVALID_UNDERSCORE_LITERALS: if lit in ('0_7', '09_99'): # octals are not recognized here continue if not any(ch in lit for ch in 'jJxXoObB'): self.assertRaises(ValueError, float, lit) # Additional test cases; nan and inf are never valid as literals, # only in the float() constructor, but we don't allow underscores # in or around them. self.assertRaises(ValueError, float, '_NaN') self.assertRaises(ValueError, float, 'Na_N') self.assertRaises(ValueError, float, 'IN_F') self.assertRaises(ValueError, float, '-_INF') self.assertRaises(ValueError, float, '-INF_') # Check that we handle bytes values correctly. self.assertRaises(ValueError, float, b'0_.\xff9') def test_non_numeric_input_types(self): # Test possible non-numeric types for the argument x, including # subclasses of the explicitly documented accepted types. class CustomStr(str): pass class CustomBytes(bytes): pass class CustomByteArray(bytearray): pass factories = [ bytes, bytearray, lambda b: CustomStr(b.decode()), CustomBytes, CustomByteArray, memoryview, ] try: from array import array except ImportError: pass else: factories.append(lambda b: array('B', b)) for f in factories: x = f(b" 3.14 ") with self.subTest(type(x)): self.assertEqual(float(x), 3.14) with self.assertRaisesRegex(ValueError, "could not convert"): float(f(b'A' * 0x10)) def test_float_memoryview(self): self.assertEqual(float(memoryview(b'12.3')[1:4]), 2.3) self.assertEqual(float(memoryview(b'12.3\x00')[1:4]), 2.3) self.assertEqual(float(memoryview(b'12.3 ')[1:4]), 2.3) self.assertEqual(float(memoryview(b'12.3A')[1:4]), 2.3) self.assertEqual(float(memoryview(b'12.34')[1:4]), 2.3) def test_error_message(self): def check(s): with self.assertRaises(ValueError, msg='float(%r)' % (s,)) as cm: float(s) self.assertEqual(str(cm.exception), 'could not convert string to float: %r' % (s,)) check('\xbd') check('123\xbd') check(' 123 456 ') check(b' 123 456 ') # non-ascii digits (error came from non-digit '!') check('\u0663\u0661\u0664!') # embedded NUL check('123\x00') check('123\x00 245') check('123\x00245') # byte string with embedded NUL check(b'123\x00') # non-UTF-8 byte string check(b'123\xa0') @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but # it still has to accept the normal python syntax import locale if not locale.localeconv()['decimal_point'] == ',': self.skipTest('decimal_point is not ","') self.assertEqual(float(" 3.14 "), 3.14) self.assertEqual(float("+3.14 "), 3.14) self.assertEqual(float("-3.14 "), -3.14) self.assertEqual(float(".14 "), .14) self.assertEqual(float("3. "), 3.0) self.assertEqual(float("3.e3 "), 3000.0) self.assertEqual(float("3.2e3 "), 3200.0) self.assertEqual(float("2.5e-1 "), 0.25) self.assertEqual(float("5e-1"), 0.5) self.assertRaises(ValueError, float, " 3,14 ") self.assertRaises(ValueError, float, " +3,14 ") self.assertRaises(ValueError, float, " -3,14 ") self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertEqual(float(" 25.e-1 "), 2.5) self.assertAlmostEqual(float(" .25e-1 "), .025) def test_floatconversion(self): # Make sure that calls to __float__() work properly class Foo1(object): def __float__(self): return 42. class Foo2(float): def __float__(self): return 42. class Foo3(float): def __new__(cls, value=0.): return float.__new__(cls, 2*value) def __float__(self): return self class Foo4(float): def __float__(self): return 42 # Issue 5759: __float__ not called on str subclasses (though it is on # unicode subclasses). class FooStr(str): def __float__(self): return float(str(self)) + 1 self.assertEqual(float(Foo1()), 42.) self.assertEqual(float(Foo2()), 42.) with self.assertWarns(DeprecationWarning): self.assertEqual(float(Foo3(21)), 42.) self.assertRaises(TypeError, float, Foo4(42)) self.assertEqual(float(FooStr('8')), 9.) class Foo5: def __float__(self): return "" self.assertRaises(TypeError, time.sleep, Foo5()) # Issue #24731 class F: def __float__(self): return OtherFloatSubclass(42.) with self.assertWarns(DeprecationWarning): self.assertEqual(float(F()), 42.) with self.assertWarns(DeprecationWarning): self.assertIs(type(float(F())), float) with self.assertWarns(DeprecationWarning): self.assertEqual(FloatSubclass(F()), 42.) with self.assertWarns(DeprecationWarning): self.assertIs(type(FloatSubclass(F())), FloatSubclass) def test_is_integer(self): self.assertFalse((1.1).is_integer()) self.assertTrue((1.).is_integer()) self.assertFalse(float("nan").is_integer()) self.assertFalse(float("inf").is_integer()) def test_floatasratio(self): for f, ratio in [ (0.875, (7, 8)), (-0.875, (-7, 8)), (0.0, (0, 1)), (11.5, (23, 2)), ]: self.assertEqual(f.as_integer_ratio(), ratio) for i in range(10000): f = random.random() f *= 10 ** random.randint(-100, 100) n, d = f.as_integer_ratio() self.assertEqual(float(n).__truediv__(d), f) R = fractions.Fraction self.assertEqual(R(0, 1), R(*float(0.0).as_integer_ratio())) self.assertEqual(R(5, 2), R(*float(2.5).as_integer_ratio())) self.assertEqual(R(1, 2), R(*float(0.5).as_integer_ratio())) self.assertEqual(R(4728779608739021, 2251799813685248), R(*float(2.1).as_integer_ratio())) self.assertEqual(R(-4728779608739021, 2251799813685248), R(*float(-2.1).as_integer_ratio())) self.assertEqual(R(-2100, 1), R(*float(-2100.0).as_integer_ratio())) self.assertRaises(OverflowError, float('inf').as_integer_ratio) self.assertRaises(OverflowError, float('-inf').as_integer_ratio) self.assertRaises(ValueError, float('nan').as_integer_ratio) def test_float_containment(self): floats = (INF, -INF, 0.0, 1.0, NAN) for f in floats: self.assertIn(f, [f]) self.assertIn(f, (f,)) self.assertIn(f, {f}) self.assertIn(f, {f: None}) self.assertEqual([f].count(f), 1, "[].count('%r') != 1" % f) self.assertIn(f, floats) for f in floats: # nonidentical containers, same type, same contents self.assertTrue([f] == [f], "[%r] != [%r]" % (f, f)) self.assertTrue((f,) == (f,), "(%r,) != (%r,)" % (f, f)) self.assertTrue({f} == {f}, "{%r} != {%r}" % (f, f)) self.assertTrue({f : None} == {f: None}, "{%r : None} != " "{%r : None}" % (f, f)) # identical containers l, t, s, d = [f], (f,), {f}, {f: None} self.assertTrue(l == l, "[%r] not equal to itself" % f) self.assertTrue(t == t, "(%r,) not equal to itself" % f) self.assertTrue(s == s, "{%r} not equal to itself" % f) self.assertTrue(d == d, "{%r : None} not equal to itself" % f) def assertEqualAndEqualSign(self, a, b): # fail unless a == b and a and b have the same sign bit; # the only difference from assertEqual is that this test # distinguishes -0.0 and 0.0. self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b))) @support.requires_IEEE_754 def test_float_mod(self): # Check behaviour of % operator for IEEE 754 special cases. # In particular, check signs of zeros. mod = operator.mod self.assertEqualAndEqualSign(mod(-1.0, 1.0), 0.0) self.assertEqualAndEqualSign(mod(-1e-100, 1.0), 1.0) self.assertEqualAndEqualSign(mod(-0.0, 1.0), 0.0) self.assertEqualAndEqualSign(mod(0.0, 1.0), 0.0) self.assertEqualAndEqualSign(mod(1e-100, 1.0), 1e-100) self.assertEqualAndEqualSign(mod(1.0, 1.0), 0.0) self.assertEqualAndEqualSign(mod(-1.0, -1.0), -0.0) self.assertEqualAndEqualSign(mod(-1e-100, -1.0), -1e-100) self.assertEqualAndEqualSign(mod(-0.0, -1.0), -0.0) self.assertEqualAndEqualSign(mod(0.0, -1.0), -0.0) self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0) self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0) @support.requires_IEEE_754 def test_float_pow(self): # test builtin pow and ** operator for IEEE 754 special cases. # Special cases taken from section F.9.4.4 of the C99 specification for pow_op in pow, operator.pow: # x**NAN is NAN for any x except 1 self.assertTrue(isnan(pow_op(-INF, NAN))) self.assertTrue(isnan(pow_op(-2.0, NAN))) self.assertTrue(isnan(pow_op(-1.0, NAN))) self.assertTrue(isnan(pow_op(-0.5, NAN))) self.assertTrue(isnan(pow_op(-0.0, NAN))) self.assertTrue(isnan(pow_op(0.0, NAN))) self.assertTrue(isnan(pow_op(0.5, NAN))) self.assertTrue(isnan(pow_op(2.0, NAN))) self.assertTrue(isnan(pow_op(INF, NAN))) self.assertTrue(isnan(pow_op(NAN, NAN))) # NAN**y is NAN for any y except +-0 self.assertTrue(isnan(pow_op(NAN, -INF))) self.assertTrue(isnan(pow_op(NAN, -2.0))) self.assertTrue(isnan(pow_op(NAN, -1.0))) self.assertTrue(isnan(pow_op(NAN, -0.5))) self.assertTrue(isnan(pow_op(NAN, 0.5))) self.assertTrue(isnan(pow_op(NAN, 1.0))) self.assertTrue(isnan(pow_op(NAN, 2.0))) self.assertTrue(isnan(pow_op(NAN, INF))) # (+-0)**y raises ZeroDivisionError for y a negative odd integer self.assertRaises(ZeroDivisionError, pow_op, -0.0, -1.0) self.assertRaises(ZeroDivisionError, pow_op, 0.0, -1.0) # (+-0)**y raises ZeroDivisionError for y finite and negative # but not an odd integer self.assertRaises(ZeroDivisionError, pow_op, -0.0, -2.0) self.assertRaises(ZeroDivisionError, pow_op, -0.0, -0.5) self.assertRaises(ZeroDivisionError, pow_op, 0.0, -2.0) self.assertRaises(ZeroDivisionError, pow_op, 0.0, -0.5) # (+-0)**y is +-0 for y a positive odd integer self.assertEqualAndEqualSign(pow_op(-0.0, 1.0), -0.0) self.assertEqualAndEqualSign(pow_op(0.0, 1.0), 0.0) # (+-0)**y is 0 for y finite and positive but not an odd integer self.assertEqualAndEqualSign(pow_op(-0.0, 0.5), 0.0) self.assertEqualAndEqualSign(pow_op(-0.0, 2.0), 0.0) self.assertEqualAndEqualSign(pow_op(0.0, 0.5), 0.0) self.assertEqualAndEqualSign(pow_op(0.0, 2.0), 0.0) # (-1)**+-inf is 1 self.assertEqualAndEqualSign(pow_op(-1.0, -INF), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, INF), 1.0) # 1**y is 1 for any y, even if y is an infinity or nan self.assertEqualAndEqualSign(pow_op(1.0, -INF), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, -2.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, -1.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, -0.5), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, 0.5), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, 1.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, 2.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, INF), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, NAN), 1.0) # x**+-0 is 1 for any x, even if x is a zero, infinity, or nan self.assertEqualAndEqualSign(pow_op(-INF, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-2.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-0.5, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-0.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(0.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(0.5, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(2.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(INF, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(NAN, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-INF, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-2.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-0.5, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-0.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(0.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(0.5, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(2.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(INF, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(NAN, -0.0), 1.0) # x**y defers to complex pow for finite negative x and # non-integral y. self.assertEqual(type(pow_op(-2.0, -0.5)), complex) self.assertEqual(type(pow_op(-2.0, 0.5)), complex) self.assertEqual(type(pow_op(-1.0, -0.5)), complex) self.assertEqual(type(pow_op(-1.0, 0.5)), complex) self.assertEqual(type(pow_op(-0.5, -0.5)), complex) self.assertEqual(type(pow_op(-0.5, 0.5)), complex) # x**-INF is INF for abs(x) < 1 self.assertEqualAndEqualSign(pow_op(-0.5, -INF), INF) self.assertEqualAndEqualSign(pow_op(-0.0, -INF), INF) self.assertEqualAndEqualSign(pow_op(0.0, -INF), INF) self.assertEqualAndEqualSign(pow_op(0.5, -INF), INF) # x**-INF is 0 for abs(x) > 1 self.assertEqualAndEqualSign(pow_op(-INF, -INF), 0.0) self.assertEqualAndEqualSign(pow_op(-2.0, -INF), 0.0) self.assertEqualAndEqualSign(pow_op(2.0, -INF), 0.0) self.assertEqualAndEqualSign(pow_op(INF, -INF), 0.0) # x**INF is 0 for abs(x) < 1 self.assertEqualAndEqualSign(pow_op(-0.5, INF), 0.0) self.assertEqualAndEqualSign(pow_op(-0.0, INF), 0.0) self.assertEqualAndEqualSign(pow_op(0.0, INF), 0.0) self.assertEqualAndEqualSign(pow_op(0.5, INF), 0.0) # x**INF is INF for abs(x) > 1 self.assertEqualAndEqualSign(pow_op(-INF, INF), INF) self.assertEqualAndEqualSign(pow_op(-2.0, INF), INF) self.assertEqualAndEqualSign(pow_op(2.0, INF), INF) self.assertEqualAndEqualSign(pow_op(INF, INF), INF) # (-INF)**y is -0.0 for y a negative odd integer self.assertEqualAndEqualSign(pow_op(-INF, -1.0), -0.0) # (-INF)**y is 0.0 for y negative but not an odd integer self.assertEqualAndEqualSign(pow_op(-INF, -0.5), 0.0) self.assertEqualAndEqualSign(pow_op(-INF, -2.0), 0.0) # (-INF)**y is -INF for y a positive odd integer self.assertEqualAndEqualSign(pow_op(-INF, 1.0), -INF) # (-INF)**y is INF for y positive but not an odd integer self.assertEqualAndEqualSign(pow_op(-INF, 0.5), INF) self.assertEqualAndEqualSign(pow_op(-INF, 2.0), INF) # INF**y is INF for y positive self.assertEqualAndEqualSign(pow_op(INF, 0.5), INF) self.assertEqualAndEqualSign(pow_op(INF, 1.0), INF) self.assertEqualAndEqualSign(pow_op(INF, 2.0), INF) # INF**y is 0.0 for y negative self.assertEqualAndEqualSign(pow_op(INF, -2.0), 0.0) self.assertEqualAndEqualSign(pow_op(INF, -1.0), 0.0) self.assertEqualAndEqualSign(pow_op(INF, -0.5), 0.0) # basic checks not covered by the special cases above self.assertEqualAndEqualSign(pow_op(-2.0, -2.0), 0.25) self.assertEqualAndEqualSign(pow_op(-2.0, -1.0), -0.5) self.assertEqualAndEqualSign(pow_op(-2.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-2.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-2.0, 1.0), -2.0) self.assertEqualAndEqualSign(pow_op(-2.0, 2.0), 4.0) self.assertEqualAndEqualSign(pow_op(-1.0, -2.0), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, -1.0), -1.0) self.assertEqualAndEqualSign(pow_op(-1.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, 1.0), -1.0) self.assertEqualAndEqualSign(pow_op(-1.0, 2.0), 1.0) self.assertEqualAndEqualSign(pow_op(2.0, -2.0), 0.25) self.assertEqualAndEqualSign(pow_op(2.0, -1.0), 0.5) self.assertEqualAndEqualSign(pow_op(2.0, -0.0), 1.0) self.assertEqualAndEqualSign(pow_op(2.0, 0.0), 1.0) self.assertEqualAndEqualSign(pow_op(2.0, 1.0), 2.0) self.assertEqualAndEqualSign(pow_op(2.0, 2.0), 4.0) # 1 ** large and -1 ** large; some libms apparently # have problems with these self.assertEqualAndEqualSign(pow_op(1.0, -1e100), 1.0) self.assertEqualAndEqualSign(pow_op(1.0, 1e100), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, -1e100), 1.0) self.assertEqualAndEqualSign(pow_op(-1.0, 1e100), 1.0) # check sign for results that underflow to 0 self.assertEqualAndEqualSign(pow_op(-2.0, -2000.0), 0.0) self.assertEqual(type(pow_op(-2.0, -2000.5)), complex) self.assertEqualAndEqualSign(pow_op(-2.0, -2001.0), -0.0) self.assertEqualAndEqualSign(pow_op(2.0, -2000.0), 0.0) self.assertEqualAndEqualSign(pow_op(2.0, -2000.5), 0.0) self.assertEqualAndEqualSign(pow_op(2.0, -2001.0), 0.0) self.assertEqualAndEqualSign(pow_op(-0.5, 2000.0), 0.0) self.assertEqual(type(pow_op(-0.5, 2000.5)), complex) self.assertEqualAndEqualSign(pow_op(-0.5, 2001.0), -0.0) self.assertEqualAndEqualSign(pow_op(0.5, 2000.0), 0.0) self.assertEqualAndEqualSign(pow_op(0.5, 2000.5), 0.0) self.assertEqualAndEqualSign(pow_op(0.5, 2001.0), 0.0) # check we don't raise an exception for subnormal results, # and validate signs. Tests currently disabled, since # they fail on systems where a subnormal result from pow # is flushed to zero (e.g. Debian/ia64.) #self.assertTrue(0.0 < pow_op(0.5, 1048) < 1e-315) #self.assertTrue(0.0 < pow_op(-0.5, 1048) < 1e-315) #self.assertTrue(0.0 < pow_op(0.5, 1047) < 1e-315) #self.assertTrue(0.0 > pow_op(-0.5, 1047) > -1e-315) #self.assertTrue(0.0 < pow_op(2.0, -1048) < 1e-315) #self.assertTrue(0.0 < pow_op(-2.0, -1048) < 1e-315) #self.assertTrue(0.0 < pow_op(2.0, -1047) < 1e-315) #self.assertTrue(0.0 > pow_op(-2.0, -1047) > -1e-315) @requires_setformat class FormatFunctionsTestCase(unittest.TestCase): def setUp(self): self.save_formats = {'double':float.__getformat__('double'), 'float':float.__getformat__('float')} def tearDown(self): float.__setformat__('double', self.save_formats['double']) float.__setformat__('float', self.save_formats['float']) def test_getformat(self): self.assertIn(float.__getformat__('double'), ['unknown', 'IEEE, big-endian', 'IEEE, little-endian']) self.assertIn(float.__getformat__('float'), ['unknown', 'IEEE, big-endian', 'IEEE, little-endian']) self.assertRaises(ValueError, float.__getformat__, 'chicken') self.assertRaises(TypeError, float.__getformat__, 1) def test_setformat(self): for t in 'double', 'float': float.__setformat__(t, 'unknown') if self.save_formats[t] == 'IEEE, big-endian': self.assertRaises(ValueError, float.__setformat__, t, 'IEEE, little-endian') elif self.save_formats[t] == 'IEEE, little-endian': self.assertRaises(ValueError, float.__setformat__, t, 'IEEE, big-endian') else: self.assertRaises(ValueError, float.__setformat__, t, 'IEEE, big-endian') self.assertRaises(ValueError, float.__setformat__, t, 'IEEE, little-endian') self.assertRaises(ValueError, float.__setformat__, t, 'chicken') self.assertRaises(ValueError, float.__setformat__, 'chicken', 'unknown') BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00' LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF)) BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00' LE_DOUBLE_NAN = bytes(reversed(BE_DOUBLE_NAN)) BE_FLOAT_INF = b'\x7f\x80\x00\x00' LE_FLOAT_INF = bytes(reversed(BE_FLOAT_INF)) BE_FLOAT_NAN = b'\x7f\xc0\x00\x00' LE_FLOAT_NAN = bytes(reversed(BE_FLOAT_NAN)) # on non-IEEE platforms, attempting to unpack a bit pattern # representing an infinity or a NaN should raise an exception. @requires_setformat class UnknownFormatTestCase(unittest.TestCase): def setUp(self): self.save_formats = {'double':float.__getformat__('double'), 'float':float.__getformat__('float')} float.__setformat__('double', 'unknown') float.__setformat__('float', 'unknown') def tearDown(self): float.__setformat__('double', self.save_formats['double']) float.__setformat__('float', self.save_formats['float']) def test_double_specials_dont_unpack(self): for fmt, data in [('>d', BE_DOUBLE_INF), ('>d', BE_DOUBLE_NAN), ('<d', LE_DOUBLE_INF), ('<d', LE_DOUBLE_NAN)]: self.assertRaises(ValueError, struct.unpack, fmt, data) def test_float_specials_dont_unpack(self): for fmt, data in [('>f', BE_FLOAT_INF), ('>f', BE_FLOAT_NAN), ('<f', LE_FLOAT_INF), ('<f', LE_FLOAT_NAN)]: self.assertRaises(ValueError, struct.unpack, fmt, data) # on an IEEE platform, all we guarantee is that bit patterns # representing infinities or NaNs do not raise an exception; all else # is accident (today). # let's also try to guarantee that -0.0 and 0.0 don't get confused. class IEEEFormatTestCase(unittest.TestCase): @support.requires_IEEE_754 def test_double_specials_do_unpack(self): for fmt, data in [('>d', BE_DOUBLE_INF), ('>d', BE_DOUBLE_NAN), ('<d', LE_DOUBLE_INF), ('<d', LE_DOUBLE_NAN)]: struct.unpack(fmt, data) @support.requires_IEEE_754 def test_float_specials_do_unpack(self): for fmt, data in [('>f', BE_FLOAT_INF), ('>f', BE_FLOAT_NAN), ('<f', LE_FLOAT_INF), ('<f', LE_FLOAT_NAN)]: struct.unpack(fmt, data) @support.requires_IEEE_754 def test_serialized_float_rounding(self): from _testcapi import FLT_MAX self.assertEqual(struct.pack("<f", 3.40282356e38), struct.pack("<f", FLT_MAX)) self.assertEqual(struct.pack("<f", -3.40282356e38), struct.pack("<f", -FLT_MAX)) class FormatTestCase(unittest.TestCase): def test_format(self): # these should be rewritten to use both format(x, spec) and # x.__format__(spec) self.assertEqual(format(0.0, 'f'), '0.000000') # the default is 'g', except for empty format spec self.assertEqual(format(0.0, ''), '0.0') self.assertEqual(format(0.01, ''), '0.01') self.assertEqual(format(0.01, 'g'), '0.01') # empty presentation type should format in the same way as str # (issue 5920) x = 100/7. self.assertEqual(format(x, ''), str(x)) self.assertEqual(format(x, '-'), str(x)) self.assertEqual(format(x, '>'), str(x)) self.assertEqual(format(x, '2'), str(x)) self.assertEqual(format(1.0, 'f'), '1.000000') self.assertEqual(format(-1.0, 'f'), '-1.000000') self.assertEqual(format( 1.0, ' f'), ' 1.000000') self.assertEqual(format(-1.0, ' f'), '-1.000000') self.assertEqual(format( 1.0, '+f'), '+1.000000') self.assertEqual(format(-1.0, '+f'), '-1.000000') # % formatting self.assertEqual(format(-1.0, '%'), '-100.000000%') # conversion to string should fail self.assertRaises(ValueError, format, 3.0, "s") # other format specifiers shouldn't work on floats, # in particular int specifiers for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + [chr(x) for x in range(ord('A'), ord('Z')+1)]): if not format_spec in 'eEfFgGn%': self.assertRaises(ValueError, format, 0.0, format_spec) self.assertRaises(ValueError, format, 1.0, format_spec) self.assertRaises(ValueError, format, -1.0, format_spec) self.assertRaises(ValueError, format, 1e100, format_spec) self.assertRaises(ValueError, format, -1e100, format_spec) self.assertRaises(ValueError, format, 1e-100, format_spec) self.assertRaises(ValueError, format, -1e-100, format_spec) # issue 3382 self.assertEqual(format(NAN, 'f'), 'nan') self.assertEqual(format(NAN, 'F'), 'NAN') self.assertEqual(format(INF, 'f'), 'inf') self.assertEqual(format(INF, 'F'), 'INF') @support.requires_IEEE_754 def test_format_testfile(self): with open(format_testfile) as testfile: for line in testfile: if line.startswith('--'): continue line = line.strip() if not line: continue lhs, rhs = map(str.strip, line.split('->')) fmt, arg = lhs.split() self.assertEqual(fmt % float(arg), rhs) self.assertEqual(fmt % -float(arg), '-' + rhs) def test_issue5864(self): self.assertEqual(format(123.456, '.4'), '123.5') self.assertEqual(format(1234.56, '.4'), '1.235e+03') self.assertEqual(format(12345.6, '.4'), '1.235e+04') def test_issue35560(self): self.assertEqual(format(123.0, '00'), '123.0') self.assertEqual(format(123.34, '00f'), '123.340000') self.assertEqual(format(123.34, '00e'), '1.233400e+02') self.assertEqual(format(123.34, '00g'), '123.34') self.assertEqual(format(123.34, '00.10f'), '123.3400000000') self.assertEqual(format(123.34, '00.10e'), '1.2334000000e+02') self.assertEqual(format(123.34, '00.10g'), '123.34') self.assertEqual(format(123.34, '01f'), '123.340000') self.assertEqual(format(-123.0, '00'), '-123.0') self.assertEqual(format(-123.34, '00f'), '-123.340000') self.assertEqual(format(-123.34, '00e'), '-1.233400e+02') self.assertEqual(format(-123.34, '00g'), '-123.34') self.assertEqual(format(-123.34, '00.10f'), '-123.3400000000') self.assertEqual(format(-123.34, '00.10f'), '-123.3400000000') self.assertEqual(format(-123.34, '00.10e'), '-1.2334000000e+02') self.assertEqual(format(-123.34, '00.10g'), '-123.34') class ReprTestCase(unittest.TestCase): def test_repr(self): floats_file = open(os.path.join(os.path.split(__file__)[0], 'floating_points.txt')) for line in floats_file: line = line.strip() if not line or line.startswith('#'): continue v = eval(line) self.assertEqual(v, eval(repr(v))) floats_file.close() @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', "applies only when using short float repr style") def test_short_repr(self): # test short float repr introduced in Python 3.1. One aspect # of this repr is that we get some degree of str -> float -> # str roundtripping. In particular, for any numeric string # containing 15 or fewer significant digits, those exact same # digits (modulo trailing zeros) should appear in the output. # No more repr(0.03) -> "0.029999999999999999"! test_strings = [ # output always includes *either* a decimal point and at # least one digit after that point, or an exponent. '0.0', '1.0', '0.01', '0.02', '0.03', '0.04', '0.05', '1.23456789', '10.0', '100.0', # values >= 1e16 get an exponent... '1000000000000000.0', '9999999999999990.0', '1e+16', '1e+17', # ... and so do values < 1e-4 '0.001', '0.001001', '0.00010000000000001', '0.0001', '9.999999999999e-05', '1e-05', # values designed to provoke failure if the FPU rounding # precision isn't set correctly '8.72293771110361e+25', '7.47005307342313e+26', '2.86438000439698e+28', '8.89142905246179e+28', '3.08578087079232e+35', ] for s in test_strings: negs = '-'+s self.assertEqual(s, repr(float(s))) self.assertEqual(negs, repr(float(negs))) # Since Python 3.2, repr and str are identical self.assertEqual(repr(float(s)), str(float(s))) self.assertEqual(repr(float(negs)), str(float(negs))) @support.requires_IEEE_754 class RoundTestCase(unittest.TestCase): def test_inf_nan(self): self.assertRaises(OverflowError, round, INF) self.assertRaises(OverflowError, round, -INF) self.assertRaises(ValueError, round, NAN) self.assertRaises(TypeError, round, INF, 0.0) self.assertRaises(TypeError, round, -INF, 1.0) self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer") self.assertRaises(TypeError, round, -0.0, 1j) def test_large_n(self): for n in [324, 325, 400, 2**31-1, 2**31, 2**32, 2**100]: self.assertEqual(round(123.456, n), 123.456) self.assertEqual(round(-123.456, n), -123.456) self.assertEqual(round(1e300, n), 1e300) self.assertEqual(round(1e-320, n), 1e-320) self.assertEqual(round(1e150, 300), 1e150) self.assertEqual(round(1e300, 307), 1e300) self.assertEqual(round(-3.1415, 308), -3.1415) self.assertEqual(round(1e150, 309), 1e150) self.assertEqual(round(1.4e-315, 315), 1e-315) def test_small_n(self): for n in [-308, -309, -400, 1-2**31, -2**31, -2**31-1, -2**100]: self.assertEqual(round(123.456, n), 0.0) self.assertEqual(round(-123.456, n), -0.0) self.assertEqual(round(1e300, n), 0.0) self.assertEqual(round(1e-320, n), 0.0) def test_overflow(self): self.assertRaises(OverflowError, round, 1.6e308, -308) self.assertRaises(OverflowError, round, -1.7e308, -308) @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', "applies only when using short float repr style") def test_previous_round_bugs(self): # particular cases that have occurred in bug reports self.assertEqual(round(562949953421312.5, 1), 562949953421312.5) self.assertEqual(round(56294995342131.5, 3), 56294995342131.5) # round-half-even self.assertEqual(round(25.0, -1), 20.0) self.assertEqual(round(35.0, -1), 40.0) self.assertEqual(round(45.0, -1), 40.0) self.assertEqual(round(55.0, -1), 60.0) self.assertEqual(round(65.0, -1), 60.0) self.assertEqual(round(75.0, -1), 80.0) self.assertEqual(round(85.0, -1), 80.0) self.assertEqual(round(95.0, -1), 100.0) @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', "applies only when using short float repr style") def test_matches_float_format(self): # round should give the same results as float formatting for i in range(500): x = i/1000. self.assertEqual(float(format(x, '.0f')), round(x, 0)) self.assertEqual(float(format(x, '.1f')), round(x, 1)) self.assertEqual(float(format(x, '.2f')), round(x, 2)) self.assertEqual(float(format(x, '.3f')), round(x, 3)) for i in range(5, 5000, 10): x = i/1000. self.assertEqual(float(format(x, '.0f')), round(x, 0)) self.assertEqual(float(format(x, '.1f')), round(x, 1)) self.assertEqual(float(format(x, '.2f')), round(x, 2)) self.assertEqual(float(format(x, '.3f')), round(x, 3)) for i in range(500): x = random.random() self.assertEqual(float(format(x, '.0f')), round(x, 0)) self.assertEqual(float(format(x, '.1f')), round(x, 1)) self.assertEqual(float(format(x, '.2f')), round(x, 2)) self.assertEqual(float(format(x, '.3f')), round(x, 3)) def test_format_specials(self): # Test formatting of nans and infs. def test(fmt, value, expected): # Test with both % and format(). self.assertEqual(fmt % value, expected, fmt) fmt = fmt[1:] # strip off the % self.assertEqual(format(value, fmt), expected, fmt) for fmt in ['%e', '%f', '%g', '%.0e', '%.6f', '%.20g', '%#e', '%#f', '%#g', '%#.20e', '%#.15f', '%#.3g']: pfmt = '%+' + fmt[1:] sfmt = '% ' + fmt[1:] test(fmt, INF, 'inf') test(fmt, -INF, '-inf') test(fmt, NAN, 'nan') test(fmt, -NAN, 'nan') # When asking for a sign, it's always provided. nans are # always positive. test(pfmt, INF, '+inf') test(pfmt, -INF, '-inf') test(pfmt, NAN, '+nan') test(pfmt, -NAN, '+nan') # When using ' ' for a sign code, only infs can be negative. # Others have a space. test(sfmt, INF, ' inf') test(sfmt, -INF, '-inf') test(sfmt, NAN, ' nan') test(sfmt, -NAN, ' nan') def test_None_ndigits(self): for x in round(1.23), round(1.23, None), round(1.23, ndigits=None): self.assertEqual(x, 1) self.assertIsInstance(x, int) for x in round(1.78), round(1.78, None), round(1.78, ndigits=None): self.assertEqual(x, 2) self.assertIsInstance(x, int) # Beginning with Python 2.6 float has cross platform compatible # ways to create and represent inf and nan class InfNanTest(unittest.TestCase): def test_inf_from_str(self): self.assertTrue(isinf(float("inf"))) self.assertTrue(isinf(float("+inf"))) self.assertTrue(isinf(float("-inf"))) self.assertTrue(isinf(float("infinity"))) self.assertTrue(isinf(float("+infinity"))) self.assertTrue(isinf(float("-infinity"))) self.assertEqual(repr(float("inf")), "inf") self.assertEqual(repr(float("+inf")), "inf") self.assertEqual(repr(float("-inf")), "-inf") self.assertEqual(repr(float("infinity")), "inf") self.assertEqual(repr(float("+infinity")), "inf") self.assertEqual(repr(float("-infinity")), "-inf") self.assertEqual(repr(float("INF")), "inf") self.assertEqual(repr(float("+Inf")), "inf") self.assertEqual(repr(float("-iNF")), "-inf") self.assertEqual(repr(float("Infinity")), "inf") self.assertEqual(repr(float("+iNfInItY")), "inf") self.assertEqual(repr(float("-INFINITY")), "-inf") self.assertEqual(str(float("inf")), "inf") self.assertEqual(str(float("+inf")), "inf") self.assertEqual(str(float("-inf")), "-inf") self.assertEqual(str(float("infinity")), "inf") self.assertEqual(str(float("+infinity")), "inf") self.assertEqual(str(float("-infinity")), "-inf") self.assertRaises(ValueError, float, "info") self.assertRaises(ValueError, float, "+info") self.assertRaises(ValueError, float, "-info") self.assertRaises(ValueError, float, "in") self.assertRaises(ValueError, float, "+in") self.assertRaises(ValueError, float, "-in") self.assertRaises(ValueError, float, "infinit") self.assertRaises(ValueError, float, "+Infin") self.assertRaises(ValueError, float, "-INFI") self.assertRaises(ValueError, float, "infinitys") self.assertRaises(ValueError, float, "++Inf") self.assertRaises(ValueError, float, "-+inf") self.assertRaises(ValueError, float, "+-infinity") self.assertRaises(ValueError, float, "--Infinity") def test_inf_as_str(self): self.assertEqual(repr(1e300 * 1e300), "inf") self.assertEqual(repr(-1e300 * 1e300), "-inf") self.assertEqual(str(1e300 * 1e300), "inf") self.assertEqual(str(-1e300 * 1e300), "-inf") def test_nan_from_str(self): self.assertTrue(isnan(float("nan"))) self.assertTrue(isnan(float("+nan"))) self.assertTrue(isnan(float("-nan"))) self.assertEqual(repr(float("nan")), "nan") self.assertEqual(repr(float("+nan")), "nan") self.assertEqual(repr(float("-nan")), "nan") self.assertEqual(repr(float("NAN")), "nan") self.assertEqual(repr(float("+NAn")), "nan") self.assertEqual(repr(float("-NaN")), "nan") self.assertEqual(str(float("nan")), "nan") self.assertEqual(str(float("+nan")), "nan") self.assertEqual(str(float("-nan")), "nan") self.assertRaises(ValueError, float, "nana") self.assertRaises(ValueError, float, "+nana") self.assertRaises(ValueError, float, "-nana") self.assertRaises(ValueError, float, "na") self.assertRaises(ValueError, float, "+na") self.assertRaises(ValueError, float, "-na") self.assertRaises(ValueError, float, "++nan") self.assertRaises(ValueError, float, "-+NAN") self.assertRaises(ValueError, float, "+-NaN") self.assertRaises(ValueError, float, "--nAn") def test_nan_as_str(self): self.assertEqual(repr(1e300 * 1e300 * 0), "nan") self.assertEqual(repr(-1e300 * 1e300 * 0), "nan") self.assertEqual(str(1e300 * 1e300 * 0), "nan") self.assertEqual(str(-1e300 * 1e300 * 0), "nan") def test_inf_signs(self): self.assertEqual(copysign(1.0, float('inf')), 1.0) self.assertEqual(copysign(1.0, float('-inf')), -1.0) @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', "applies only when using short float repr style") def test_nan_signs(self): # When using the dtoa.c code, the sign of float('nan') should # be predictable. self.assertEqual(copysign(1.0, float('nan')), 1.0) self.assertEqual(copysign(1.0, float('-nan')), -1.0) fromHex = float.fromhex toHex = float.hex class HexFloatTestCase(unittest.TestCase): MAX = fromHex('0x.fffffffffffff8p+1024') # max normal MIN = fromHex('0x1p-1022') # min normal TINY = fromHex('0x0.0000000000001p-1022') # min subnormal EPS = fromHex('0x0.0000000000001p0') # diff between 1.0 and next float up def identical(self, x, y): # check that floats x and y are identical, or that both # are NaNs if isnan(x) or isnan(y): if isnan(x) == isnan(y): return elif x == y and (x != 0.0 or copysign(1.0, x) == copysign(1.0, y)): return self.fail('%r not identical to %r' % (x, y)) def test_ends(self): self.identical(self.MIN, ldexp(1.0, -1022)) self.identical(self.TINY, ldexp(1.0, -1074)) self.identical(self.EPS, ldexp(1.0, -52)) self.identical(self.MAX, 2.*(ldexp(1.0, 1023) - ldexp(1.0, 970))) def test_invalid_inputs(self): invalid_inputs = [ 'infi', # misspelt infinities and nans '-Infinit', '++inf', '-+Inf', '--nan', '+-NaN', 'snan', 'NaNs', 'nna', 'an', 'nf', 'nfinity', 'inity', 'iinity', '0xnan', '', ' ', 'x1.0p0', '0xX1.0p0', '+ 0x1.0p0', # internal whitespace '- 0x1.0p0', '0 x1.0p0', '0x 1.0p0', '0x1 2.0p0', '+0x1 .0p0', '0x1. 0p0', '-0x1.0 1p0', '-0x1.0 p0', '+0x1.0p +0', '0x1.0p -0', '0x1.0p 0', '+0x1.0p+ 0', '-0x1.0p- 0', '++0x1.0p-0', # double signs '--0x1.0p0', '+-0x1.0p+0', '-+0x1.0p0', '0x1.0p++0', '+0x1.0p+-0', '-0x1.0p-+0', '0x1.0p--0', '0x1.0.p0', '0x.p0', # no hex digits before or after point '0x1,p0', # wrong decimal point character '0x1pa', '0x1p\uff10', # fullwidth Unicode digits '\uff10x1p0', '0x\uff11p0', '0x1.\uff10p0', '0x1p0 \n 0x2p0', '0x1p0\0 0x1p0', # embedded null byte is not end of string ] for x in invalid_inputs: try: result = fromHex(x) except ValueError: pass else: self.fail('Expected float.fromhex(%r) to raise ValueError; ' 'got %r instead' % (x, result)) def test_whitespace(self): value_pairs = [ ('inf', INF), ('-Infinity', -INF), ('nan', NAN), ('1.0', 1.0), ('-0x.2', -0.125), ('-0.0', -0.0) ] whitespace = [ '', ' ', '\t', '\n', '\n \t', '\f', '\v', '\r' ] for inp, expected in value_pairs: for lead in whitespace: for trail in whitespace: got = fromHex(lead + inp + trail) self.identical(got, expected) def test_from_hex(self): MIN = self.MIN; MAX = self.MAX; TINY = self.TINY; EPS = self.EPS; # two spellings of infinity, with optional signs; case-insensitive self.identical(fromHex('inf'), INF) self.identical(fromHex('+Inf'), INF) self.identical(fromHex('-INF'), -INF) self.identical(fromHex('iNf'), INF) self.identical(fromHex('Infinity'), INF) self.identical(fromHex('+INFINITY'), INF) self.identical(fromHex('-infinity'), -INF) self.identical(fromHex('-iNFiNitY'), -INF) # nans with optional sign; case insensitive self.identical(fromHex('nan'), NAN) self.identical(fromHex('+NaN'), NAN) self.identical(fromHex('-NaN'), NAN) self.identical(fromHex('-nAN'), NAN) # variations in input format self.identical(fromHex('1'), 1.0) self.identical(fromHex('+1'), 1.0) self.identical(fromHex('1.'), 1.0) self.identical(fromHex('1.0'), 1.0) self.identical(fromHex('1.0p0'), 1.0) self.identical(fromHex('01'), 1.0) self.identical(fromHex('01.'), 1.0) self.identical(fromHex('0x1'), 1.0) self.identical(fromHex('0x1.'), 1.0) self.identical(fromHex('0x1.0'), 1.0) self.identical(fromHex('+0x1.0'), 1.0) self.identical(fromHex('0x1p0'), 1.0) self.identical(fromHex('0X1p0'), 1.0) self.identical(fromHex('0X1P0'), 1.0) self.identical(fromHex('0x1P0'), 1.0) self.identical(fromHex('0x1.p0'), 1.0) self.identical(fromHex('0x1.0p0'), 1.0) self.identical(fromHex('0x.1p4'), 1.0) self.identical(fromHex('0x.1p04'), 1.0) self.identical(fromHex('0x.1p004'), 1.0) self.identical(fromHex('0x1p+0'), 1.0) self.identical(fromHex('0x1P-0'), 1.0) self.identical(fromHex('+0x1p0'), 1.0) self.identical(fromHex('0x01p0'), 1.0) self.identical(fromHex('0x1p00'), 1.0) self.identical(fromHex(' 0x1p0 '), 1.0) self.identical(fromHex('\n 0x1p0'), 1.0) self.identical(fromHex('0x1p0 \t'), 1.0) self.identical(fromHex('0xap0'), 10.0) self.identical(fromHex('0xAp0'), 10.0) self.identical(fromHex('0xaP0'), 10.0) self.identical(fromHex('0xAP0'), 10.0) self.identical(fromHex('0xbep0'), 190.0) self.identical(fromHex('0xBep0'), 190.0) self.identical(fromHex('0xbEp0'), 190.0) self.identical(fromHex('0XBE0P-4'), 190.0) self.identical(fromHex('0xBEp0'), 190.0) self.identical(fromHex('0xB.Ep4'), 190.0) self.identical(fromHex('0x.BEp8'), 190.0) self.identical(fromHex('0x.0BEp12'), 190.0) # moving the point around pi = fromHex('0x1.921fb54442d18p1') self.identical(fromHex('0x.006487ed5110b46p11'), pi) self.identical(fromHex('0x.00c90fdaa22168cp10'), pi) self.identical(fromHex('0x.01921fb54442d18p9'), pi) self.identical(fromHex('0x.03243f6a8885a3p8'), pi) self.identical(fromHex('0x.06487ed5110b46p7'), pi) self.identical(fromHex('0x.0c90fdaa22168cp6'), pi) self.identical(fromHex('0x.1921fb54442d18p5'), pi) self.identical(fromHex('0x.3243f6a8885a3p4'), pi) self.identical(fromHex('0x.6487ed5110b46p3'), pi) self.identical(fromHex('0x.c90fdaa22168cp2'), pi) self.identical(fromHex('0x1.921fb54442d18p1'), pi) self.identical(fromHex('0x3.243f6a8885a3p0'), pi) self.identical(fromHex('0x6.487ed5110b46p-1'), pi) self.identical(fromHex('0xc.90fdaa22168cp-2'), pi) self.identical(fromHex('0x19.21fb54442d18p-3'), pi) self.identical(fromHex('0x32.43f6a8885a3p-4'), pi) self.identical(fromHex('0x64.87ed5110b46p-5'), pi) self.identical(fromHex('0xc9.0fdaa22168cp-6'), pi) self.identical(fromHex('0x192.1fb54442d18p-7'), pi) self.identical(fromHex('0x324.3f6a8885a3p-8'), pi) self.identical(fromHex('0x648.7ed5110b46p-9'), pi) self.identical(fromHex('0xc90.fdaa22168cp-10'), pi) self.identical(fromHex('0x1921.fb54442d18p-11'), pi) # ... self.identical(fromHex('0x1921fb54442d1.8p-47'), pi) self.identical(fromHex('0x3243f6a8885a3p-48'), pi) self.identical(fromHex('0x6487ed5110b46p-49'), pi) self.identical(fromHex('0xc90fdaa22168cp-50'), pi) self.identical(fromHex('0x1921fb54442d18p-51'), pi) self.identical(fromHex('0x3243f6a8885a30p-52'), pi) self.identical(fromHex('0x6487ed5110b460p-53'), pi) self.identical(fromHex('0xc90fdaa22168c0p-54'), pi) self.identical(fromHex('0x1921fb54442d180p-55'), pi) # results that should overflow... self.assertRaises(OverflowError, fromHex, '-0x1p1024') self.assertRaises(OverflowError, fromHex, '0x1p+1025') self.assertRaises(OverflowError, fromHex, '+0X1p1030') self.assertRaises(OverflowError, fromHex, '-0x1p+1100') self.assertRaises(OverflowError, fromHex, '0X1p123456789123456789') self.assertRaises(OverflowError, fromHex, '+0X.8p+1025') self.assertRaises(OverflowError, fromHex, '+0x0.8p1025') self.assertRaises(OverflowError, fromHex, '-0x0.4p1026') self.assertRaises(OverflowError, fromHex, '0X2p+1023') self.assertRaises(OverflowError, fromHex, '0x2.p1023') self.assertRaises(OverflowError, fromHex, '-0x2.0p+1023') self.assertRaises(OverflowError, fromHex, '+0X4p+1022') self.assertRaises(OverflowError, fromHex, '0x1.ffffffffffffffp+1023') self.assertRaises(OverflowError, fromHex, '-0X1.fffffffffffff9p1023') self.assertRaises(OverflowError, fromHex, '0X1.fffffffffffff8p1023') self.assertRaises(OverflowError, fromHex, '+0x3.fffffffffffffp1022') self.assertRaises(OverflowError, fromHex, '0x3fffffffffffffp+970') self.assertRaises(OverflowError, fromHex, '0x10000000000000000p960') self.assertRaises(OverflowError, fromHex, '-0Xffffffffffffffffp960') # ...and those that round to +-max float self.identical(fromHex('+0x1.fffffffffffffp+1023'), MAX) self.identical(fromHex('-0X1.fffffffffffff7p1023'), -MAX) self.identical(fromHex('0X1.fffffffffffff7fffffffffffffp1023'), MAX) # zeros self.identical(fromHex('0x0p0'), 0.0) self.identical(fromHex('0x0p1000'), 0.0) self.identical(fromHex('-0x0p1023'), -0.0) self.identical(fromHex('0X0p1024'), 0.0) self.identical(fromHex('-0x0p1025'), -0.0) self.identical(fromHex('0X0p2000'), 0.0) self.identical(fromHex('0x0p123456789123456789'), 0.0) self.identical(fromHex('-0X0p-0'), -0.0) self.identical(fromHex('-0X0p-1000'), -0.0) self.identical(fromHex('0x0p-1023'), 0.0) self.identical(fromHex('-0X0p-1024'), -0.0) self.identical(fromHex('-0x0p-1025'), -0.0) self.identical(fromHex('-0x0p-1072'), -0.0) self.identical(fromHex('0X0p-1073'), 0.0) self.identical(fromHex('-0x0p-1074'), -0.0) self.identical(fromHex('0x0p-1075'), 0.0) self.identical(fromHex('0X0p-1076'), 0.0) self.identical(fromHex('-0X0p-2000'), -0.0) self.identical(fromHex('-0x0p-123456789123456789'), -0.0) # values that should underflow to 0 self.identical(fromHex('0X1p-1075'), 0.0) self.identical(fromHex('-0X1p-1075'), -0.0) self.identical(fromHex('-0x1p-123456789123456789'), -0.0) self.identical(fromHex('0x1.00000000000000001p-1075'), TINY) self.identical(fromHex('-0x1.1p-1075'), -TINY) self.identical(fromHex('0x1.fffffffffffffffffp-1075'), TINY) # check round-half-even is working correctly near 0 ... self.identical(fromHex('0x1p-1076'), 0.0) self.identical(fromHex('0X2p-1076'), 0.0) self.identical(fromHex('0X3p-1076'), TINY) self.identical(fromHex('0x4p-1076'), TINY) self.identical(fromHex('0X5p-1076'), TINY) self.identical(fromHex('0X6p-1076'), 2*TINY) self.identical(fromHex('0x7p-1076'), 2*TINY) self.identical(fromHex('0X8p-1076'), 2*TINY) self.identical(fromHex('0X9p-1076'), 2*TINY) self.identical(fromHex('0xap-1076'), 2*TINY) self.identical(fromHex('0Xbp-1076'), 3*TINY) self.identical(fromHex('0xcp-1076'), 3*TINY) self.identical(fromHex('0Xdp-1076'), 3*TINY) self.identical(fromHex('0Xep-1076'), 4*TINY) self.identical(fromHex('0xfp-1076'), 4*TINY) self.identical(fromHex('0x10p-1076'), 4*TINY) self.identical(fromHex('-0x1p-1076'), -0.0) self.identical(fromHex('-0X2p-1076'), -0.0) self.identical(fromHex('-0x3p-1076'), -TINY) self.identical(fromHex('-0X4p-1076'), -TINY) self.identical(fromHex('-0x5p-1076'), -TINY) self.identical(fromHex('-0x6p-1076'), -2*TINY) self.identical(fromHex('-0X7p-1076'), -2*TINY) self.identical(fromHex('-0X8p-1076'), -2*TINY) self.identical(fromHex('-0X9p-1076'), -2*TINY) self.identical(fromHex('-0Xap-1076'), -2*TINY) self.identical(fromHex('-0xbp-1076'), -3*TINY) self.identical(fromHex('-0xcp-1076'), -3*TINY) self.identical(fromHex('-0Xdp-1076'), -3*TINY) self.identical(fromHex('-0xep-1076'), -4*TINY) self.identical(fromHex('-0Xfp-1076'), -4*TINY) self.identical(fromHex('-0X10p-1076'), -4*TINY) # ... and near MIN ... self.identical(fromHex('0x0.ffffffffffffd6p-1022'), MIN-3*TINY) self.identical(fromHex('0x0.ffffffffffffd8p-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffdap-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffdcp-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffdep-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffe0p-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffe2p-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffe4p-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffe6p-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffe8p-1022'), MIN-2*TINY) self.identical(fromHex('0x0.ffffffffffffeap-1022'), MIN-TINY) self.identical(fromHex('0x0.ffffffffffffecp-1022'), MIN-TINY) self.identical(fromHex('0x0.ffffffffffffeep-1022'), MIN-TINY) self.identical(fromHex('0x0.fffffffffffff0p-1022'), MIN-TINY) self.identical(fromHex('0x0.fffffffffffff2p-1022'), MIN-TINY) self.identical(fromHex('0x0.fffffffffffff4p-1022'), MIN-TINY) self.identical(fromHex('0x0.fffffffffffff6p-1022'), MIN-TINY) self.identical(fromHex('0x0.fffffffffffff8p-1022'), MIN) self.identical(fromHex('0x0.fffffffffffffap-1022'), MIN) self.identical(fromHex('0x0.fffffffffffffcp-1022'), MIN) self.identical(fromHex('0x0.fffffffffffffep-1022'), MIN) self.identical(fromHex('0x1.00000000000000p-1022'), MIN) self.identical(fromHex('0x1.00000000000002p-1022'), MIN) self.identical(fromHex('0x1.00000000000004p-1022'), MIN) self.identical(fromHex('0x1.00000000000006p-1022'), MIN) self.identical(fromHex('0x1.00000000000008p-1022'), MIN) self.identical(fromHex('0x1.0000000000000ap-1022'), MIN+TINY) self.identical(fromHex('0x1.0000000000000cp-1022'), MIN+TINY) self.identical(fromHex('0x1.0000000000000ep-1022'), MIN+TINY) self.identical(fromHex('0x1.00000000000010p-1022'), MIN+TINY) self.identical(fromHex('0x1.00000000000012p-1022'), MIN+TINY) self.identical(fromHex('0x1.00000000000014p-1022'), MIN+TINY) self.identical(fromHex('0x1.00000000000016p-1022'), MIN+TINY) self.identical(fromHex('0x1.00000000000018p-1022'), MIN+2*TINY) # ... and near 1.0. self.identical(fromHex('0x0.fffffffffffff0p0'), 1.0-EPS) self.identical(fromHex('0x0.fffffffffffff1p0'), 1.0-EPS) self.identical(fromHex('0X0.fffffffffffff2p0'), 1.0-EPS) self.identical(fromHex('0x0.fffffffffffff3p0'), 1.0-EPS) self.identical(fromHex('0X0.fffffffffffff4p0'), 1.0-EPS) self.identical(fromHex('0X0.fffffffffffff5p0'), 1.0-EPS/2) self.identical(fromHex('0X0.fffffffffffff6p0'), 1.0-EPS/2) self.identical(fromHex('0x0.fffffffffffff7p0'), 1.0-EPS/2) self.identical(fromHex('0x0.fffffffffffff8p0'), 1.0-EPS/2) self.identical(fromHex('0X0.fffffffffffff9p0'), 1.0-EPS/2) self.identical(fromHex('0X0.fffffffffffffap0'), 1.0-EPS/2) self.identical(fromHex('0x0.fffffffffffffbp0'), 1.0-EPS/2) self.identical(fromHex('0X0.fffffffffffffcp0'), 1.0) self.identical(fromHex('0x0.fffffffffffffdp0'), 1.0) self.identical(fromHex('0X0.fffffffffffffep0'), 1.0) self.identical(fromHex('0x0.ffffffffffffffp0'), 1.0) self.identical(fromHex('0X1.00000000000000p0'), 1.0) self.identical(fromHex('0X1.00000000000001p0'), 1.0) self.identical(fromHex('0x1.00000000000002p0'), 1.0) self.identical(fromHex('0X1.00000000000003p0'), 1.0) self.identical(fromHex('0x1.00000000000004p0'), 1.0) self.identical(fromHex('0X1.00000000000005p0'), 1.0) self.identical(fromHex('0X1.00000000000006p0'), 1.0) self.identical(fromHex('0X1.00000000000007p0'), 1.0) self.identical(fromHex('0x1.00000000000007ffffffffffffffffffffp0'), 1.0) self.identical(fromHex('0x1.00000000000008p0'), 1.0) self.identical(fromHex('0x1.00000000000008000000000000000001p0'), 1+EPS) self.identical(fromHex('0X1.00000000000009p0'), 1.0+EPS) self.identical(fromHex('0x1.0000000000000ap0'), 1.0+EPS) self.identical(fromHex('0x1.0000000000000bp0'), 1.0+EPS) self.identical(fromHex('0X1.0000000000000cp0'), 1.0+EPS) self.identical(fromHex('0x1.0000000000000dp0'), 1.0+EPS) self.identical(fromHex('0x1.0000000000000ep0'), 1.0+EPS) self.identical(fromHex('0X1.0000000000000fp0'), 1.0+EPS) self.identical(fromHex('0x1.00000000000010p0'), 1.0+EPS) self.identical(fromHex('0X1.00000000000011p0'), 1.0+EPS) self.identical(fromHex('0x1.00000000000012p0'), 1.0+EPS) self.identical(fromHex('0X1.00000000000013p0'), 1.0+EPS) self.identical(fromHex('0X1.00000000000014p0'), 1.0+EPS) self.identical(fromHex('0x1.00000000000015p0'), 1.0+EPS) self.identical(fromHex('0x1.00000000000016p0'), 1.0+EPS) self.identical(fromHex('0X1.00000000000017p0'), 1.0+EPS) self.identical(fromHex('0x1.00000000000017ffffffffffffffffffffp0'), 1.0+EPS) self.identical(fromHex('0x1.00000000000018p0'), 1.0+2*EPS) self.identical(fromHex('0X1.00000000000018000000000000000001p0'), 1.0+2*EPS) self.identical(fromHex('0x1.00000000000019p0'), 1.0+2*EPS) self.identical(fromHex('0X1.0000000000001ap0'), 1.0+2*EPS) self.identical(fromHex('0X1.0000000000001bp0'), 1.0+2*EPS) self.identical(fromHex('0x1.0000000000001cp0'), 1.0+2*EPS) self.identical(fromHex('0x1.0000000000001dp0'), 1.0+2*EPS) self.identical(fromHex('0x1.0000000000001ep0'), 1.0+2*EPS) self.identical(fromHex('0X1.0000000000001fp0'), 1.0+2*EPS) self.identical(fromHex('0x1.00000000000020p0'), 1.0+2*EPS) def test_roundtrip(self): def roundtrip(x): return fromHex(toHex(x)) for x in [NAN, INF, self.MAX, self.MIN, self.MIN-self.TINY, self.TINY, 0.0]: self.identical(x, roundtrip(x)) self.identical(-x, roundtrip(-x)) # fromHex(toHex(x)) should exactly recover x, for any non-NaN float x. import random for i in range(10000): e = random.randrange(-1200, 1200) m = random.random() s = random.choice([1.0, -1.0]) try: x = s*ldexp(m, e) except OverflowError: pass else: self.identical(x, fromHex(toHex(x))) def test_subclass(self): class F(float): def __new__(cls, value): return float.__new__(cls, value + 1) f = F.fromhex((1.5).hex()) self.assertIs(type(f), F) self.assertEqual(f, 2.5) class F2(float): def __init__(self, value): self.foo = 'bar' f = F2.fromhex((1.5).hex()) self.assertIs(type(f), F2) self.assertEqual(f, 1.5) self.assertEqual(getattr(f, 'foo', 'none'), 'bar') if __name__ == '__main__': unittest.main()
64,439
1,446
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/badkey.pem
-----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- Bad Key, though the cert should be OK -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1 NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8 M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb 08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/ iHkC6gGdBJhogs4= -----END CERTIFICATE-----
2,162
41
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_threading.py
""" Tests for the threading module. """ import test.support from test.support import (verbose, import_module, cpython_only, requires_type_collecting) from test.support.script_helper import assert_python_ok, assert_python_failure import random import sys import cosmo _thread = import_module('_thread') threading = import_module('threading') import time import unittest import weakref import os import subprocess from test import lock_tests from test import support # Between fork() and exec(), only async-safe functions are allowed (issues # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', 'hp-ux11') # A trivial mutable counter. class Counter(object): def __init__(self): self.value = 0 def inc(self): self.value += 1 def dec(self): self.value -= 1 def get(self): return self.value class TestThread(threading.Thread): def __init__(self, name, testcase, sema, mutex, nrunning): threading.Thread.__init__(self, name=name) self.testcase = testcase self.sema = sema self.mutex = mutex self.nrunning = nrunning def run(self): delay = random.random() / 10000.0 if verbose: print('task %s will run for %.1f usec' % (self.name, delay * 1e6)) with self.sema: with self.mutex: self.nrunning.inc() if verbose: print(self.nrunning.get(), 'tasks are running') self.testcase.assertLessEqual(self.nrunning.get(), 3) time.sleep(delay) if verbose: print('task', self.name, 'done') with self.mutex: self.nrunning.dec() self.testcase.assertGreaterEqual(self.nrunning.get(), 0) if verbose: print('%s is finished. %d tasks are running' % (self.name, self.nrunning.get())) class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test.support.threading_setup() def tearDown(self): test.support.threading_cleanup(*self._threads) test.support.reap_children() class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10 # no more than 3 of the 10 can run at once sema = threading.BoundedSemaphore(value=3) mutex = threading.RLock() numrunning = Counter() threads = [] for i in range(NUMTASKS): t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning) threads.append(t) self.assertIsNone(t.ident) self.assertRegex(repr(t), r'^<TestThread\(.*, initial\)>$') t.start() if verbose: print('waiting for all tasks to complete') for t in threads: t.join() self.assertFalse(t.is_alive()) self.assertNotEqual(t.ident, 0) self.assertIsNotNone(t.ident) self.assertRegex(repr(t), r'^<TestThread\(.*, stopped -?\d+\)>$') if verbose: print('all tasks done') self.assertEqual(numrunning.get(), 0) def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertIsNotNone(threading.currentThread().ident) def f(): ident.append(threading.currentThread().ident) done.set() done = threading.Event() ident = [] with support.wait_threads_exit(): tid = _thread.start_new_thread(f, ()) done.wait() self.assertEqual(ident[0], tid) # Kill the "immortal" _DummyThread del threading._active[ident[0]] # run with a small(ish) thread stack size (256kB) def test_various_ops_small_stack(self): if verbose: print('with 256kB thread stack size...') try: threading.stack_size(262144) except _thread.error: raise unittest.SkipTest( 'platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) # run with a large thread stack size (1MB) def test_various_ops_large_stack(self): if verbose: print('with 1MB thread stack size...') try: threading.stack_size(0x100000) except _thread.error: raise unittest.SkipTest( 'platform does not support changing thread stack size') self.test_various_ops() threading.stack_size(0) def test_foreign_thread(self): # Check that a "foreign" thread can use the threading module. def f(mutex): # Calling current_thread() forces an entry for the foreign # thread to get made in the threading._active map. threading.current_thread() mutex.release() mutex = threading.Lock() mutex.acquire() with support.wait_threads_exit(): tid = _thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assertIn(tid, threading._active) self.assertIsInstance(threading._active[tid], threading._DummyThread) #Issue 29376 self.assertTrue(threading._active[tid].is_alive()) self.assertRegex(repr(threading._active[tid]), '_DummyThread') del threading._active[tid] def test_limbo_cleanup(self): # Issue 7481: Failure to start thread should cleanup the limbo map. def fail_new_thread(*args): raise threading.ThreadError() _start_new_thread = threading._start_new_thread threading._start_new_thread = fail_new_thread try: t = threading.Thread(target=lambda: None) self.assertRaises(threading.ThreadError, t.start) self.assertFalse( t in threading._limbo, "Failed to cleanup _limbo map on failure of Thread.start().") finally: threading._start_new_thread = _start_new_thread def test_finalize_runnning_thread(self): # Issue 1402: the PyGILState_Ensure / _Release functions may be called # very late on python exit: on deallocation of a running thread for # example. import_module("ctypes") rc, out, err = assert_python_failure("-c", """if 1: import ctypes, sys, time, _thread # This lock is used as a simple event variable. ready = _thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: ensure = ctypes.pythonapi.PyGILState_Ensure release = ctypes.pythonapi.PyGILState_Release def __del__(self): state = self.ensure() self.release(state) def waitingThread(): x = C() ready.release() time.sleep(100) _thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """) self.assertEqual(rc, 42) def test_finalize_with_trace(self): # Issue1733757 # Avoid a deadlock when sys.settrace steps into threading._shutdown assert_python_ok("-c", """if 1: import sys, threading # A deadlock-killer, to prevent the # testsuite to hang forever def killer(): import os, time time.sleep(2) print('program blocked; aborting') os._exit(2) t = threading.Thread(target=killer) t.daemon = True t.start() # This is the trace function def func(frame, event, arg): threading.current_thread() return func sys.settrace(func) """) def test_join_nondaemon_on_shutdown(self): # Issue 1722344 # Raising SystemExit skipped threading._shutdown rc, out, err = assert_python_ok("-c", """if 1: import threading from time import sleep def child(): sleep(1) # As a non-daemon thread we SHOULD wake up and nothing # should be torn down yet print("Woke up, sleep function is:", sleep) threading.Thread(target=child).start() raise SystemExit """) self.assertEqual(out.strip(), b"Woke up, sleep function is: <built-in function sleep>") self.assertEqual(err, b"") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. enum = threading.enumerate old_interval = sys.getswitchinterval() try: for i in range(1, 100): sys.setswitchinterval(i * 0.0002) t = threading.Thread(target=lambda: None) t.start() t.join() l = enum() self.assertNotIn(t, l, "#1703448 triggered after %d trials: %s" % (i, l)) finally: sys.setswitchinterval(old_interval) def test_no_refcycle_through_target(self): class RunSelfFunction(object): def __init__(self, should_raise): # The links in this refcycle from Thread back to self # should be cleaned up when the thread completes. self.should_raise = should_raise self.thread = threading.Thread(target=self._run, args=(self,), kwargs={'yet_another':self}) self.thread.start() def _run(self, other_ref, yet_another): if self.should_raise: raise SystemExit cyclic_object = RunSelfFunction(should_raise=False) weak_cyclic_object = weakref.ref(cyclic_object) cyclic_object.thread.join() del cyclic_object self.assertIsNone(weak_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_cyclic_object()))) raising_cyclic_object = RunSelfFunction(should_raise=True) weak_raising_cyclic_object = weakref.ref(raising_cyclic_object) raising_cyclic_object.thread.join() del raising_cyclic_object self.assertIsNone(weak_raising_cyclic_object(), msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) def test_old_threading_api(self): # Just a quick sanity check to make sure the old method names are # still present t = threading.Thread() t.isDaemon() t.setDaemon(True) t.getName() t.setName("name") t.isAlive() e = threading.Event() e.isSet() threading.activeCount() def test_repr_daemon(self): t = threading.Thread() self.assertNotIn('daemon', repr(t)) t.daemon = True self.assertIn('daemon', repr(t)) def test_deamon_param(self): t = threading.Thread() self.assertFalse(t.daemon) t = threading.Thread(daemon=False) self.assertFalse(t.daemon) t = threading.Thread(daemon=True) self.assertTrue(t.daemon) @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') def test_dummy_thread_after_fork(self): # Issue #14308: a dummy thread in the active list doesn't mess up # the after-fork mechanism. code = """if 1: import _thread, threading, os, time def background_thread(evt): # Creates and registers the _DummyThread instance threading.current_thread() evt.set() time.sleep(10) evt = threading.Event() _thread.start_new_thread(background_thread, (evt,)) evt.wait() assert threading.active_count() == 2, threading.active_count() if os.fork() == 0: assert threading.active_count() == 1, threading.active_count() os._exit(0) else: os.wait() """ _, out, err = assert_python_ok("-c", code) self.assertEqual(out, b'') self.assertEqual(err, b'') @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_is_alive_after_fork(self): # Try hard to trigger #18418: is_alive() could sometimes be True on # threads that vanished after a fork. old_interval = sys.getswitchinterval() self.addCleanup(sys.setswitchinterval, old_interval) # Make the bug more likely to manifest. test.support.setswitchinterval(1e-6) for i in range(20): t = threading.Thread(target=lambda: None) t.start() pid = os.fork() if pid == 0: os._exit(11 if t.is_alive() else 10) else: t.join() pid, status = os.waitpid(pid, 0) self.assertTrue(os.WIFEXITED(status)) self.assertEqual(10, os.WEXITSTATUS(status)) def test_main_thread(self): main = threading.main_thread() self.assertEqual(main.name, 'MainThread') self.assertEqual(main.ident, threading.current_thread().ident) self.assertEqual(main.ident, threading.get_ident()) def f(): self.assertNotEqual(threading.main_thread().ident, threading.current_thread().ident) th = threading.Thread(target=f) th.start() th.join() @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") @unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()") def test_main_thread_after_fork(self): code = """if 1: import os, threading pid = os.fork() if pid == 0: main = threading.main_thread() print(main.name) print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) else: os.waitpid(pid, 0) """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') self.assertEqual(err, b"") self.assertEqual(data, "MainThread\nTrue\nTrue\n") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") @unittest.skipUnless(hasattr(os, 'waitpid'), "test needs os.waitpid()") def test_main_thread_after_fork_from_nonmain_thread(self): code = """if 1: import os, threading, sys def f(): pid = os.fork() if pid == 0: main = threading.main_thread() print(main.name) print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) # stdout is fully buffered because not a tty, # we have to flush before exit. sys.stdout.flush() else: os.waitpid(pid, 0) th = threading.Thread(target=f) th.start() th.join() """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') self.assertEqual(err, b"") self.assertEqual(data, "Thread-1\nTrue\nTrue\n") @requires_type_collecting def test_main_thread_during_shutdown(self): # bpo-31516: current_thread() should still point to the main thread # at shutdown code = """if 1: import gc, threading main_thread = threading.current_thread() assert main_thread is threading.main_thread() # sanity check class RefCycle: def __init__(self): self.cycle = self def __del__(self): print("GC:", threading.current_thread() is main_thread, threading.main_thread() is main_thread, threading.enumerate() == [main_thread]) RefCycle() gc.collect() # sanity check x = RefCycle() """ _, out, err = assert_python_ok("-c", code) data = out.decode() self.assertEqual(err, b"") self.assertEqual(data.splitlines(), ["GC: True True True"] * 2) def test_tstate_lock(self): # Test an implementation detail of Thread objects. started = _thread.allocate_lock() finish = _thread.allocate_lock() started.acquire() finish.acquire() def f(): started.release() finish.acquire() time.sleep(0.01) # The tstate lock is None until the thread is started t = threading.Thread(target=f) self.assertIs(t._tstate_lock, None) t.start() started.acquire() self.assertTrue(t.is_alive()) # The tstate lock can't be acquired when the thread is running # (or suspended). tstate_lock = t._tstate_lock self.assertFalse(tstate_lock.acquire(timeout=0), False) finish.release() # When the thread ends, the state_lock can be successfully # acquired. self.assertTrue(tstate_lock.acquire(timeout=5), False) # But is_alive() is still True: we hold _tstate_lock now, which # prevents is_alive() from knowing the thread's end-of-life C code # is done. self.assertTrue(t.is_alive()) # Let is_alive() find out the C code is done. tstate_lock.release() self.assertFalse(t.is_alive()) # And verify the thread disposed of _tstate_lock. self.assertIsNone(t._tstate_lock) t.join() def test_repr_stopped(self): # Verify that "stopped" shows up in repr(Thread) appropriately. started = _thread.allocate_lock() finish = _thread.allocate_lock() started.acquire() finish.acquire() def f(): started.release() finish.acquire() t = threading.Thread(target=f) t.start() started.acquire() self.assertIn("started", repr(t)) finish.release() # "stopped" should appear in the repr in a reasonable amount of time. # Implementation detail: as of this writing, that's trivially true # if .join() is called, and almost trivially true if .is_alive() is # called. The detail we're testing here is that "stopped" shows up # "all on its own". LOOKING_FOR = "stopped" for i in range(500): if LOOKING_FOR in repr(t): break time.sleep(0.01) self.assertIn(LOOKING_FOR, repr(t)) # we waited at least 5 seconds t.join() def test_BoundedSemaphore_limit(self): # BoundedSemaphore should raise ValueError if released too often. for limit in range(1, 10): bs = threading.BoundedSemaphore(limit) threads = [threading.Thread(target=bs.acquire) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() threads = [threading.Thread(target=bs.release) for _ in range(limit)] for t in threads: t.start() for t in threads: t.join() self.assertRaises(ValueError, bs.release) @cpython_only def test_frame_tstate_tracing(self): # Issue #14432: Crash when a generator is created in a C thread that is # destroyed while the generator is still used. The issue was that a # generator contains a frame, and the frame kept a reference to the # Python state of the destroyed C thread. The crash occurs when a trace # function is setup. def noop_trace(frame, event, arg): # no operation return noop_trace def generator(): while 1: yield "generator" def callback(): if callback.gen is None: callback.gen = generator() return next(callback.gen) callback.gen = None old_trace = sys.gettrace() sys.settrace(noop_trace) try: # Install a trace function threading.settrace(noop_trace) # Create a generator in a C thread which exits after the call import _testcapi _testcapi.call_in_temporary_c_thread(callback) # Call the generator in a different Python thread, check that the # generator didn't keep a reference to the destroyed thread state for test in range(3): # The trace function is still called here callback() finally: sys.settrace(old_trace) class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): script = """if 1: import sys, os, time, threading # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() print('end of thread') # stdout is fully buffered because not a tty, we have to flush # before exit. sys.stdout.flush() \n""" + script rc, out, err = assert_python_ok("-c", script) data = out.decode().replace('\r', '') self.assertEqual(data, "end of main\nend of thread\n") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread script = """if 1: import os t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() time.sleep(0.1) print('end of main') """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter script = """if 1: childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() print('end of main') """ self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. script = """if 1: main_thread = threading.current_thread() def worker(): childpid = os.fork() if childpid != 0: os.waitpid(childpid, 0) sys.exit(0) t = threading.Thread(target=joiningfunc, args=(main_thread,)) print('end of main') t.start() t.join() # Should not block: main_thread is already stopped w = threading.Thread(target=worker) w.start() """ self._run_and_join(script) @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_4_daemon_threads(self): # Check that a daemon thread cannot crash the interpreter on shutdown # by manipulating internal structures that are being disposed of in # the main thread. script = """if True: import os import random import sys import time import threading thread_has_run = set() def random_io(): '''Loop for a while sleeping random tiny amounts and doing some I/O.''' while True: in_f = open(os.__file__, 'rb') stuff = in_f.read(200) null_f = open(os.devnull, 'wb') null_f.write(stuff) time.sleep(random.random() / 1995) null_f.close() in_f.close() thread_has_run.add(threading.current_thread()) def main(): count = 0 for _ in range(40): new_thread = threading.Thread(target=random_io) new_thread.daemon = True new_thread.start() count += 1 while len(thread_has_run) < count: time.sleep(0.001) # Trigger process shutdown sys.exit(0) main() """ rc, out, err = assert_python_ok('-c', script) self.assertFalse(err) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self): # Issue #13817: fork() would deadlock in a multithreaded program with # the ad-hoc TLS implementation. def do_fork_and_wait(): # just fork a child process and wait it pid = os.fork() if pid > 0: os.waitpid(pid, 0) else: os._exit(0) # start a bunch of threads that will fork() child processes threads = [] for i in range(16): t = threading.Thread(target=do_fork_and_wait) threads.append(t) t.start() for t in threads: t.join() @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") def test_clear_threads_states_after_fork(self): # Issue #17094: check that threads states are cleared after fork() # start a bunch of threads threads = [] for i in range(16): t = threading.Thread(target=lambda : time.sleep(0.3)) threads.append(t) t.start() pid = os.fork() if pid == 0: # check that threads states have been cleared if len(sys._current_frames()) == 1: os._exit(0) else: os._exit(1) else: _, status = os.waitpid(pid, 0) self.assertEqual(0, status) for t in threads: t.join() class SubinterpThreadingTests(BaseTestCase): def test_threads_join(self): # Non-daemon threads should be joined at subinterpreter shutdown # (issue #18808) r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) code = r"""if 1: import os import threading import time def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. time.sleep(0.05) os.write(%d, b"x") threading.Thread(target=f).start() """ % (w,) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0) # The thread was joined properly. self.assertEqual(os.read(r, 1), b"x") def test_threads_join_2(self): # Same as above, but a delay gets introduced after the thread's # Python code returned but before the thread state is deleted. # To achieve this, we register a thread-local object which sleeps # a bit when deallocated. r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) code = r"""if 1: import os import threading import time class Sleeper: def __del__(self): time.sleep(0.05) tls = threading.local() def f(): # Sleep a bit so that the thread is still running when # Py_EndInterpreter is called. time.sleep(0.05) tls.x = Sleeper() os.write(%d, b"x") threading.Thread(target=f).start() """ % (w,) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0) # The thread was joined properly. self.assertEqual(os.read(r, 1), b"x") @cpython_only def test_daemon_threads_fatal_error(self): subinterp_code = r"""if 1: import os import threading import time def f(): # Make sure the daemon thread is still running when # Py_EndInterpreter is called. time.sleep(10) threading.Thread(target=f, daemon=True).start() """ script = r"""if 1: import _testcapi _testcapi.run_in_subinterp(%r) """ % (subinterp_code,) with test.support.SuppressCrashReport(): rc, out, err = assert_python_failure("-c", script) self.assertIn("Fatal Python error: Py_EndInterpreter: " "not the last thread", err.decode()) class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, thread.start) thread.join() def test_joining_current_thread(self): current_thread = threading.current_thread() self.assertRaises(RuntimeError, current_thread.join); def test_joining_inactive_thread(self): thread = threading.Thread() self.assertRaises(RuntimeError, thread.join) def test_daemonize_active_thread(self): thread = threading.Thread() thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) thread.join() def test_releasing_unacquired_lock(self): lock = threading.Lock() self.assertRaises(RuntimeError, lock.release) @unittest.skipUnless(sys.platform == 'darwin' and test.support.python_is_optimized(), 'test macosx problem') def test_recursion_limit(self): # Issue 9670 # test that excessive recursion within a non-main thread causes # an exception rather than crashing the interpreter on platforms # like Mac OS X or FreeBSD which have small default stack sizes # for threads script = """if True: import threading def recurse(): return recurse() def outer(): try: recurse() except RecursionError: pass w = threading.Thread(target=outer) w.start() w.join() print('end of main thread') """ expected_output = "end of main thread\n" p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() data = stdout.decode().replace('\r', '') self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode()) self.assertEqual(data, expected_output) def test_print_exception(self): script = r"""if True: import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') err = err.decode() self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) @requires_type_collecting def test_print_exception_stderr_is_none_1(self): script = r"""if True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) sys.stderr = None running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') err = err.decode() self.assertIn("Exception in thread", err) self.assertIn("Traceback (most recent call last):", err) self.assertIn("ZeroDivisionError", err) self.assertNotIn("Unhandled exception", err) def test_print_exception_stderr_is_none_2(self): script = r"""if True: import sys import threading import time running = False def run(): global running running = True while running: time.sleep(0.01) 1/0 sys.stderr = None t = threading.Thread(target=run) t.start() while not running: time.sleep(0.01) running = False t.join() """ rc, out, err = assert_python_ok("-c", script) self.assertEqual(out, b'') self.assertNotIn("Unhandled exception", err.decode()) def test_bare_raise_in_brand_new_thread(self): def bare_raise(): raise class Issue27558(threading.Thread): exc = None def run(self): try: bare_raise() except Exception as exc: self.exc = exc thread = Issue27558() thread.start() thread.join() self.assertIsNotNone(thread.exc) self.assertIsInstance(thread.exc, RuntimeError) # explicitly break the reference cycle to not leak a dangling thread thread.exc = None class TimerTests(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) self.callback_args = [] self.callback_event = threading.Event() def test_init_immutable_default_args(self): # Issue 17435: constructor defaults were mutable objects, they could be # mutated via the object attributes and affect other Timer objects. timer1 = threading.Timer(0.01, self._callback_spy) timer1.start() self.callback_event.wait() timer1.args.append("blah") timer1.kwargs["foo"] = "bar" self.callback_event.clear() timer2 = threading.Timer(0.01, self._callback_spy) timer2.start() self.callback_event.wait() self.assertEqual(len(self.callback_args), 2) self.assertEqual(self.callback_args, [((), {}), ((), {})]) timer1.join() timer2.join() def _callback_spy(self, *args, **kwargs): self.callback_args.append((args[:], kwargs.copy())) self.callback_event.set() class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) class PyRLockTests(lock_tests.RLockTests): locktype = staticmethod(threading._PyRLock) @unittest.skipIf(threading._CRLock is None, 'RLock not implemented in C') class CRLockTests(lock_tests.RLockTests): locktype = staticmethod(threading._CRLock) class EventTests(lock_tests.EventTests): eventtype = staticmethod(threading.Event) class ConditionAsRLockTests(lock_tests.RLockTests): # Condition uses an RLock by default and exports its API. locktype = staticmethod(threading.Condition) class ConditionTests(lock_tests.ConditionTests): condtype = staticmethod(threading.Condition) class SemaphoreTests(lock_tests.SemaphoreTests): semtype = staticmethod(threading.Semaphore) class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests): semtype = staticmethod(threading.BoundedSemaphore) class BarrierTests(lock_tests.BarrierTests): barriertype = staticmethod(threading.Barrier) class MiscTestCase(unittest.TestCase): def test__all__(self): extra = {"ThreadError"} blacklist = {'currentThread', 'activeCount'} support.check__all__(self, threading, ('threading', '_thread'), extra=extra, blacklist=blacklist) if __name__ == "__main__": unittest.main()
38,254
1,088
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/pyclbr_input.py
"""Test cases for test_pyclbr.py""" def f(): pass class Other(object): @classmethod def foo(c): pass def om(self): pass class B (object): def bm(self): pass class C (B): foo = Other().foo om = Other.om d = 10 # XXX: This causes test_pyclbr.py to fail, but only because the # introspection-based is_method() code in the test can't # distinguish between this and a genuine method function like m(). # The pyclbr.py module gets this right as it parses the text. # #f = f def m(self): pass @staticmethod def sm(self): pass @classmethod def cm(self): pass
648
34
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_zipimport.py
import sys import os import marshal import importlib import importlib.util import struct import time import unittest from test import support from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED import zipimport import linecache import doctest import inspect import io from traceback import extract_tb, extract_stack, print_tb test_src = """\ def get_name(): return __name__ def get_file(): return __file__ """ test_co = compile(test_src, "<???>", "exec") raise_src = 'def do_raise(): raise TypeError\n' def make_pyc(co, mtime, size): data = marshal.dumps(co) if type(mtime) is type(0.0): # Mac mtimes need a bit of special casing if mtime < 0x7fffffff: mtime = int(mtime) else: mtime = int(-0x100000000 + int(mtime)) pyc = (importlib.util.MAGIC_NUMBER + struct.pack("<ii", int(mtime), size & 0xFFFFFFFF) + data) return pyc def module_path_to_dotted_name(path): return path.replace(os.sep, '.') NOW = time.time() test_pyc = make_pyc(test_co, NOW, len(test_src)) TESTMOD = "ziptestmodule" TESTPACK = "ziptestpackage" TESTPACK2 = "ziptestpackage2" TEMP_DIR = os.path.abspath("junk95142") TEMP_ZIP = os.path.abspath("junk95142.zip") pyc_file = importlib.util.cache_from_source(TESTMOD + '.py') pyc_ext = '.pyc' class ImportHooksBaseTestCase(unittest.TestCase): def setUp(self): self.path = sys.path[:] self.meta_path = sys.meta_path[:] self.path_hooks = sys.path_hooks[:] sys.path_importer_cache.clear() self.modules_before = support.modules_setup() def tearDown(self): sys.path[:] = self.path sys.meta_path[:] = self.meta_path sys.path_hooks[:] = self.path_hooks sys.path_importer_cache.clear() support.modules_cleanup(*self.modules_before) class UncompressedZipImportTestCase(ImportHooksBaseTestCase): compression = ZIP_STORED def setUp(self): # We're reusing the zip archive path, so we must clear the # cached directory info and linecache. linecache.clearcache() zipimport._zip_directory_cache.clear() ImportHooksBaseTestCase.setUp(self) def makeTree(self, files, dirName=TEMP_DIR): # Create a filesystem based set of modules/packages # defined by files under the directory dirName. self.addCleanup(support.rmtree, dirName) for name, (mtime, data) in files.items(): path = os.path.join(dirName, name) if path[-1] == os.sep: if not os.path.isdir(path): os.makedirs(path) else: dname = os.path.dirname(path) if not os.path.isdir(dname): os.makedirs(dname) with open(path, 'wb') as fp: fp.write(data) def makeZip(self, files, zipName=TEMP_ZIP, **kw): # Create a zip archive based set of modules/packages # defined by files in the zip file zipName. If the # key 'stuff' exists in kw it is prepended to the archive. self.addCleanup(support.unlink, zipName) with ZipFile(zipName, "w") as z: for name, (mtime, data) in files.items(): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression z.writestr(zinfo, data) stuff = kw.get("stuff", None) if stuff is not None: # Prepend 'stuff' to the start of the zipfile with open(zipName, "rb") as f: data = f.read() with open(zipName, "wb") as f: f.write(stuff) f.write(data) def doTest(self, expected_ext, files, *modules, **kw): self.makeZip(files, **kw) sys.path.insert(0, TEMP_ZIP) mod = importlib.import_module(".".join(modules)) call = kw.get('call') if call is not None: call(mod) if expected_ext: file = mod.get_file() self.assertEqual(file, os.path.join(TEMP_ZIP, *modules) + expected_ext) def testAFakeZlib(self): # # This could cause a stack overflow before: importing zlib.py # from a compressed archive would cause zlib to be imported # which would find zlib.py in the archive, which would... etc. # # This test *must* be executed first: it must be the first one # to trigger zipimport to import zlib (zipimport caches the # zlib.decompress function object, after which the problem being # tested here wouldn't be a problem anymore... # (Hence the 'A' in the test method name: to make it the first # item in a list sorted by name, like unittest.makeSuite() does.) # # This test fails on platforms on which the zlib module is # statically linked, but the problem it tests for can't # occur in that case (builtin modules are always found first), # so we'll simply skip it then. Bug #765456. # if "zlib" in sys.builtin_module_names: self.skipTest('zlib is a builtin module') if "zlib" in sys.modules: del sys.modules["zlib"] files = {"zlib.py": (NOW, test_src)} try: self.doTest(".py", files, "zlib") except ImportError: if self.compression != ZIP_DEFLATED: self.fail("expected test to not raise ImportError") else: if self.compression != ZIP_STORED: self.fail("expected test to raise ImportError") def testPy(self): files = {TESTMOD + ".py": (NOW, test_src)} self.doTest(".py", files, TESTMOD) def testPyc(self): files = {TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTMOD) def testBoth(self): files = {TESTMOD + ".py": (NOW, test_src), TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTMOD) def testEmptyPy(self): files = {TESTMOD + ".py": (NOW, "")} self.doTest(None, files, TESTMOD) def testBadMagic(self): # make pyc magic word invalid, forcing loading from .py badmagic_pyc = bytearray(test_pyc) badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit files = {TESTMOD + ".py": (NOW, test_src), TESTMOD + pyc_ext: (NOW, badmagic_pyc)} self.doTest(".py", files, TESTMOD) def testBadMagic2(self): # make pyc magic word invalid, causing an ImportError badmagic_pyc = bytearray(test_pyc) badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit files = {TESTMOD + pyc_ext: (NOW, badmagic_pyc)} try: self.doTest(".py", files, TESTMOD) except ImportError: pass else: self.fail("expected ImportError; import from bad pyc") def testBadMTime(self): return # fix issue in Modules/zipimport.c badtime_pyc = bytearray(test_pyc) # flip the second bit -- not the first as that one isn't stored in the # .py's mtime in the zip archive. badtime_pyc[7] ^= 0x02 files = {TESTMOD + ".py": (NOW, test_src), TESTMOD + pyc_ext: (NOW, badtime_pyc)} self.doTest(".py", files, TESTMOD) def testPackage(self): packdir = TESTPACK + os.sep files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc), packdir + TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTPACK, TESTMOD) def testSubPackage(self): # Test that subpackages function when loaded from zip # archives. packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc), packdir2 + "__init__" + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTPACK, TESTPACK2, TESTMOD) def testSubNamespacePackage(self): # Test that implicit namespace subpackages function # when loaded from zip archives. packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep # The first two files are just directory entries (so have no data). files = {packdir: (NOW, ""), packdir2: (NOW, ""), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTPACK, TESTPACK2, TESTMOD) def testMixedNamespacePackage(self): # Test implicit namespace packages spread between a # real filesystem and a zip archive. packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep packdir3 = packdir2 + TESTPACK + '3' + os.sep files1 = {packdir: (NOW, ""), packdir + TESTMOD + pyc_ext: (NOW, test_pyc), packdir2: (NOW, ""), packdir3: (NOW, ""), packdir3 + TESTMOD + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + '3' + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} files2 = {packdir: (NOW, ""), packdir + TESTMOD + '2' + pyc_ext: (NOW, test_pyc), packdir2: (NOW, ""), packdir2 + TESTMOD + '2' + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} zip1 = os.path.abspath("path1.zip") self.makeZip(files1, zip1) zip2 = TEMP_DIR self.makeTree(files2, zip2) # zip2 should override zip1. sys.path.insert(0, zip1) sys.path.insert(0, zip2) mod = importlib.import_module(TESTPACK) # if TESTPACK is functioning as a namespace pkg then # there should be two entries in the __path__. # First should be path2 and second path1. self.assertEqual(2, len(mod.__path__)) p1, p2 = mod.__path__ self.assertEqual(os.path.basename(TEMP_DIR), p1.split(os.sep)[-2]) self.assertEqual("path1.zip", p2.split(os.sep)[-2]) # packdir3 should import as a namespace package. # Its __path__ is an iterable of 1 element from zip1. mod = importlib.import_module(packdir3.replace(os.sep, '.')[:-1]) self.assertEqual(1, len(mod.__path__)) mpath = list(mod.__path__)[0].split('path1.zip' + os.sep)[1] self.assertEqual(packdir3[:-1], mpath) # TESTPACK/TESTMOD only exists in path1. mod = importlib.import_module('.'.join((TESTPACK, TESTMOD))) self.assertEqual("path1.zip", mod.__file__.split(os.sep)[-3]) # And TESTPACK/(TESTMOD + '2') only exists in path2. mod = importlib.import_module('.'.join((TESTPACK, TESTMOD + '2'))) self.assertEqual(os.path.basename(TEMP_DIR), mod.__file__.split(os.sep)[-3]) # One level deeper... subpkg = '.'.join((TESTPACK, TESTPACK2)) mod = importlib.import_module(subpkg) self.assertEqual(2, len(mod.__path__)) p1, p2 = mod.__path__ self.assertEqual(os.path.basename(TEMP_DIR), p1.split(os.sep)[-3]) self.assertEqual("path1.zip", p2.split(os.sep)[-3]) # subpkg.TESTMOD exists in both zips should load from zip2. mod = importlib.import_module('.'.join((subpkg, TESTMOD))) self.assertEqual(os.path.basename(TEMP_DIR), mod.__file__.split(os.sep)[-4]) # subpkg.TESTMOD + '2' only exists in zip2. mod = importlib.import_module('.'.join((subpkg, TESTMOD + '2'))) self.assertEqual(os.path.basename(TEMP_DIR), mod.__file__.split(os.sep)[-4]) # Finally subpkg.TESTMOD + '3' only exists in zip1. mod = importlib.import_module('.'.join((subpkg, TESTMOD + '3'))) self.assertEqual('path1.zip', mod.__file__.split(os.sep)[-4]) def testNamespacePackage(self): # Test implicit namespace packages spread between multiple zip # archives. packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep packdir3 = packdir2 + TESTPACK + '3' + os.sep files1 = {packdir: (NOW, ""), packdir + TESTMOD + pyc_ext: (NOW, test_pyc), packdir2: (NOW, ""), packdir3: (NOW, ""), packdir3 + TESTMOD + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + '3' + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} zip1 = os.path.abspath("path1.zip") self.makeZip(files1, zip1) files2 = {packdir: (NOW, ""), packdir + TESTMOD + '2' + pyc_ext: (NOW, test_pyc), packdir2: (NOW, ""), packdir2 + TESTMOD + '2' + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} zip2 = os.path.abspath("path2.zip") self.makeZip(files2, zip2) # zip2 should override zip1. sys.path.insert(0, zip1) sys.path.insert(0, zip2) mod = importlib.import_module(TESTPACK) # if TESTPACK is functioning as a namespace pkg then # there should be two entries in the __path__. # First should be path2 and second path1. self.assertEqual(2, len(mod.__path__)) p1, p2 = mod.__path__ self.assertEqual("path2.zip", p1.split(os.sep)[-2]) self.assertEqual("path1.zip", p2.split(os.sep)[-2]) # packdir3 should import as a namespace package. # Tts __path__ is an iterable of 1 element from zip1. mod = importlib.import_module(packdir3.replace(os.sep, '.')[:-1]) self.assertEqual(1, len(mod.__path__)) mpath = list(mod.__path__)[0].split('path1.zip' + os.sep)[1] self.assertEqual(packdir3[:-1], mpath) # TESTPACK/TESTMOD only exists in path1. mod = importlib.import_module('.'.join((TESTPACK, TESTMOD))) self.assertEqual("path1.zip", mod.__file__.split(os.sep)[-3]) # And TESTPACK/(TESTMOD + '2') only exists in path2. mod = importlib.import_module('.'.join((TESTPACK, TESTMOD + '2'))) self.assertEqual("path2.zip", mod.__file__.split(os.sep)[-3]) # One level deeper... subpkg = '.'.join((TESTPACK, TESTPACK2)) mod = importlib.import_module(subpkg) self.assertEqual(2, len(mod.__path__)) p1, p2 = mod.__path__ self.assertEqual("path2.zip", p1.split(os.sep)[-3]) self.assertEqual("path1.zip", p2.split(os.sep)[-3]) # subpkg.TESTMOD exists in both zips should load from zip2. mod = importlib.import_module('.'.join((subpkg, TESTMOD))) self.assertEqual('path2.zip', mod.__file__.split(os.sep)[-4]) # subpkg.TESTMOD + '2' only exists in zip2. mod = importlib.import_module('.'.join((subpkg, TESTMOD + '2'))) self.assertEqual('path2.zip', mod.__file__.split(os.sep)[-4]) # Finally subpkg.TESTMOD + '3' only exists in zip1. mod = importlib.import_module('.'.join((subpkg, TESTMOD + '3'))) self.assertEqual('path1.zip', mod.__file__.split(os.sep)[-4]) def testZipImporterMethods(self): packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc), packdir2 + "__init__" + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc), "spam" + pyc_ext: (NOW, test_pyc)} z = ZipFile(TEMP_ZIP, "w") try: for name, (mtime, data) in files.items(): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression zinfo.comment = b"spam" z.writestr(zinfo, data) z.close() zi = zipimport.zipimporter(TEMP_ZIP) self.assertEqual(zi.archive, TEMP_ZIP) self.assertEqual(zi.is_package(TESTPACK), True) find_mod = zi.find_module('spam') self.assertIsNotNone(find_mod) self.assertIsInstance(find_mod, zipimport.zipimporter) self.assertFalse(find_mod.is_package('spam')) load_mod = find_mod.load_module('spam') self.assertEqual(find_mod.get_filename('spam'), load_mod.__file__) mod = zi.load_module(TESTPACK) self.assertEqual(zi.get_filename(TESTPACK), mod.__file__) existing_pack_path = importlib.import_module(TESTPACK).__path__[0] expected_path_path = os.path.join(TEMP_ZIP, TESTPACK) self.assertEqual(existing_pack_path, expected_path_path) self.assertEqual(zi.is_package(packdir + '__init__'), False) self.assertEqual(zi.is_package(packdir + TESTPACK2), True) self.assertEqual(zi.is_package(packdir2 + TESTMOD), False) mod_path = packdir2 + TESTMOD mod_name = module_path_to_dotted_name(mod_path) mod = importlib.import_module(mod_name) self.assertTrue(mod_name in sys.modules) self.assertEqual(zi.get_source(TESTPACK), None) self.assertEqual(zi.get_source(mod_path), None) self.assertEqual(zi.get_filename(mod_path), mod.__file__) # To pass in the module name instead of the path, we must use the # right importer loader = mod.__loader__ self.assertEqual(loader.get_source(mod_name), None) self.assertEqual(loader.get_filename(mod_name), mod.__file__) # test prefix and archivepath members zi2 = zipimport.zipimporter(TEMP_ZIP + os.sep + TESTPACK) self.assertEqual(zi2.archive, TEMP_ZIP) self.assertEqual(zi2.prefix, TESTPACK + os.sep) finally: z.close() os.remove(TEMP_ZIP) def testZipImporterMethodsInSubDirectory(self): packdir = TESTPACK + os.sep packdir2 = packdir + TESTPACK2 + os.sep files = {packdir2 + "__init__" + pyc_ext: (NOW, test_pyc), packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} z = ZipFile(TEMP_ZIP, "w") try: for name, (mtime, data) in files.items(): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression zinfo.comment = b"eggs" z.writestr(zinfo, data) z.close() zi = zipimport.zipimporter(TEMP_ZIP + os.sep + packdir) self.assertEqual(zi.archive, TEMP_ZIP) self.assertEqual(zi.prefix, packdir) self.assertEqual(zi.is_package(TESTPACK2), True) mod = zi.load_module(TESTPACK2) self.assertEqual(zi.get_filename(TESTPACK2), mod.__file__) self.assertEqual( zi.is_package(TESTPACK2 + os.sep + '__init__'), False) self.assertEqual( zi.is_package(TESTPACK2 + os.sep + TESTMOD), False) pkg_path = TEMP_ZIP + os.sep + packdir + TESTPACK2 zi2 = zipimport.zipimporter(pkg_path) find_mod_dotted = zi2.find_module(TESTMOD) self.assertIsNotNone(find_mod_dotted) self.assertIsInstance(find_mod_dotted, zipimport.zipimporter) self.assertFalse(zi2.is_package(TESTMOD)) load_mod = find_mod_dotted.load_module(TESTMOD) self.assertEqual( find_mod_dotted.get_filename(TESTMOD), load_mod.__file__) mod_path = TESTPACK2 + os.sep + TESTMOD mod_name = module_path_to_dotted_name(mod_path) mod = importlib.import_module(mod_name) self.assertTrue(mod_name in sys.modules) self.assertEqual(zi.get_source(TESTPACK2), None) self.assertEqual(zi.get_source(mod_path), None) self.assertEqual(zi.get_filename(mod_path), mod.__file__) # To pass in the module name instead of the path, we must use the # right importer. loader = mod.__loader__ self.assertEqual(loader.get_source(mod_name), None) self.assertEqual(loader.get_filename(mod_name), mod.__file__) finally: z.close() os.remove(TEMP_ZIP) def testGetData(self): z = ZipFile(TEMP_ZIP, "w") z.compression = self.compression try: name = "testdata.dat" data = bytes(x for x in range(256)) z.writestr(name, data) z.close() zi = zipimport.zipimporter(TEMP_ZIP) self.assertEqual(data, zi.get_data(name)) self.assertIn('zipimporter object', repr(zi)) finally: z.close() os.remove(TEMP_ZIP) def test_issue31291(self): # There shouldn't be an assertion failure in get_data(). class FunnyStr(str): def replace(self, old, new): return 42 z = ZipFile(TEMP_ZIP, "w") try: name = "test31291.dat" data = b'foo' z.writestr(name, data) z.close() zi = zipimport.zipimporter(TEMP_ZIP) self.assertEqual(data, zi.get_data(FunnyStr(name))) finally: z.close() os.remove(TEMP_ZIP) def testImporterAttr(self): src = """if 1: # indent hack def get_file(): return __file__ if __loader__.get_data("some.data") != b"some data": raise AssertionError("bad data")\n""" pyc = make_pyc(compile(src, "<???>", "exec"), NOW, len(src)) files = {TESTMOD + pyc_ext: (NOW, pyc), "some.data": (NOW, "some data")} self.doTest(pyc_ext, files, TESTMOD) def testDefaultOptimizationLevel(self): # zipimport should use the default optimization level (#28131) src = """if 1: # indent hack def test(val): assert(val) return val\n""" files = {TESTMOD + '.py': (NOW, src)} self.makeZip(files) sys.path.insert(0, TEMP_ZIP) mod = importlib.import_module(TESTMOD) self.assertEqual(mod.test(1), 1) self.assertRaises(AssertionError, mod.test, False) def testImport_WithStuff(self): # try importing from a zipfile which contains additional # stuff at the beginning of the file files = {TESTMOD + ".py": (NOW, test_src)} self.doTest(".py", files, TESTMOD, stuff=b"Some Stuff"*31) def assertModuleSource(self, module): self.assertEqual(inspect.getsource(module), test_src) def testGetSource(self): files = {TESTMOD + ".py": (NOW, test_src)} self.doTest(".py", files, TESTMOD, call=self.assertModuleSource) def testGetCompiledSource(self): pyc = make_pyc(compile(test_src, "<???>", "exec"), NOW, len(test_src)) files = {TESTMOD + ".py": (NOW, test_src), TESTMOD + pyc_ext: (NOW, pyc)} self.doTest(pyc_ext, files, TESTMOD, call=self.assertModuleSource) def runDoctest(self, callback): files = {TESTMOD + ".py": (NOW, test_src), "xyz.txt": (NOW, ">>> log.append(True)\n")} self.doTest(".py", files, TESTMOD, call=callback) def doDoctestFile(self, module): log = [] old_master, doctest.master = doctest.master, None try: doctest.testfile( 'xyz.txt', package=module, module_relative=True, globs=locals() ) finally: doctest.master = old_master self.assertEqual(log,[True]) def testDoctestFile(self): self.runDoctest(self.doDoctestFile) def doDoctestSuite(self, module): log = [] doctest.DocFileTest( 'xyz.txt', package=module, module_relative=True, globs=locals() ).run() self.assertEqual(log,[True]) def testDoctestSuite(self): self.runDoctest(self.doDoctestSuite) def doTraceback(self, module): try: module.do_raise() except: tb = sys.exc_info()[2].tb_next f,lno,n,line = extract_tb(tb, 1)[0] self.assertEqual(line, raise_src.strip()) f,lno,n,line = extract_stack(tb.tb_frame, 1)[0] self.assertEqual(line, raise_src.strip()) s = io.StringIO() print_tb(tb, 1, s) self.assertTrue(s.getvalue().endswith(raise_src)) else: raise AssertionError("This ought to be impossible") def testTraceback(self): files = {TESTMOD + ".py": (NOW, raise_src)} self.doTest(None, files, TESTMOD, call=self.doTraceback) @unittest.skipIf(support.TESTFN_UNENCODABLE is None, "need an unencodable filename") def testUnencodable(self): filename = support.TESTFN_UNENCODABLE + ".zip" z = ZipFile(filename, "w") zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW)) zinfo.compress_type = self.compression z.writestr(zinfo, test_src) z.close() try: zipimport.zipimporter(filename).load_module(TESTMOD) finally: os.remove(filename) def testBytesPath(self): filename = support.TESTFN + ".zip" self.addCleanup(support.unlink, filename) with ZipFile(filename, "w") as z: zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW)) zinfo.compress_type = self.compression z.writestr(zinfo, test_src) zipimport.zipimporter(filename) zipimport.zipimporter(os.fsencode(filename)) with self.assertWarns(DeprecationWarning): zipimport.zipimporter(bytearray(os.fsencode(filename))) with self.assertWarns(DeprecationWarning): zipimport.zipimporter(memoryview(os.fsencode(filename))) @support.requires_zlib class CompressedZipImportTestCase(UncompressedZipImportTestCase): compression = ZIP_DEFLATED class BadFileZipImportTestCase(unittest.TestCase): def assertZipFailure(self, filename): self.assertRaises(zipimport.ZipImportError, zipimport.zipimporter, filename) def testNoFile(self): self.assertZipFailure('AdfjdkFJKDFJjdklfjs') def testEmptyFilename(self): self.assertZipFailure('') def testBadArgs(self): self.assertRaises(TypeError, zipimport.zipimporter, None) self.assertRaises(TypeError, zipimport.zipimporter, TESTMOD, kwd=None) self.assertRaises(TypeError, zipimport.zipimporter, list(os.fsencode(TESTMOD))) def testFilenameTooLong(self): self.assertZipFailure('A' * 33000) def testEmptyFile(self): support.unlink(TESTMOD) support.create_empty_file(TESTMOD) self.assertZipFailure(TESTMOD) def testFileUnreadable(self): support.unlink(TESTMOD) fd = os.open(TESTMOD, os.O_CREAT, 000) try: os.close(fd) with self.assertRaises(zipimport.ZipImportError) as cm: zipimport.zipimporter(TESTMOD) finally: # If we leave "the read-only bit" set on Windows, nothing can # delete TESTMOD, and later tests suffer bogus failures. os.chmod(TESTMOD, 0o666) support.unlink(TESTMOD) def testNotZipFile(self): support.unlink(TESTMOD) fp = open(TESTMOD, 'w+') fp.write('a' * 22) fp.close() self.assertZipFailure(TESTMOD) # XXX: disabled until this works on Big-endian machines def _testBogusZipFile(self): support.unlink(TESTMOD) fp = open(TESTMOD, 'w+') fp.write(struct.pack('=I', 0x06054B50)) fp.write('a' * 18) fp.close() z = zipimport.zipimporter(TESTMOD) try: self.assertRaises(TypeError, z.find_module, None) self.assertRaises(TypeError, z.load_module, None) self.assertRaises(TypeError, z.is_package, None) self.assertRaises(TypeError, z.get_code, None) self.assertRaises(TypeError, z.get_data, None) self.assertRaises(TypeError, z.get_source, None) error = zipimport.ZipImportError self.assertEqual(z.find_module('abc'), None) self.assertRaises(error, z.load_module, 'abc') self.assertRaises(error, z.get_code, 'abc') self.assertRaises(OSError, z.get_data, 'abc') self.assertRaises(error, z.get_source, 'abc') self.assertRaises(error, z.is_package, 'abc') finally: zipimport._zip_directory_cache.clear() def test_main(): try: support.run_unittest( UncompressedZipImportTestCase, CompressedZipImportTestCase, BadFileZipImportTestCase, ) finally: support.unlink(TESTMOD) if __name__ == "__main__": test_main()
29,161
761
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_pkgimport.py
import os import sys import shutil import string import random import tempfile import unittest from importlib.util import cache_from_source from test.support import create_empty_file class TestImport(unittest.TestCase): def __init__(self, *args, **kw): self.package_name = 'PACKAGE_' while self.package_name in sys.modules: self.package_name += random.choose(string.ascii_letters) self.module_name = self.package_name + '.foo' unittest.TestCase.__init__(self, *args, **kw) def remove_modules(self): for module_name in (self.package_name, self.module_name): if module_name in sys.modules: del sys.modules[module_name] def setUp(self): self.test_dir = tempfile.mkdtemp() sys.path.append(self.test_dir) self.package_dir = os.path.join(self.test_dir, self.package_name) os.mkdir(self.package_dir) create_empty_file(os.path.join(self.package_dir, '__init__.py')) self.module_path = os.path.join(self.package_dir, 'foo.py') def tearDown(self): shutil.rmtree(self.test_dir) self.assertNotEqual(sys.path.count(self.test_dir), 0) sys.path.remove(self.test_dir) self.remove_modules() def rewrite_file(self, contents): compiled_path = cache_from_source(self.module_path) if os.path.exists(compiled_path): os.remove(compiled_path) with open(self.module_path, 'w') as f: f.write(contents) def test_package_import__semantics(self): # Generate a couple of broken modules to try importing. # ...try loading the module when there's a SyntaxError self.rewrite_file('for') try: __import__(self.module_name) except SyntaxError: pass else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()? self.assertNotIn(self.module_name, sys.modules) self.assertFalse(hasattr(sys.modules[self.package_name], 'foo')) # ...make up a variable name that isn't bound in __builtins__ var = 'a' while var in dir(__builtins__): var += random.choose(string.ascii_letters) # ...make a module that just contains that self.rewrite_file(var) try: __import__(self.module_name) except NameError: pass else: raise RuntimeError('Failed to induce NameError.') # ...now change the module so that the NameError doesn't # happen self.rewrite_file('%s = 1' % var) module = __import__(self.module_name).foo self.assertEqual(getattr(module, var), 1) if __name__ == "__main__": unittest.main()
2,729
81
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/multibytecodec_support.py
# # multibytecodec_support.py # Common Unittest Routines for CJK codecs # import codecs import os import re import sys import unittest from test import support from io import BytesIO class TestBase: encoding = '' # codec name codec = None # codec tuple (with 4 elements) tstring = None # must set. 2 strings to test StreamReader codectests = None # must set. codec test tuple roundtriptest = 1 # set if roundtrip is possible with unicode has_iso10646 = 0 # set if this encoding contains whole iso10646 map xmlcharnametest = None # string to test xmlcharrefreplace unmappedunicode = '\udeee' # a unicode code point that is not mapped. def setUp(self): if self.codec is None: self.codec = codecs.lookup(self.encoding) self.encode = self.codec.encode self.decode = self.codec.decode self.reader = self.codec.streamreader self.writer = self.codec.streamwriter self.incrementalencoder = self.codec.incrementalencoder self.incrementaldecoder = self.codec.incrementaldecoder def test_chunkcoding(self): tstring_lines = [] for b in self.tstring: lines = b.split(b"\n") last = lines.pop() assert last == b"" lines = [line + b"\n" for line in lines] tstring_lines.append(lines) for native, utf8 in zip(*tstring_lines): u = self.decode(native)[0] self.assertEqual(u, utf8.decode('utf-8')) if self.roundtriptest: self.assertEqual(native, self.encode(u)[0]) def test_errorhandle(self): for source, scheme, expected in self.codectests: if isinstance(source, bytes): func = self.decode else: func = self.encode if expected: result = func(source, scheme)[0] if func is self.decode: self.assertTrue(type(result) is str, type(result)) self.assertEqual(result, expected, '%a.decode(%r, %r)=%a != %a' % (source, self.encoding, scheme, result, expected)) else: self.assertTrue(type(result) is bytes, type(result)) self.assertEqual(result, expected, '%a.encode(%r, %r)=%a != %a' % (source, self.encoding, scheme, result, expected)) else: self.assertRaises(UnicodeError, func, source, scheme) def test_xmlcharrefreplace(self): if self.has_iso10646: self.skipTest('encoding contains full ISO 10646 map') s = "\u0b13\u0b23\u0b60 nd eggs" self.assertEqual( self.encode(s, "xmlcharrefreplace")[0], b"&#2835;&#2851;&#2912; nd eggs" ) def test_customreplace_encode(self): if self.has_iso10646: self.skipTest('encoding contains full ISO 10646 map') from html.entities import codepoint2name def xmlcharnamereplace(exc): if not isinstance(exc, UnicodeEncodeError): raise TypeError("don't know how to handle %r" % exc) l = [] for c in exc.object[exc.start:exc.end]: if ord(c) in codepoint2name: l.append("&%s;" % codepoint2name[ord(c)]) else: l.append("&#%d;" % ord(c)) return ("".join(l), exc.end) codecs.register_error("test.xmlcharnamereplace", xmlcharnamereplace) if self.xmlcharnametest: sin, sout = self.xmlcharnametest else: sin = "\xab\u211c\xbb = \u2329\u1234\u232a" sout = b"&laquo;&real;&raquo; = &lang;&#4660;&rang;" self.assertEqual(self.encode(sin, "test.xmlcharnamereplace")[0], sout) def test_callback_returns_bytes(self): def myreplace(exc): return (b"1234", exc.end) codecs.register_error("test.cjktest", myreplace) enc = self.encode("abc" + self.unmappedunicode + "def", "test.cjktest")[0] self.assertEqual(enc, b"abc1234def") def test_callback_wrong_objects(self): def myreplace(exc): return (ret, exc.end) codecs.register_error("test.cjktest", myreplace) for ret in ([1, 2, 3], [], None, object()): self.assertRaises(TypeError, self.encode, self.unmappedunicode, 'test.cjktest') def test_callback_long_index(self): def myreplace(exc): return ('x', int(exc.end)) codecs.register_error("test.cjktest", myreplace) self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh', 'test.cjktest'), (b'abcdxefgh', 9)) def myreplace(exc): return ('x', sys.maxsize + 1) codecs.register_error("test.cjktest", myreplace) self.assertRaises(IndexError, self.encode, self.unmappedunicode, 'test.cjktest') def test_callback_None_index(self): def myreplace(exc): return ('x', None) codecs.register_error("test.cjktest", myreplace) self.assertRaises(TypeError, self.encode, self.unmappedunicode, 'test.cjktest') def test_callback_backward_index(self): def myreplace(exc): if myreplace.limit > 0: myreplace.limit -= 1 return ('REPLACED', 0) else: return ('TERMINAL', exc.end) myreplace.limit = 3 codecs.register_error("test.cjktest", myreplace) self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh', 'test.cjktest'), (b'abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefgh', 9)) def test_callback_forward_index(self): def myreplace(exc): return ('REPLACED', exc.end + 2) codecs.register_error("test.cjktest", myreplace) self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh', 'test.cjktest'), (b'abcdREPLACEDgh', 9)) def test_callback_index_outofbound(self): def myreplace(exc): return ('TERM', 100) codecs.register_error("test.cjktest", myreplace) self.assertRaises(IndexError, self.encode, self.unmappedunicode, 'test.cjktest') def test_incrementalencoder(self): UTF8Reader = codecs.getreader('utf-8') for sizehint in [None] + list(range(1, 33)) + \ [64, 128, 256, 512, 1024]: istream = UTF8Reader(BytesIO(self.tstring[1])) ostream = BytesIO() encoder = self.incrementalencoder() while 1: if sizehint is not None: data = istream.read(sizehint) else: data = istream.read() if not data: break e = encoder.encode(data) ostream.write(e) self.assertEqual(ostream.getvalue(), self.tstring[0]) def test_incrementaldecoder(self): UTF8Writer = codecs.getwriter('utf-8') for sizehint in [None, -1] + list(range(1, 33)) + \ [64, 128, 256, 512, 1024]: istream = BytesIO(self.tstring[0]) ostream = UTF8Writer(BytesIO()) decoder = self.incrementaldecoder() while 1: data = istream.read(sizehint) if not data: break else: u = decoder.decode(data) ostream.write(u) self.assertEqual(ostream.getvalue(), self.tstring[1]) def test_incrementalencoder_error_callback(self): inv = self.unmappedunicode e = self.incrementalencoder() self.assertRaises(UnicodeEncodeError, e.encode, inv, True) e.errors = 'ignore' self.assertEqual(e.encode(inv, True), b'') e.reset() def tempreplace(exc): return ('called', exc.end) codecs.register_error('test.incremental_error_callback', tempreplace) e.errors = 'test.incremental_error_callback' self.assertEqual(e.encode(inv, True), b'called') # again e.errors = 'ignore' self.assertEqual(e.encode(inv, True), b'') def test_streamreader(self): UTF8Writer = codecs.getwriter('utf-8') for name in ["read", "readline", "readlines"]: for sizehint in [None, -1] + list(range(1, 33)) + \ [64, 128, 256, 512, 1024]: istream = self.reader(BytesIO(self.tstring[0])) ostream = UTF8Writer(BytesIO()) func = getattr(istream, name) while 1: data = func(sizehint) if not data: break if name == "readlines": ostream.writelines(data) else: ostream.write(data) self.assertEqual(ostream.getvalue(), self.tstring[1]) def test_streamwriter(self): readfuncs = ('read', 'readline', 'readlines') UTF8Reader = codecs.getreader('utf-8') for name in readfuncs: for sizehint in [None] + list(range(1, 33)) + \ [64, 128, 256, 512, 1024]: istream = UTF8Reader(BytesIO(self.tstring[1])) ostream = self.writer(BytesIO()) func = getattr(istream, name) while 1: if sizehint is not None: data = func(sizehint) else: data = func() if not data: break if name == "readlines": ostream.writelines(data) else: ostream.write(data) self.assertEqual(ostream.getvalue(), self.tstring[0]) def test_streamwriter_reset_no_pending(self): # Issue #23247: Calling reset() on a fresh StreamWriter instance # (without pending data) must not crash stream = BytesIO() writer = self.writer(stream) writer.reset() class TestBase_Mapping(unittest.TestCase): pass_enctest = [] pass_dectest = [] supmaps = [] codectests = [] def setUp(self): pass def open_mapping_file(self): return open(self.mapfileurl) def test_mapping_file(self): if self.mapfileurl.endswith('.ucm'): self._test_mapping_file_ucm() else: self._test_mapping_file_plain() def _test_mapping_file_plain(self): def unichrs(s): return ''.join(chr(int(x, 16)) for x in s.split('+')) urt_wa = {} with self.open_mapping_file() as f: for line in f: line = line.split('#')[0].strip() if not line: break data = line.split() if len(data) != 2: continue csetch = bytes.fromhex(data[0]) if len(csetch) == 1 and 0x80 <= csetch[0]: continue unich = unichrs(data[1]) if ord(unich) == 0xfffd or unich in urt_wa: continue urt_wa[unich] = csetch self._testpoint(csetch, unich) def _test_mapping_file_ucm(self): with self.open_mapping_file() as f: ucmdata = f.read() for uni, coded in re.findall('^([A-F0-9]+)\t([0-9A-F ]+)$', ucmdata): unich = chr(int(uni, 16)) codech = bytes(int(c, 16) for c in coded.split()) self._testpoint(codech, unich) def test_mapping_supplemental(self): for mapping in self.supmaps: self._testpoint(*mapping) def _testpoint(self, csetch, unich): if (csetch, unich) not in self.pass_enctest: self.assertEqual(unich.encode(self.encoding), csetch) if (csetch, unich) not in self.pass_dectest: self.assertEqual(str(csetch, self.encoding), unich) def test_errorhandle(self): for source, scheme, expected in self.codectests: if isinstance(source, bytes): func = source.decode else: func = source.encode if expected: if isinstance(source, bytes): result = func(self.encoding, scheme) self.assertTrue(type(result) is str, type(result)) self.assertEqual(result, expected, '%a.decode(%r, %r)=%a != %a' % (source, self.encoding, scheme, result, expected)) else: result = func(self.encoding, scheme) self.assertTrue(type(result) is bytes, type(result)) self.assertEqual(result, expected, '%a.encode(%r, %r)=%a != %a' % (source, self.encoding, scheme, result, expected)) else: self.assertRaises(UnicodeError, func, self.encoding, scheme) def load_teststring(name): dir = os.path.join(os.path.dirname(__file__), 'cjkencodings') with open(os.path.join(dir, name + '.txt'), 'rb') as f: encoded = f.read() with open(os.path.join(dir, name + '-utf8.txt'), 'rb') as f: utf8 = f.read() return encoded, utf8
14,024
370
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_print.py
import unittest from io import StringIO from test import support NotDefined = object() # A dispatch table all 8 combinations of providing # sep, end, and file. # I use this machinery so that I'm not just passing default # values to print, I'm either passing or not passing in the # arguments. dispatch = { (False, False, False): lambda args, sep, end, file: print(*args), (False, False, True): lambda args, sep, end, file: print(file=file, *args), (False, True, False): lambda args, sep, end, file: print(end=end, *args), (False, True, True): lambda args, sep, end, file: print(end=end, file=file, *args), (True, False, False): lambda args, sep, end, file: print(sep=sep, *args), (True, False, True): lambda args, sep, end, file: print(sep=sep, file=file, *args), (True, True, False): lambda args, sep, end, file: print(sep=sep, end=end, *args), (True, True, True): lambda args, sep, end, file: print(sep=sep, end=end, file=file, *args), } # Class used to test __str__ and print class ClassWith__str__: def __init__(self, x): self.x = x def __str__(self): return self.x class TestPrint(unittest.TestCase): """Test correct operation of the print function.""" def check(self, expected, args, sep=NotDefined, end=NotDefined, file=NotDefined): # Capture sys.stdout in a StringIO. Call print with args, # and with sep, end, and file, if they're defined. Result # must match expected. # Look up the actual function to call, based on if sep, end, # and file are defined. fn = dispatch[(sep is not NotDefined, end is not NotDefined, file is not NotDefined)] with support.captured_stdout() as t: fn(args, sep, end, file) self.assertEqual(t.getvalue(), expected) def test_print(self): def x(expected, args, sep=NotDefined, end=NotDefined): # Run the test 2 ways: not using file, and using # file directed to a StringIO. self.check(expected, args, sep=sep, end=end) # When writing to a file, stdout is expected to be empty o = StringIO() self.check('', args, sep=sep, end=end, file=o) # And o will contain the expected output self.assertEqual(o.getvalue(), expected) x('\n', ()) x('a\n', ('a',)) x('None\n', (None,)) x('1 2\n', (1, 2)) x('1 2\n', (1, ' ', 2)) x('1*2\n', (1, 2), sep='*') x('1 s', (1, 's'), end='') x('a\nb\n', ('a', 'b'), sep='\n') x('1.01', (1.0, 1), sep='', end='') x('1*a*1.3+', (1, 'a', 1.3), sep='*', end='+') x('a\n\nb\n', ('a\n', 'b'), sep='\n') x('\0+ +\0\n', ('\0', ' ', '\0'), sep='+') x('a\n b\n', ('a\n', 'b')) x('a\n b\n', ('a\n', 'b'), sep=None) x('a\n b\n', ('a\n', 'b'), end=None) x('a\n b\n', ('a\n', 'b'), sep=None, end=None) x('*\n', (ClassWith__str__('*'),)) x('abc 1\n', (ClassWith__str__('abc'), 1)) # errors self.assertRaises(TypeError, print, '', sep=3) self.assertRaises(TypeError, print, '', end=3) self.assertRaises(AttributeError, print, '', file='') def test_print_flush(self): # operation of the flush flag class filelike: def __init__(self): self.written = '' self.flushed = 0 def write(self, str): self.written += str def flush(self): self.flushed += 1 f = filelike() print(1, file=f, end='', flush=True) print(2, file=f, end='', flush=True) print(3, file=f, flush=False) self.assertEqual(f.written, '123\n') self.assertEqual(f.flushed, 2) # ensure exceptions from flush are passed through class noflush: def write(self, str): pass def flush(self): raise RuntimeError self.assertRaises(RuntimeError, print, 1, file=noflush(), flush=True) if __name__ == "__main__": unittest.main()
4,258
133
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_hmac.py
import functools import hmac import hashlib import unittest import warnings def ignore_warning(func): @functools.wraps(func) def wrapper(*args, **kwargs): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=PendingDeprecationWarning) return func(*args, **kwargs) return wrapper class TestVectorsTestCase(unittest.TestCase): def test_md5_vectors(self): # Test the HMAC module against test vectors from the RFC. def md5test(key, data, digest): h = hmac.HMAC(key, data, digestmod=hashlib.md5) self.assertEqual(h.hexdigest().upper(), digest.upper()) self.assertEqual(h.name, "hmac-md5") self.assertEqual(h.digest_size, 16) self.assertEqual(h.block_size, 64) h = hmac.HMAC(key, data, digestmod='md5') self.assertEqual(h.hexdigest().upper(), digest.upper()) self.assertEqual(h.name, "hmac-md5") self.assertEqual(h.digest_size, 16) self.assertEqual(h.block_size, 64) md5test(b"\x0b" * 16, b"Hi There", "9294727A3638BB1C13F48EF8158BFC9D") md5test(b"Jefe", b"what do ya want for nothing?", "750c783e6ab0b503eaa86e310a5db738") md5test(b"\xaa" * 16, b"\xdd" * 50, "56be34521d144c88dbb8c733f0e8b3f6") md5test(bytes(range(1, 26)), b"\xcd" * 50, "697eaf0aca3a3aea3a75164746ffaa79") md5test(b"\x0C" * 16, b"Test With Truncation", "56461ef2342edc00f9bab995690efd4c") md5test(b"\xaa" * 80, b"Test Using Larger Than Block-Size Key - Hash Key First", "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd") md5test(b"\xaa" * 80, (b"Test Using Larger Than Block-Size Key " b"and Larger Than One Block-Size Data"), "6f630fad67cda0ee1fb1f562db3aa53e") def test_sha_vectors(self): def shatest(key, data, digest): h = hmac.HMAC(key, data, digestmod=hashlib.sha1) self.assertEqual(h.hexdigest().upper(), digest.upper()) self.assertEqual(h.name, "hmac-sha1") self.assertEqual(h.digest_size, 20) self.assertEqual(h.block_size, 64) h = hmac.HMAC(key, data, digestmod='sha1') self.assertEqual(h.hexdigest().upper(), digest.upper()) self.assertEqual(h.name, "hmac-sha1") self.assertEqual(h.digest_size, 20) self.assertEqual(h.block_size, 64) shatest(b"\x0b" * 20, b"Hi There", "b617318655057264e28bc0b6fb378c8ef146be00") shatest(b"Jefe", b"what do ya want for nothing?", "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79") shatest(b"\xAA" * 20, b"\xDD" * 50, "125d7342b9ac11cd91a39af48aa17b4f63f175d3") shatest(bytes(range(1, 26)), b"\xCD" * 50, "4c9007f4026250c6bc8414f9bf50c86c2d7235da") shatest(b"\x0C" * 20, b"Test With Truncation", "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04") shatest(b"\xAA" * 80, b"Test Using Larger Than Block-Size Key - Hash Key First", "aa4ae5e15272d00e95705637ce8a3b55ed402112") shatest(b"\xAA" * 80, (b"Test Using Larger Than Block-Size Key " b"and Larger Than One Block-Size Data"), "e8e99d0f45237d786d6bbaa7965c7808bbff1a91") def _rfc4231_test_cases(self, hashfunc, hash_name, digest_size, block_size): def hmactest(key, data, hexdigests): hmac_name = "hmac-" + hash_name h = hmac.HMAC(key, data, digestmod=hashfunc) self.assertEqual(h.hexdigest().lower(), hexdigests[hashfunc]) self.assertEqual(h.name, hmac_name) self.assertEqual(h.digest_size, digest_size) self.assertEqual(h.block_size, block_size) h = hmac.HMAC(key, data, digestmod=hash_name) self.assertEqual(h.hexdigest().lower(), hexdigests[hashfunc]) self.assertEqual(h.name, hmac_name) self.assertEqual(h.digest_size, digest_size) self.assertEqual(h.block_size, block_size) # 4.2. Test Case 1 hmactest(key = b'\x0b'*20, data = b'Hi There', hexdigests = { hashlib.sha224: '896fb1128abbdf196832107cd49df33f' '47b4b1169912ba4f53684b22', hashlib.sha256: 'b0344c61d8db38535ca8afceaf0bf12b' '881dc200c9833da726e9376c2e32cff7', hashlib.sha384: 'afd03944d84895626b0825f4ab46907f' '15f9dadbe4101ec682aa034c7cebc59c' 'faea9ea9076ede7f4af152e8b2fa9cb6', hashlib.sha512: '87aa7cdea5ef619d4ff0b4241a1d6cb0' '2379f4e2ce4ec2787ad0b30545e17cde' 'daa833b7d6b8a702038b274eaea3f4e4' 'be9d914eeb61f1702e696c203a126854', }) # 4.3. Test Case 2 hmactest(key = b'Jefe', data = b'what do ya want for nothing?', hexdigests = { hashlib.sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f' '8bbea2a39e6148008fd05e44', hashlib.sha256: '5bdcc146bf60754e6a042426089575c7' '5a003f089d2739839dec58b964ec3843', hashlib.sha384: 'af45d2e376484031617f78d2b58a6b1b' '9c7ef464f5a01b47e42ec3736322445e' '8e2240ca5e69e2c78b3239ecfab21649', hashlib.sha512: '164b7a7bfcf819e2e395fbe73b56e0a3' '87bd64222e831fd610270cd7ea250554' '9758bf75c05a994a6d034f65f8f0e6fd' 'caeab1a34d4a6b4b636e070a38bce737', }) # 4.4. Test Case 3 hmactest(key = b'\xaa'*20, data = b'\xdd'*50, hexdigests = { hashlib.sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad264' '9365b0c1f65d69d1ec8333ea', hashlib.sha256: '773ea91e36800e46854db8ebd09181a7' '2959098b3ef8c122d9635514ced565fe', hashlib.sha384: '88062608d3e6ad8a0aa2ace014c8a86f' '0aa635d947ac9febe83ef4e55966144b' '2a5ab39dc13814b94e3ab6e101a34f27', hashlib.sha512: 'fa73b0089d56a284efb0f0756c890be9' 'b1b5dbdd8ee81a3655f83e33b2279d39' 'bf3e848279a722c806b485a47e67c807' 'b946a337bee8942674278859e13292fb', }) # 4.5. Test Case 4 hmactest(key = bytes(x for x in range(0x01, 0x19+1)), data = b'\xcd'*50, hexdigests = { hashlib.sha224: '6c11506874013cac6a2abc1bb382627c' 'ec6a90d86efc012de7afec5a', hashlib.sha256: '82558a389a443c0ea4cc819899f2083a' '85f0faa3e578f8077a2e3ff46729665b', hashlib.sha384: '3e8a69b7783c25851933ab6290af6ca7' '7a9981480850009cc5577c6e1f573b4e' '6801dd23c4a7d679ccf8a386c674cffb', hashlib.sha512: 'b0ba465637458c6990e5a8c5f61d4af7' 'e576d97ff94b872de76f8050361ee3db' 'a91ca5c11aa25eb4d679275cc5788063' 'a5f19741120c4f2de2adebeb10a298dd', }) # 4.7. Test Case 6 hmactest(key = b'\xaa'*131, data = b'Test Using Larger Than Block-Siz' b'e Key - Hash Key First', hexdigests = { hashlib.sha224: '95e9a0db962095adaebe9b2d6f0dbce2' 'd499f112f2d2b7273fa6870e', hashlib.sha256: '60e431591ee0b67f0d8a26aacbf5b77f' '8e0bc6213728c5140546040f0ee37f54', hashlib.sha384: '4ece084485813e9088d2c63a041bc5b4' '4f9ef1012a2b588f3cd11f05033ac4c6' '0c2ef6ab4030fe8296248df163f44952', hashlib.sha512: '80b24263c7c1a3ebb71493c1dd7be8b4' '9b46d1f41b4aeec1121b013783f8f352' '6b56d037e05f2598bd0fd2215d6a1e52' '95e64f73f63f0aec8b915a985d786598', }) # 4.8. Test Case 7 hmactest(key = b'\xaa'*131, data = b'This is a test using a larger th' b'an block-size key and a larger t' b'han block-size data. The key nee' b'ds to be hashed before being use' b'd by the HMAC algorithm.', hexdigests = { hashlib.sha224: '3a854166ac5d9f023f54d517d0b39dbd' '946770db9c2b95c9f6f565d1', hashlib.sha256: '9b09ffa71b942fcb27635fbcd5b0e944' 'bfdc63644f0713938a7f51535c3a35e2', hashlib.sha384: '6617178e941f020d351e2f254e8fd32c' '602420feb0b8fb9adccebb82461e99c5' 'a678cc31e799176d3860e6110c46523e', hashlib.sha512: 'e37b6a775dc87dbaa4dfa9f96e5e3ffd' 'debd71f8867289865df5a32d20cdc944' 'b6022cac3c4982b10d5eeb55c3e4de15' '134676fb6de0446065c97440fa8c6a58', }) def test_sha224_rfc4231(self): self._rfc4231_test_cases(hashlib.sha224, 'sha224', 28, 64) def test_sha256_rfc4231(self): self._rfc4231_test_cases(hashlib.sha256, 'sha256', 32, 64) def test_sha384_rfc4231(self): self._rfc4231_test_cases(hashlib.sha384, 'sha384', 48, 128) def test_sha512_rfc4231(self): self._rfc4231_test_cases(hashlib.sha512, 'sha512', 64, 128) def test_legacy_block_size_warnings(self): class MockCrazyHash(object): """Ain't no block_size attribute here.""" def __init__(self, *args): self._x = hashlib.sha1(*args) self.digest_size = self._x.digest_size def update(self, v): self._x.update(v) def digest(self): return self._x.digest() with warnings.catch_warnings(): warnings.simplefilter('error', RuntimeWarning) with self.assertRaises(RuntimeWarning): hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash) self.fail('Expected warning about missing block_size') MockCrazyHash.block_size = 1 with self.assertRaises(RuntimeWarning): hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash) self.fail('Expected warning about small block_size') def test_with_digestmod_warning(self): with self.assertWarns(PendingDeprecationWarning): key = b"\x0b" * 16 data = b"Hi There" digest = "9294727A3638BB1C13F48EF8158BFC9D" h = hmac.HMAC(key, data) self.assertEqual(h.hexdigest().upper(), digest) class ConstructorTestCase(unittest.TestCase): @ignore_warning def test_normal(self): # Standard constructor call. failed = 0 try: h = hmac.HMAC(b"key") except Exception: self.fail("Standard constructor call raised exception.") @ignore_warning def test_with_str_key(self): # Pass a key of type str, which is an error, because it expects a key # of type bytes with self.assertRaises(TypeError): h = hmac.HMAC("key") @ignore_warning def test_dot_new_with_str_key(self): # Pass a key of type str, which is an error, because it expects a key # of type bytes with self.assertRaises(TypeError): h = hmac.new("key") @ignore_warning def test_withtext(self): # Constructor call with text. try: h = hmac.HMAC(b"key", b"hash this!") except Exception: self.fail("Constructor call with text argument raised exception.") self.assertEqual(h.hexdigest(), '34325b639da4cfd95735b381e28cb864') def test_with_bytearray(self): try: h = hmac.HMAC(bytearray(b"key"), bytearray(b"hash this!"), digestmod="md5") except Exception: self.fail("Constructor call with bytearray arguments raised exception.") self.assertEqual(h.hexdigest(), '34325b639da4cfd95735b381e28cb864') def test_with_memoryview_msg(self): try: h = hmac.HMAC(b"key", memoryview(b"hash this!"), digestmod="md5") except Exception: self.fail("Constructor call with memoryview msg raised exception.") self.assertEqual(h.hexdigest(), '34325b639da4cfd95735b381e28cb864') def test_withmodule(self): # Constructor call with text and digest module. try: h = hmac.HMAC(b"key", b"", hashlib.sha1) except Exception: self.fail("Constructor call with hashlib.sha1 raised exception.") class SanityTestCase(unittest.TestCase): @ignore_warning def test_default_is_md5(self): # Testing if HMAC defaults to MD5 algorithm. # NOTE: this whitebox test depends on the hmac class internals h = hmac.HMAC(b"key") self.assertEqual(h.digest_cons, hashlib.md5) def test_exercise_all_methods(self): # Exercising all methods once. # This must not raise any exceptions try: h = hmac.HMAC(b"my secret key", digestmod="md5") h.update(b"compute the hash of this text!") dig = h.digest() dig = h.hexdigest() h2 = h.copy() except Exception: self.fail("Exception raised during normal usage of HMAC class.") class CopyTestCase(unittest.TestCase): def test_attributes(self): # Testing if attributes are of same type. h1 = hmac.HMAC(b"key", digestmod="md5") h2 = h1.copy() self.assertTrue(h1.digest_cons == h2.digest_cons, "digest constructors don't match.") self.assertEqual(type(h1.inner), type(h2.inner), "Types of inner don't match.") self.assertEqual(type(h1.outer), type(h2.outer), "Types of outer don't match.") def test_realcopy(self): # Testing if the copy method created a real copy. h1 = hmac.HMAC(b"key", digestmod="md5") h2 = h1.copy() # Using id() in case somebody has overridden __eq__/__ne__. self.assertTrue(id(h1) != id(h2), "No real copy of the HMAC instance.") self.assertTrue(id(h1.inner) != id(h2.inner), "No real copy of the attribute 'inner'.") self.assertTrue(id(h1.outer) != id(h2.outer), "No real copy of the attribute 'outer'.") def test_equality(self): # Testing if the copy has the same digests. h1 = hmac.HMAC(b"key", digestmod="md5") h1.update(b"some random text") h2 = h1.copy() self.assertEqual(h1.digest(), h2.digest(), "Digest of copy doesn't match original digest.") self.assertEqual(h1.hexdigest(), h2.hexdigest(), "Hexdigest of copy doesn't match original hexdigest.") class CompareDigestTestCase(unittest.TestCase): def test_compare_digest(self): # Testing input type exception handling a, b = 100, 200 self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = 100, b"foobar" self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = b"foobar", 200 self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = "foobar", b"foobar" self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = b"foobar", "foobar" self.assertRaises(TypeError, hmac.compare_digest, a, b) # Testing bytes of different lengths a, b = b"foobar", b"foo" self.assertFalse(hmac.compare_digest(a, b)) a, b = b"\xde\xad\xbe\xef", b"\xde\xad" self.assertFalse(hmac.compare_digest(a, b)) # Testing bytes of same lengths, different values a, b = b"foobar", b"foobaz" self.assertFalse(hmac.compare_digest(a, b)) a, b = b"\xde\xad\xbe\xef", b"\xab\xad\x1d\xea" self.assertFalse(hmac.compare_digest(a, b)) # Testing bytes of same lengths, same values a, b = b"foobar", b"foobar" self.assertTrue(hmac.compare_digest(a, b)) a, b = b"\xde\xad\xbe\xef", b"\xde\xad\xbe\xef" self.assertTrue(hmac.compare_digest(a, b)) # Testing bytearrays of same lengths, same values a, b = bytearray(b"foobar"), bytearray(b"foobar") self.assertTrue(hmac.compare_digest(a, b)) # Testing bytearrays of diffeent lengths a, b = bytearray(b"foobar"), bytearray(b"foo") self.assertFalse(hmac.compare_digest(a, b)) # Testing bytearrays of same lengths, different values a, b = bytearray(b"foobar"), bytearray(b"foobaz") self.assertFalse(hmac.compare_digest(a, b)) # Testing byte and bytearray of same lengths, same values a, b = bytearray(b"foobar"), b"foobar" self.assertTrue(hmac.compare_digest(a, b)) self.assertTrue(hmac.compare_digest(b, a)) # Testing byte bytearray of diffeent lengths a, b = bytearray(b"foobar"), b"foo" self.assertFalse(hmac.compare_digest(a, b)) self.assertFalse(hmac.compare_digest(b, a)) # Testing byte and bytearray of same lengths, different values a, b = bytearray(b"foobar"), b"foobaz" self.assertFalse(hmac.compare_digest(a, b)) self.assertFalse(hmac.compare_digest(b, a)) # Testing str of same lengths a, b = "foobar", "foobar" self.assertTrue(hmac.compare_digest(a, b)) # Testing str of diffeent lengths a, b = "foo", "foobar" self.assertFalse(hmac.compare_digest(a, b)) # Testing bytes of same lengths, different values a, b = "foobar", "foobaz" self.assertFalse(hmac.compare_digest(a, b)) # Testing error cases a, b = "foobar", b"foobar" self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = b"foobar", "foobar" self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = b"foobar", 1 self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = 100, 200 self.assertRaises(TypeError, hmac.compare_digest, a, b) a, b = "fooä", "fooä" self.assertRaises(TypeError, hmac.compare_digest, a, b) # subclasses are supported by ignore __eq__ class mystr(str): def __eq__(self, other): return False a, b = mystr("foobar"), mystr("foobar") self.assertTrue(hmac.compare_digest(a, b)) a, b = mystr("foobar"), "foobar" self.assertTrue(hmac.compare_digest(a, b)) a, b = mystr("foobar"), mystr("foobaz") self.assertFalse(hmac.compare_digest(a, b)) class mybytes(bytes): def __eq__(self, other): return False a, b = mybytes(b"foobar"), mybytes(b"foobar") self.assertTrue(hmac.compare_digest(a, b)) a, b = mybytes(b"foobar"), b"foobar" self.assertTrue(hmac.compare_digest(a, b)) a, b = mybytes(b"foobar"), mybytes(b"foobaz") self.assertFalse(hmac.compare_digest(a, b)) if __name__ == "__main__": unittest.main()
20,486
497
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_enum.py
import enum import cosmo import inspect import pydoc import unittest from collections import OrderedDict from enum import Enum, IntEnum, EnumMeta, Flag, IntFlag, unique, auto from io import StringIO from pickle import dumps, loads, PicklingError, HIGHEST_PROTOCOL from test import support try: import _thread import threading except ImportError: threading = None # for pickle tests try: class Stooges(Enum): LARRY = 1 CURLY = 2 MOE = 3 except Exception as exc: Stooges = exc try: class IntStooges(int, Enum): LARRY = 1 CURLY = 2 MOE = 3 except Exception as exc: IntStooges = exc try: class FloatStooges(float, Enum): LARRY = 1.39 CURLY = 2.72 MOE = 3.142596 except Exception as exc: FloatStooges = exc try: class FlagStooges(Flag): LARRY = 1 CURLY = 2 MOE = 3 except Exception as exc: FlagStooges = exc # for pickle test and subclass tests try: class StrEnum(str, Enum): 'accepts only string values' class Name(StrEnum): BDFL = 'Guido van Rossum' FLUFL = 'Barry Warsaw' except Exception as exc: Name = exc try: Question = Enum('Question', 'who what when where why', module=__name__) except Exception as exc: Question = exc try: Answer = Enum('Answer', 'him this then there because') except Exception as exc: Answer = exc try: Theory = Enum('Theory', 'rule law supposition', qualname='spanish_inquisition') except Exception as exc: Theory = exc # for doctests try: class Fruit(Enum): TOMATO = 1 BANANA = 2 CHERRY = 3 except Exception: pass def test_pickle_dump_load(assertion, source, target=None): if target is None: target = source for protocol in range(HIGHEST_PROTOCOL + 1): assertion(loads(dumps(source, protocol=protocol)), target) def test_pickle_exception(assertion, exception, obj): for protocol in range(HIGHEST_PROTOCOL + 1): with assertion(exception): dumps(obj, protocol=protocol) class TestHelpers(unittest.TestCase): # _is_descriptor, _is_sunder, _is_dunder def test_is_descriptor(self): class foo: pass for attr in ('__get__','__set__','__delete__'): obj = foo() self.assertFalse(enum._is_descriptor(obj)) setattr(obj, attr, 1) self.assertTrue(enum._is_descriptor(obj)) def test_is_sunder(self): for s in ('_a_', '_aa_'): self.assertTrue(enum._is_sunder(s)) for s in ('a', 'a_', '_a', '__a', 'a__', '__a__', '_a__', '__a_', '_', '__', '___', '____', '_____',): self.assertFalse(enum._is_sunder(s)) def test_is_dunder(self): for s in ('__a__', '__aa__'): self.assertTrue(enum._is_dunder(s)) for s in ('a', 'a_', '_a', '__a', 'a__', '_a_', '_a__', '__a_', '_', '__', '___', '____', '_____',): self.assertFalse(enum._is_dunder(s)) # tests class TestEnum(unittest.TestCase): def setUp(self): class Season(Enum): SPRING = 1 SUMMER = 2 AUTUMN = 3 WINTER = 4 self.Season = Season class Konstants(float, Enum): E = 2.7182818 PI = 3.1415926 TAU = 2 * PI self.Konstants = Konstants class Grades(IntEnum): A = 5 B = 4 C = 3 D = 2 F = 0 self.Grades = Grades class Directional(str, Enum): EAST = 'east' WEST = 'west' NORTH = 'north' SOUTH = 'south' self.Directional = Directional from datetime import date class Holiday(date, Enum): NEW_YEAR = 2013, 1, 1 IDES_OF_MARCH = 2013, 3, 15 self.Holiday = Holiday def test_dir_on_class(self): Season = self.Season self.assertEqual( set(dir(Season)), set(['__class__', '__doc__', '__members__', '__module__', 'SPRING', 'SUMMER', 'AUTUMN', 'WINTER']), ) def test_dir_on_item(self): Season = self.Season self.assertEqual( set(dir(Season.WINTER)), set(['__class__', '__doc__', '__module__', 'name', 'value']), ) def test_dir_with_added_behavior(self): class Test(Enum): this = 'that' these = 'those' def wowser(self): return ("Wowser! I'm %s!" % self.name) self.assertEqual( set(dir(Test)), set(['__class__', '__doc__', '__members__', '__module__', 'this', 'these']), ) self.assertEqual( set(dir(Test.this)), set(['__class__', '__doc__', '__module__', 'name', 'value', 'wowser']), ) def test_dir_on_sub_with_behavior_on_super(self): # see issue22506 class SuperEnum(Enum): def invisible(self): return "did you see me?" class SubEnum(SuperEnum): sample = 5 self.assertEqual( set(dir(SubEnum.sample)), set(['__class__', '__doc__', '__module__', 'name', 'value', 'invisible']), ) def test_enum_in_enum_out(self): Season = self.Season self.assertIs(Season(Season.WINTER), Season.WINTER) def test_enum_value(self): Season = self.Season self.assertEqual(Season.SPRING.value, 1) def test_intenum_value(self): self.assertEqual(IntStooges.CURLY.value, 2) def test_enum(self): Season = self.Season lst = list(Season) self.assertEqual(len(lst), len(Season)) self.assertEqual(len(Season), 4, Season) self.assertEqual( [Season.SPRING, Season.SUMMER, Season.AUTUMN, Season.WINTER], lst) for i, season in enumerate('SPRING SUMMER AUTUMN WINTER'.split(), 1): e = Season(i) self.assertEqual(e, getattr(Season, season)) self.assertEqual(e.value, i) self.assertNotEqual(e, i) self.assertEqual(e.name, season) self.assertIn(e, Season) self.assertIs(type(e), Season) self.assertIsInstance(e, Season) self.assertEqual(str(e), 'Season.' + season) self.assertEqual( repr(e), '<Season.{0}: {1}>'.format(season, i), ) def test_value_name(self): Season = self.Season self.assertEqual(Season.SPRING.name, 'SPRING') self.assertEqual(Season.SPRING.value, 1) with self.assertRaises(AttributeError): Season.SPRING.name = 'invierno' with self.assertRaises(AttributeError): Season.SPRING.value = 2 def test_changing_member(self): Season = self.Season with self.assertRaises(AttributeError): Season.WINTER = 'really cold' def test_attribute_deletion(self): class Season(Enum): SPRING = 1 SUMMER = 2 AUTUMN = 3 WINTER = 4 def spam(cls): pass self.assertTrue(hasattr(Season, 'spam')) del Season.spam self.assertFalse(hasattr(Season, 'spam')) with self.assertRaises(AttributeError): del Season.SPRING with self.assertRaises(AttributeError): del Season.DRY with self.assertRaises(AttributeError): del Season.SPRING.name def test_bool_of_class(self): class Empty(Enum): pass self.assertTrue(bool(Empty)) def test_bool_of_member(self): class Count(Enum): zero = 0 one = 1 two = 2 for member in Count: self.assertTrue(bool(member)) def test_invalid_names(self): with self.assertRaises(ValueError): class Wrong(Enum): mro = 9 with self.assertRaises(ValueError): class Wrong(Enum): _create_= 11 with self.assertRaises(ValueError): class Wrong(Enum): _get_mixins_ = 9 with self.assertRaises(ValueError): class Wrong(Enum): _find_new_ = 1 with self.assertRaises(ValueError): class Wrong(Enum): _any_name_ = 9 def test_bool(self): # plain Enum members are always True class Logic(Enum): true = True false = False self.assertTrue(Logic.true) self.assertTrue(Logic.false) # unless overridden class RealLogic(Enum): true = True false = False def __bool__(self): return bool(self._value_) self.assertTrue(RealLogic.true) self.assertFalse(RealLogic.false) # mixed Enums depend on mixed-in type class IntLogic(int, Enum): true = 1 false = 0 self.assertTrue(IntLogic.true) self.assertFalse(IntLogic.false) def test_contains(self): Season = self.Season self.assertIn(Season.AUTUMN, Season) self.assertNotIn(3, Season) val = Season(3) self.assertIn(val, Season) class OtherEnum(Enum): one = 1; two = 2 self.assertNotIn(OtherEnum.two, Season) def test_comparisons(self): Season = self.Season with self.assertRaises(TypeError): Season.SPRING < Season.WINTER with self.assertRaises(TypeError): Season.SPRING > 4 self.assertNotEqual(Season.SPRING, 1) class Part(Enum): SPRING = 1 CLIP = 2 BARREL = 3 self.assertNotEqual(Season.SPRING, Part.SPRING) with self.assertRaises(TypeError): Season.SPRING < Part.CLIP def test_enum_duplicates(self): class Season(Enum): SPRING = 1 SUMMER = 2 AUTUMN = FALL = 3 WINTER = 4 ANOTHER_SPRING = 1 lst = list(Season) self.assertEqual( lst, [Season.SPRING, Season.SUMMER, Season.AUTUMN, Season.WINTER, ]) self.assertIs(Season.FALL, Season.AUTUMN) self.assertEqual(Season.FALL.value, 3) self.assertEqual(Season.AUTUMN.value, 3) self.assertIs(Season(3), Season.AUTUMN) self.assertIs(Season(1), Season.SPRING) self.assertEqual(Season.FALL.name, 'AUTUMN') self.assertEqual( [k for k,v in Season.__members__.items() if v.name != k], ['FALL', 'ANOTHER_SPRING'], ) def test_duplicate_name(self): with self.assertRaises(TypeError): class Color(Enum): red = 1 green = 2 blue = 3 red = 4 with self.assertRaises(TypeError): class Color(Enum): red = 1 green = 2 blue = 3 def red(self): return 'red' with self.assertRaises(TypeError): class Color(Enum): @property def red(self): return 'redder' red = 1 green = 2 blue = 3 def test_enum_with_value_name(self): class Huh(Enum): name = 1 value = 2 self.assertEqual( list(Huh), [Huh.name, Huh.value], ) self.assertIs(type(Huh.name), Huh) self.assertEqual(Huh.name.name, 'name') self.assertEqual(Huh.name.value, 1) def test_format_enum(self): Season = self.Season self.assertEqual('{}'.format(Season.SPRING), '{}'.format(str(Season.SPRING))) self.assertEqual( '{:}'.format(Season.SPRING), '{:}'.format(str(Season.SPRING))) self.assertEqual('{:20}'.format(Season.SPRING), '{:20}'.format(str(Season.SPRING))) self.assertEqual('{:^20}'.format(Season.SPRING), '{:^20}'.format(str(Season.SPRING))) self.assertEqual('{:>20}'.format(Season.SPRING), '{:>20}'.format(str(Season.SPRING))) self.assertEqual('{:<20}'.format(Season.SPRING), '{:<20}'.format(str(Season.SPRING))) def test_format_enum_custom(self): class TestFloat(float, Enum): one = 1.0 two = 2.0 def __format__(self, spec): return 'TestFloat success!' self.assertEqual('{}'.format(TestFloat.one), 'TestFloat success!') def assertFormatIsValue(self, spec, member): self.assertEqual(spec.format(member), spec.format(member.value)) def test_format_enum_date(self): Holiday = self.Holiday self.assertFormatIsValue('{}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:20}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:^20}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:>20}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:<20}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:%Y %m}', Holiday.IDES_OF_MARCH) self.assertFormatIsValue('{:%Y %m %M:00}', Holiday.IDES_OF_MARCH) def test_format_enum_float(self): Konstants = self.Konstants self.assertFormatIsValue('{}', Konstants.TAU) self.assertFormatIsValue('{:}', Konstants.TAU) self.assertFormatIsValue('{:20}', Konstants.TAU) self.assertFormatIsValue('{:^20}', Konstants.TAU) self.assertFormatIsValue('{:>20}', Konstants.TAU) self.assertFormatIsValue('{:<20}', Konstants.TAU) self.assertFormatIsValue('{:n}', Konstants.TAU) self.assertFormatIsValue('{:5.2}', Konstants.TAU) self.assertFormatIsValue('{:f}', Konstants.TAU) def test_format_enum_int(self): Grades = self.Grades self.assertFormatIsValue('{}', Grades.C) self.assertFormatIsValue('{:}', Grades.C) self.assertFormatIsValue('{:20}', Grades.C) self.assertFormatIsValue('{:^20}', Grades.C) self.assertFormatIsValue('{:>20}', Grades.C) self.assertFormatIsValue('{:<20}', Grades.C) self.assertFormatIsValue('{:+}', Grades.C) self.assertFormatIsValue('{:08X}', Grades.C) self.assertFormatIsValue('{:b}', Grades.C) def test_format_enum_str(self): Directional = self.Directional self.assertFormatIsValue('{}', Directional.WEST) self.assertFormatIsValue('{:}', Directional.WEST) self.assertFormatIsValue('{:20}', Directional.WEST) self.assertFormatIsValue('{:^20}', Directional.WEST) self.assertFormatIsValue('{:>20}', Directional.WEST) self.assertFormatIsValue('{:<20}', Directional.WEST) def test_hash(self): Season = self.Season dates = {} dates[Season.WINTER] = '1225' dates[Season.SPRING] = '0315' dates[Season.SUMMER] = '0704' dates[Season.AUTUMN] = '1031' self.assertEqual(dates[Season.AUTUMN], '1031') def test_intenum_from_scratch(self): class phy(int, Enum): pi = 3 tau = 2 * pi self.assertTrue(phy.pi < phy.tau) def test_intenum_inherited(self): class IntEnum(int, Enum): pass class phy(IntEnum): pi = 3 tau = 2 * pi self.assertTrue(phy.pi < phy.tau) def test_floatenum_from_scratch(self): class phy(float, Enum): pi = 3.1415926 tau = 2 * pi self.assertTrue(phy.pi < phy.tau) def test_floatenum_inherited(self): class FloatEnum(float, Enum): pass class phy(FloatEnum): pi = 3.1415926 tau = 2 * pi self.assertTrue(phy.pi < phy.tau) def test_strenum_from_scratch(self): class phy(str, Enum): pi = 'Pi' tau = 'Tau' self.assertTrue(phy.pi < phy.tau) def test_strenum_inherited(self): class StrEnum(str, Enum): pass class phy(StrEnum): pi = 'Pi' tau = 'Tau' self.assertTrue(phy.pi < phy.tau) def test_intenum(self): class WeekDay(IntEnum): SUNDAY = 1 MONDAY = 2 TUESDAY = 3 WEDNESDAY = 4 THURSDAY = 5 FRIDAY = 6 SATURDAY = 7 self.assertEqual(['a', 'b', 'c'][WeekDay.MONDAY], 'c') self.assertEqual([i for i in range(WeekDay.TUESDAY)], [0, 1, 2]) lst = list(WeekDay) self.assertEqual(len(lst), len(WeekDay)) self.assertEqual(len(WeekDay), 7) target = 'SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY' target = target.split() for i, weekday in enumerate(target, 1): e = WeekDay(i) self.assertEqual(e, i) self.assertEqual(int(e), i) self.assertEqual(e.name, weekday) self.assertIn(e, WeekDay) self.assertEqual(lst.index(e)+1, i) self.assertTrue(0 < e < 8) self.assertIs(type(e), WeekDay) self.assertIsInstance(e, int) self.assertIsInstance(e, Enum) def test_intenum_duplicates(self): class WeekDay(IntEnum): SUNDAY = 1 MONDAY = 2 TUESDAY = TEUSDAY = 3 WEDNESDAY = 4 THURSDAY = 5 FRIDAY = 6 SATURDAY = 7 self.assertIs(WeekDay.TEUSDAY, WeekDay.TUESDAY) self.assertEqual(WeekDay(3).name, 'TUESDAY') self.assertEqual([k for k,v in WeekDay.__members__.items() if v.name != k], ['TEUSDAY', ]) def test_intenum_from_bytes(self): self.assertIs(IntStooges.from_bytes(b'\x00\x03', 'big'), IntStooges.MOE) with self.assertRaises(ValueError): IntStooges.from_bytes(b'\x00\x05', 'big') def test_floatenum_fromhex(self): h = float.hex(FloatStooges.MOE.value) self.assertIs(FloatStooges.fromhex(h), FloatStooges.MOE) h = float.hex(FloatStooges.MOE.value + 0.01) with self.assertRaises(ValueError): FloatStooges.fromhex(h) def test_pickle_enum(self): if isinstance(Stooges, Exception): raise Stooges test_pickle_dump_load(self.assertIs, Stooges.CURLY) test_pickle_dump_load(self.assertIs, Stooges) def test_pickle_int(self): if isinstance(IntStooges, Exception): raise IntStooges test_pickle_dump_load(self.assertIs, IntStooges.CURLY) test_pickle_dump_load(self.assertIs, IntStooges) def test_pickle_float(self): if isinstance(FloatStooges, Exception): raise FloatStooges test_pickle_dump_load(self.assertIs, FloatStooges.CURLY) test_pickle_dump_load(self.assertIs, FloatStooges) def test_pickle_enum_function(self): if isinstance(Answer, Exception): raise Answer test_pickle_dump_load(self.assertIs, Answer.him) test_pickle_dump_load(self.assertIs, Answer) def test_pickle_enum_function_with_module(self): if isinstance(Question, Exception): raise Question test_pickle_dump_load(self.assertIs, Question.who) test_pickle_dump_load(self.assertIs, Question) def test_enum_function_with_qualname(self): if isinstance(Theory, Exception): raise Theory self.assertEqual(Theory.__qualname__, 'spanish_inquisition') def test_class_nested_enum_and_pickle_protocol_four(self): # would normally just have this directly in the class namespace class NestedEnum(Enum): twigs = 'common' shiny = 'rare' self.__class__.NestedEnum = NestedEnum self.NestedEnum.__qualname__ = '%s.NestedEnum' % self.__class__.__name__ test_pickle_dump_load(self.assertIs, self.NestedEnum.twigs) def test_pickle_by_name(self): class ReplaceGlobalInt(IntEnum): ONE = 1 TWO = 2 ReplaceGlobalInt.__reduce_ex__ = enum._reduce_ex_by_name for proto in range(HIGHEST_PROTOCOL): self.assertEqual(ReplaceGlobalInt.TWO.__reduce_ex__(proto), 'TWO') def test_exploding_pickle(self): BadPickle = Enum( 'BadPickle', 'dill sweet bread-n-butter', module=__name__) globals()['BadPickle'] = BadPickle # now break BadPickle to test exception raising enum._make_class_unpicklable(BadPickle) test_pickle_exception(self.assertRaises, TypeError, BadPickle.dill) test_pickle_exception(self.assertRaises, PicklingError, BadPickle) def test_string_enum(self): class SkillLevel(str, Enum): master = 'what is the sound of one hand clapping?' journeyman = 'why did the chicken cross the road?' apprentice = 'knock, knock!' self.assertEqual(SkillLevel.apprentice, 'knock, knock!') def test_getattr_getitem(self): class Period(Enum): morning = 1 noon = 2 evening = 3 night = 4 self.assertIs(Period(2), Period.noon) self.assertIs(getattr(Period, 'night'), Period.night) self.assertIs(Period['morning'], Period.morning) def test_getattr_dunder(self): Season = self.Season self.assertTrue(getattr(Season, '__eq__')) def test_iteration_order(self): class Season(Enum): SUMMER = 2 WINTER = 4 AUTUMN = 3 SPRING = 1 self.assertEqual( list(Season), [Season.SUMMER, Season.WINTER, Season.AUTUMN, Season.SPRING], ) def test_reversed_iteration_order(self): self.assertEqual( list(reversed(self.Season)), [self.Season.WINTER, self.Season.AUTUMN, self.Season.SUMMER, self.Season.SPRING] ) def test_programmatic_function_string(self): SummerMonth = Enum('SummerMonth', 'june july august') lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 1): e = SummerMonth(i) self.assertEqual(int(e.value), i) self.assertNotEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_string_with_start(self): SummerMonth = Enum('SummerMonth', 'june july august', start=10) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 10): e = SummerMonth(i) self.assertEqual(int(e.value), i) self.assertNotEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_string_list(self): SummerMonth = Enum('SummerMonth', ['june', 'july', 'august']) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 1): e = SummerMonth(i) self.assertEqual(int(e.value), i) self.assertNotEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_string_list_with_start(self): SummerMonth = Enum('SummerMonth', ['june', 'july', 'august'], start=20) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 20): e = SummerMonth(i) self.assertEqual(int(e.value), i) self.assertNotEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_iterable(self): SummerMonth = Enum( 'SummerMonth', (('june', 1), ('july', 2), ('august', 3)) ) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 1): e = SummerMonth(i) self.assertEqual(int(e.value), i) self.assertNotEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_from_dict(self): SummerMonth = Enum( 'SummerMonth', OrderedDict((('june', 1), ('july', 2), ('august', 3))) ) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 1): e = SummerMonth(i) self.assertEqual(int(e.value), i) self.assertNotEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_type(self): SummerMonth = Enum('SummerMonth', 'june july august', type=int) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 1): e = SummerMonth(i) self.assertEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_type_with_start(self): SummerMonth = Enum('SummerMonth', 'june july august', type=int, start=30) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 30): e = SummerMonth(i) self.assertEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_type_from_subclass(self): SummerMonth = IntEnum('SummerMonth', 'june july august') lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 1): e = SummerMonth(i) self.assertEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_programmatic_function_type_from_subclass_with_start(self): SummerMonth = IntEnum('SummerMonth', 'june july august', start=40) lst = list(SummerMonth) self.assertEqual(len(lst), len(SummerMonth)) self.assertEqual(len(SummerMonth), 3, SummerMonth) self.assertEqual( [SummerMonth.june, SummerMonth.july, SummerMonth.august], lst, ) for i, month in enumerate('june july august'.split(), 40): e = SummerMonth(i) self.assertEqual(e, i) self.assertEqual(e.name, month) self.assertIn(e, SummerMonth) self.assertIs(type(e), SummerMonth) def test_subclassing(self): if isinstance(Name, Exception): raise Name self.assertEqual(Name.BDFL, 'Guido van Rossum') self.assertTrue(Name.BDFL, Name('Guido van Rossum')) self.assertIs(Name.BDFL, getattr(Name, 'BDFL')) test_pickle_dump_load(self.assertIs, Name.BDFL) def test_extending(self): class Color(Enum): red = 1 green = 2 blue = 3 with self.assertRaises(TypeError): class MoreColor(Color): cyan = 4 magenta = 5 yellow = 6 def test_exclude_methods(self): class whatever(Enum): this = 'that' these = 'those' def really(self): return 'no, not %s' % self.value self.assertIsNot(type(whatever.really), whatever) self.assertEqual(whatever.this.really(), 'no, not that') def test_wrong_inheritance_order(self): with self.assertRaises(TypeError): class Wrong(Enum, str): NotHere = 'error before this point' def test_intenum_transitivity(self): class number(IntEnum): one = 1 two = 2 three = 3 class numero(IntEnum): uno = 1 dos = 2 tres = 3 self.assertEqual(number.one, numero.uno) self.assertEqual(number.two, numero.dos) self.assertEqual(number.three, numero.tres) def test_wrong_enum_in_call(self): class Monochrome(Enum): black = 0 white = 1 class Gender(Enum): male = 0 female = 1 self.assertRaises(ValueError, Monochrome, Gender.male) def test_wrong_enum_in_mixed_call(self): class Monochrome(IntEnum): black = 0 white = 1 class Gender(Enum): male = 0 female = 1 self.assertRaises(ValueError, Monochrome, Gender.male) def test_mixed_enum_in_call_1(self): class Monochrome(IntEnum): black = 0 white = 1 class Gender(IntEnum): male = 0 female = 1 self.assertIs(Monochrome(Gender.female), Monochrome.white) def test_mixed_enum_in_call_2(self): class Monochrome(Enum): black = 0 white = 1 class Gender(IntEnum): male = 0 female = 1 self.assertIs(Monochrome(Gender.male), Monochrome.black) def test_flufl_enum(self): class Fluflnum(Enum): def __int__(self): return int(self.value) class MailManOptions(Fluflnum): option1 = 1 option2 = 2 option3 = 3 self.assertEqual(int(MailManOptions.option1), 1) def test_introspection(self): class Number(IntEnum): one = 100 two = 200 self.assertIs(Number.one._member_type_, int) self.assertIs(Number._member_type_, int) class String(str, Enum): yarn = 'soft' rope = 'rough' wire = 'hard' self.assertIs(String.yarn._member_type_, str) self.assertIs(String._member_type_, str) class Plain(Enum): vanilla = 'white' one = 1 self.assertIs(Plain.vanilla._member_type_, object) self.assertIs(Plain._member_type_, object) def test_no_such_enum_member(self): class Color(Enum): red = 1 green = 2 blue = 3 with self.assertRaises(ValueError): Color(4) with self.assertRaises(KeyError): Color['chartreuse'] def test_new_repr(self): class Color(Enum): red = 1 green = 2 blue = 3 def __repr__(self): return "don't you just love shades of %s?" % self.name self.assertEqual( repr(Color.blue), "don't you just love shades of blue?", ) def test_inherited_repr(self): class MyEnum(Enum): def __repr__(self): return "My name is %s." % self.name class MyIntEnum(int, MyEnum): this = 1 that = 2 theother = 3 self.assertEqual(repr(MyIntEnum.that), "My name is that.") def test_multiple_mixin_mro(self): class auto_enum(type(Enum)): def __new__(metacls, cls, bases, classdict): temp = type(classdict)() names = set(classdict._member_names) i = 0 for k in classdict._member_names: v = classdict[k] if v is Ellipsis: v = i else: i = v i += 1 temp[k] = v for k, v in classdict.items(): if k not in names: temp[k] = v return super(auto_enum, metacls).__new__( metacls, cls, bases, temp) class AutoNumberedEnum(Enum, metaclass=auto_enum): pass class AutoIntEnum(IntEnum, metaclass=auto_enum): pass class TestAutoNumber(AutoNumberedEnum): a = ... b = 3 c = ... class TestAutoInt(AutoIntEnum): a = ... b = 3 c = ... def test_subclasses_with_getnewargs(self): class NamedInt(int): __qualname__ = 'NamedInt' # needed for pickle protocol 4 def __new__(cls, *args): _args = args name, *args = args if len(args) == 0: raise TypeError("name and value must be specified") self = int.__new__(cls, *args) self._intname = name self._args = _args return self def __getnewargs__(self): return self._args @property def __name__(self): return self._intname def __repr__(self): # repr() is updated to include the name and type info return "{}({!r}, {})".format(type(self).__name__, self.__name__, int.__repr__(self)) def __str__(self): # str() is unchanged, even if it relies on the repr() fallback base = int base_str = base.__str__ if base_str.__objclass__ is object: return base.__repr__(self) return base_str(self) # for simplicity, we only define one operator that # propagates expressions def __add__(self, other): temp = int(self) + int( other) if isinstance(self, NamedInt) and isinstance(other, NamedInt): return NamedInt( '({0} + {1})'.format(self.__name__, other.__name__), temp ) else: return temp class NEI(NamedInt, Enum): __qualname__ = 'NEI' # needed for pickle protocol 4 x = ('the-x', 1) y = ('the-y', 2) self.assertIs(NEI.__new__, Enum.__new__) self.assertEqual(repr(NEI.x + NEI.y), "NamedInt('(the-x + the-y)', 3)") globals()['NamedInt'] = NamedInt globals()['NEI'] = NEI NI5 = NamedInt('test', 5) self.assertEqual(NI5, 5) test_pickle_dump_load(self.assertEqual, NI5, 5) self.assertEqual(NEI.y.value, 2) test_pickle_dump_load(self.assertIs, NEI.y) test_pickle_dump_load(self.assertIs, NEI) def test_subclasses_with_getnewargs_ex(self): class NamedInt(int): __qualname__ = 'NamedInt' # needed for pickle protocol 4 def __new__(cls, *args): _args = args name, *args = args if len(args) == 0: raise TypeError("name and value must be specified") self = int.__new__(cls, *args) self._intname = name self._args = _args return self def __getnewargs_ex__(self): return self._args, {} @property def __name__(self): return self._intname def __repr__(self): # repr() is updated to include the name and type info return "{}({!r}, {})".format(type(self).__name__, self.__name__, int.__repr__(self)) def __str__(self): # str() is unchanged, even if it relies on the repr() fallback base = int base_str = base.__str__ if base_str.__objclass__ is object: return base.__repr__(self) return base_str(self) # for simplicity, we only define one operator that # propagates expressions def __add__(self, other): temp = int(self) + int( other) if isinstance(self, NamedInt) and isinstance(other, NamedInt): return NamedInt( '({0} + {1})'.format(self.__name__, other.__name__), temp ) else: return temp class NEI(NamedInt, Enum): __qualname__ = 'NEI' # needed for pickle protocol 4 x = ('the-x', 1) y = ('the-y', 2) self.assertIs(NEI.__new__, Enum.__new__) self.assertEqual(repr(NEI.x + NEI.y), "NamedInt('(the-x + the-y)', 3)") globals()['NamedInt'] = NamedInt globals()['NEI'] = NEI NI5 = NamedInt('test', 5) self.assertEqual(NI5, 5) test_pickle_dump_load(self.assertEqual, NI5, 5) self.assertEqual(NEI.y.value, 2) test_pickle_dump_load(self.assertIs, NEI.y) test_pickle_dump_load(self.assertIs, NEI) def test_subclasses_with_reduce(self): class NamedInt(int): __qualname__ = 'NamedInt' # needed for pickle protocol 4 def __new__(cls, *args): _args = args name, *args = args if len(args) == 0: raise TypeError("name and value must be specified") self = int.__new__(cls, *args) self._intname = name self._args = _args return self def __reduce__(self): return self.__class__, self._args @property def __name__(self): return self._intname def __repr__(self): # repr() is updated to include the name and type info return "{}({!r}, {})".format(type(self).__name__, self.__name__, int.__repr__(self)) def __str__(self): # str() is unchanged, even if it relies on the repr() fallback base = int base_str = base.__str__ if base_str.__objclass__ is object: return base.__repr__(self) return base_str(self) # for simplicity, we only define one operator that # propagates expressions def __add__(self, other): temp = int(self) + int( other) if isinstance(self, NamedInt) and isinstance(other, NamedInt): return NamedInt( '({0} + {1})'.format(self.__name__, other.__name__), temp ) else: return temp class NEI(NamedInt, Enum): __qualname__ = 'NEI' # needed for pickle protocol 4 x = ('the-x', 1) y = ('the-y', 2) self.assertIs(NEI.__new__, Enum.__new__) self.assertEqual(repr(NEI.x + NEI.y), "NamedInt('(the-x + the-y)', 3)") globals()['NamedInt'] = NamedInt globals()['NEI'] = NEI NI5 = NamedInt('test', 5) self.assertEqual(NI5, 5) test_pickle_dump_load(self.assertEqual, NI5, 5) self.assertEqual(NEI.y.value, 2) test_pickle_dump_load(self.assertIs, NEI.y) test_pickle_dump_load(self.assertIs, NEI) def test_subclasses_with_reduce_ex(self): class NamedInt(int): __qualname__ = 'NamedInt' # needed for pickle protocol 4 def __new__(cls, *args): _args = args name, *args = args if len(args) == 0: raise TypeError("name and value must be specified") self = int.__new__(cls, *args) self._intname = name self._args = _args return self def __reduce_ex__(self, proto): return self.__class__, self._args @property def __name__(self): return self._intname def __repr__(self): # repr() is updated to include the name and type info return "{}({!r}, {})".format(type(self).__name__, self.__name__, int.__repr__(self)) def __str__(self): # str() is unchanged, even if it relies on the repr() fallback base = int base_str = base.__str__ if base_str.__objclass__ is object: return base.__repr__(self) return base_str(self) # for simplicity, we only define one operator that # propagates expressions def __add__(self, other): temp = int(self) + int( other) if isinstance(self, NamedInt) and isinstance(other, NamedInt): return NamedInt( '({0} + {1})'.format(self.__name__, other.__name__), temp ) else: return temp class NEI(NamedInt, Enum): __qualname__ = 'NEI' # needed for pickle protocol 4 x = ('the-x', 1) y = ('the-y', 2) self.assertIs(NEI.__new__, Enum.__new__) self.assertEqual(repr(NEI.x + NEI.y), "NamedInt('(the-x + the-y)', 3)") globals()['NamedInt'] = NamedInt globals()['NEI'] = NEI NI5 = NamedInt('test', 5) self.assertEqual(NI5, 5) test_pickle_dump_load(self.assertEqual, NI5, 5) self.assertEqual(NEI.y.value, 2) test_pickle_dump_load(self.assertIs, NEI.y) test_pickle_dump_load(self.assertIs, NEI) def test_subclasses_without_direct_pickle_support(self): class NamedInt(int): __qualname__ = 'NamedInt' def __new__(cls, *args): _args = args name, *args = args if len(args) == 0: raise TypeError("name and value must be specified") self = int.__new__(cls, *args) self._intname = name self._args = _args return self @property def __name__(self): return self._intname def __repr__(self): # repr() is updated to include the name and type info return "{}({!r}, {})".format(type(self).__name__, self.__name__, int.__repr__(self)) def __str__(self): # str() is unchanged, even if it relies on the repr() fallback base = int base_str = base.__str__ if base_str.__objclass__ is object: return base.__repr__(self) return base_str(self) # for simplicity, we only define one operator that # propagates expressions def __add__(self, other): temp = int(self) + int( other) if isinstance(self, NamedInt) and isinstance(other, NamedInt): return NamedInt( '({0} + {1})'.format(self.__name__, other.__name__), temp ) else: return temp class NEI(NamedInt, Enum): __qualname__ = 'NEI' x = ('the-x', 1) y = ('the-y', 2) self.assertIs(NEI.__new__, Enum.__new__) self.assertEqual(repr(NEI.x + NEI.y), "NamedInt('(the-x + the-y)', 3)") globals()['NamedInt'] = NamedInt globals()['NEI'] = NEI NI5 = NamedInt('test', 5) self.assertEqual(NI5, 5) self.assertEqual(NEI.y.value, 2) test_pickle_exception(self.assertRaises, TypeError, NEI.x) test_pickle_exception(self.assertRaises, PicklingError, NEI) def test_subclasses_without_direct_pickle_support_using_name(self): class NamedInt(int): __qualname__ = 'NamedInt' def __new__(cls, *args): _args = args name, *args = args if len(args) == 0: raise TypeError("name and value must be specified") self = int.__new__(cls, *args) self._intname = name self._args = _args return self @property def __name__(self): return self._intname def __repr__(self): # repr() is updated to include the name and type info return "{}({!r}, {})".format(type(self).__name__, self.__name__, int.__repr__(self)) def __str__(self): # str() is unchanged, even if it relies on the repr() fallback base = int base_str = base.__str__ if base_str.__objclass__ is object: return base.__repr__(self) return base_str(self) # for simplicity, we only define one operator that # propagates expressions def __add__(self, other): temp = int(self) + int( other) if isinstance(self, NamedInt) and isinstance(other, NamedInt): return NamedInt( '({0} + {1})'.format(self.__name__, other.__name__), temp ) else: return temp class NEI(NamedInt, Enum): __qualname__ = 'NEI' x = ('the-x', 1) y = ('the-y', 2) def __reduce_ex__(self, proto): return getattr, (self.__class__, self._name_) self.assertIs(NEI.__new__, Enum.__new__) self.assertEqual(repr(NEI.x + NEI.y), "NamedInt('(the-x + the-y)', 3)") globals()['NamedInt'] = NamedInt globals()['NEI'] = NEI NI5 = NamedInt('test', 5) self.assertEqual(NI5, 5) self.assertEqual(NEI.y.value, 2) test_pickle_dump_load(self.assertIs, NEI.y) test_pickle_dump_load(self.assertIs, NEI) def test_tuple_subclass(self): class SomeTuple(tuple, Enum): __qualname__ = 'SomeTuple' # needed for pickle protocol 4 first = (1, 'for the money') second = (2, 'for the show') third = (3, 'for the music') self.assertIs(type(SomeTuple.first), SomeTuple) self.assertIsInstance(SomeTuple.second, tuple) self.assertEqual(SomeTuple.third, (3, 'for the music')) globals()['SomeTuple'] = SomeTuple test_pickle_dump_load(self.assertIs, SomeTuple.first) def test_duplicate_values_give_unique_enum_items(self): class AutoNumber(Enum): first = () second = () third = () def __new__(cls): value = len(cls.__members__) + 1 obj = object.__new__(cls) obj._value_ = value return obj def __int__(self): return int(self._value_) self.assertEqual( list(AutoNumber), [AutoNumber.first, AutoNumber.second, AutoNumber.third], ) self.assertEqual(int(AutoNumber.second), 2) self.assertEqual(AutoNumber.third.value, 3) self.assertIs(AutoNumber(1), AutoNumber.first) def test_inherited_new_from_enhanced_enum(self): class AutoNumber(Enum): def __new__(cls): value = len(cls.__members__) + 1 obj = object.__new__(cls) obj._value_ = value return obj def __int__(self): return int(self._value_) class Color(AutoNumber): red = () green = () blue = () self.assertEqual(list(Color), [Color.red, Color.green, Color.blue]) self.assertEqual(list(map(int, Color)), [1, 2, 3]) def test_inherited_new_from_mixed_enum(self): class AutoNumber(IntEnum): def __new__(cls): value = len(cls.__members__) + 1 obj = int.__new__(cls, value) obj._value_ = value return obj class Color(AutoNumber): red = () green = () blue = () self.assertEqual(list(Color), [Color.red, Color.green, Color.blue]) self.assertEqual(list(map(int, Color)), [1, 2, 3]) def test_equality(self): class AlwaysEqual: def __eq__(self, other): return True class OrdinaryEnum(Enum): a = 1 self.assertEqual(AlwaysEqual(), OrdinaryEnum.a) self.assertEqual(OrdinaryEnum.a, AlwaysEqual()) def test_ordered_mixin(self): class OrderedEnum(Enum): def __ge__(self, other): if self.__class__ is other.__class__: return self._value_ >= other._value_ return NotImplemented def __gt__(self, other): if self.__class__ is other.__class__: return self._value_ > other._value_ return NotImplemented def __le__(self, other): if self.__class__ is other.__class__: return self._value_ <= other._value_ return NotImplemented def __lt__(self, other): if self.__class__ is other.__class__: return self._value_ < other._value_ return NotImplemented class Grade(OrderedEnum): A = 5 B = 4 C = 3 D = 2 F = 1 self.assertGreater(Grade.A, Grade.B) self.assertLessEqual(Grade.F, Grade.C) self.assertLess(Grade.D, Grade.A) self.assertGreaterEqual(Grade.B, Grade.B) self.assertEqual(Grade.B, Grade.B) self.assertNotEqual(Grade.C, Grade.D) def test_extending2(self): class Shade(Enum): def shade(self): print(self.name) class Color(Shade): red = 1 green = 2 blue = 3 with self.assertRaises(TypeError): class MoreColor(Color): cyan = 4 magenta = 5 yellow = 6 def test_extending3(self): class Shade(Enum): def shade(self): return self.name class Color(Shade): def hex(self): return '%s hexlified!' % self.value class MoreColor(Color): cyan = 4 magenta = 5 yellow = 6 self.assertEqual(MoreColor.magenta.hex(), '5 hexlified!') def test_subclass_duplicate_name(self): class Base(Enum): def test(self): pass class Test(Base): test = 1 self.assertIs(type(Test.test), Test) def test_subclass_duplicate_name_dynamic(self): from types import DynamicClassAttribute class Base(Enum): @DynamicClassAttribute def test(self): return 'dynamic' class Test(Base): test = 1 self.assertEqual(Test.test.test, 'dynamic') def test_no_duplicates(self): class UniqueEnum(Enum): def __init__(self, *args): cls = self.__class__ if any(self.value == e.value for e in cls): a = self.name e = cls(self.value).name raise ValueError( "aliases not allowed in UniqueEnum: %r --> %r" % (a, e) ) class Color(UniqueEnum): red = 1 green = 2 blue = 3 with self.assertRaises(ValueError): class Color(UniqueEnum): red = 1 green = 2 blue = 3 grene = 2 def test_init(self): class Planet(Enum): MERCURY = (3.303e+23, 2.4397e6) VENUS = (4.869e+24, 6.0518e6) EARTH = (5.976e+24, 6.37814e6) MARS = (6.421e+23, 3.3972e6) JUPITER = (1.9e+27, 7.1492e7) SATURN = (5.688e+26, 6.0268e7) URANUS = (8.686e+25, 2.5559e7) NEPTUNE = (1.024e+26, 2.4746e7) def __init__(self, mass, radius): self.mass = mass # in kilograms self.radius = radius # in meters @property def surface_gravity(self): # universal gravitational constant (m3 kg-1 s-2) G = 6.67300E-11 return G * self.mass / (self.radius * self.radius) self.assertEqual(round(Planet.EARTH.surface_gravity, 2), 9.80) self.assertEqual(Planet.EARTH.value, (5.976e+24, 6.37814e6)) def test_nonhash_value(self): class AutoNumberInAList(Enum): def __new__(cls): value = [len(cls.__members__) + 1] obj = object.__new__(cls) obj._value_ = value return obj class ColorInAList(AutoNumberInAList): red = () green = () blue = () self.assertEqual(list(ColorInAList), [ColorInAList.red, ColorInAList.green, ColorInAList.blue]) for enum, value in zip(ColorInAList, range(3)): value += 1 self.assertEqual(enum.value, [value]) self.assertIs(ColorInAList([value]), enum) def test_conflicting_types_resolved_in_new(self): class LabelledIntEnum(int, Enum): def __new__(cls, *args): value, label = args obj = int.__new__(cls, value) obj.label = label obj._value_ = value return obj class LabelledList(LabelledIntEnum): unprocessed = (1, "Unprocessed") payment_complete = (2, "Payment Complete") self.assertEqual(list(LabelledList), [LabelledList.unprocessed, LabelledList.payment_complete]) self.assertEqual(LabelledList.unprocessed, 1) self.assertEqual(LabelledList(1), LabelledList.unprocessed) def test_auto_number(self): class Color(Enum): red = auto() blue = auto() green = auto() self.assertEqual(list(Color), [Color.red, Color.blue, Color.green]) self.assertEqual(Color.red.value, 1) self.assertEqual(Color.blue.value, 2) self.assertEqual(Color.green.value, 3) def test_auto_name(self): class Color(Enum): def _generate_next_value_(name, start, count, last): return name red = auto() blue = auto() green = auto() self.assertEqual(list(Color), [Color.red, Color.blue, Color.green]) self.assertEqual(Color.red.value, 'red') self.assertEqual(Color.blue.value, 'blue') self.assertEqual(Color.green.value, 'green') def test_auto_name_inherit(self): class AutoNameEnum(Enum): def _generate_next_value_(name, start, count, last): return name class Color(AutoNameEnum): red = auto() blue = auto() green = auto() self.assertEqual(list(Color), [Color.red, Color.blue, Color.green]) self.assertEqual(Color.red.value, 'red') self.assertEqual(Color.blue.value, 'blue') self.assertEqual(Color.green.value, 'green') def test_auto_garbage(self): class Color(Enum): red = 'red' blue = auto() self.assertEqual(Color.blue.value, 1) def test_auto_garbage_corrected(self): class Color(Enum): red = 'red' blue = 2 green = auto() self.assertEqual(list(Color), [Color.red, Color.blue, Color.green]) self.assertEqual(Color.red.value, 'red') self.assertEqual(Color.blue.value, 2) self.assertEqual(Color.green.value, 3) def test_duplicate_auto(self): class Dupes(Enum): first = primero = auto() second = auto() third = auto() self.assertEqual([Dupes.first, Dupes.second, Dupes.third], list(Dupes)) class TestOrder(unittest.TestCase): def test_same_members(self): class Color(Enum): _order_ = 'red green blue' red = 1 green = 2 blue = 3 def test_same_members_with_aliases(self): class Color(Enum): _order_ = 'red green blue' red = 1 green = 2 blue = 3 verde = green def test_same_members_wrong_order(self): with self.assertRaisesRegex(TypeError, 'member order does not match _order_'): class Color(Enum): _order_ = 'red green blue' red = 1 blue = 3 green = 2 def test_order_has_extra_members(self): with self.assertRaisesRegex(TypeError, 'member order does not match _order_'): class Color(Enum): _order_ = 'red green blue purple' red = 1 green = 2 blue = 3 def test_order_has_extra_members_with_aliases(self): with self.assertRaisesRegex(TypeError, 'member order does not match _order_'): class Color(Enum): _order_ = 'red green blue purple' red = 1 green = 2 blue = 3 verde = green def test_enum_has_extra_members(self): with self.assertRaisesRegex(TypeError, 'member order does not match _order_'): class Color(Enum): _order_ = 'red green blue' red = 1 green = 2 blue = 3 purple = 4 def test_enum_has_extra_members_with_aliases(self): with self.assertRaisesRegex(TypeError, 'member order does not match _order_'): class Color(Enum): _order_ = 'red green blue' red = 1 green = 2 blue = 3 purple = 4 verde = green class TestFlag(unittest.TestCase): """Tests of the Flags.""" class Perm(Flag): R, W, X = 4, 2, 1 class Open(Flag): RO = 0 WO = 1 RW = 2 AC = 3 CE = 1<<19 def test_str(self): Perm = self.Perm self.assertEqual(str(Perm.R), 'Perm.R') self.assertEqual(str(Perm.W), 'Perm.W') self.assertEqual(str(Perm.X), 'Perm.X') self.assertEqual(str(Perm.R | Perm.W), 'Perm.R|W') self.assertEqual(str(Perm.R | Perm.W | Perm.X), 'Perm.R|W|X') self.assertEqual(str(Perm(0)), 'Perm.0') self.assertEqual(str(~Perm.R), 'Perm.W|X') self.assertEqual(str(~Perm.W), 'Perm.R|X') self.assertEqual(str(~Perm.X), 'Perm.R|W') self.assertEqual(str(~(Perm.R | Perm.W)), 'Perm.X') self.assertEqual(str(~(Perm.R | Perm.W | Perm.X)), 'Perm.0') self.assertEqual(str(Perm(~0)), 'Perm.R|W|X') Open = self.Open self.assertEqual(str(Open.RO), 'Open.RO') self.assertEqual(str(Open.WO), 'Open.WO') self.assertEqual(str(Open.AC), 'Open.AC') self.assertEqual(str(Open.RO | Open.CE), 'Open.CE') self.assertEqual(str(Open.WO | Open.CE), 'Open.CE|WO') self.assertEqual(str(~Open.RO), 'Open.CE|AC|RW|WO') self.assertEqual(str(~Open.WO), 'Open.CE|RW') self.assertEqual(str(~Open.AC), 'Open.CE') self.assertEqual(str(~(Open.RO | Open.CE)), 'Open.AC') self.assertEqual(str(~(Open.WO | Open.CE)), 'Open.RW') def test_repr(self): Perm = self.Perm self.assertEqual(repr(Perm.R), '<Perm.R: 4>') self.assertEqual(repr(Perm.W), '<Perm.W: 2>') self.assertEqual(repr(Perm.X), '<Perm.X: 1>') self.assertEqual(repr(Perm.R | Perm.W), '<Perm.R|W: 6>') self.assertEqual(repr(Perm.R | Perm.W | Perm.X), '<Perm.R|W|X: 7>') self.assertEqual(repr(Perm(0)), '<Perm.0: 0>') self.assertEqual(repr(~Perm.R), '<Perm.W|X: 3>') self.assertEqual(repr(~Perm.W), '<Perm.R|X: 5>') self.assertEqual(repr(~Perm.X), '<Perm.R|W: 6>') self.assertEqual(repr(~(Perm.R | Perm.W)), '<Perm.X: 1>') self.assertEqual(repr(~(Perm.R | Perm.W | Perm.X)), '<Perm.0: 0>') self.assertEqual(repr(Perm(~0)), '<Perm.R|W|X: 7>') Open = self.Open self.assertEqual(repr(Open.RO), '<Open.RO: 0>') self.assertEqual(repr(Open.WO), '<Open.WO: 1>') self.assertEqual(repr(Open.AC), '<Open.AC: 3>') self.assertEqual(repr(Open.RO | Open.CE), '<Open.CE: 524288>') self.assertEqual(repr(Open.WO | Open.CE), '<Open.CE|WO: 524289>') self.assertEqual(repr(~Open.RO), '<Open.CE|AC|RW|WO: 524291>') self.assertEqual(repr(~Open.WO), '<Open.CE|RW: 524290>') self.assertEqual(repr(~Open.AC), '<Open.CE: 524288>') self.assertEqual(repr(~(Open.RO | Open.CE)), '<Open.AC: 3>') self.assertEqual(repr(~(Open.WO | Open.CE)), '<Open.RW: 2>') def test_or(self): Perm = self.Perm for i in Perm: for j in Perm: self.assertEqual((i | j), Perm(i.value | j.value)) self.assertEqual((i | j).value, i.value | j.value) self.assertIs(type(i | j), Perm) for i in Perm: self.assertIs(i | i, i) Open = self.Open self.assertIs(Open.RO | Open.CE, Open.CE) def test_and(self): Perm = self.Perm RW = Perm.R | Perm.W RX = Perm.R | Perm.X WX = Perm.W | Perm.X RWX = Perm.R | Perm.W | Perm.X values = list(Perm) + [RW, RX, WX, RWX, Perm(0)] for i in values: for j in values: self.assertEqual((i & j).value, i.value & j.value) self.assertIs(type(i & j), Perm) for i in Perm: self.assertIs(i & i, i) self.assertIs(i & RWX, i) self.assertIs(RWX & i, i) Open = self.Open self.assertIs(Open.RO & Open.CE, Open.RO) def test_xor(self): Perm = self.Perm for i in Perm: for j in Perm: self.assertEqual((i ^ j).value, i.value ^ j.value) self.assertIs(type(i ^ j), Perm) for i in Perm: self.assertIs(i ^ Perm(0), i) self.assertIs(Perm(0) ^ i, i) Open = self.Open self.assertIs(Open.RO ^ Open.CE, Open.CE) self.assertIs(Open.CE ^ Open.CE, Open.RO) def test_invert(self): Perm = self.Perm RW = Perm.R | Perm.W RX = Perm.R | Perm.X WX = Perm.W | Perm.X RWX = Perm.R | Perm.W | Perm.X values = list(Perm) + [RW, RX, WX, RWX, Perm(0)] for i in values: self.assertIs(type(~i), Perm) self.assertEqual(~~i, i) for i in Perm: self.assertIs(~~i, i) Open = self.Open self.assertIs(Open.WO & ~Open.WO, Open.RO) self.assertIs((Open.WO|Open.CE) & ~Open.WO, Open.CE) def test_bool(self): Perm = self.Perm for f in Perm: self.assertTrue(f) Open = self.Open for f in Open: self.assertEqual(bool(f.value), bool(f)) def test_programatic_function_string(self): Perm = Flag('Perm', 'R W X') lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<i e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_string_with_start(self): Perm = Flag('Perm', 'R W X', start=8) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 8<<i e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_string_list(self): Perm = Flag('Perm', ['R', 'W', 'X']) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<i e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_iterable(self): Perm = Flag('Perm', (('R', 2), ('W', 8), ('X', 32))) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<(2*i+1) e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_from_dict(self): Perm = Flag('Perm', OrderedDict((('R', 2), ('W', 8), ('X', 32)))) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<(2*i+1) e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_pickle(self): if isinstance(FlagStooges, Exception): raise FlagStooges test_pickle_dump_load(self.assertIs, FlagStooges.CURLY|FlagStooges.MOE) test_pickle_dump_load(self.assertIs, FlagStooges) def test_containment(self): Perm = self.Perm R, W, X = Perm RW = R | W RX = R | X WX = W | X RWX = R | W | X self.assertTrue(R in RW) self.assertTrue(R in RX) self.assertTrue(R in RWX) self.assertTrue(W in RW) self.assertTrue(W in WX) self.assertTrue(W in RWX) self.assertTrue(X in RX) self.assertTrue(X in WX) self.assertTrue(X in RWX) self.assertFalse(R in WX) self.assertFalse(W in RX) self.assertFalse(X in RW) def test_auto_number(self): class Color(Flag): red = auto() blue = auto() green = auto() self.assertEqual(list(Color), [Color.red, Color.blue, Color.green]) self.assertEqual(Color.red.value, 1) self.assertEqual(Color.blue.value, 2) self.assertEqual(Color.green.value, 4) def test_auto_number_garbage(self): with self.assertRaisesRegex(TypeError, 'Invalid Flag value: .not an int.'): class Color(Flag): red = 'not an int' blue = auto() def test_cascading_failure(self): class Bizarre(Flag): c = 3 d = 4 f = 6 # Bizarre.c | Bizarre.d self.assertRaisesRegex(ValueError, "5 is not a valid Bizarre", Bizarre, 5) self.assertRaisesRegex(ValueError, "5 is not a valid Bizarre", Bizarre, 5) self.assertRaisesRegex(ValueError, "2 is not a valid Bizarre", Bizarre, 2) self.assertRaisesRegex(ValueError, "2 is not a valid Bizarre", Bizarre, 2) self.assertRaisesRegex(ValueError, "1 is not a valid Bizarre", Bizarre, 1) self.assertRaisesRegex(ValueError, "1 is not a valid Bizarre", Bizarre, 1) def test_duplicate_auto(self): class Dupes(Enum): first = primero = auto() second = auto() third = auto() self.assertEqual([Dupes.first, Dupes.second, Dupes.third], list(Dupes)) def test_bizarre(self): class Bizarre(Flag): b = 3 c = 4 d = 6 self.assertEqual(repr(Bizarre(7)), '<Bizarre.d|c|b: 7>') @unittest.skipUnless(threading, 'Threading required for this test.') @support.reap_threads def test_unique_composite(self): # override __eq__ to be identity only class TestFlag(Flag): one = auto() two = auto() three = auto() four = auto() five = auto() six = auto() seven = auto() eight = auto() def __eq__(self, other): return self is other def __hash__(self): return hash(self._value_) # have multiple threads competing to complete the composite members seen = set() failed = False def cycle_enum(): nonlocal failed try: for i in range(256): seen.add(TestFlag(i)) except Exception: failed = True threads = [ threading.Thread(target=cycle_enum) for _ in range(8) ] with support.start_threads(threads): pass # check that only 248 members were created self.assertFalse( failed, 'at least one thread failed while creating composite members') self.assertEqual(256, len(seen), 'too many composite members created') class TestIntFlag(unittest.TestCase): """Tests of the IntFlags.""" class Perm(IntFlag): X = 1 << 0 W = 1 << 1 R = 1 << 2 class Open(IntFlag): RO = 0 WO = 1 RW = 2 AC = 3 CE = 1<<19 def test_type(self): Perm = self.Perm Open = self.Open for f in Perm: self.assertTrue(isinstance(f, Perm)) self.assertEqual(f, f.value) self.assertTrue(isinstance(Perm.W | Perm.X, Perm)) self.assertEqual(Perm.W | Perm.X, 3) for f in Open: self.assertTrue(isinstance(f, Open)) self.assertEqual(f, f.value) self.assertTrue(isinstance(Open.WO | Open.RW, Open)) self.assertEqual(Open.WO | Open.RW, 3) def test_str(self): Perm = self.Perm self.assertEqual(str(Perm.R), 'Perm.R') self.assertEqual(str(Perm.W), 'Perm.W') self.assertEqual(str(Perm.X), 'Perm.X') self.assertEqual(str(Perm.R | Perm.W), 'Perm.R|W') self.assertEqual(str(Perm.R | Perm.W | Perm.X), 'Perm.R|W|X') self.assertEqual(str(Perm.R | 8), 'Perm.8|R') self.assertEqual(str(Perm(0)), 'Perm.0') self.assertEqual(str(Perm(8)), 'Perm.8') self.assertEqual(str(~Perm.R), 'Perm.W|X') self.assertEqual(str(~Perm.W), 'Perm.R|X') self.assertEqual(str(~Perm.X), 'Perm.R|W') self.assertEqual(str(~(Perm.R | Perm.W)), 'Perm.X') self.assertEqual(str(~(Perm.R | Perm.W | Perm.X)), 'Perm.-8') self.assertEqual(str(~(Perm.R | 8)), 'Perm.W|X') self.assertEqual(str(Perm(~0)), 'Perm.R|W|X') self.assertEqual(str(Perm(~8)), 'Perm.R|W|X') Open = self.Open self.assertEqual(str(Open.RO), 'Open.RO') self.assertEqual(str(Open.WO), 'Open.WO') self.assertEqual(str(Open.AC), 'Open.AC') self.assertEqual(str(Open.RO | Open.CE), 'Open.CE') self.assertEqual(str(Open.WO | Open.CE), 'Open.CE|WO') self.assertEqual(str(Open(4)), 'Open.4') self.assertEqual(str(~Open.RO), 'Open.CE|AC|RW|WO') self.assertEqual(str(~Open.WO), 'Open.CE|RW') self.assertEqual(str(~Open.AC), 'Open.CE') self.assertEqual(str(~(Open.RO | Open.CE)), 'Open.AC|RW|WO') self.assertEqual(str(~(Open.WO | Open.CE)), 'Open.RW') self.assertEqual(str(Open(~4)), 'Open.CE|AC|RW|WO') def test_repr(self): Perm = self.Perm self.assertEqual(repr(Perm.R), '<Perm.R: 4>') self.assertEqual(repr(Perm.W), '<Perm.W: 2>') self.assertEqual(repr(Perm.X), '<Perm.X: 1>') self.assertEqual(repr(Perm.R | Perm.W), '<Perm.R|W: 6>') self.assertEqual(repr(Perm.R | Perm.W | Perm.X), '<Perm.R|W|X: 7>') self.assertEqual(repr(Perm.R | 8), '<Perm.8|R: 12>') self.assertEqual(repr(Perm(0)), '<Perm.0: 0>') self.assertEqual(repr(Perm(8)), '<Perm.8: 8>') self.assertEqual(repr(~Perm.R), '<Perm.W|X: -5>') self.assertEqual(repr(~Perm.W), '<Perm.R|X: -3>') self.assertEqual(repr(~Perm.X), '<Perm.R|W: -2>') self.assertEqual(repr(~(Perm.R | Perm.W)), '<Perm.X: -7>') self.assertEqual(repr(~(Perm.R | Perm.W | Perm.X)), '<Perm.-8: -8>') self.assertEqual(repr(~(Perm.R | 8)), '<Perm.W|X: -13>') self.assertEqual(repr(Perm(~0)), '<Perm.R|W|X: -1>') self.assertEqual(repr(Perm(~8)), '<Perm.R|W|X: -9>') Open = self.Open self.assertEqual(repr(Open.RO), '<Open.RO: 0>') self.assertEqual(repr(Open.WO), '<Open.WO: 1>') self.assertEqual(repr(Open.AC), '<Open.AC: 3>') self.assertEqual(repr(Open.RO | Open.CE), '<Open.CE: 524288>') self.assertEqual(repr(Open.WO | Open.CE), '<Open.CE|WO: 524289>') self.assertEqual(repr(Open(4)), '<Open.4: 4>') self.assertEqual(repr(~Open.RO), '<Open.CE|AC|RW|WO: -1>') self.assertEqual(repr(~Open.WO), '<Open.CE|RW: -2>') self.assertEqual(repr(~Open.AC), '<Open.CE: -4>') self.assertEqual(repr(~(Open.RO | Open.CE)), '<Open.AC|RW|WO: -524289>') self.assertEqual(repr(~(Open.WO | Open.CE)), '<Open.RW: -524290>') self.assertEqual(repr(Open(~4)), '<Open.CE|AC|RW|WO: -5>') def test_or(self): Perm = self.Perm for i in Perm: for j in Perm: self.assertEqual(i | j, i.value | j.value) self.assertEqual((i | j).value, i.value | j.value) self.assertIs(type(i | j), Perm) for j in range(8): self.assertEqual(i | j, i.value | j) self.assertEqual((i | j).value, i.value | j) self.assertIs(type(i | j), Perm) self.assertEqual(j | i, j | i.value) self.assertEqual((j | i).value, j | i.value) self.assertIs(type(j | i), Perm) for i in Perm: self.assertIs(i | i, i) self.assertIs(i | 0, i) self.assertIs(0 | i, i) Open = self.Open self.assertIs(Open.RO | Open.CE, Open.CE) def test_and(self): Perm = self.Perm RW = Perm.R | Perm.W RX = Perm.R | Perm.X WX = Perm.W | Perm.X RWX = Perm.R | Perm.W | Perm.X values = list(Perm) + [RW, RX, WX, RWX, Perm(0)] for i in values: for j in values: self.assertEqual(i & j, i.value & j.value, 'i is %r, j is %r' % (i, j)) self.assertEqual((i & j).value, i.value & j.value, 'i is %r, j is %r' % (i, j)) self.assertIs(type(i & j), Perm, 'i is %r, j is %r' % (i, j)) for j in range(8): self.assertEqual(i & j, i.value & j) self.assertEqual((i & j).value, i.value & j) self.assertIs(type(i & j), Perm) self.assertEqual(j & i, j & i.value) self.assertEqual((j & i).value, j & i.value) self.assertIs(type(j & i), Perm) for i in Perm: self.assertIs(i & i, i) self.assertIs(i & 7, i) self.assertIs(7 & i, i) Open = self.Open self.assertIs(Open.RO & Open.CE, Open.RO) def test_xor(self): Perm = self.Perm for i in Perm: for j in Perm: self.assertEqual(i ^ j, i.value ^ j.value) self.assertEqual((i ^ j).value, i.value ^ j.value) self.assertIs(type(i ^ j), Perm) for j in range(8): self.assertEqual(i ^ j, i.value ^ j) self.assertEqual((i ^ j).value, i.value ^ j) self.assertIs(type(i ^ j), Perm) self.assertEqual(j ^ i, j ^ i.value) self.assertEqual((j ^ i).value, j ^ i.value) self.assertIs(type(j ^ i), Perm) for i in Perm: self.assertIs(i ^ 0, i) self.assertIs(0 ^ i, i) Open = self.Open self.assertIs(Open.RO ^ Open.CE, Open.CE) self.assertIs(Open.CE ^ Open.CE, Open.RO) def test_invert(self): Perm = self.Perm RW = Perm.R | Perm.W RX = Perm.R | Perm.X WX = Perm.W | Perm.X RWX = Perm.R | Perm.W | Perm.X values = list(Perm) + [RW, RX, WX, RWX, Perm(0)] for i in values: self.assertEqual(~i, ~i.value) self.assertEqual((~i).value, ~i.value) self.assertIs(type(~i), Perm) self.assertEqual(~~i, i) for i in Perm: self.assertIs(~~i, i) Open = self.Open self.assertIs(Open.WO & ~Open.WO, Open.RO) self.assertIs((Open.WO|Open.CE) & ~Open.WO, Open.CE) def test_programatic_function_string(self): Perm = IntFlag('Perm', 'R W X') lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<i e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e, v) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_string_with_start(self): Perm = IntFlag('Perm', 'R W X', start=8) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 8<<i e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e, v) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_string_list(self): Perm = IntFlag('Perm', ['R', 'W', 'X']) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<i e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e, v) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_iterable(self): Perm = IntFlag('Perm', (('R', 2), ('W', 8), ('X', 32))) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<(2*i+1) e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e, v) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_from_dict(self): Perm = IntFlag('Perm', OrderedDict((('R', 2), ('W', 8), ('X', 32)))) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 3, Perm) self.assertEqual(lst, [Perm.R, Perm.W, Perm.X]) for i, n in enumerate('R W X'.split()): v = 1<<(2*i+1) e = Perm(v) self.assertEqual(e.value, v) self.assertEqual(type(e.value), int) self.assertEqual(e, v) self.assertEqual(e.name, n) self.assertIn(e, Perm) self.assertIs(type(e), Perm) def test_programatic_function_from_empty_list(self): Perm = enum.IntFlag('Perm', []) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 0, Perm) Thing = enum.Enum('Thing', []) lst = list(Thing) self.assertEqual(len(lst), len(Thing)) self.assertEqual(len(Thing), 0, Thing) def test_programatic_function_from_empty_tuple(self): Perm = enum.IntFlag('Perm', ()) lst = list(Perm) self.assertEqual(len(lst), len(Perm)) self.assertEqual(len(Perm), 0, Perm) Thing = enum.Enum('Thing', ()) self.assertEqual(len(lst), len(Thing)) self.assertEqual(len(Thing), 0, Thing) def test_containment(self): Perm = self.Perm R, W, X = Perm RW = R | W RX = R | X WX = W | X RWX = R | W | X self.assertTrue(R in RW) self.assertTrue(R in RX) self.assertTrue(R in RWX) self.assertTrue(W in RW) self.assertTrue(W in WX) self.assertTrue(W in RWX) self.assertTrue(X in RX) self.assertTrue(X in WX) self.assertTrue(X in RWX) self.assertFalse(R in WX) self.assertFalse(W in RX) self.assertFalse(X in RW) def test_bool(self): Perm = self.Perm for f in Perm: self.assertTrue(f) Open = self.Open for f in Open: self.assertEqual(bool(f.value), bool(f)) @unittest.skipUnless(threading, 'Threading required for this test.') @support.reap_threads def test_unique_composite(self): # override __eq__ to be identity only class TestFlag(IntFlag): one = auto() two = auto() three = auto() four = auto() five = auto() six = auto() seven = auto() eight = auto() def __eq__(self, other): return self is other def __hash__(self): return hash(self._value_) # have multiple threads competing to complete the composite members seen = set() failed = False def cycle_enum(): nonlocal failed try: for i in range(256): seen.add(TestFlag(i)) except Exception: failed = True threads = [ threading.Thread(target=cycle_enum) for _ in range(8) ] with support.start_threads(threads): pass # check that only 248 members were created self.assertFalse( failed, 'at least one thread failed while creating composite members') self.assertEqual(256, len(seen), 'too many composite members created') class TestUnique(unittest.TestCase): def test_unique_clean(self): @unique class Clean(Enum): one = 1 two = 'dos' tres = 4.0 @unique class Cleaner(IntEnum): single = 1 double = 2 triple = 3 def test_unique_dirty(self): with self.assertRaisesRegex(ValueError, 'tres.*one'): @unique class Dirty(Enum): one = 1 two = 'dos' tres = 1 with self.assertRaisesRegex( ValueError, 'double.*single.*turkey.*triple', ): @unique class Dirtier(IntEnum): single = 1 double = 1 triple = 3 turkey = 3 def test_unique_with_name(self): @unique class Silly(Enum): one = 1 two = 'dos' name = 3 @unique class Sillier(IntEnum): single = 1 name = 2 triple = 3 value = 4 expected_help_output_with_docs = """\ Help on class Color in module %s: class Color(enum.Enum) | An enumeration. |\x20\x20 | Method resolution order: | Color | enum.Enum | builtins.object |\x20\x20 | Data and other attributes defined here: |\x20\x20 | blue = <Color.blue: 3> |\x20\x20 | green = <Color.green: 2> |\x20\x20 | red = <Color.red: 1> |\x20\x20 | ---------------------------------------------------------------------- | Data descriptors inherited from enum.Enum: |\x20\x20 | name | The name of the Enum member. |\x20\x20 | value | The value of the Enum member. |\x20\x20 | ---------------------------------------------------------------------- | Data descriptors inherited from enum.EnumMeta: |\x20\x20 | __members__ | Returns a mapping of member name->value. |\x20\x20\x20\x20\x20\x20 | This mapping lists all enum members, including aliases. Note that this | is a read-only view of the internal mapping.""" expected_help_output_without_docs = """\ Help on class Color in module %s: class Color(enum.Enum) | Method resolution order: | Color | enum.Enum | builtins.object |\x20\x20 | Data and other attributes defined here: |\x20\x20 | blue = <Color.blue: 3> |\x20\x20 | green = <Color.green: 2> |\x20\x20 | red = <Color.red: 1> |\x20\x20 | ---------------------------------------------------------------------- | Data descriptors inherited from enum.Enum: |\x20\x20 | name |\x20\x20 | value |\x20\x20 | ---------------------------------------------------------------------- | Data descriptors inherited from enum.EnumMeta: |\x20\x20 | __members__""" class TestStdLib(unittest.TestCase): maxDiff = None class Color(Enum): red = 1 green = 2 blue = 3 @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "no pydocs in rel mode") def test_pydoc(self): # indirectly test __objclass__ if StrEnum.__doc__ is None: expected_text = expected_help_output_without_docs % __name__ else: expected_text = expected_help_output_with_docs % __name__ output = StringIO() helper = pydoc.Helper(output=output) helper(self.Color) result = output.getvalue().strip() self.assertEqual(result, expected_text) def test_inspect_getmembers(self): values = dict(( ('__class__', EnumMeta), ('__doc__', 'An enumeration.'), ('__members__', self.Color.__members__), ('__module__', __name__), ('blue', self.Color.blue), ('green', self.Color.green), ('name', Enum.__dict__['name']), ('red', self.Color.red), ('value', Enum.__dict__['value']), )) result = dict(inspect.getmembers(self.Color)) self.assertEqual(values.keys(), result.keys()) failed = False for k in values.keys(): if result[k] != values[k]: print() print('\n%s\n key: %s\n result: %s\nexpected: %s\n%s\n' % ('=' * 75, k, result[k], values[k], '=' * 75), sep='') failed = True if failed: self.fail("result does not equal expected, see print above") def test_inspect_classify_class_attrs(self): # indirectly test __objclass__ from inspect import Attribute values = [ Attribute(name='__class__', kind='data', defining_class=object, object=EnumMeta), Attribute(name='__doc__', kind='data', defining_class=self.Color, object='An enumeration.'), Attribute(name='__members__', kind='property', defining_class=EnumMeta, object=EnumMeta.__members__), Attribute(name='__module__', kind='data', defining_class=self.Color, object=__name__), Attribute(name='blue', kind='data', defining_class=self.Color, object=self.Color.blue), Attribute(name='green', kind='data', defining_class=self.Color, object=self.Color.green), Attribute(name='red', kind='data', defining_class=self.Color, object=self.Color.red), Attribute(name='name', kind='data', defining_class=Enum, object=Enum.__dict__['name']), Attribute(name='value', kind='data', defining_class=Enum, object=Enum.__dict__['value']), ] values.sort(key=lambda item: item.name) result = list(inspect.classify_class_attrs(self.Color)) result.sort(key=lambda item: item.name) failed = False for v, r in zip(values, result): if r != v: print('\n%s\n%s\n%s\n%s\n' % ('=' * 75, r, v, '=' * 75), sep='') failed = True if failed: self.fail("result does not equal expected, see print above") class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, enum) # These are unordered here on purpose to ensure that declaration order # makes no difference. CONVERT_TEST_NAME_D = 5 CONVERT_TEST_NAME_C = 5 CONVERT_TEST_NAME_B = 5 CONVERT_TEST_NAME_A = 5 # This one should sort first. CONVERT_TEST_NAME_E = 5 CONVERT_TEST_NAME_F = 5 class TestIntEnumConvert(unittest.TestCase): def test_convert_value_lookup_priority(self): test_type = enum.IntEnum._convert( 'UnittestConvert', ('test.test_enum', '__main__')[__name__=='__main__'], filter=lambda x: x.startswith('CONVERT_TEST_')) # We don't want the reverse lookup value to vary when there are # multiple possible names for a given value. It should always # report the first lexigraphical name in that case. self.assertEqual(test_type(5).name, 'CONVERT_TEST_NAME_A') def test_convert(self): test_type = enum.IntEnum._convert( 'UnittestConvert', ('test.test_enum', '__main__')[__name__=='__main__'], filter=lambda x: x.startswith('CONVERT_TEST_')) # Ensure that test_type has all of the desired names and values. self.assertEqual(test_type.CONVERT_TEST_NAME_F, test_type.CONVERT_TEST_NAME_A) self.assertEqual(test_type.CONVERT_TEST_NAME_B, 5) self.assertEqual(test_type.CONVERT_TEST_NAME_C, 5) self.assertEqual(test_type.CONVERT_TEST_NAME_D, 5) self.assertEqual(test_type.CONVERT_TEST_NAME_E, 5) # Ensure that test_type only picked up names matching the filter. self.assertEqual([name for name in dir(test_type) if name[0:2] not in ('CO', '__')], [], msg='Names other than CONVERT_TEST_* found.') if __name__ == '__main__': unittest.main()
94,973
2,640
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_xml_etree.py
# IMPORTANT: the same tests are run from "test_xml_etree_c" in order # to ensure consistency between the C implementation and the Python # implementation. # # For this purpose, the module-level "ET" symbol is temporarily # monkey-patched when running the "test_xml_etree_c" test suite. import cosmo import copy import html import io import operator import pickle import sys import types import unittest import warnings import weakref from encodings import utf_16 from itertools import product from test import support from test.support import TESTFN, findfile, import_fresh_module, gc_collect, swap_attr # pyET is the pure-Python implementation. # # ET is pyET in test_xml_etree and is the C accelerated version in # test_xml_etree_c. pyET = None ET = None SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata") try: SIMPLE_XMLFILE.encode("utf-8") except UnicodeEncodeError: raise unittest.SkipTest("filename is not encodable to utf8") SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir="xmltestdata") UTF8_BUG_XMLFILE = findfile("expat224_utf8_bug.xml", subdir="xmltestdata") SAMPLE_XML = """\ <body> <tag class='a'>text</tag> <tag class='b' /> <section> <tag class='b' id='inner'>subtext</tag> </section> </body> """ SAMPLE_SECTION = """\ <section> <tag class='b' id='inner'>subtext</tag> <nexttag /> <nextsection> <tag /> </nextsection> </section> """ SAMPLE_XML_NS = """ <body xmlns="http://effbot.org/ns"> <tag>text</tag> <tag /> <section> <tag>subtext</tag> </section> </body> """ SAMPLE_XML_NS_ELEMS = """ <root> <h:table xmlns:h="hello"> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> <f:table xmlns:f="foo"> <f:name>African Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table> </root> """ ENTITY_XML = """\ <!DOCTYPE points [ <!ENTITY % user-entities SYSTEM 'user-entities.xml'> %user-entities; ]> <document>&entity;</document> """ EXTERNAL_ENTITY_XML = """\ <!DOCTYPE points [ <!ENTITY entity SYSTEM "file:///non-existing-file.xml"> ]> <document>&entity;</document> """ class ModuleTest(unittest.TestCase): def test_sanity(self): # Import sanity. from xml.etree import ElementTree from xml.etree import ElementInclude from xml.etree import ElementPath def test_all(self): names = ("xml.etree.ElementTree", "_elementtree") support.check__all__(self, ET, names, blacklist=("HTML_EMPTY",)) def serialize(elem, to_string=True, encoding='unicode', **options): if encoding != 'unicode': file = io.BytesIO() else: file = io.StringIO() tree = ET.ElementTree(elem) tree.write(file, encoding=encoding, **options) if to_string: return file.getvalue() else: file.seek(0) return file def summarize_list(seq): return [elem.tag for elem in seq] class ElementTestCase: @classmethod def setUpClass(cls): cls.modules = {pyET, ET} def pickleRoundTrip(self, obj, name, dumper, loader, proto): save_m = sys.modules[name] try: sys.modules[name] = dumper temp = pickle.dumps(obj, proto) sys.modules[name] = loader result = pickle.loads(temp) except pickle.PicklingError as pe: # pyET must be second, because pyET may be (equal to) ET. human = dict([(ET, "cET"), (pyET, "pyET")]) raise support.TestFailed("Failed to round-trip %r from %r to %r" % (obj, human.get(dumper, dumper), human.get(loader, loader))) from pe finally: sys.modules[name] = save_m return result def assertEqualElements(self, alice, bob): self.assertIsInstance(alice, (ET.Element, pyET.Element)) self.assertIsInstance(bob, (ET.Element, pyET.Element)) self.assertEqual(len(list(alice)), len(list(bob))) for x, y in zip(alice, bob): self.assertEqualElements(x, y) properties = operator.attrgetter('tag', 'tail', 'text', 'attrib') self.assertEqual(properties(alice), properties(bob)) # -------------------------------------------------------------------- # element tree tests class ElementTreeTest(unittest.TestCase): def serialize_check(self, elem, expected): self.assertEqual(serialize(elem), expected) def test_interface(self): # Test element tree interface. def check_string(string): len(string) for char in string: self.assertEqual(len(char), 1, msg="expected one-character string, got %r" % char) new_string = string + "" new_string = string + " " string[:0] def check_mapping(mapping): len(mapping) keys = mapping.keys() items = mapping.items() for key in keys: item = mapping[key] mapping["key"] = "value" self.assertEqual(mapping["key"], "value", msg="expected value string, got %r" % mapping["key"]) def check_element(element): self.assertTrue(ET.iselement(element), msg="not an element") direlem = dir(element) for attr in 'tag', 'attrib', 'text', 'tail': self.assertTrue(hasattr(element, attr), msg='no %s member' % attr) self.assertIn(attr, direlem, msg='no %s visible by dir' % attr) check_string(element.tag) check_mapping(element.attrib) if element.text is not None: check_string(element.text) if element.tail is not None: check_string(element.tail) for elem in element: check_element(elem) element = ET.Element("tag") check_element(element) tree = ET.ElementTree(element) check_element(tree.getroot()) element = ET.Element("t\xe4g", key="value") tree = ET.ElementTree(element) self.assertRegex(repr(element), r"^<Element 't\xe4g' at 0x.*>$") element = ET.Element("tag", key="value") # Make sure all standard element methods exist. def check_method(method): self.assertTrue(hasattr(method, '__call__'), msg="%s not callable" % method) check_method(element.append) check_method(element.extend) check_method(element.insert) check_method(element.remove) check_method(element.getchildren) check_method(element.find) check_method(element.iterfind) check_method(element.findall) check_method(element.findtext) check_method(element.clear) check_method(element.get) check_method(element.set) check_method(element.keys) check_method(element.items) check_method(element.iter) check_method(element.itertext) check_method(element.getiterator) # These methods return an iterable. See bug 6472. def check_iter(it): check_method(it.__next__) check_iter(element.iterfind("tag")) check_iter(element.iterfind("*")) check_iter(tree.iterfind("tag")) check_iter(tree.iterfind("*")) # These aliases are provided: self.assertEqual(ET.XML, ET.fromstring) self.assertEqual(ET.PI, ET.ProcessingInstruction) def test_set_attribute(self): element = ET.Element('tag') self.assertEqual(element.tag, 'tag') element.tag = 'Tag' self.assertEqual(element.tag, 'Tag') element.tag = 'TAG' self.assertEqual(element.tag, 'TAG') self.assertIsNone(element.text) element.text = 'Text' self.assertEqual(element.text, 'Text') element.text = 'TEXT' self.assertEqual(element.text, 'TEXT') self.assertIsNone(element.tail) element.tail = 'Tail' self.assertEqual(element.tail, 'Tail') element.tail = 'TAIL' self.assertEqual(element.tail, 'TAIL') self.assertEqual(element.attrib, {}) element.attrib = {'a': 'b', 'c': 'd'} self.assertEqual(element.attrib, {'a': 'b', 'c': 'd'}) element.attrib = {'A': 'B', 'C': 'D'} self.assertEqual(element.attrib, {'A': 'B', 'C': 'D'}) def test_simpleops(self): # Basic method sanity checks. elem = ET.XML("<body><tag/></body>") self.serialize_check(elem, '<body><tag /></body>') e = ET.Element("tag2") elem.append(e) self.serialize_check(elem, '<body><tag /><tag2 /></body>') elem.remove(e) self.serialize_check(elem, '<body><tag /></body>') elem.insert(0, e) self.serialize_check(elem, '<body><tag2 /><tag /></body>') elem.remove(e) elem.extend([e]) self.serialize_check(elem, '<body><tag /><tag2 /></body>') elem.remove(e) element = ET.Element("tag", key="value") self.serialize_check(element, '<tag key="value" />') # 1 subelement = ET.Element("subtag") element.append(subelement) self.serialize_check(element, '<tag key="value"><subtag /></tag>') # 2 element.insert(0, subelement) self.serialize_check(element, '<tag key="value"><subtag /><subtag /></tag>') # 3 element.remove(subelement) self.serialize_check(element, '<tag key="value"><subtag /></tag>') # 4 element.remove(subelement) self.serialize_check(element, '<tag key="value" />') # 5 with self.assertRaises(ValueError) as cm: element.remove(subelement) self.assertEqual(str(cm.exception), 'list.remove(x): x not in list') self.serialize_check(element, '<tag key="value" />') # 6 element[0:0] = [subelement, subelement, subelement] self.serialize_check(element[1], '<subtag />') self.assertEqual(element[1:9], [element[1], element[2]]) self.assertEqual(element[:9:2], [element[0], element[2]]) del element[1:2] self.serialize_check(element, '<tag key="value"><subtag /><subtag /></tag>') def test_cdata(self): # Test CDATA handling (etc). self.serialize_check(ET.XML("<tag>hello</tag>"), '<tag>hello</tag>') self.serialize_check(ET.XML("<tag>&#104;&#101;&#108;&#108;&#111;</tag>"), '<tag>hello</tag>') self.serialize_check(ET.XML("<tag><![CDATA[hello]]></tag>"), '<tag>hello</tag>') def test_file_init(self): stringfile = io.BytesIO(SAMPLE_XML.encode("utf-8")) tree = ET.ElementTree(file=stringfile) self.assertEqual(tree.find("tag").tag, 'tag') self.assertEqual(tree.find("section/tag").tag, 'tag') tree = ET.ElementTree(file=SIMPLE_XMLFILE) self.assertEqual(tree.find("element").tag, 'element') self.assertEqual(tree.find("element/../empty-element").tag, 'empty-element') def test_path_cache(self): # Check that the path cache behaves sanely. from xml.etree import ElementPath elem = ET.XML(SAMPLE_XML) for i in range(10): ET.ElementTree(elem).find('./'+str(i)) cache_len_10 = len(ElementPath._cache) for i in range(10): ET.ElementTree(elem).find('./'+str(i)) self.assertEqual(len(ElementPath._cache), cache_len_10) for i in range(20): ET.ElementTree(elem).find('./'+str(i)) self.assertGreater(len(ElementPath._cache), cache_len_10) for i in range(600): ET.ElementTree(elem).find('./'+str(i)) self.assertLess(len(ElementPath._cache), 500) def test_copy(self): # Test copy handling (etc). import copy e1 = ET.XML("<tag>hello<foo/></tag>") e2 = copy.copy(e1) e3 = copy.deepcopy(e1) e1.find("foo").tag = "bar" self.serialize_check(e1, '<tag>hello<bar /></tag>') self.serialize_check(e2, '<tag>hello<bar /></tag>') self.serialize_check(e3, '<tag>hello<foo /></tag>') def test_attrib(self): # Test attribute handling. elem = ET.Element("tag") elem.get("key") # 1.1 self.assertEqual(elem.get("key", "default"), 'default') # 1.2 elem.set("key", "value") self.assertEqual(elem.get("key"), 'value') # 1.3 elem = ET.Element("tag", key="value") self.assertEqual(elem.get("key"), 'value') # 2.1 self.assertEqual(elem.attrib, {'key': 'value'}) # 2.2 attrib = {"key": "value"} elem = ET.Element("tag", attrib) attrib.clear() # check for aliasing issues self.assertEqual(elem.get("key"), 'value') # 3.1 self.assertEqual(elem.attrib, {'key': 'value'}) # 3.2 attrib = {"key": "value"} elem = ET.Element("tag", **attrib) attrib.clear() # check for aliasing issues self.assertEqual(elem.get("key"), 'value') # 4.1 self.assertEqual(elem.attrib, {'key': 'value'}) # 4.2 elem = ET.Element("tag", {"key": "other"}, key="value") self.assertEqual(elem.get("key"), 'value') # 5.1 self.assertEqual(elem.attrib, {'key': 'value'}) # 5.2 elem = ET.Element('test') elem.text = "aa" elem.set('testa', 'testval') elem.set('testb', 'test2') self.assertEqual(ET.tostring(elem), b'<test testa="testval" testb="test2">aa</test>') self.assertEqual(sorted(elem.keys()), ['testa', 'testb']) self.assertEqual(sorted(elem.items()), [('testa', 'testval'), ('testb', 'test2')]) self.assertEqual(elem.attrib['testb'], 'test2') elem.attrib['testb'] = 'test1' elem.attrib['testc'] = 'test2' self.assertEqual(ET.tostring(elem), b'<test testa="testval" testb="test1" testc="test2">aa</test>') elem = ET.Element('test') elem.set('a', '\r') elem.set('b', '\r\n') elem.set('c', '\t\n\r ') elem.set('d', '\n\n') self.assertEqual(ET.tostring(elem), b'<test a="&#10;" b="&#10;" c="&#09;&#10;&#10; " d="&#10;&#10;" />') def test_makeelement(self): # Test makeelement handling. elem = ET.Element("tag") attrib = {"key": "value"} subelem = elem.makeelement("subtag", attrib) self.assertIsNot(subelem.attrib, attrib, msg="attrib aliasing") elem.append(subelem) self.serialize_check(elem, '<tag><subtag key="value" /></tag>') elem.clear() self.serialize_check(elem, '<tag />') elem.append(subelem) self.serialize_check(elem, '<tag><subtag key="value" /></tag>') elem.extend([subelem, subelem]) self.serialize_check(elem, '<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>') elem[:] = [subelem] self.serialize_check(elem, '<tag><subtag key="value" /></tag>') elem[:] = tuple([subelem]) self.serialize_check(elem, '<tag><subtag key="value" /></tag>') def test_parsefile(self): # Test parsing from file. tree = ET.parse(SIMPLE_XMLFILE) stream = io.StringIO() tree.write(stream, encoding='unicode') self.assertEqual(stream.getvalue(), '<root>\n' ' <element key="value">text</element>\n' ' <element>text</element>tail\n' ' <empty-element />\n' '</root>') tree = ET.parse(SIMPLE_NS_XMLFILE) stream = io.StringIO() tree.write(stream, encoding='unicode') self.assertEqual(stream.getvalue(), '<ns0:root xmlns:ns0="namespace">\n' ' <ns0:element key="value">text</ns0:element>\n' ' <ns0:element>text</ns0:element>tail\n' ' <ns0:empty-element />\n' '</ns0:root>') with open(SIMPLE_XMLFILE) as f: data = f.read() parser = ET.XMLParser() self.assertRegex(parser.version, r'^Expat ') parser.feed(data) self.serialize_check(parser.close(), '<root>\n' ' <element key="value">text</element>\n' ' <element>text</element>tail\n' ' <empty-element />\n' '</root>') target = ET.TreeBuilder() parser = ET.XMLParser(target=target) parser.feed(data) self.serialize_check(parser.close(), '<root>\n' ' <element key="value">text</element>\n' ' <element>text</element>tail\n' ' <empty-element />\n' '</root>') def test_parseliteral(self): element = ET.XML("<html><body>text</body></html>") self.assertEqual(ET.tostring(element, encoding='unicode'), '<html><body>text</body></html>') element = ET.fromstring("<html><body>text</body></html>") self.assertEqual(ET.tostring(element, encoding='unicode'), '<html><body>text</body></html>') sequence = ["<html><body>", "text</bo", "dy></html>"] element = ET.fromstringlist(sequence) self.assertEqual(ET.tostring(element), b'<html><body>text</body></html>') self.assertEqual(b"".join(ET.tostringlist(element)), b'<html><body>text</body></html>') self.assertEqual(ET.tostring(element, "ascii"), b"<?xml version='1.0' encoding='ascii'?>\n" b"<html><body>text</body></html>") _, ids = ET.XMLID("<html><body>text</body></html>") self.assertEqual(len(ids), 0) _, ids = ET.XMLID("<html><body id='body'>text</body></html>") self.assertEqual(len(ids), 1) self.assertEqual(ids["body"].tag, 'body') def test_iterparse(self): # Test iterparse interface. iterparse = ET.iterparse context = iterparse(SIMPLE_XMLFILE) action, elem = next(context) self.assertEqual((action, elem.tag), ('end', 'element')) self.assertEqual([(action, elem.tag) for action, elem in context], [ ('end', 'element'), ('end', 'empty-element'), ('end', 'root'), ]) self.assertEqual(context.root.tag, 'root') context = iterparse(SIMPLE_NS_XMLFILE) self.assertEqual([(action, elem.tag) for action, elem in context], [ ('end', '{namespace}element'), ('end', '{namespace}element'), ('end', '{namespace}empty-element'), ('end', '{namespace}root'), ]) events = () context = iterparse(SIMPLE_XMLFILE, events) self.assertEqual([(action, elem.tag) for action, elem in context], []) events = () context = iterparse(SIMPLE_XMLFILE, events=events) self.assertEqual([(action, elem.tag) for action, elem in context], []) events = ("start", "end") context = iterparse(SIMPLE_XMLFILE, events) self.assertEqual([(action, elem.tag) for action, elem in context], [ ('start', 'root'), ('start', 'element'), ('end', 'element'), ('start', 'element'), ('end', 'element'), ('start', 'empty-element'), ('end', 'empty-element'), ('end', 'root'), ]) events = ("start", "end", "start-ns", "end-ns") context = iterparse(SIMPLE_NS_XMLFILE, events) self.assertEqual([(action, elem.tag) if action in ("start", "end") else (action, elem) for action, elem in context], [ ('start-ns', ('', 'namespace')), ('start', '{namespace}root'), ('start', '{namespace}element'), ('end', '{namespace}element'), ('start', '{namespace}element'), ('end', '{namespace}element'), ('start', '{namespace}empty-element'), ('end', '{namespace}empty-element'), ('end', '{namespace}root'), ('end-ns', None), ]) events = ('start-ns', 'end-ns') context = iterparse(io.StringIO(r"<root xmlns=''/>"), events) res = [action for action, elem in context] self.assertEqual(res, ['start-ns', 'end-ns']) events = ("start", "end", "bogus") with open(SIMPLE_XMLFILE, "rb") as f: with self.assertRaises(ValueError) as cm: iterparse(f, events) self.assertFalse(f.closed) self.assertEqual(str(cm.exception), "unknown event 'bogus'") with support.check_no_resource_warning(self): with self.assertRaises(ValueError) as cm: iterparse(SIMPLE_XMLFILE, events) self.assertEqual(str(cm.exception), "unknown event 'bogus'") del cm source = io.BytesIO( b"<?xml version='1.0' encoding='iso-8859-1'?>\n" b"<body xmlns='http://&#233;ffbot.org/ns'\n" b" xmlns:cl\xe9='http://effbot.org/ns'>text</body>\n") events = ("start-ns",) context = iterparse(source, events) self.assertEqual([(action, elem) for action, elem in context], [ ('start-ns', ('', 'http://\xe9ffbot.org/ns')), ('start-ns', ('cl\xe9', 'http://effbot.org/ns')), ]) source = io.StringIO("<document />junk") it = iterparse(source) action, elem = next(it) self.assertEqual((action, elem.tag), ('end', 'document')) with self.assertRaises(ET.ParseError) as cm: next(it) self.assertEqual(str(cm.exception), 'junk after document element: line 1, column 12') self.addCleanup(support.unlink, TESTFN) with open(TESTFN, "wb") as f: f.write(b"<document />junk") it = iterparse(TESTFN) action, elem = next(it) self.assertEqual((action, elem.tag), ('end', 'document')) with support.check_no_resource_warning(self): with self.assertRaises(ET.ParseError) as cm: next(it) self.assertEqual(str(cm.exception), 'junk after document element: line 1, column 12') del cm, it def test_writefile(self): elem = ET.Element("tag") elem.text = "text" self.serialize_check(elem, '<tag>text</tag>') ET.SubElement(elem, "subtag").text = "subtext" self.serialize_check(elem, '<tag>text<subtag>subtext</subtag></tag>') # Test tag suppression elem.tag = None self.serialize_check(elem, 'text<subtag>subtext</subtag>') elem.insert(0, ET.Comment("comment")) self.serialize_check(elem, 'text<!--comment--><subtag>subtext</subtag>') # assumes 1.3 elem[0] = ET.PI("key", "value") self.serialize_check(elem, 'text<?key value?><subtag>subtext</subtag>') def test_custom_builder(self): # Test parser w. custom builder. with open(SIMPLE_XMLFILE) as f: data = f.read() class Builder(list): def start(self, tag, attrib): self.append(("start", tag)) def end(self, tag): self.append(("end", tag)) def data(self, text): pass builder = Builder() parser = ET.XMLParser(target=builder) parser.feed(data) self.assertEqual(builder, [ ('start', 'root'), ('start', 'element'), ('end', 'element'), ('start', 'element'), ('end', 'element'), ('start', 'empty-element'), ('end', 'empty-element'), ('end', 'root'), ]) with open(SIMPLE_NS_XMLFILE) as f: data = f.read() class Builder(list): def start(self, tag, attrib): self.append(("start", tag)) def end(self, tag): self.append(("end", tag)) def data(self, text): pass def pi(self, target, data): self.append(("pi", target, data)) def comment(self, data): self.append(("comment", data)) builder = Builder() parser = ET.XMLParser(target=builder) parser.feed(data) self.assertEqual(builder, [ ('pi', 'pi', 'data'), ('comment', ' comment '), ('start', '{namespace}root'), ('start', '{namespace}element'), ('end', '{namespace}element'), ('start', '{namespace}element'), ('end', '{namespace}element'), ('start', '{namespace}empty-element'), ('end', '{namespace}empty-element'), ('end', '{namespace}root'), ]) def test_getchildren(self): # Test Element.getchildren() with open(SIMPLE_XMLFILE, "rb") as f: tree = ET.parse(f) self.assertEqual([summarize_list(elem.getchildren()) for elem in tree.getroot().iter()], [ ['element', 'element', 'empty-element'], [], [], [], ]) self.assertEqual([summarize_list(elem.getchildren()) for elem in tree.getiterator()], [ ['element', 'element', 'empty-element'], [], [], [], ]) elem = ET.XML(SAMPLE_XML) self.assertEqual(len(elem.getchildren()), 3) self.assertEqual(len(elem[2].getchildren()), 1) self.assertEqual(elem[:], elem.getchildren()) child1 = elem[0] child2 = elem[2] del elem[1:2] self.assertEqual(len(elem.getchildren()), 2) self.assertEqual(child1, elem[0]) self.assertEqual(child2, elem[1]) elem[0:2] = [child2, child1] self.assertEqual(child2, elem[0]) self.assertEqual(child1, elem[1]) self.assertNotEqual(child1, elem[0]) elem.clear() self.assertEqual(elem.getchildren(), []) def test_writestring(self): elem = ET.XML("<html><body>text</body></html>") self.assertEqual(ET.tostring(elem), b'<html><body>text</body></html>') elem = ET.fromstring("<html><body>text</body></html>") self.assertEqual(ET.tostring(elem), b'<html><body>text</body></html>') def test_encoding(self): def check(encoding, body=''): xml = ("<?xml version='1.0' encoding='%s'?><xml>%s</xml>" % (encoding, body)) self.assertEqual(ET.XML(xml.encode(encoding)).text, body) self.assertEqual(ET.XML(xml).text, body) check("ascii", 'a') check("us-ascii", 'a') check("iso-8859-1", '\xbd') check("iso-8859-15", '\u20ac') check("cp437", '\u221a') check("mac-roman", '\u02da') def xml(encoding): return "<?xml version='1.0' encoding='%s'?><xml />" % encoding def bxml(encoding): return xml(encoding).encode(encoding) supported_encodings = [ 'ascii', 'utf-8', 'utf-8-sig', 'utf-16', 'utf-16be', 'utf-16le', 'iso8859-1', 'iso8859-2', 'iso8859-3', 'iso8859-4', 'iso8859-5', 'iso8859-6', 'iso8859-7', 'iso8859-8', 'iso8859-9', 'iso8859-10', 'iso8859-13', 'iso8859-14', 'iso8859-15', 'iso8859-16', 'cp437', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp865', 'cp866', 'cp869', 'cp874', 'cp1006', 'cp1125', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'mac-cyrillic', 'mac-greek', 'mac-iceland', 'mac-latin2', 'mac-roman', 'mac-turkish', 'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2', 'iso2022-jp-2004', 'iso2022-jp-3', 'iso2022-jp-ext', 'koi8-r', 'koi8-t', 'koi8-u', 'kz1048', 'hz', 'ptcp154', ] for encoding in supported_encodings: self.assertEqual(ET.tostring(ET.XML(bxml(encoding))), b'<xml />') unsupported_ascii_compatible_encodings = [ 'big5', 'big5hkscs', 'cp932', 'cp949', 'cp950', 'euc-jp', 'euc-jis-2004', 'euc-jisx0213', 'euc-kr', 'gb2312', 'gbk', 'gb18030', 'iso2022-kr', 'johab', 'shift-jis', 'shift-jis-2004', 'shift-jisx0213', 'utf-7', ] for encoding in unsupported_ascii_compatible_encodings: self.assertRaises(ValueError, ET.XML, bxml(encoding)) unsupported_ascii_incompatible_encodings = [ 'cp037', 'cp424', 'cp500', 'cp864', 'cp875', 'cp1026', 'cp1140', 'utf_32', 'utf_32_be', 'utf_32_le', ] for encoding in unsupported_ascii_incompatible_encodings: self.assertRaises(ET.ParseError, ET.XML, bxml(encoding)) self.assertRaises(ValueError, ET.XML, xml('undefined').encode('ascii')) self.assertRaises(LookupError, ET.XML, xml('xxx').encode('ascii')) def test_methods(self): # Test serialization methods. e = ET.XML("<html><link/><script>1 &lt; 2</script></html>") e.tail = "\n" self.assertEqual(serialize(e), '<html><link /><script>1 &lt; 2</script></html>\n') self.assertEqual(serialize(e, method=None), '<html><link /><script>1 &lt; 2</script></html>\n') self.assertEqual(serialize(e, method="xml"), '<html><link /><script>1 &lt; 2</script></html>\n') self.assertEqual(serialize(e, method="html"), '<html><link><script>1 < 2</script></html>\n') self.assertEqual(serialize(e, method="text"), '1 < 2\n') def test_issue18347(self): e = ET.XML('<html><CamelCase>text</CamelCase></html>') self.assertEqual(serialize(e), '<html><CamelCase>text</CamelCase></html>') self.assertEqual(serialize(e, method="html"), '<html><CamelCase>text</CamelCase></html>') def test_entity(self): # Test entity handling. # 1) good entities e = ET.XML("<document title='&#x8230;'>test</document>") self.assertEqual(serialize(e, encoding="us-ascii"), b'<document title="&#33328;">test</document>') self.serialize_check(e, '<document title="\u8230">test</document>') # 2) bad entities with self.assertRaises(ET.ParseError) as cm: ET.XML("<document>&entity;</document>") self.assertEqual(str(cm.exception), 'undefined entity: line 1, column 10') with self.assertRaises(ET.ParseError) as cm: ET.XML(ENTITY_XML) self.assertEqual(str(cm.exception), 'undefined entity &entity;: line 5, column 10') # 3) custom entity parser = ET.XMLParser() parser.entity["entity"] = "text" parser.feed(ENTITY_XML) root = parser.close() self.serialize_check(root, '<document>text</document>') # 4) external (SYSTEM) entity with self.assertRaises(ET.ParseError) as cm: ET.XML(EXTERNAL_ENTITY_XML) self.assertEqual(str(cm.exception), 'undefined entity &entity;: line 4, column 10') def test_namespace(self): # Test namespace issues. # 1) xml namespace elem = ET.XML("<tag xml:lang='en' />") self.serialize_check(elem, '<tag xml:lang="en" />') # 1.1 # 2) other "well-known" namespaces elem = ET.XML("<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' />") self.serialize_check(elem, '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />') # 2.1 elem = ET.XML("<html:html xmlns:html='http://www.w3.org/1999/xhtml' />") self.serialize_check(elem, '<html:html xmlns:html="http://www.w3.org/1999/xhtml" />') # 2.2 elem = ET.XML("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope' />") self.serialize_check(elem, '<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope" />') # 2.3 # 3) unknown namespaces elem = ET.XML(SAMPLE_XML_NS) self.serialize_check(elem, '<ns0:body xmlns:ns0="http://effbot.org/ns">\n' ' <ns0:tag>text</ns0:tag>\n' ' <ns0:tag />\n' ' <ns0:section>\n' ' <ns0:tag>subtext</ns0:tag>\n' ' </ns0:section>\n' '</ns0:body>') def test_qname(self): # Test QName handling. # 1) decorated tags elem = ET.Element("{uri}tag") self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" />') # 1.1 elem = ET.Element(ET.QName("{uri}tag")) self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" />') # 1.2 elem = ET.Element(ET.QName("uri", "tag")) self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" />') # 1.3 elem = ET.Element(ET.QName("uri", "tag")) subelem = ET.SubElement(elem, ET.QName("uri", "tag1")) subelem = ET.SubElement(elem, ET.QName("uri", "tag2")) self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>') # 1.4 # 2) decorated attributes elem.clear() elem.attrib["{uri}key"] = "value" self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" ns0:key="value" />') # 2.1 elem.clear() elem.attrib[ET.QName("{uri}key")] = "value" self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" ns0:key="value" />') # 2.2 # 3) decorated values are not converted by default, but the # QName wrapper can be used for values elem.clear() elem.attrib["{uri}key"] = "{uri}value" self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" ns0:key="{uri}value" />') # 3.1 elem.clear() elem.attrib["{uri}key"] = ET.QName("{uri}value") self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" ns0:key="ns0:value" />') # 3.2 elem.clear() subelem = ET.Element("tag") subelem.attrib["{uri1}key"] = ET.QName("{uri2}value") elem.append(subelem) elem.append(subelem) self.serialize_check(elem, '<ns0:tag xmlns:ns0="uri" xmlns:ns1="uri1" xmlns:ns2="uri2">' '<tag ns1:key="ns2:value" />' '<tag ns1:key="ns2:value" />' '</ns0:tag>') # 3.3 # 4) Direct QName tests self.assertEqual(str(ET.QName('ns', 'tag')), '{ns}tag') self.assertEqual(str(ET.QName('{ns}tag')), '{ns}tag') q1 = ET.QName('ns', 'tag') q2 = ET.QName('ns', 'tag') self.assertEqual(q1, q2) q2 = ET.QName('ns', 'other-tag') self.assertNotEqual(q1, q2) self.assertNotEqual(q1, 'ns:tag') self.assertEqual(q1, '{ns}tag') def test_doctype_public(self): # Test PUBLIC doctype. elem = ET.XML('<!DOCTYPE html PUBLIC' ' "-//W3C//DTD XHTML 1.0 Transitional//EN"' ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' '<html>text</html>') def test_xpath_tokenizer(self): # Test the XPath tokenizer. from xml.etree import ElementPath def check(p, expected): self.assertEqual([op or tag for op, tag in ElementPath.xpath_tokenizer(p)], expected) # tests from the xml specification check("*", ['*']) check("text()", ['text', '()']) check("@name", ['@', 'name']) check("@*", ['@', '*']) check("para[1]", ['para', '[', '1', ']']) check("para[last()]", ['para', '[', 'last', '()', ']']) check("*/para", ['*', '/', 'para']) check("/doc/chapter[5]/section[2]", ['/', 'doc', '/', 'chapter', '[', '5', ']', '/', 'section', '[', '2', ']']) check("chapter//para", ['chapter', '//', 'para']) check("//para", ['//', 'para']) check("//olist/item", ['//', 'olist', '/', 'item']) check(".", ['.']) check(".//para", ['.', '//', 'para']) check("..", ['..']) check("../@lang", ['..', '/', '@', 'lang']) check("chapter[title]", ['chapter', '[', 'title', ']']) check("employee[@secretary and @assistant]", ['employee', '[', '@', 'secretary', '', 'and', '', '@', 'assistant', ']']) # additional tests check("{http://spam}egg", ['{http://spam}egg']) check("./spam.egg", ['.', '/', 'spam.egg']) check(".//{http://spam}egg", ['.', '//', '{http://spam}egg']) def test_processinginstruction(self): # Test ProcessingInstruction directly self.assertEqual(ET.tostring(ET.ProcessingInstruction('test', 'instruction')), b'<?test instruction?>') self.assertEqual(ET.tostring(ET.PI('test', 'instruction')), b'<?test instruction?>') # Issue #2746 self.assertEqual(ET.tostring(ET.PI('test', '<testing&>')), b'<?test <testing&>?>') self.assertEqual(ET.tostring(ET.PI('test', '<testing&>\xe3'), 'latin-1'), b"<?xml version='1.0' encoding='latin-1'?>\n" b"<?test <testing&>\xe3?>") def test_html_empty_elems_serialization(self): # issue 15970 # from http://www.w3.org/TR/html401/index/elements.html for element in ['AREA', 'BASE', 'BASEFONT', 'BR', 'COL', 'FRAME', 'HR', 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM']: for elem in [element, element.lower()]: expected = '<%s>' % elem serialized = serialize(ET.XML('<%s />' % elem), method='html') self.assertEqual(serialized, expected) serialized = serialize(ET.XML('<%s></%s>' % (elem,elem)), method='html') self.assertEqual(serialized, expected) class XMLPullParserTest(unittest.TestCase): def _feed(self, parser, data, chunk_size=None): if chunk_size is None: parser.feed(data) else: for i in range(0, len(data), chunk_size): parser.feed(data[i:i+chunk_size]) def assert_event_tags(self, parser, expected): events = parser.read_events() self.assertEqual([(action, elem.tag) for action, elem in events], expected) def test_simple_xml(self): for chunk_size in (None, 1, 5): with self.subTest(chunk_size=chunk_size): parser = ET.XMLPullParser() self.assert_event_tags(parser, []) self._feed(parser, "<!-- comment -->\n", chunk_size) self.assert_event_tags(parser, []) self._feed(parser, "<root>\n <element key='value'>text</element", chunk_size) self.assert_event_tags(parser, []) self._feed(parser, ">\n", chunk_size) self.assert_event_tags(parser, [('end', 'element')]) self._feed(parser, "<element>text</element>tail\n", chunk_size) self._feed(parser, "<empty-element/>\n", chunk_size) self.assert_event_tags(parser, [ ('end', 'element'), ('end', 'empty-element'), ]) self._feed(parser, "</root>\n", chunk_size) self.assert_event_tags(parser, [('end', 'root')]) self.assertIsNone(parser.close()) def test_feed_while_iterating(self): parser = ET.XMLPullParser() it = parser.read_events() self._feed(parser, "<root>\n <element key='value'>text</element>\n") action, elem = next(it) self.assertEqual((action, elem.tag), ('end', 'element')) self._feed(parser, "</root>\n") action, elem = next(it) self.assertEqual((action, elem.tag), ('end', 'root')) with self.assertRaises(StopIteration): next(it) def test_simple_xml_with_ns(self): parser = ET.XMLPullParser() self.assert_event_tags(parser, []) self._feed(parser, "<!-- comment -->\n") self.assert_event_tags(parser, []) self._feed(parser, "<root xmlns='namespace'>\n") self.assert_event_tags(parser, []) self._feed(parser, "<element key='value'>text</element") self.assert_event_tags(parser, []) self._feed(parser, ">\n") self.assert_event_tags(parser, [('end', '{namespace}element')]) self._feed(parser, "<element>text</element>tail\n") self._feed(parser, "<empty-element/>\n") self.assert_event_tags(parser, [ ('end', '{namespace}element'), ('end', '{namespace}empty-element'), ]) self._feed(parser, "</root>\n") self.assert_event_tags(parser, [('end', '{namespace}root')]) self.assertIsNone(parser.close()) def test_ns_events(self): parser = ET.XMLPullParser(events=('start-ns', 'end-ns')) self._feed(parser, "<!-- comment -->\n") self._feed(parser, "<root xmlns='namespace'>\n") self.assertEqual( list(parser.read_events()), [('start-ns', ('', 'namespace'))]) self._feed(parser, "<element key='value'>text</element") self._feed(parser, ">\n") self._feed(parser, "<element>text</element>tail\n") self._feed(parser, "<empty-element/>\n") self._feed(parser, "</root>\n") self.assertEqual(list(parser.read_events()), [('end-ns', None)]) self.assertIsNone(parser.close()) def test_events(self): parser = ET.XMLPullParser(events=()) self._feed(parser, "<root/>\n") self.assert_event_tags(parser, []) parser = ET.XMLPullParser(events=('start', 'end')) self._feed(parser, "<!-- comment -->\n") self.assert_event_tags(parser, []) self._feed(parser, "<root>\n") self.assert_event_tags(parser, [('start', 'root')]) self._feed(parser, "<element key='value'>text</element") self.assert_event_tags(parser, [('start', 'element')]) self._feed(parser, ">\n") self.assert_event_tags(parser, [('end', 'element')]) self._feed(parser, "<element xmlns='foo'>text<empty-element/></element>tail\n") self.assert_event_tags(parser, [ ('start', '{foo}element'), ('start', '{foo}empty-element'), ('end', '{foo}empty-element'), ('end', '{foo}element'), ]) self._feed(parser, "</root>") self.assertIsNone(parser.close()) self.assert_event_tags(parser, [('end', 'root')]) parser = ET.XMLPullParser(events=('start',)) self._feed(parser, "<!-- comment -->\n") self.assert_event_tags(parser, []) self._feed(parser, "<root>\n") self.assert_event_tags(parser, [('start', 'root')]) self._feed(parser, "<element key='value'>text</element") self.assert_event_tags(parser, [('start', 'element')]) self._feed(parser, ">\n") self.assert_event_tags(parser, []) self._feed(parser, "<element xmlns='foo'>text<empty-element/></element>tail\n") self.assert_event_tags(parser, [ ('start', '{foo}element'), ('start', '{foo}empty-element'), ]) self._feed(parser, "</root>") self.assertIsNone(parser.close()) def test_events_sequence(self): # Test that events can be some sequence that's not just a tuple or list eventset = {'end', 'start'} parser = ET.XMLPullParser(events=eventset) self._feed(parser, "<foo>bar</foo>") self.assert_event_tags(parser, [('start', 'foo'), ('end', 'foo')]) class DummyIter: def __init__(self): self.events = iter(['start', 'end', 'start-ns']) def __iter__(self): return self def __next__(self): return next(self.events) parser = ET.XMLPullParser(events=DummyIter()) self._feed(parser, "<foo>bar</foo>") self.assert_event_tags(parser, [('start', 'foo'), ('end', 'foo')]) def test_unknown_event(self): with self.assertRaises(ValueError): ET.XMLPullParser(events=('start', 'end', 'bogus')) # # xinclude tests (samples from appendix C of the xinclude specification) XINCLUDE = {} XINCLUDE["C1.xml"] = """\ <?xml version='1.0'?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <p>120 Mz is adequate for an average home user.</p> <xi:include href="disclaimer.xml"/> </document> """ XINCLUDE["disclaimer.xml"] = """\ <?xml version='1.0'?> <disclaimer> <p>The opinions represented herein represent those of the individual and should not be interpreted as official policy endorsed by this organization.</p> </disclaimer> """ XINCLUDE["C2.xml"] = """\ <?xml version='1.0'?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <p>This document has been accessed <xi:include href="count.txt" parse="text"/> times.</p> </document> """ XINCLUDE["count.txt"] = "324387" XINCLUDE["C2b.xml"] = """\ <?xml version='1.0'?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <p>This document has been <em>accessed</em> <xi:include href="count.txt" parse="text"/> times.</p> </document> """ XINCLUDE["C3.xml"] = """\ <?xml version='1.0'?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <p>The following is the source of the "data.xml" resource:</p> <example><xi:include href="data.xml" parse="text"/></example> </document> """ XINCLUDE["data.xml"] = """\ <?xml version='1.0'?> <data> <item><![CDATA[Brooks & Shields]]></item> </data> """ XINCLUDE["C5.xml"] = """\ <?xml version='1.0'?> <div xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="example.txt" parse="text"> <xi:fallback> <xi:include href="fallback-example.txt" parse="text"> <xi:fallback><a href="mailto:[email protected]">Report error</a></xi:fallback> </xi:include> </xi:fallback> </xi:include> </div> """ XINCLUDE["default.xml"] = """\ <?xml version='1.0'?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <p>Example.</p> <xi:include href="{}"/> </document> """.format(html.escape(SIMPLE_XMLFILE, True)) # # badly formatted xi:include tags XINCLUDE_BAD = {} XINCLUDE_BAD["B1.xml"] = """\ <?xml version='1.0'?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <p>120 Mz is adequate for an average home user.</p> <xi:include href="disclaimer.xml" parse="BAD_TYPE"/> </document> """ XINCLUDE_BAD["B2.xml"] = """\ <?xml version='1.0'?> <div xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:fallback></xi:fallback> </div> """ class XIncludeTest(unittest.TestCase): def xinclude_loader(self, href, parse="xml", encoding=None): try: data = XINCLUDE[href] except KeyError: raise OSError("resource not found") if parse == "xml": data = ET.XML(data) return data def none_loader(self, href, parser, encoding=None): return None def _my_loader(self, href, parse): # Used to avoid a test-dependency problem where the default loader # of ElementInclude uses the pyET parser for cET tests. if parse == 'xml': with open(href, 'rb') as f: return ET.parse(f).getroot() else: return None def test_xinclude_default(self): from xml.etree import ElementInclude doc = self.xinclude_loader('default.xml') ElementInclude.include(doc, self._my_loader) self.assertEqual(serialize(doc), '<document>\n' ' <p>Example.</p>\n' ' <root>\n' ' <element key="value">text</element>\n' ' <element>text</element>tail\n' ' <empty-element />\n' '</root>\n' '</document>') def test_xinclude(self): from xml.etree import ElementInclude # Basic inclusion example (XInclude C.1) document = self.xinclude_loader("C1.xml") ElementInclude.include(document, self.xinclude_loader) self.assertEqual(serialize(document), '<document>\n' ' <p>120 Mz is adequate for an average home user.</p>\n' ' <disclaimer>\n' ' <p>The opinions represented herein represent those of the individual\n' ' and should not be interpreted as official policy endorsed by this\n' ' organization.</p>\n' '</disclaimer>\n' '</document>') # C1 # Textual inclusion example (XInclude C.2) document = self.xinclude_loader("C2.xml") ElementInclude.include(document, self.xinclude_loader) self.assertEqual(serialize(document), '<document>\n' ' <p>This document has been accessed\n' ' 324387 times.</p>\n' '</document>') # C2 # Textual inclusion after sibling element (based on modified XInclude C.2) document = self.xinclude_loader("C2b.xml") ElementInclude.include(document, self.xinclude_loader) self.assertEqual(serialize(document), '<document>\n' ' <p>This document has been <em>accessed</em>\n' ' 324387 times.</p>\n' '</document>') # C2b # Textual inclusion of XML example (XInclude C.3) document = self.xinclude_loader("C3.xml") ElementInclude.include(document, self.xinclude_loader) self.assertEqual(serialize(document), '<document>\n' ' <p>The following is the source of the "data.xml" resource:</p>\n' " <example>&lt;?xml version='1.0'?&gt;\n" '&lt;data&gt;\n' ' &lt;item&gt;&lt;![CDATA[Brooks &amp; Shields]]&gt;&lt;/item&gt;\n' '&lt;/data&gt;\n' '</example>\n' '</document>') # C3 # Fallback example (XInclude C.5) # Note! Fallback support is not yet implemented document = self.xinclude_loader("C5.xml") with self.assertRaises(OSError) as cm: ElementInclude.include(document, self.xinclude_loader) self.assertEqual(str(cm.exception), 'resource not found') self.assertEqual(serialize(document), '<div xmlns:ns0="http://www.w3.org/2001/XInclude">\n' ' <ns0:include href="example.txt" parse="text">\n' ' <ns0:fallback>\n' ' <ns0:include href="fallback-example.txt" parse="text">\n' ' <ns0:fallback><a href="mailto:[email protected]">Report error</a></ns0:fallback>\n' ' </ns0:include>\n' ' </ns0:fallback>\n' ' </ns0:include>\n' '</div>') # C5 def test_xinclude_failures(self): from xml.etree import ElementInclude # Test failure to locate included XML file. document = ET.XML(XINCLUDE["C1.xml"]) with self.assertRaises(ElementInclude.FatalIncludeError) as cm: ElementInclude.include(document, loader=self.none_loader) self.assertEqual(str(cm.exception), "cannot load 'disclaimer.xml' as 'xml'") # Test failure to locate included text file. document = ET.XML(XINCLUDE["C2.xml"]) with self.assertRaises(ElementInclude.FatalIncludeError) as cm: ElementInclude.include(document, loader=self.none_loader) self.assertEqual(str(cm.exception), "cannot load 'count.txt' as 'text'") # Test bad parse type. document = ET.XML(XINCLUDE_BAD["B1.xml"]) with self.assertRaises(ElementInclude.FatalIncludeError) as cm: ElementInclude.include(document, loader=self.none_loader) self.assertEqual(str(cm.exception), "unknown parse type in xi:include tag ('BAD_TYPE')") # Test xi:fallback outside xi:include. document = ET.XML(XINCLUDE_BAD["B2.xml"]) with self.assertRaises(ElementInclude.FatalIncludeError) as cm: ElementInclude.include(document, loader=self.none_loader) self.assertEqual(str(cm.exception), "xi:fallback tag must be child of xi:include " "('{http://www.w3.org/2001/XInclude}fallback')") # -------------------------------------------------------------------- # reported bugs class BugsTest(unittest.TestCase): def test_bug_xmltoolkit21(self): # marshaller gives obscure errors for non-string values def check(elem): with self.assertRaises(TypeError) as cm: serialize(elem) self.assertEqual(str(cm.exception), 'cannot serialize 123 (type int)') elem = ET.Element(123) check(elem) # tag elem = ET.Element("elem") elem.text = 123 check(elem) # text elem = ET.Element("elem") elem.tail = 123 check(elem) # tail elem = ET.Element("elem") elem.set(123, "123") check(elem) # attribute key elem = ET.Element("elem") elem.set("123", 123) check(elem) # attribute value def test_bug_xmltoolkit25(self): # typo in ElementTree.findtext elem = ET.XML(SAMPLE_XML) tree = ET.ElementTree(elem) self.assertEqual(tree.findtext("tag"), 'text') self.assertEqual(tree.findtext("section/tag"), 'subtext') def test_bug_xmltoolkit28(self): # .//tag causes exceptions tree = ET.XML("<doc><table><tbody/></table></doc>") self.assertEqual(summarize_list(tree.findall(".//thead")), []) self.assertEqual(summarize_list(tree.findall(".//tbody")), ['tbody']) def test_bug_xmltoolkitX1(self): # dump() doesn't flush the output buffer tree = ET.XML("<doc><table><tbody/></table></doc>") with support.captured_stdout() as stdout: ET.dump(tree) self.assertEqual(stdout.getvalue(), '<doc><table><tbody /></table></doc>\n') def test_bug_xmltoolkit39(self): # non-ascii element and attribute names doesn't work tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><t\xe4g />") self.assertEqual(ET.tostring(tree, "utf-8"), b'<t\xc3\xa4g />') tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?>" b"<tag \xe4ttr='v&#228;lue' />") self.assertEqual(tree.attrib, {'\xe4ttr': 'v\xe4lue'}) self.assertEqual(ET.tostring(tree, "utf-8"), b'<tag \xc3\xa4ttr="v\xc3\xa4lue" />') tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?>" b'<t\xe4g>text</t\xe4g>') self.assertEqual(ET.tostring(tree, "utf-8"), b'<t\xc3\xa4g>text</t\xc3\xa4g>') tree = ET.Element("t\u00e4g") self.assertEqual(ET.tostring(tree, "utf-8"), b'<t\xc3\xa4g />') tree = ET.Element("tag") tree.set("\u00e4ttr", "v\u00e4lue") self.assertEqual(ET.tostring(tree, "utf-8"), b'<tag \xc3\xa4ttr="v\xc3\xa4lue" />') def test_bug_xmltoolkit54(self): # problems handling internally defined entities e = ET.XML("<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]>" '<doc>&ldots;</doc>') self.assertEqual(serialize(e, encoding="us-ascii"), b'<doc>&#33328;</doc>') self.assertEqual(serialize(e), '<doc>\u8230</doc>') def test_bug_xmltoolkit55(self): # make sure we're reporting the first error, not the last with self.assertRaises(ET.ParseError) as cm: ET.XML(b"<!DOCTYPE doc SYSTEM 'doc.dtd'>" b'<doc>&ldots;&ndots;&rdots;</doc>') self.assertEqual(str(cm.exception), 'undefined entity &ldots;: line 1, column 36') def test_bug_xmltoolkit60(self): # Handle crash in stream source. class ExceptionFile: def read(self, x): raise OSError self.assertRaises(OSError, ET.parse, ExceptionFile()) def test_bug_xmltoolkit62(self): # Don't crash when using custom entities. ENTITIES = {'rsquo': '\u2019', 'lsquo': '\u2018'} parser = ET.XMLParser() parser.entity.update(ENTITIES) parser.feed("""<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE patent-application-publication SYSTEM "pap-v15-2001-01-31.dtd" []> <patent-application-publication> <subdoc-abstract> <paragraph id="A-0001" lvl="0">A new cultivar of Begonia plant named &lsquo;BCT9801BEG&rsquo;.</paragraph> </subdoc-abstract> </patent-application-publication>""") t = parser.close() self.assertEqual(t.find('.//paragraph').text, 'A new cultivar of Begonia plant named \u2018BCT9801BEG\u2019.') @unittest.skipIf(sys.gettrace(), "Skips under coverage.") def test_bug_xmltoolkit63(self): # Check reference leak. def xmltoolkit63(): tree = ET.TreeBuilder() tree.start("tag", {}) tree.data("text") tree.end("tag") xmltoolkit63() count = sys.getrefcount(None) for i in range(1000): xmltoolkit63() self.assertEqual(sys.getrefcount(None), count) def test_bug_200708_newline(self): # Preserve newlines in attributes. e = ET.Element('SomeTag', text="def _f():\n return 3\n") self.assertEqual(ET.tostring(e), b'<SomeTag text="def _f():&#10; return 3&#10;" />') self.assertEqual(ET.XML(ET.tostring(e)).get("text"), 'def _f():\n return 3\n') self.assertEqual(ET.tostring(ET.XML(ET.tostring(e))), b'<SomeTag text="def _f():&#10; return 3&#10;" />') def test_bug_200708_close(self): # Test default builder. parser = ET.XMLParser() # default parser.feed("<element>some text</element>") self.assertEqual(parser.close().tag, 'element') # Test custom builder. class EchoTarget: def close(self): return ET.Element("element") # simulate root parser = ET.XMLParser(EchoTarget()) parser.feed("<element>some text</element>") self.assertEqual(parser.close().tag, 'element') def test_bug_200709_default_namespace(self): e = ET.Element("{default}elem") s = ET.SubElement(e, "{default}elem") self.assertEqual(serialize(e, default_namespace="default"), # 1 '<elem xmlns="default"><elem /></elem>') e = ET.Element("{default}elem") s = ET.SubElement(e, "{default}elem") s = ET.SubElement(e, "{not-default}elem") self.assertEqual(serialize(e, default_namespace="default"), # 2 '<elem xmlns="default" xmlns:ns1="not-default">' '<elem />' '<ns1:elem />' '</elem>') e = ET.Element("{default}elem") s = ET.SubElement(e, "{default}elem") s = ET.SubElement(e, "elem") # unprefixed name with self.assertRaises(ValueError) as cm: serialize(e, default_namespace="default") # 3 self.assertEqual(str(cm.exception), 'cannot use non-qualified names with default_namespace option') def test_bug_200709_register_namespace(self): e = ET.Element("{http://namespace.invalid/does/not/exist/}title") self.assertEqual(ET.tostring(e), b'<ns0:title xmlns:ns0="http://namespace.invalid/does/not/exist/" />') ET.register_namespace("foo", "http://namespace.invalid/does/not/exist/") e = ET.Element("{http://namespace.invalid/does/not/exist/}title") self.assertEqual(ET.tostring(e), b'<foo:title xmlns:foo="http://namespace.invalid/does/not/exist/" />') # And the Dublin Core namespace is in the default list: e = ET.Element("{http://purl.org/dc/elements/1.1/}title") self.assertEqual(ET.tostring(e), b'<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" />') def test_bug_200709_element_comment(self): # Not sure if this can be fixed, really (since the serializer needs # ET.Comment, not cET.comment). a = ET.Element('a') a.append(ET.Comment('foo')) self.assertEqual(a[0].tag, ET.Comment) a = ET.Element('a') a.append(ET.PI('foo')) self.assertEqual(a[0].tag, ET.PI) def test_bug_200709_element_insert(self): a = ET.Element('a') b = ET.SubElement(a, 'b') c = ET.SubElement(a, 'c') d = ET.Element('d') a.insert(0, d) self.assertEqual(summarize_list(a), ['d', 'b', 'c']) a.insert(-1, d) self.assertEqual(summarize_list(a), ['d', 'b', 'd', 'c']) def test_bug_200709_iter_comment(self): a = ET.Element('a') b = ET.SubElement(a, 'b') comment_b = ET.Comment("TEST-b") b.append(comment_b) self.assertEqual(summarize_list(a.iter(ET.Comment)), [ET.Comment]) # -------------------------------------------------------------------- # reported on bugs.python.org def test_bug_1534630(self): bob = ET.TreeBuilder() e = bob.data("data") e = bob.start("tag", {}) e = bob.end("tag") e = bob.close() self.assertEqual(serialize(e), '<tag />') def test_issue6233(self): e = ET.XML(b"<?xml version='1.0' encoding='utf-8'?>" b'<body>t\xc3\xa3g</body>') self.assertEqual(ET.tostring(e, 'ascii'), b"<?xml version='1.0' encoding='ascii'?>\n" b'<body>t&#227;g</body>') e = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?>" b'<body>t\xe3g</body>') self.assertEqual(ET.tostring(e, 'ascii'), b"<?xml version='1.0' encoding='ascii'?>\n" b'<body>t&#227;g</body>') def test_issue3151(self): e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>') self.assertEqual(e.tag, '{${stuff}}localname') t = ET.ElementTree(e) self.assertEqual(ET.tostring(e), b'<ns0:localname xmlns:ns0="${stuff}" />') def test_issue6565(self): elem = ET.XML("<body><tag/></body>") self.assertEqual(summarize_list(elem), ['tag']) newelem = ET.XML(SAMPLE_XML) elem[:] = newelem[:] self.assertEqual(summarize_list(elem), ['tag', 'tag', 'section']) def test_issue10777(self): # Registering a namespace twice caused a "dictionary changed size during # iteration" bug. ET.register_namespace('test10777', 'http://myuri/') ET.register_namespace('test10777', 'http://myuri/') def test_lost_text(self): # Issue #25902: Borrowed text can disappear class Text: def __bool__(self): e.text = 'changed' return True e = ET.Element('tag') e.text = Text() i = e.itertext() t = next(i) self.assertIsInstance(t, Text) self.assertIsInstance(e.text, str) self.assertEqual(e.text, 'changed') def test_lost_tail(self): # Issue #25902: Borrowed tail can disappear class Text: def __bool__(self): e[0].tail = 'changed' return True e = ET.Element('root') e.append(ET.Element('tag')) e[0].tail = Text() i = e.itertext() t = next(i) self.assertIsInstance(t, Text) self.assertIsInstance(e[0].tail, str) self.assertEqual(e[0].tail, 'changed') def test_lost_elem(self): # Issue #25902: Borrowed element can disappear class Tag: def __eq__(self, other): e[0] = ET.Element('changed') next(i) return True e = ET.Element('root') e.append(ET.Element(Tag())) e.append(ET.Element('tag')) i = e.iter('tag') try: t = next(i) except ValueError: self.skipTest('generators are not reentrant') self.assertIsInstance(t.tag, Tag) self.assertIsInstance(e[0].tag, str) self.assertEqual(e[0].tag, 'changed') def check_expat224_utf8_bug(self, text): xml = b'<a b="%s"/>' % text root = ET.XML(xml) self.assertEqual(root.get('b'), text.decode('utf-8')) def test_expat224_utf8_bug(self): # bpo-31170: Expat 2.2.3 had a bug in its UTF-8 decoder. # Check that Expat 2.2.4 fixed the bug. # # Test buffer bounds at odd and even positions. text = b'\xc3\xa0' * 1024 self.check_expat224_utf8_bug(text) text = b'x' + b'\xc3\xa0' * 1024 self.check_expat224_utf8_bug(text) def test_expat224_utf8_bug_file(self): with open(UTF8_BUG_XMLFILE, 'rb') as fp: raw = fp.read() root = ET.fromstring(raw) xmlattr = root.get('b') # "Parse" manually the XML file to extract the value of the 'b' # attribute of the <a b='xxx' /> XML element text = raw.decode('utf-8').strip() text = text.replace('\r\n', ' ') text = text[6:-4] self.assertEqual(root.get('b'), text) # -------------------------------------------------------------------- class BasicElementTest(ElementTestCase, unittest.TestCase): def test_augmentation_type_errors(self): e = ET.Element('joe') self.assertRaises(TypeError, e.append, 'b') self.assertRaises(TypeError, e.extend, [ET.Element('bar'), 'foo']) self.assertRaises(TypeError, e.insert, 0, 'foo') def test_cyclic_gc(self): class Dummy: pass # Test the shortest cycle: d->element->d d = Dummy() d.dummyref = ET.Element('joe', attr=d) wref = weakref.ref(d) del d gc_collect() self.assertIsNone(wref()) # A longer cycle: d->e->e2->d e = ET.Element('joe') d = Dummy() d.dummyref = e wref = weakref.ref(d) e2 = ET.SubElement(e, 'foo', attr=d) del d, e, e2 gc_collect() self.assertIsNone(wref()) # A cycle between Element objects as children of one another # e1->e2->e3->e1 e1 = ET.Element('e1') e2 = ET.Element('e2') e3 = ET.Element('e3') e1.append(e2) e2.append(e2) e3.append(e1) wref = weakref.ref(e1) del e1, e2, e3 gc_collect() self.assertIsNone(wref()) def test_weakref(self): flag = False def wref_cb(w): nonlocal flag flag = True e = ET.Element('e') wref = weakref.ref(e, wref_cb) self.assertEqual(wref().tag, 'e') del e self.assertEqual(flag, True) self.assertEqual(wref(), None) def test_get_keyword_args(self): e1 = ET.Element('foo' , x=1, y=2, z=3) self.assertEqual(e1.get('x', default=7), 1) self.assertEqual(e1.get('w', default=7), 7) def test_pickle(self): # issue #16076: the C implementation wasn't pickleable. for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): for dumper, loader in product(self.modules, repeat=2): e = dumper.Element('foo', bar=42) e.text = "text goes here" e.tail = "opposite of head" dumper.SubElement(e, 'child').append(dumper.Element('grandchild')) e.append(dumper.Element('child')) e.findall('.//grandchild')[0].set('attr', 'other value') e2 = self.pickleRoundTrip(e, 'xml.etree.ElementTree', dumper, loader, proto) self.assertEqual(e2.tag, 'foo') self.assertEqual(e2.attrib['bar'], 42) self.assertEqual(len(e2), 2) self.assertEqualElements(e, e2) def test_pickle_issue18997(self): for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): for dumper, loader in product(self.modules, repeat=2): XMLTEXT = """<?xml version="1.0"?> <group><dogs>4</dogs> </group>""" e1 = dumper.fromstring(XMLTEXT) if hasattr(e1, '__getstate__'): self.assertEqual(e1.__getstate__()['tag'], 'group') e2 = self.pickleRoundTrip(e1, 'xml.etree.ElementTree', dumper, loader, proto) self.assertEqual(e2.tag, 'group') self.assertEqual(e2[0].tag, 'dogs') class BadElementTest(ElementTestCase, unittest.TestCase): def test_extend_mutable_list(self): class X: @property def __class__(self): L[:] = [ET.Element('baz')] return ET.Element L = [X()] e = ET.Element('foo') try: e.extend(L) except TypeError: pass class Y(X, ET.Element): pass L = [Y('x')] e = ET.Element('foo') e.extend(L) def test_extend_mutable_list2(self): class X: @property def __class__(self): del L[:] return ET.Element L = [X(), ET.Element('baz')] e = ET.Element('foo') try: e.extend(L) except TypeError: pass class Y(X, ET.Element): pass L = [Y('bar'), ET.Element('baz')] e = ET.Element('foo') e.extend(L) def test_remove_with_mutating(self): class X(ET.Element): def __eq__(self, o): del e[:] return False e = ET.Element('foo') e.extend([X('bar')]) self.assertRaises(ValueError, e.remove, ET.Element('baz')) e = ET.Element('foo') e.extend([ET.Element('bar')]) self.assertRaises(ValueError, e.remove, X('baz')) def test_recursive_repr(self): # Issue #25455 e = ET.Element('foo') with swap_attr(e, 'tag', e): with self.assertRaises(RuntimeError): repr(e) # Should not crash def test_element_get_text(self): # Issue #27863 class X(str): def __del__(self): try: elem.text except NameError: pass b = ET.TreeBuilder() b.start('tag', {}) b.data('ABCD') b.data(X('EFGH')) b.data('IJKL') b.end('tag') elem = b.close() self.assertEqual(elem.text, 'ABCDEFGHIJKL') def test_element_get_tail(self): # Issue #27863 class X(str): def __del__(self): try: elem[0].tail except NameError: pass b = ET.TreeBuilder() b.start('root', {}) b.start('tag', {}) b.end('tag') b.data('ABCD') b.data(X('EFGH')) b.data('IJKL') b.end('root') elem = b.close() self.assertEqual(elem[0].tail, 'ABCDEFGHIJKL') def test_element_iter(self): # Issue #27863 state = { 'tag': 'tag', '_children': [None], # non-Element 'attrib': 'attr', 'tail': 'tail', 'text': 'text', } e = ET.Element('tag') try: e.__setstate__(state) except AttributeError: e.__dict__ = state it = e.iter() self.assertIs(next(it), e) self.assertRaises(AttributeError, next, it) def test_subscr(self): # Issue #27863 class X: def __index__(self): del e[:] return 1 e = ET.Element('elem') e.append(ET.Element('child')) e[:X()] # shouldn't crash e.append(ET.Element('child')) e[0:10:X()] # shouldn't crash def test_ass_subscr(self): # Issue #27863 class X: def __index__(self): e[:] = [] return 1 e = ET.Element('elem') for _ in range(10): e.insert(0, ET.Element('child')) e[0:10:X()] = [] # shouldn't crash def test_treebuilder_start(self): # Issue #27863 def element_factory(x, y): return [] b = ET.TreeBuilder(element_factory=element_factory) b.start('tag', {}) b.data('ABCD') self.assertRaises(AttributeError, b.start, 'tag2', {}) del b gc_collect() def test_treebuilder_end(self): # Issue #27863 def element_factory(x, y): return [] b = ET.TreeBuilder(element_factory=element_factory) b.start('tag', {}) b.data('ABCD') self.assertRaises(AttributeError, b.end, 'tag') del b gc_collect() class MutatingElementPath(str): def __new__(cls, elem, *args): self = str.__new__(cls, *args) self.elem = elem return self def __eq__(self, o): del self.elem[:] return True MutatingElementPath.__hash__ = str.__hash__ class BadElementPath(str): def __eq__(self, o): raise 1/0 BadElementPath.__hash__ = str.__hash__ class BadElementPathTest(ElementTestCase, unittest.TestCase): def setUp(self): super().setUp() from xml.etree import ElementPath self.path_cache = ElementPath._cache ElementPath._cache = {} def tearDown(self): from xml.etree import ElementPath ElementPath._cache = self.path_cache super().tearDown() def test_find_with_mutating(self): e = ET.Element('foo') e.extend([ET.Element('bar')]) e.find(MutatingElementPath(e, 'x')) def test_find_with_error(self): e = ET.Element('foo') e.extend([ET.Element('bar')]) try: e.find(BadElementPath('x')) except ZeroDivisionError: pass def test_findtext_with_mutating(self): e = ET.Element('foo') e.extend([ET.Element('bar')]) e.findtext(MutatingElementPath(e, 'x')) def test_findtext_with_error(self): e = ET.Element('foo') e.extend([ET.Element('bar')]) try: e.findtext(BadElementPath('x')) except ZeroDivisionError: pass def test_findall_with_mutating(self): e = ET.Element('foo') e.extend([ET.Element('bar')]) e.findall(MutatingElementPath(e, 'x')) def test_findall_with_error(self): e = ET.Element('foo') e.extend([ET.Element('bar')]) try: e.findall(BadElementPath('x')) except ZeroDivisionError: pass class ElementTreeTypeTest(unittest.TestCase): def test_istype(self): self.assertIsInstance(ET.ParseError, type) self.assertIsInstance(ET.QName, type) self.assertIsInstance(ET.ElementTree, type) self.assertIsInstance(ET.Element, type) self.assertIsInstance(ET.TreeBuilder, type) self.assertIsInstance(ET.XMLParser, type) def test_Element_subclass_trivial(self): class MyElement(ET.Element): pass mye = MyElement('foo') self.assertIsInstance(mye, ET.Element) self.assertIsInstance(mye, MyElement) self.assertEqual(mye.tag, 'foo') # test that attribute assignment works (issue 14849) mye.text = "joe" self.assertEqual(mye.text, "joe") def test_Element_subclass_constructor(self): class MyElement(ET.Element): def __init__(self, tag, attrib={}, **extra): super(MyElement, self).__init__(tag + '__', attrib, **extra) mye = MyElement('foo', {'a': 1, 'b': 2}, c=3, d=4) self.assertEqual(mye.tag, 'foo__') self.assertEqual(sorted(mye.items()), [('a', 1), ('b', 2), ('c', 3), ('d', 4)]) def test_Element_subclass_new_method(self): class MyElement(ET.Element): def newmethod(self): return self.tag mye = MyElement('joe') self.assertEqual(mye.newmethod(), 'joe') def test_Element_subclass_find(self): class MyElement(ET.Element): pass e = ET.Element('foo') e.text = 'text' sub = MyElement('bar') sub.text = 'subtext' e.append(sub) self.assertEqual(e.findtext('bar'), 'subtext') self.assertEqual(e.find('bar').tag, 'bar') found = list(e.findall('bar')) self.assertEqual(len(found), 1, found) self.assertEqual(found[0].tag, 'bar') class ElementFindTest(unittest.TestCase): def test_find_simple(self): e = ET.XML(SAMPLE_XML) self.assertEqual(e.find('tag').tag, 'tag') self.assertEqual(e.find('section/tag').tag, 'tag') self.assertEqual(e.find('./tag').tag, 'tag') e[2] = ET.XML(SAMPLE_SECTION) self.assertEqual(e.find('section/nexttag').tag, 'nexttag') self.assertEqual(e.findtext('./tag'), 'text') self.assertEqual(e.findtext('section/tag'), 'subtext') # section/nexttag is found but has no text self.assertEqual(e.findtext('section/nexttag'), '') self.assertEqual(e.findtext('section/nexttag', 'default'), '') # tog doesn't exist and 'default' kicks in self.assertIsNone(e.findtext('tog')) self.assertEqual(e.findtext('tog', 'default'), 'default') # Issue #16922 self.assertEqual(ET.XML('<tag><empty /></tag>').findtext('empty'), '') def test_find_xpath(self): LINEAR_XML = ''' <body> <tag class='a'/> <tag class='b'/> <tag class='c'/> <tag class='d'/> </body>''' e = ET.XML(LINEAR_XML) # Test for numeric indexing and last() self.assertEqual(e.find('./tag[1]').attrib['class'], 'a') self.assertEqual(e.find('./tag[2]').attrib['class'], 'b') self.assertEqual(e.find('./tag[last()]').attrib['class'], 'd') self.assertEqual(e.find('./tag[last()-1]').attrib['class'], 'c') self.assertEqual(e.find('./tag[last()-2]').attrib['class'], 'b') self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[0]') self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[-1]') self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()-0]') self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()+1]') def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) self.assertEqual(summarize_list(e.findall('.')), ['body']) self.assertEqual(summarize_list(e.findall('tag')), ['tag', 'tag']) self.assertEqual(summarize_list(e.findall('tog')), []) self.assertEqual(summarize_list(e.findall('tog/foo')), []) self.assertEqual(summarize_list(e.findall('*')), ['tag', 'tag', 'section']) self.assertEqual(summarize_list(e.findall('.//tag')), ['tag'] * 4) self.assertEqual(summarize_list(e.findall('section/tag')), ['tag']) self.assertEqual(summarize_list(e.findall('section//tag')), ['tag'] * 2) self.assertEqual(summarize_list(e.findall('section/*')), ['tag', 'nexttag', 'nextsection']) self.assertEqual(summarize_list(e.findall('section//*')), ['tag', 'nexttag', 'nextsection', 'tag']) self.assertEqual(summarize_list(e.findall('section/.//*')), ['tag', 'nexttag', 'nextsection', 'tag']) self.assertEqual(summarize_list(e.findall('*/*')), ['tag', 'nexttag', 'nextsection']) self.assertEqual(summarize_list(e.findall('*//*')), ['tag', 'nexttag', 'nextsection', 'tag']) self.assertEqual(summarize_list(e.findall('*/tag')), ['tag']) self.assertEqual(summarize_list(e.findall('*/./tag')), ['tag']) self.assertEqual(summarize_list(e.findall('./tag')), ['tag'] * 2) self.assertEqual(summarize_list(e.findall('././tag')), ['tag'] * 2) self.assertEqual(summarize_list(e.findall('.//tag[@class]')), ['tag'] * 3) self.assertEqual(summarize_list(e.findall('.//tag[@class="a"]')), ['tag']) self.assertEqual(summarize_list(e.findall('.//tag[@class="b"]')), ['tag'] * 2) self.assertEqual(summarize_list(e.findall('.//tag[@id]')), ['tag']) self.assertEqual(summarize_list(e.findall('.//section[tag]')), ['section']) self.assertEqual(summarize_list(e.findall('.//section[element]')), []) self.assertEqual(summarize_list(e.findall('../tag')), []) self.assertEqual(summarize_list(e.findall('section/../tag')), ['tag'] * 2) self.assertEqual(e.findall('section//'), e.findall('section//*')) def test_test_find_with_ns(self): e = ET.XML(SAMPLE_XML_NS) self.assertEqual(summarize_list(e.findall('tag')), []) self.assertEqual( summarize_list(e.findall("{http://effbot.org/ns}tag")), ['{http://effbot.org/ns}tag'] * 2) self.assertEqual( summarize_list(e.findall(".//{http://effbot.org/ns}tag")), ['{http://effbot.org/ns}tag'] * 3) def test_findall_different_nsmaps(self): root = ET.XML(''' <a xmlns:x="X" xmlns:y="Y"> <x:b><c/></x:b> <b/> <c><x:b/><b/></c><y:b/> </a>''') nsmap = {'xx': 'X'} self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 2) self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2) nsmap = {'xx': 'Y'} self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 1) self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2) def test_bad_find(self): e = ET.XML(SAMPLE_XML) with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): e.findall('/tag') def test_find_through_ElementTree(self): e = ET.XML(SAMPLE_XML) self.assertEqual(ET.ElementTree(e).find('tag').tag, 'tag') self.assertEqual(ET.ElementTree(e).findtext('tag'), 'text') self.assertEqual(summarize_list(ET.ElementTree(e).findall('tag')), ['tag'] * 2) # this produces a warning self.assertEqual(summarize_list(ET.ElementTree(e).findall('//tag')), ['tag'] * 3) class ElementIterTest(unittest.TestCase): def _ilist(self, elem, tag=None): return summarize_list(elem.iter(tag)) def test_basic(self): doc = ET.XML("<html><body>this is a <i>paragraph</i>.</body>..</html>") self.assertEqual(self._ilist(doc), ['html', 'body', 'i']) self.assertEqual(self._ilist(doc.find('body')), ['body', 'i']) self.assertEqual(next(doc.iter()).tag, 'html') self.assertEqual(''.join(doc.itertext()), 'this is a paragraph...') self.assertEqual(''.join(doc.find('body').itertext()), 'this is a paragraph.') self.assertEqual(next(doc.itertext()), 'this is a ') # iterparse should return an iterator sourcefile = serialize(doc, to_string=False) self.assertEqual(next(ET.iterparse(sourcefile))[0], 'end') # With an explicit parser too (issue #9708) sourcefile = serialize(doc, to_string=False) parser = ET.XMLParser(target=ET.TreeBuilder()) self.assertEqual(next(ET.iterparse(sourcefile, parser=parser))[0], 'end') tree = ET.ElementTree(None) self.assertRaises(AttributeError, tree.iter) # Issue #16913 doc = ET.XML("<root>a&amp;<sub>b&amp;</sub>c&amp;</root>") self.assertEqual(''.join(doc.itertext()), 'a&b&c&') def test_corners(self): # single root, no subelements a = ET.Element('a') self.assertEqual(self._ilist(a), ['a']) # one child b = ET.SubElement(a, 'b') self.assertEqual(self._ilist(a), ['a', 'b']) # one child and one grandchild c = ET.SubElement(b, 'c') self.assertEqual(self._ilist(a), ['a', 'b', 'c']) # two children, only first with grandchild d = ET.SubElement(a, 'd') self.assertEqual(self._ilist(a), ['a', 'b', 'c', 'd']) # replace first child by second a[0] = a[1] del a[1] self.assertEqual(self._ilist(a), ['a', 'd']) def test_iter_by_tag(self): doc = ET.XML(''' <document> <house> <room>bedroom1</room> <room>bedroom2</room> </house> <shed>nothing here </shed> <house> <room>bedroom8</room> </house> </document>''') self.assertEqual(self._ilist(doc, 'room'), ['room'] * 3) self.assertEqual(self._ilist(doc, 'house'), ['house'] * 2) # test that iter also accepts 'tag' as a keyword arg self.assertEqual( summarize_list(doc.iter(tag='room')), ['room'] * 3) # make sure both tag=None and tag='*' return all tags all_tags = ['document', 'house', 'room', 'room', 'shed', 'house', 'room'] self.assertEqual(summarize_list(doc.iter()), all_tags) self.assertEqual(self._ilist(doc), all_tags) self.assertEqual(self._ilist(doc, '*'), all_tags) def test_getiterator(self): doc = ET.XML(''' <document> <house> <room>bedroom1</room> <room>bedroom2</room> </house> <shed>nothing here </shed> <house> <room>bedroom8</room> </house> </document>''') self.assertEqual(summarize_list(doc.getiterator('room')), ['room'] * 3) self.assertEqual(summarize_list(doc.getiterator('house')), ['house'] * 2) # test that getiterator also accepts 'tag' as a keyword arg self.assertEqual( summarize_list(doc.getiterator(tag='room')), ['room'] * 3) # make sure both tag=None and tag='*' return all tags all_tags = ['document', 'house', 'room', 'room', 'shed', 'house', 'room'] self.assertEqual(summarize_list(doc.getiterator()), all_tags) self.assertEqual(summarize_list(doc.getiterator(None)), all_tags) self.assertEqual(summarize_list(doc.getiterator('*')), all_tags) def test_copy(self): a = ET.Element('a') it = a.iter() with self.assertRaises(TypeError): copy.copy(it) def test_pickle(self): a = ET.Element('a') it = a.iter() for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises((TypeError, pickle.PicklingError)): pickle.dumps(it, proto) class TreeBuilderTest(unittest.TestCase): sample1 = ('<!DOCTYPE html PUBLIC' ' "-//W3C//DTD XHTML 1.0 Transitional//EN"' ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' '<html>text<div>subtext</div>tail</html>') sample2 = '''<toplevel>sometext</toplevel>''' def _check_sample1_element(self, e): self.assertEqual(e.tag, 'html') self.assertEqual(e.text, 'text') self.assertEqual(e.tail, None) self.assertEqual(e.attrib, {}) children = list(e) self.assertEqual(len(children), 1) child = children[0] self.assertEqual(child.tag, 'div') self.assertEqual(child.text, 'subtext') self.assertEqual(child.tail, 'tail') self.assertEqual(child.attrib, {}) def test_dummy_builder(self): class BaseDummyBuilder: def close(self): return 42 class DummyBuilder(BaseDummyBuilder): data = start = end = lambda *a: None parser = ET.XMLParser(target=DummyBuilder()) parser.feed(self.sample1) self.assertEqual(parser.close(), 42) parser = ET.XMLParser(target=BaseDummyBuilder()) parser.feed(self.sample1) self.assertEqual(parser.close(), 42) parser = ET.XMLParser(target=object()) parser.feed(self.sample1) self.assertIsNone(parser.close()) def test_treebuilder_elementfactory_none(self): parser = ET.XMLParser(target=ET.TreeBuilder(element_factory=None)) parser.feed(self.sample1) e = parser.close() self._check_sample1_element(e) def test_subclass(self): class MyTreeBuilder(ET.TreeBuilder): def foobar(self, x): return x * 2 tb = MyTreeBuilder() self.assertEqual(tb.foobar(10), 20) parser = ET.XMLParser(target=tb) parser.feed(self.sample1) e = parser.close() self._check_sample1_element(e) def test_element_factory(self): lst = [] def myfactory(tag, attrib): nonlocal lst lst.append(tag) return ET.Element(tag, attrib) tb = ET.TreeBuilder(element_factory=myfactory) parser = ET.XMLParser(target=tb) parser.feed(self.sample2) parser.close() self.assertEqual(lst, ['toplevel']) def _check_element_factory_class(self, cls): tb = ET.TreeBuilder(element_factory=cls) parser = ET.XMLParser(target=tb) parser.feed(self.sample1) e = parser.close() self.assertIsInstance(e, cls) self._check_sample1_element(e) def test_element_factory_subclass(self): class MyElement(ET.Element): pass self._check_element_factory_class(MyElement) def test_element_factory_pure_python_subclass(self): # Mimick SimpleTAL's behaviour (issue #16089): both versions of # TreeBuilder should be able to cope with a subclass of the # pure Python Element class. base = ET._Element_Py # Not from a C extension self.assertEqual(base.__module__, 'xml.etree.ElementTree') # Force some multiple inheritance with a C class to make things # more interesting. class MyElement(base, ValueError): pass self._check_element_factory_class(MyElement) def test_doctype(self): class DoctypeParser: _doctype = None def doctype(self, name, pubid, system): self._doctype = (name, pubid, system) def close(self): return self._doctype parser = ET.XMLParser(target=DoctypeParser()) parser.feed(self.sample1) self.assertEqual(parser.close(), ('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')) def test_builder_lookup_errors(self): class RaisingBuilder: def __init__(self, raise_in=None, what=ValueError): self.raise_in = raise_in self.what = what def __getattr__(self, name): if name == self.raise_in: raise self.what(self.raise_in) def handle(*args): pass return handle ET.XMLParser(target=RaisingBuilder()) # cET also checks for 'close' and 'doctype', PyET does it only at need for event in ('start', 'data', 'end', 'comment', 'pi'): with self.assertRaisesRegex(ValueError, event): ET.XMLParser(target=RaisingBuilder(event)) ET.XMLParser(target=RaisingBuilder(what=AttributeError)) for event in ('start', 'data', 'end', 'comment', 'pi'): parser = ET.XMLParser(target=RaisingBuilder(event, what=AttributeError)) parser.feed(self.sample1) self.assertIsNone(parser.close()) class XMLParserTest(unittest.TestCase): sample1 = b'<file><line>22</line></file>' sample2 = (b'<!DOCTYPE html PUBLIC' b' "-//W3C//DTD XHTML 1.0 Transitional//EN"' b' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' b'<html>text</html>') sample3 = ('<?xml version="1.0" encoding="iso-8859-1"?>\n' '<money value="$\xa3\u20ac\U0001017b">$\xa3\u20ac\U0001017b</money>') def _check_sample_element(self, e): self.assertEqual(e.tag, 'file') self.assertEqual(e[0].tag, 'line') self.assertEqual(e[0].text, '22') def test_constructor_args(self): # Positional args. The first (html) is not supported, but should be # nevertheless correctly accepted. parser = ET.XMLParser(None, ET.TreeBuilder(), 'utf-8') parser.feed(self.sample1) self._check_sample_element(parser.close()) # Now as keyword args. parser2 = ET.XMLParser(encoding='utf-8', html=[{}], target=ET.TreeBuilder()) parser2.feed(self.sample1) self._check_sample_element(parser2.close()) def test_subclass(self): class MyParser(ET.XMLParser): pass parser = MyParser() parser.feed(self.sample1) self._check_sample_element(parser.close()) def test_doctype_warning(self): parser = ET.XMLParser() with self.assertWarns(DeprecationWarning): parser.doctype('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd') parser.feed('<html/>') parser.close() with warnings.catch_warnings(): warnings.simplefilter('error', DeprecationWarning) parser = ET.XMLParser() parser.feed(self.sample2) parser.close() def test_subclass_doctype(self): _doctype = None class MyParserWithDoctype(ET.XMLParser): def doctype(self, name, pubid, system): nonlocal _doctype _doctype = (name, pubid, system) parser = MyParserWithDoctype() with self.assertWarns(DeprecationWarning): parser.feed(self.sample2) parser.close() self.assertEqual(_doctype, ('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')) _doctype = _doctype2 = None with warnings.catch_warnings(): warnings.simplefilter('error', DeprecationWarning) class DoctypeParser: def doctype(self, name, pubid, system): nonlocal _doctype2 _doctype2 = (name, pubid, system) parser = MyParserWithDoctype(target=DoctypeParser()) parser.feed(self.sample2) parser.close() self.assertIsNone(_doctype) self.assertEqual(_doctype2, ('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')) def test_inherited_doctype(self): '''Ensure that ordinary usage is not deprecated (Issue 19176)''' with warnings.catch_warnings(): warnings.simplefilter('error', DeprecationWarning) class MyParserWithoutDoctype(ET.XMLParser): pass parser = MyParserWithoutDoctype() parser.feed(self.sample2) parser.close() def test_parse_string(self): parser = ET.XMLParser(target=ET.TreeBuilder()) parser.feed(self.sample3) e = parser.close() self.assertEqual(e.tag, 'money') self.assertEqual(e.attrib['value'], '$\xa3\u20ac\U0001017b') self.assertEqual(e.text, '$\xa3\u20ac\U0001017b') class NamespaceParseTest(unittest.TestCase): def test_find_with_namespace(self): nsmap = {'h': 'hello', 'f': 'foo'} doc = ET.fromstring(SAMPLE_XML_NS_ELEMS) self.assertEqual(len(doc.findall('{hello}table', nsmap)), 1) self.assertEqual(len(doc.findall('.//{hello}td', nsmap)), 2) self.assertEqual(len(doc.findall('.//{foo}name', nsmap)), 1) class ElementSlicingTest(unittest.TestCase): def _elem_tags(self, elemlist): return [e.tag for e in elemlist] def _subelem_tags(self, elem): return self._elem_tags(list(elem)) def _make_elem_with_children(self, numchildren): """Create an Element with a tag 'a', with the given amount of children named 'a0', 'a1' ... and so on. """ e = ET.Element('a') for i in range(numchildren): ET.SubElement(e, 'a%s' % i) return e def test_getslice_single_index(self): e = self._make_elem_with_children(10) self.assertEqual(e[1].tag, 'a1') self.assertEqual(e[-2].tag, 'a8') self.assertRaises(IndexError, lambda: e[12]) self.assertRaises(IndexError, lambda: e[-12]) def test_getslice_range(self): e = self._make_elem_with_children(6) self.assertEqual(self._elem_tags(e[3:]), ['a3', 'a4', 'a5']) self.assertEqual(self._elem_tags(e[3:6]), ['a3', 'a4', 'a5']) self.assertEqual(self._elem_tags(e[3:16]), ['a3', 'a4', 'a5']) self.assertEqual(self._elem_tags(e[3:5]), ['a3', 'a4']) self.assertEqual(self._elem_tags(e[3:-1]), ['a3', 'a4']) self.assertEqual(self._elem_tags(e[:2]), ['a0', 'a1']) def test_getslice_steps(self): e = self._make_elem_with_children(10) self.assertEqual(self._elem_tags(e[8:10:1]), ['a8', 'a9']) self.assertEqual(self._elem_tags(e[::3]), ['a0', 'a3', 'a6', 'a9']) self.assertEqual(self._elem_tags(e[::8]), ['a0', 'a8']) self.assertEqual(self._elem_tags(e[1::8]), ['a1', 'a9']) self.assertEqual(self._elem_tags(e[3::sys.maxsize]), ['a3']) self.assertEqual(self._elem_tags(e[3::sys.maxsize<<64]), ['a3']) def test_getslice_negative_steps(self): e = self._make_elem_with_children(4) self.assertEqual(self._elem_tags(e[::-1]), ['a3', 'a2', 'a1', 'a0']) self.assertEqual(self._elem_tags(e[::-2]), ['a3', 'a1']) self.assertEqual(self._elem_tags(e[3::-sys.maxsize]), ['a3']) self.assertEqual(self._elem_tags(e[3::-sys.maxsize-1]), ['a3']) self.assertEqual(self._elem_tags(e[3::-sys.maxsize<<64]), ['a3']) def test_delslice(self): e = self._make_elem_with_children(4) del e[0:2] self.assertEqual(self._subelem_tags(e), ['a2', 'a3']) e = self._make_elem_with_children(4) del e[0:] self.assertEqual(self._subelem_tags(e), []) e = self._make_elem_with_children(4) del e[::-1] self.assertEqual(self._subelem_tags(e), []) e = self._make_elem_with_children(4) del e[::-2] self.assertEqual(self._subelem_tags(e), ['a0', 'a2']) e = self._make_elem_with_children(4) del e[1::2] self.assertEqual(self._subelem_tags(e), ['a0', 'a2']) e = self._make_elem_with_children(2) del e[::2] self.assertEqual(self._subelem_tags(e), ['a1']) def test_setslice_single_index(self): e = self._make_elem_with_children(4) e[1] = ET.Element('b') self.assertEqual(self._subelem_tags(e), ['a0', 'b', 'a2', 'a3']) e[-2] = ET.Element('c') self.assertEqual(self._subelem_tags(e), ['a0', 'b', 'c', 'a3']) with self.assertRaises(IndexError): e[5] = ET.Element('d') with self.assertRaises(IndexError): e[-5] = ET.Element('d') self.assertEqual(self._subelem_tags(e), ['a0', 'b', 'c', 'a3']) def test_setslice_range(self): e = self._make_elem_with_children(4) e[1:3] = [ET.Element('b%s' % i) for i in range(2)] self.assertEqual(self._subelem_tags(e), ['a0', 'b0', 'b1', 'a3']) e = self._make_elem_with_children(4) e[1:3] = [ET.Element('b')] self.assertEqual(self._subelem_tags(e), ['a0', 'b', 'a3']) e = self._make_elem_with_children(4) e[1:3] = [ET.Element('b%s' % i) for i in range(3)] self.assertEqual(self._subelem_tags(e), ['a0', 'b0', 'b1', 'b2', 'a3']) def test_setslice_steps(self): e = self._make_elem_with_children(6) e[1:5:2] = [ET.Element('b%s' % i) for i in range(2)] self.assertEqual(self._subelem_tags(e), ['a0', 'b0', 'a2', 'b1', 'a4', 'a5']) e = self._make_elem_with_children(6) with self.assertRaises(ValueError): e[1:5:2] = [ET.Element('b')] with self.assertRaises(ValueError): e[1:5:2] = [ET.Element('b%s' % i) for i in range(3)] with self.assertRaises(ValueError): e[1:5:2] = [] self.assertEqual(self._subelem_tags(e), ['a0', 'a1', 'a2', 'a3', 'a4', 'a5']) e = self._make_elem_with_children(4) e[1::sys.maxsize] = [ET.Element('b')] self.assertEqual(self._subelem_tags(e), ['a0', 'b', 'a2', 'a3']) e[1::sys.maxsize<<64] = [ET.Element('c')] self.assertEqual(self._subelem_tags(e), ['a0', 'c', 'a2', 'a3']) def test_setslice_negative_steps(self): e = self._make_elem_with_children(4) e[2:0:-1] = [ET.Element('b%s' % i) for i in range(2)] self.assertEqual(self._subelem_tags(e), ['a0', 'b1', 'b0', 'a3']) e = self._make_elem_with_children(4) with self.assertRaises(ValueError): e[2:0:-1] = [ET.Element('b')] with self.assertRaises(ValueError): e[2:0:-1] = [ET.Element('b%s' % i) for i in range(3)] with self.assertRaises(ValueError): e[2:0:-1] = [] self.assertEqual(self._subelem_tags(e), ['a0', 'a1', 'a2', 'a3']) e = self._make_elem_with_children(4) e[1::-sys.maxsize] = [ET.Element('b')] self.assertEqual(self._subelem_tags(e), ['a0', 'b', 'a2', 'a3']) e[1::-sys.maxsize-1] = [ET.Element('c')] self.assertEqual(self._subelem_tags(e), ['a0', 'c', 'a2', 'a3']) e[1::-sys.maxsize<<64] = [ET.Element('d')] self.assertEqual(self._subelem_tags(e), ['a0', 'd', 'a2', 'a3']) class IOTest(unittest.TestCase): def test_encoding(self): # Test encoding issues. elem = ET.Element("tag") elem.text = "abc" self.assertEqual(serialize(elem), '<tag>abc</tag>') for enc in ("utf-8", "us-ascii"): with self.subTest(enc): self.assertEqual(serialize(elem, encoding=enc), b'<tag>abc</tag>') self.assertEqual(serialize(elem, encoding=enc.upper()), b'<tag>abc</tag>') for enc in ("iso-8859-1", "utf-16", "utf-32"): with self.subTest(enc): self.assertEqual(serialize(elem, encoding=enc), ("<?xml version='1.0' encoding='%s'?>\n" "<tag>abc</tag>" % enc).encode(enc)) upper = enc.upper() self.assertEqual(serialize(elem, encoding=upper), ("<?xml version='1.0' encoding='%s'?>\n" "<tag>abc</tag>" % upper).encode(enc)) elem = ET.Element("tag") elem.text = "<&\"\'>" self.assertEqual(serialize(elem), '<tag>&lt;&amp;"\'&gt;</tag>') self.assertEqual(serialize(elem, encoding="utf-8"), b'<tag>&lt;&amp;"\'&gt;</tag>') self.assertEqual(serialize(elem, encoding="us-ascii"), b'<tag>&lt;&amp;"\'&gt;</tag>') for enc in ("iso-8859-1", "utf-16", "utf-32"): self.assertEqual(serialize(elem, encoding=enc), ("<?xml version='1.0' encoding='%s'?>\n" "<tag>&lt;&amp;\"'&gt;</tag>" % enc).encode(enc)) elem = ET.Element("tag") elem.attrib["key"] = "<&\"\'>" self.assertEqual(serialize(elem), '<tag key="&lt;&amp;&quot;\'&gt;" />') self.assertEqual(serialize(elem, encoding="utf-8"), b'<tag key="&lt;&amp;&quot;\'&gt;" />') self.assertEqual(serialize(elem, encoding="us-ascii"), b'<tag key="&lt;&amp;&quot;\'&gt;" />') for enc in ("iso-8859-1", "utf-16", "utf-32"): self.assertEqual(serialize(elem, encoding=enc), ("<?xml version='1.0' encoding='%s'?>\n" "<tag key=\"&lt;&amp;&quot;'&gt;\" />" % enc).encode(enc)) elem = ET.Element("tag") elem.text = '\xe5\xf6\xf6<>' self.assertEqual(serialize(elem), '<tag>\xe5\xf6\xf6&lt;&gt;</tag>') self.assertEqual(serialize(elem, encoding="utf-8"), b'<tag>\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;</tag>') self.assertEqual(serialize(elem, encoding="us-ascii"), b'<tag>&#229;&#246;&#246;&lt;&gt;</tag>') for enc in ("iso-8859-1", "utf-16", "utf-32"): self.assertEqual(serialize(elem, encoding=enc), ("<?xml version='1.0' encoding='%s'?>\n" "<tag>åöö&lt;&gt;</tag>" % enc).encode(enc)) elem = ET.Element("tag") elem.attrib["key"] = '\xe5\xf6\xf6<>' self.assertEqual(serialize(elem), '<tag key="\xe5\xf6\xf6&lt;&gt;" />') self.assertEqual(serialize(elem, encoding="utf-8"), b'<tag key="\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;" />') self.assertEqual(serialize(elem, encoding="us-ascii"), b'<tag key="&#229;&#246;&#246;&lt;&gt;" />') for enc in ("iso-8859-1", "utf-16", "utf-16le", "utf-16be", "utf-32"): self.assertEqual(serialize(elem, encoding=enc), ("<?xml version='1.0' encoding='%s'?>\n" "<tag key=\"åöö&lt;&gt;\" />" % enc).encode(enc)) def test_write_to_filename(self): self.addCleanup(support.unlink, TESTFN) tree = ET.ElementTree(ET.XML('''<site />''')) tree.write(TESTFN) with open(TESTFN, 'rb') as f: self.assertEqual(f.read(), b'''<site />''') def test_write_to_text_file(self): self.addCleanup(support.unlink, TESTFN) tree = ET.ElementTree(ET.XML('''<site />''')) with open(TESTFN, 'w', encoding='utf-8') as f: tree.write(f, encoding='unicode') self.assertFalse(f.closed) with open(TESTFN, 'rb') as f: self.assertEqual(f.read(), b'''<site />''') def test_write_to_binary_file(self): self.addCleanup(support.unlink, TESTFN) tree = ET.ElementTree(ET.XML('''<site />''')) with open(TESTFN, 'wb') as f: tree.write(f) self.assertFalse(f.closed) with open(TESTFN, 'rb') as f: self.assertEqual(f.read(), b'''<site />''') def test_write_to_binary_file_with_bom(self): self.addCleanup(support.unlink, TESTFN) tree = ET.ElementTree(ET.XML('''<site />''')) # test BOM writing to buffered file with open(TESTFN, 'wb') as f: tree.write(f, encoding='utf-16') self.assertFalse(f.closed) with open(TESTFN, 'rb') as f: self.assertEqual(f.read(), '''<?xml version='1.0' encoding='utf-16'?>\n''' '''<site />'''.encode("utf-16")) # test BOM writing to non-buffered file with open(TESTFN, 'wb', buffering=0) as f: tree.write(f, encoding='utf-16') self.assertFalse(f.closed) with open(TESTFN, 'rb') as f: self.assertEqual(f.read(), '''<?xml version='1.0' encoding='utf-16'?>\n''' '''<site />'''.encode("utf-16")) def test_read_from_stringio(self): tree = ET.ElementTree() stream = io.StringIO('''<?xml version="1.0"?><site></site>''') tree.parse(stream) self.assertEqual(tree.getroot().tag, 'site') def test_write_to_stringio(self): tree = ET.ElementTree(ET.XML('''<site />''')) stream = io.StringIO() tree.write(stream, encoding='unicode') self.assertEqual(stream.getvalue(), '''<site />''') def test_read_from_bytesio(self): tree = ET.ElementTree() raw = io.BytesIO(b'''<?xml version="1.0"?><site></site>''') tree.parse(raw) self.assertEqual(tree.getroot().tag, 'site') def test_write_to_bytesio(self): tree = ET.ElementTree(ET.XML('''<site />''')) raw = io.BytesIO() tree.write(raw) self.assertEqual(raw.getvalue(), b'''<site />''') class dummy: pass def test_read_from_user_text_reader(self): stream = io.StringIO('''<?xml version="1.0"?><site></site>''') reader = self.dummy() reader.read = stream.read tree = ET.ElementTree() tree.parse(reader) self.assertEqual(tree.getroot().tag, 'site') def test_write_to_user_text_writer(self): tree = ET.ElementTree(ET.XML('''<site />''')) stream = io.StringIO() writer = self.dummy() writer.write = stream.write tree.write(writer, encoding='unicode') self.assertEqual(stream.getvalue(), '''<site />''') def test_read_from_user_binary_reader(self): raw = io.BytesIO(b'''<?xml version="1.0"?><site></site>''') reader = self.dummy() reader.read = raw.read tree = ET.ElementTree() tree.parse(reader) self.assertEqual(tree.getroot().tag, 'site') tree = ET.ElementTree() def test_write_to_user_binary_writer(self): tree = ET.ElementTree(ET.XML('''<site />''')) raw = io.BytesIO() writer = self.dummy() writer.write = raw.write tree.write(writer) self.assertEqual(raw.getvalue(), b'''<site />''') def test_write_to_user_binary_writer_with_bom(self): tree = ET.ElementTree(ET.XML('''<site />''')) raw = io.BytesIO() writer = self.dummy() writer.write = raw.write writer.seekable = lambda: True writer.tell = raw.tell tree.write(writer, encoding="utf-16") self.assertEqual(raw.getvalue(), '''<?xml version='1.0' encoding='utf-16'?>\n''' '''<site />'''.encode("utf-16")) def test_tostringlist_invariant(self): root = ET.fromstring('<tag>foo</tag>') self.assertEqual( ET.tostring(root, 'unicode'), ''.join(ET.tostringlist(root, 'unicode'))) self.assertEqual( ET.tostring(root, 'utf-16'), b''.join(ET.tostringlist(root, 'utf-16'))) def test_short_empty_elements(self): root = ET.fromstring('<tag>a<x />b<y></y>c</tag>') self.assertEqual( ET.tostring(root, 'unicode'), '<tag>a<x />b<y />c</tag>') self.assertEqual( ET.tostring(root, 'unicode', short_empty_elements=True), '<tag>a<x />b<y />c</tag>') self.assertEqual( ET.tostring(root, 'unicode', short_empty_elements=False), '<tag>a<x></x>b<y></y>c</tag>') class ParseErrorTest(unittest.TestCase): def test_subclass(self): self.assertIsInstance(ET.ParseError(), SyntaxError) def _get_error(self, s): try: ET.fromstring(s) except ET.ParseError as e: return e def test_error_position(self): self.assertEqual(self._get_error('foo').position, (1, 0)) self.assertEqual(self._get_error('<tag>&foo;</tag>').position, (1, 5)) self.assertEqual(self._get_error('foobar<').position, (1, 6)) def test_error_code(self): import xml.parsers.expat.errors as ERRORS self.assertEqual(self._get_error('foo').code, ERRORS.codes[ERRORS.XML_ERROR_SYNTAX]) class KeywordArgsTest(unittest.TestCase): # Test various issues with keyword arguments passed to ET.Element # constructor and methods def test_issue14818(self): x = ET.XML("<a>foo</a>") self.assertEqual(x.find('a', None), x.find(path='a', namespaces=None)) self.assertEqual(x.findtext('a', None, None), x.findtext(path='a', default=None, namespaces=None)) self.assertEqual(x.findall('a', None), x.findall(path='a', namespaces=None)) self.assertEqual(list(x.iterfind('a', None)), list(x.iterfind(path='a', namespaces=None))) self.assertEqual(ET.Element('a').attrib, {}) elements = [ ET.Element('a', dict(href="#", id="foo")), ET.Element('a', attrib=dict(href="#", id="foo")), ET.Element('a', dict(href="#"), id="foo"), ET.Element('a', href="#", id="foo"), ET.Element('a', dict(href="#", id="foo"), href="#", id="foo"), ] for e in elements: self.assertEqual(e.tag, 'a') self.assertEqual(e.attrib, dict(href="#", id="foo")) e2 = ET.SubElement(elements[0], 'foobar', attrib={'key1': 'value1'}) self.assertEqual(e2.attrib['key1'], 'value1') with self.assertRaisesRegex(TypeError, 'must be dict, not str'): ET.Element('a', "I'm not a dict") with self.assertRaisesRegex(TypeError, 'must be dict, not str'): ET.Element('a', attrib="I'm not a dict") # -------------------------------------------------------------------- class NoAcceleratorTest(unittest.TestCase): def setUp(self): if not pyET: raise unittest.SkipTest('only for the Python version') # Test that the C accelerator was not imported for pyET def test_correct_import_pyET(self): # The type of methods defined in Python code is types.FunctionType, # while the type of methods defined inside _elementtree is # <class 'wrapper_descriptor'> self.assertIsInstance(pyET.Element.__init__, types.FunctionType) self.assertIsInstance(pyET.XMLParser.__init__, types.FunctionType) # -------------------------------------------------------------------- class CleanContext(object): """Provide default namespace mapping and path cache.""" checkwarnings = None def __init__(self, quiet=False): if sys.flags.optimize >= 2: # under -OO, doctests cannot be run and therefore not all warnings # will be emitted quiet = True deprecations = ( # Search behaviour is broken if search path starts with "/". ("This search is broken in 1.3 and earlier, and will be fixed " "in a future version. If you rely on the current behaviour, " "change it to '.+'", FutureWarning), # Element.getchildren() and Element.getiterator() are deprecated. ("This method will be removed in future versions. " "Use .+ instead.", DeprecationWarning), ("This method will be removed in future versions. " "Use .+ instead.", PendingDeprecationWarning)) self.checkwarnings = support.check_warnings(*deprecations, quiet=quiet) def __enter__(self): from xml.etree import ElementPath self._nsmap = ET.register_namespace._namespace_map # Copy the default namespace mapping self._nsmap_copy = self._nsmap.copy() # Copy the path cache (should be empty) self._path_cache = ElementPath._cache ElementPath._cache = self._path_cache.copy() self.checkwarnings.__enter__() def __exit__(self, *args): from xml.etree import ElementPath # Restore mapping and path cache self._nsmap.clear() self._nsmap.update(self._nsmap_copy) ElementPath._cache = self._path_cache self.checkwarnings.__exit__(*args) def test_main(module=None): # When invoked without a module, runs the Python ET tests by loading pyET. # Otherwise, uses the given module as the ET. global pyET pyET = import_fresh_module('xml.etree.ElementTree', blocked=['_elementtree']) if module is None: module = pyET global ET ET = module test_classes = [ ModuleTest, ElementSlicingTest, BasicElementTest, BadElementTest, BadElementPathTest, ElementTreeTest, IOTest, ParseErrorTest, XIncludeTest, ElementTreeTypeTest, ElementFindTest, ElementIterTest, TreeBuilderTest, XMLParserTest, XMLPullParserTest, BugsTest, ] # These tests will only run for the pure-Python version that doesn't import # _elementtree. We can't use skipUnless here, because pyET is filled in only # after the module is loaded. if pyET is not ET: test_classes.extend([ NoAcceleratorTest, ]) try: # XXX the C module should give the same warnings as the Python module with CleanContext(quiet=(pyET is not ET)): support.run_unittest(*test_classes) finally: # don't interfere with subsequent tests ET = pyET = None if __name__ == '__main__': test_main()
118,224
3,199
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_socket.py
import unittest from test import support import errno import io import itertools import socket import select import tempfile import time import traceback import queue import sys import os import array import contextlib from weakref import proxy import signal import math import pickle import struct import random import string try: import multiprocessing except ImportError: multiprocessing = False try: import fcntl except ImportError: fcntl = None HOST = support.HOST MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8') ## test unicode string and carriage return MAIN_TIMEOUT = 60.0 try: import _thread as thread import threading except ImportError: thread = None threading = None try: import _socket except ImportError: _socket = None def _have_socket_can(): """Check whether CAN sockets are supported on this host.""" try: s = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) except (AttributeError, OSError): return False else: s.close() return True def _have_socket_rds(): """Check whether RDS sockets are supported on this host.""" try: s = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) except (AttributeError, OSError): return False else: s.close() return True def _have_socket_alg(): """Check whether AF_ALG sockets are supported on this host.""" try: s = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0) except (AttributeError, OSError): return False else: s.close() return True HAVE_SOCKET_CAN = _have_socket_can() HAVE_SOCKET_RDS = _have_socket_rds() HAVE_SOCKET_ALG = _have_socket_alg() # Size in bytes of the int type SIZEOF_INT = array.array("i").itemsize class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(self.serv) self.serv.listen() def tearDown(self): self.serv.close() self.serv = None class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = support.bind_port(self.serv) def tearDown(self): self.serv.close() self.serv = None class ThreadSafeCleanupTestCase(unittest.TestCase): """Subclass of unittest.TestCase with thread-safe cleanup methods. This subclass protects the addCleanup() and doCleanups() methods with a recursive lock. """ if threading: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._cleanup_lock = threading.RLock() def addCleanup(self, *args, **kwargs): with self._cleanup_lock: return super().addCleanup(*args, **kwargs) def doCleanups(self, *args, **kwargs): with self._cleanup_lock: return super().doCleanups(*args, **kwargs) class SocketCANTest(unittest.TestCase): """To be able to run this test, a `vcan0` CAN interface can be created with the following commands: # modprobe vcan # ip link add dev vcan0 type vcan # ifconfig vcan0 up """ interface = 'vcan0' bufsize = 128 """The CAN frame structure is defined in <linux/can.h>: struct can_frame { canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ __u8 can_dlc; /* data length code: 0 .. 8 */ __u8 data[8] __attribute__((aligned(8))); }; """ can_frame_fmt = "=IB3x8s" can_frame_size = struct.calcsize(can_frame_fmt) """The Broadcast Management Command frame structure is defined in <linux/can/bcm.h>: struct bcm_msg_head { __u32 opcode; __u32 flags; __u32 count; struct timeval ival1, ival2; canid_t can_id; __u32 nframes; struct can_frame frames[0]; } `bcm_msg_head` must be 8 bytes aligned because of the `frames` member (see `struct can_frame` definition). Must use native not standard types for packing. """ bcm_cmd_msg_fmt = "@3I4l2I" bcm_cmd_msg_fmt += "x" * (struct.calcsize(bcm_cmd_msg_fmt) % 8) def setUp(self): self.s = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) self.addCleanup(self.s.close) try: self.s.bind((self.interface,)) except OSError: self.skipTest('network interface `%s` does not exist' % self.interface) class SocketRDSTest(unittest.TestCase): """To be able to run this test, the `rds` kernel module must be loaded: # modprobe rds """ bufsize = 8192 def setUp(self): self.serv = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) self.addCleanup(self.serv.close) try: self.port = support.bind_port(self.serv) except OSError: self.skipTest('unable to bind RDS socket') class ThreadableTest: """Threadable Test class The ThreadableTest class makes it easy to create a threaded client/server pair from an existing unit test. To create a new threaded class from an existing unit test, use multiple inheritance: class NewClass (OldClass, ThreadableTest): pass This class defines two new fixture functions with obvious purposes for overriding: clientSetUp () clientTearDown () Any new test functions within the class must then define tests in pairs, where the test name is preceded with a '_' to indicate the client portion of the test. Ex: def testFoo(self): # Server portion def _testFoo(self): # Client portion Any exceptions raised by the clients during their tests are caught and transferred to the main thread to alert the testing framework. Note, the server setup function cannot call any blocking functions that rely on the client thread during setup, unless serverExplicitReady() is called just before the blocking call (such as in setting up a client/server connection and performing the accept() in setUp(). """ def __init__(self): # Swap the true setup function self.__setUp = self.setUp self.__tearDown = self.tearDown self.setUp = self._setUp self.tearDown = self._tearDown def serverExplicitReady(self): """This method allows the server to explicitly indicate that it wants the client thread to proceed. This is useful if the server is about to execute a blocking routine that is dependent upon the client thread during its setup routine.""" self.server_ready.set() def _setUp(self): self.wait_threads = support.wait_threads_exit() self.wait_threads.__enter__() self.server_ready = threading.Event() self.client_ready = threading.Event() self.done = threading.Event() self.queue = queue.Queue(1) self.server_crashed = False # Do some munging to start the client test. methodname = self.id() i = methodname.rfind('.') methodname = methodname[i+1:] test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) try: self.__setUp() except: self.server_crashed = True raise finally: self.server_ready.set() self.client_ready.wait() def _tearDown(self): self.__tearDown() self.done.wait() self.wait_threads.__exit__(None, None, None) if self.queue.qsize(): exc = self.queue.get() raise exc def clientRun(self, test_func): self.server_ready.wait() try: self.clientSetUp() except BaseException as e: self.queue.put(e) self.clientTearDown() return finally: self.client_ready.set() if self.server_crashed: self.clientTearDown() return if not hasattr(test_func, '__call__'): raise TypeError("test_func must be a callable function") try: test_func() except BaseException as e: self.queue.put(e) finally: self.clientTearDown() def clientSetUp(self): raise NotImplementedError("clientSetUp must be implemented.") def clientTearDown(self): self.done.set() thread.exit() class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketUDPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedCANSocketTest(SocketCANTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketCANTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) try: self.cli.bind((self.interface,)) except OSError: # skipTest should not be called here, and will be called in the # server instead pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ThreadedRDSSocketTest(SocketRDSTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketRDSTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) try: # RDS sockets must be bound explicitly to send or receive data self.cli.bind((HOST, 0)) self.cli_addr = self.cli.getsockname() except OSError: # skipTest should not be called here, and will be called in the # server instead pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class SocketConnectedTest(ThreadedTCPSocketTest): """Socket tests for client-server connection. self.cli_conn is a client socket connected to the server. The setUp() method guarantees that it is connected to the server. """ def __init__(self, methodName='runTest'): ThreadedTCPSocketTest.__init__(self, methodName=methodName) def setUp(self): ThreadedTCPSocketTest.setUp(self) # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None ThreadedTCPSocketTest.tearDown(self) def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) self.cli.connect((HOST, self.port)) self.serv_conn = self.cli def clientTearDown(self): self.serv_conn.close() self.serv_conn = None ThreadedTCPSocketTest.clientTearDown(self) class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def setUp(self): self.serv, self.cli = socket.socketpair() def tearDown(self): self.serv.close() self.serv = None def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) # The following classes are used by the sendmsg()/recvmsg() tests. # Combining, for instance, ConnectedStreamTestMixin and TCPTestBase # gives a drop-in replacement for SocketConnectedTest, but different # address families can be used, and the attributes serv_addr and # cli_addr will be set to the addresses of the endpoints. class SocketTestBase(unittest.TestCase): """A base class for socket tests. Subclasses must provide methods newSocket() to return a new socket and bindSock(sock) to bind it to an unused address. Creates a socket self.serv and sets self.serv_addr to its address. """ def setUp(self): self.serv = self.newSocket() self.bindServer() def bindServer(self): """Bind server socket and set self.serv_addr to its address.""" self.bindSock(self.serv) self.serv_addr = self.serv.getsockname() def tearDown(self): self.serv.close() self.serv = None class SocketListeningTestMixin(SocketTestBase): """Mixin to listen on the server socket.""" def setUp(self): super().setUp() self.serv.listen() class ThreadedSocketTestMixin(ThreadSafeCleanupTestCase, SocketTestBase, ThreadableTest): """Mixin to add client socket and allow client/server tests. Client socket is self.cli and its address is self.cli_addr. See ThreadableTest for usage information. """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) ThreadableTest.__init__(self) def clientSetUp(self): self.cli = self.newClientSocket() self.bindClient() def newClientSocket(self): """Return a new socket for use as client.""" return self.newSocket() def bindClient(self): """Bind client socket and set self.cli_addr to its address.""" self.bindSock(self.cli) self.cli_addr = self.cli.getsockname() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) class ConnectedStreamTestMixin(SocketListeningTestMixin, ThreadedSocketTestMixin): """Mixin to allow client/server stream tests with connected client. Server's socket representing connection to client is self.cli_conn and client's connection to server is self.serv_conn. (Based on SocketConnectedTest.) """ def setUp(self): super().setUp() # Indicate explicitly we're ready for the client thread to # proceed and then perform the blocking call to accept self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn def tearDown(self): self.cli_conn.close() self.cli_conn = None super().tearDown() def clientSetUp(self): super().clientSetUp() self.cli.connect(self.serv_addr) self.serv_conn = self.cli def clientTearDown(self): try: self.serv_conn.close() self.serv_conn = None except AttributeError: pass super().clientTearDown() class UnixSocketTestBase(SocketTestBase): """Base class for Unix-domain socket tests.""" # This class is used for file descriptor passing tests, so we # create the sockets in a private directory so that other users # can't send anything that might be problematic for a privileged # user running the tests. def setUp(self): self.dir_path = tempfile.mkdtemp() self.addCleanup(os.rmdir, self.dir_path) super().setUp() def bindSock(self, sock): path = tempfile.mktemp(dir=self.dir_path) support.bind_unix_socket(sock, path) self.addCleanup(support.unlink, path) class UnixStreamBase(UnixSocketTestBase): """Base class for Unix-domain SOCK_STREAM tests.""" def newSocket(self): return socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) class InetTestBase(SocketTestBase): """Base class for IPv4 socket tests.""" host = HOST def setUp(self): super().setUp() self.port = self.serv_addr[1] def bindSock(self, sock): support.bind_port(sock, host=self.host) class TCPTestBase(InetTestBase): """Base class for TCP-over-IPv4 tests.""" def newSocket(self): return socket.socket(socket.AF_INET, socket.SOCK_STREAM) class UDPTestBase(InetTestBase): """Base class for UDP-over-IPv4 tests.""" def newSocket(self): return socket.socket(socket.AF_INET, socket.SOCK_DGRAM) class SCTPStreamBase(InetTestBase): """Base class for SCTP tests in one-to-one (SOCK_STREAM) mode.""" def newSocket(self): return socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SCTP) class Inet6TestBase(InetTestBase): """Base class for IPv6 socket tests.""" host = support.HOSTv6 class UDP6TestBase(Inet6TestBase): """Base class for UDP-over-IPv6 tests.""" def newSocket(self): return socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) # Test-skipping decorators for use with ThreadableTest. def skipWithClientIf(condition, reason): """Skip decorated test if condition is true, add client_skip decorator. If the decorated object is not a class, sets its attribute "client_skip" to a decorator which will return an empty function if the test is to be skipped, or the original function if it is not. This can be used to avoid running the client part of a skipped test when using ThreadableTest. """ def client_pass(*args, **kwargs): pass def skipdec(obj): retval = unittest.skip(reason)(obj) if not isinstance(obj, type): retval.client_skip = lambda f: client_pass return retval def noskipdec(obj): if not (isinstance(obj, type) or hasattr(obj, "client_skip")): obj.client_skip = lambda f: f return obj return skipdec if condition else noskipdec def requireAttrs(obj, *attributes): """Skip decorated test if obj is missing any of the given attributes. Sets client_skip attribute as skipWithClientIf() does. """ missing = [name for name in attributes if not hasattr(obj, name)] return skipWithClientIf( missing, "don't have " + ", ".join(name for name in missing)) def requireSocket(*args): """Skip decorated test if a socket cannot be created with given arguments. When an argument is given as a string, will use the value of that attribute of the socket module, or skip the test if it doesn't exist. Sets client_skip attribute as skipWithClientIf() does. """ err = None missing = [obj for obj in args if isinstance(obj, str) and not hasattr(socket, obj)] if missing: err = "don't have " + ", ".join(name for name in missing) else: callargs = [getattr(socket, obj) if isinstance(obj, str) else obj for obj in args] try: s = socket.socket(*callargs) except OSError as e: # XXX: check errno? err = str(e) else: s.close() return skipWithClientIf( err is not None, "can't create socket({0}): {1}".format( ", ".join(str(o) for o in args), err)) ####################################################################### ## Begin Tests class GeneralModuleTests(unittest.TestCase): def test_SocketType_is_socketobject(self): import _socket self.assertTrue(socket.SocketType is _socket.socket) s = socket.socket() self.assertIsInstance(s, socket.SocketType) s.close() def test_repr(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) with s: self.assertIn('fd=%i' % s.fileno(), repr(s)) self.assertIn('family=%s' % socket.AF_INET, repr(s)) self.assertIn('type=%s' % socket.SOCK_STREAM, repr(s)) self.assertIn('proto=0', repr(s)) self.assertNotIn('raddr', repr(s)) s.bind(('127.0.0.1', 0)) self.assertIn('laddr', repr(s)) self.assertIn(str(s.getsockname()), repr(s)) self.assertIn('[closed]', repr(s)) self.assertNotIn('laddr', repr(s)) @unittest.skipUnless(_socket is not None, 'need _socket module') def test_csocket_repr(self): s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) try: expected = ('<socket object, fd=%s, family=%s, type=%s, proto=%s>' % (s.fileno(), s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) finally: s.close() expected = ('<socket object, fd=-1, family=%s, type=%s, proto=%s>' % (s.family, s.type, s.proto)) self.assertEqual(repr(s), expected) def test_weakref(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) p = proxy(s) self.assertEqual(p.fileno(), s.fileno()) s.close() s = None try: p.fileno() except ReferenceError: pass else: self.fail('Socket proxy still exists') def testSocketError(self): # Testing socket module exceptions msg = "Error raising socket exception (%s)." with self.assertRaises(OSError, msg=msg % 'OSError'): raise OSError with self.assertRaises(OSError, msg=msg % 'socket.herror'): raise socket.herror with self.assertRaises(OSError, msg=msg % 'socket.gaierror'): raise socket.gaierror def testSendtoErrors(self): # Testing that sendto doesn't mask failures. See #10169. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.addCleanup(s.close) s.bind(('', 0)) sockname = s.getsockname() # 2 args with self.assertRaises(TypeError) as cm: s.sendto('\u2620', sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'str'") with self.assertRaises(TypeError) as cm: s.sendto(5j, sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'complex'") with self.assertRaises(TypeError) as cm: s.sendto(b'foo', None) self.assertIn('not NoneType',str(cm.exception)) # 3 args with self.assertRaises(TypeError) as cm: s.sendto('\u2620', 0, sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'str'") with self.assertRaises(TypeError) as cm: s.sendto(5j, 0, sockname) self.assertEqual(str(cm.exception), "a bytes-like object is required, not 'complex'") with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 0, None) self.assertIn('not NoneType', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 'bar', sockname) self.assertIn('an integer is required', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', None, None) self.assertIn('an integer is required', str(cm.exception)) # wrong number of args with self.assertRaises(TypeError) as cm: s.sendto(b'foo') self.assertIn('(1 given)', str(cm.exception)) with self.assertRaises(TypeError) as cm: s.sendto(b'foo', 0, sockname, 4) self.assertIn('(4 given)', str(cm.exception)) def testCrucialConstants(self): # Testing for mission critical constants socket.AF_INET socket.SOCK_STREAM socket.SOCK_DGRAM socket.SOCK_RAW socket.SOCK_RDM socket.SOCK_SEQPACKET socket.SOL_SOCKET socket.SO_REUSEADDR def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() try: ip = socket.gethostbyname(hostname) except OSError: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except OSError: # Probably a similar problem as above; skip this test self.skipTest('name lookup failure') all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) def test_host_resolution(self): for addr in [support.HOST, '10.0.0.1', '255.255.255.255']: self.assertEqual(socket.gethostbyname(addr), addr) # we don't test support.HOSTv6 because there's a chance it doesn't have # a matching name entry (e.g. 'ip6-localhost') for host in [support.HOST]: self.assertIn(host, socket.gethostbyaddr(host)[2]) def test_host_resolution_bad_address(self): # These are all malformed IP addresses and expected not to resolve to # any result. But some ISPs, e.g. AWS, may successfully resolve these # IPs. explanation = ( "resolving an invalid IP address did not raise OSError; " "can be caused by a broken DNS server" ) for addr in ['0.1.1.~1', '1+.1.1.1', '::1q', '::1::2', '1:1:1:1:1:1:1:1:1']: with self.assertRaises(OSError): socket.gethostbyname(addr) with self.assertRaises(OSError, msg=explanation): socket.gethostbyaddr(addr) @unittest.skipUnless(hasattr(socket, 'sethostname'), "test needs socket.sethostname()") @unittest.skipUnless(hasattr(socket, 'gethostname'), "test needs socket.gethostname()") def test_sethostname(self): oldhn = socket.gethostname() try: socket.sethostname('new') except OSError as e: if e.errno == errno.EPERM: self.skipTest("test should be run as root") else: raise try: # running test as root! self.assertEqual(socket.gethostname(), 'new') # Should work with bytes objects too socket.sethostname(b'bar') self.assertEqual(socket.gethostname(), 'bar') finally: socket.sethostname(oldhn) @unittest.skipUnless(hasattr(socket, 'if_nameindex'), 'socket.if_nameindex() not available.') def testInterfaceNameIndex(self): interfaces = socket.if_nameindex() for index, name in interfaces: self.assertIsInstance(index, int) self.assertIsInstance(name, str) # interface indices are non-zero integers self.assertGreater(index, 0) _index = socket.if_nametoindex(name) self.assertIsInstance(_index, int) self.assertEqual(index, _index) _name = socket.if_indextoname(index) self.assertIsInstance(_name, str) self.assertEqual(name, _name) @unittest.skipUnless(hasattr(socket, 'if_nameindex'), 'socket.if_nameindex() not available.') def testInvalidInterfaceNameIndex(self): # test nonexistent interface index/name self.assertRaises(OSError, socket.if_indextoname, 0) self.assertRaises(OSError, socket.if_nametoindex, '_DEADBEEF') # test with invalid values self.assertRaises(TypeError, socket.if_nametoindex, 0) self.assertRaises(TypeError, socket.if_indextoname, '_DEADBEEF') @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo try: # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except TypeError: if sys.getrefcount(__name__) != orig: self.fail("socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter try: # On some versions, this crashes the interpreter. socket.getnameinfo(('x', 0, 0, 0), 0) except OSError: pass def testNtoH(self): # This just checks that htons etc. are their own inverse, # when looking at the lower 16 or 32 bits. sizes = {socket.htonl: 32, socket.ntohl: 32, socket.htons: 16, socket.ntohs: 16} for func, size in sizes.items(): mask = (1<<size) - 1 for i in (0, 1, 0xffff, ~0xffff, 2, 0x01234567, 0x76543210): self.assertEqual(i & mask, func(func(i&mask)) & mask) swapped = func(mask) self.assertEqual(swapped & mask, mask) self.assertRaises(OverflowError, func, 1<<34) @support.cpython_only def testNtoHErrors(self): good_values = [ 1, 2, 3, 1, 2, 3 ] bad_values = [ -1, -2, -3, -1, -2, -3 ] for k in good_values: socket.ntohl(k) socket.ntohs(k) socket.htonl(k) socket.htons(k) for k in bad_values: self.assertRaises(OverflowError, socket.ntohl, k) self.assertRaises(OverflowError, socket.ntohs, k) self.assertRaises(OverflowError, socket.htonl, k) self.assertRaises(OverflowError, socket.htons, k) def testGetServBy(self): eq = self.assertEqual # Find one service that exists, then check all the related interfaces. # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. if (sys.platform.startswith(('freebsd', 'netbsd', 'gnukfreebsd')) or sys.platform in ('linux', 'darwin')): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry services = ('daytime', 'qotd', 'domain') else: services = ('echo', 'daytime', 'domain') for service in services: try: port = socket.getservbyname(service, 'tcp') break except OSError: pass else: raise OSError # Try same call with optional protocol omitted port2 = socket.getservbyname(service) eq(port, port2) # Try udp, but don't barf if it doesn't exist try: udpport = socket.getservbyname(service, 'udp') except OSError: udpport = None else: eq(udpport, port) # Now make sure the lookup by port returns the same service name eq(socket.getservbyport(port2), service) eq(socket.getservbyport(port, 'tcp'), service) if udpport is not None: eq(socket.getservbyport(udpport, 'udp'), service) # Make sure getservbyport does not accept out of range ports. self.assertRaises(OverflowError, socket.getservbyport, -1) self.assertRaises(OverflowError, socket.getservbyport, 65536) def testDefaultTimeout(self): # Testing default timeout # The default timeout should initially be None self.assertEqual(socket.getdefaulttimeout(), None) s = socket.socket() self.assertEqual(s.gettimeout(), None) s.close() # Set the default timeout to 10, and see if it propagates socket.setdefaulttimeout(10) self.assertEqual(socket.getdefaulttimeout(), 10) s = socket.socket() self.assertEqual(s.gettimeout(), 10) s.close() # Reset the default timeout to None, and see if it propagates socket.setdefaulttimeout(None) self.assertEqual(socket.getdefaulttimeout(), None) s = socket.socket() self.assertEqual(s.gettimeout(), None) s.close() # Check that setting it to an invalid value raises ValueError self.assertRaises(ValueError, socket.setdefaulttimeout, -1) # Check that setting it to an invalid type raises TypeError self.assertRaises(TypeError, socket.setdefaulttimeout, "spam") @unittest.skipUnless(hasattr(socket, 'inet_aton'), 'test needs socket.inet_aton()') def testIPv4_inet_aton_fourbytes(self): # Test that issue1008086 and issue767150 are fixed. # It must return 4 bytes. self.assertEqual(b'\x00'*4, socket.inet_aton('0.0.0.0')) self.assertEqual(b'\xff'*4, socket.inet_aton('255.255.255.255')) @unittest.skipUnless(hasattr(socket, 'inet_pton'), 'test needs socket.inet_pton()') def testIPv4toString(self): from socket import inet_aton as f, inet_pton, AF_INET g = lambda a: inet_pton(AF_INET, a) assertInvalid = lambda func,a: self.assertRaises( (OSError, ValueError), func, a ) self.assertEqual(b'\x00\x00\x00\x00', f('0.0.0.0')) self.assertEqual(b'\xff\x00\xff\x00', f('255.0.255.0')) self.assertEqual(b'\xaa\xaa\xaa\xaa', f('170.170.170.170')) self.assertEqual(b'\x01\x02\x03\x04', f('1.2.3.4')) self.assertEqual(b'\xff\xff\xff\xff', f('255.255.255.255')) assertInvalid(f, '0.0.0.') assertInvalid(f, '300.0.0.0') assertInvalid(f, 'a.0.0.0') assertInvalid(f, '1.2.3.4.5') assertInvalid(f, '::1') self.assertEqual(b'\x00\x00\x00\x00', g('0.0.0.0')) self.assertEqual(b'\xff\x00\xff\x00', g('255.0.255.0')) self.assertEqual(b'\xaa\xaa\xaa\xaa', g('170.170.170.170')) self.assertEqual(b'\xff\xff\xff\xff', g('255.255.255.255')) assertInvalid(g, '0.0.0.') assertInvalid(g, '300.0.0.0') assertInvalid(g, 'a.0.0.0') assertInvalid(g, '1.2.3.4.5') assertInvalid(g, '::1') @unittest.skipUnless(hasattr(socket, 'inet_pton'), 'test needs socket.inet_pton()') def testIPv6toString(self): try: from socket import inet_pton, AF_INET6, has_ipv6 if not has_ipv6: self.skipTest('IPv6 not available') except ImportError: self.skipTest('could not import needed symbols from socket') if sys.platform == "win32": try: inet_pton(AF_INET6, '::') except OSError as e: if e.winerror == 10022: self.skipTest('IPv6 might not be supported') f = lambda a: inet_pton(AF_INET6, a) assertInvalid = lambda a: self.assertRaises( (OSError, ValueError), f, a ) self.assertEqual(b'\x00' * 16, f('::')) self.assertEqual(b'\x00' * 16, f('0::0')) self.assertEqual(b'\x00\x01' + b'\x00' * 14, f('1::')) self.assertEqual( b'\x45\xef\x76\xcb\x00\x1a\x56\xef\xaf\xeb\x0b\xac\x19\x24\xae\xae', f('45ef:76cb:1a:56ef:afeb:bac:1924:aeae') ) self.assertEqual( b'\xad\x42\x0a\xbc' + b'\x00' * 4 + b'\x01\x27\x00\x00\x02\x54\x00\x02', f('ad42:abc::127:0:254:2') ) self.assertEqual(b'\x00\x12\x00\x0a' + b'\x00' * 12, f('12:a::')) assertInvalid('0x20::') assertInvalid(':::') assertInvalid('::0::') assertInvalid('1::abc::') assertInvalid('1::abc::def') assertInvalid('1:2:3:4:5:6:') assertInvalid('1:2:3:4:5:6') assertInvalid('1:2:3:4:5:6:7:8:') assertInvalid('1:2:3:4:5:6:7:8:0') self.assertEqual(b'\x00' * 12 + b'\xfe\x2a\x17\x40', f('::254.42.23.64') ) self.assertEqual( b'\x00\x42' + b'\x00' * 8 + b'\xa2\x9b\xfe\x2a\x17\x40', f('42::a29b:254.42.23.64') ) self.assertEqual( b'\x00\x42\xa8\xb9\x00\x00\x00\x02\xff\xff\xa2\x9b\xfe\x2a\x17\x40', f('42:a8b9:0:2:ffff:a29b:254.42.23.64') ) assertInvalid('255.254.253.252') assertInvalid('1::260.2.3.0') assertInvalid('1::0.be.e.0') assertInvalid('1:2:3:4:5:6:7:1.2.3.4') assertInvalid('::1.2.3.4:0') assertInvalid('0.100.200.0:3:4:5:6:7:8') @unittest.skipUnless(hasattr(socket, 'inet_ntop'), 'test needs socket.inet_ntop()') def testStringToIPv4(self): from socket import inet_ntoa as f, inet_ntop, AF_INET g = lambda a: inet_ntop(AF_INET, a) assertInvalid = lambda func,a: self.assertRaises( (OSError, ValueError), func, a ) self.assertEqual('1.0.1.0', f(b'\x01\x00\x01\x00')) self.assertEqual('170.85.170.85', f(b'\xaa\x55\xaa\x55')) self.assertEqual('255.255.255.255', f(b'\xff\xff\xff\xff')) self.assertEqual('1.2.3.4', f(b'\x01\x02\x03\x04')) assertInvalid(f, b'\x00' * 3) assertInvalid(f, b'\x00' * 5) assertInvalid(f, b'\x00' * 16) self.assertEqual('170.85.170.85', f(bytearray(b'\xaa\x55\xaa\x55'))) self.assertEqual('1.0.1.0', g(b'\x01\x00\x01\x00')) self.assertEqual('170.85.170.85', g(b'\xaa\x55\xaa\x55')) self.assertEqual('255.255.255.255', g(b'\xff\xff\xff\xff')) assertInvalid(g, b'\x00' * 3) assertInvalid(g, b'\x00' * 5) assertInvalid(g, b'\x00' * 16) self.assertEqual('170.85.170.85', g(bytearray(b'\xaa\x55\xaa\x55'))) @unittest.skipUnless(hasattr(socket, 'inet_ntop'), 'test needs socket.inet_ntop()') def testStringToIPv6(self): try: from socket import inet_ntop, AF_INET6, has_ipv6 if not has_ipv6: self.skipTest('IPv6 not available') except ImportError: self.skipTest('could not import needed symbols from socket') if sys.platform == "win32": try: inet_ntop(AF_INET6, b'\x00' * 16) except OSError as e: if e.winerror == 10022: self.skipTest('IPv6 might not be supported') f = lambda a: inet_ntop(AF_INET6, a) assertInvalid = lambda a: self.assertRaises( (OSError, ValueError), f, a ) self.assertEqual('::', f(b'\x00' * 16)) self.assertEqual('::1', f(b'\x00' * 15 + b'\x01')) self.assertEqual( 'aef:b01:506:1001:ffff:9997:55:170', f(b'\x0a\xef\x0b\x01\x05\x06\x10\x01\xff\xff\x99\x97\x00\x55\x01\x70') ) self.assertEqual('::1', f(bytearray(b'\x00' * 15 + b'\x01'))) assertInvalid(b'\x12' * 15) assertInvalid(b'\x12' * 17) assertInvalid(b'\x12' * 4) # XXX The following don't test module-level functionality... def testSockName(self): # Testing getsockname() port = support.find_unused_port() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) sock.bind(("0.0.0.0", port)) name = sock.getsockname() # XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate # it reasonable to get the host's addr in addition to 0.0.0.0. # At least for eCos. This is required for the S/390 to pass. try: my_ip_addr = socket.gethostbyname(socket.gethostname()) except OSError: # Probably name lookup wasn't set up right; skip this test self.skipTest('name lookup failure') self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0]) self.assertEqual(name[1], port) def testGetSockOpt(self): # Testing getsockopt() # We know a socket should start without reuse==0 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assertFalse(reuse != 0, "initial mode is reuse") def testSetSockOpt(self): # Testing setsockopt() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assertFalse(reuse == 0, "failed to set reuse mode") def testSendAfterClose(self): # testing send() after close() with timeout sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(1) sock.close() self.assertRaises(OSError, sock.send, b"spam") def testCloseException(self): sock = socket.socket() socket.socket(fileno=sock.fileno()).close() try: sock.close() except OSError as err: # Winsock apparently raises ENOTSOCK self.assertIn(err.errno, (errno.EBADF, errno.ENOTSOCK)) else: self.fail("close() should raise EBADF/ENOTSOCK") def testNewAttributes(self): # testing .family, .type and .protocol sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.assertEqual(sock.family, socket.AF_INET) if hasattr(socket, 'SOCK_CLOEXEC'): self.assertIn(sock.type, (socket.SOCK_STREAM | socket.SOCK_CLOEXEC, socket.SOCK_STREAM)) else: self.assertEqual(sock.type, socket.SOCK_STREAM) self.assertEqual(sock.proto, 0) sock.close() def test_getsockaddrarg(self): sock = socket.socket() self.addCleanup(sock.close) port = support.find_unused_port() big_port = port + 65536 neg_port = port - 65536 self.assertRaises(OverflowError, sock.bind, (HOST, big_port)) self.assertRaises(OverflowError, sock.bind, (HOST, neg_port)) # Since find_unused_port() is inherently subject to race conditions, we # call it a couple times if necessary. for i in itertools.count(): port = support.find_unused_port() try: sock.bind((HOST, port)) except OSError as e: if e.errno != errno.EADDRINUSE or i == 5: raise else: break @unittest.skipUnless(os.name == "nt", "Windows specific") def test_sock_ioctl(self): self.assertTrue(hasattr(socket.socket, 'ioctl')) self.assertTrue(hasattr(socket, 'SIO_RCVALL')) self.assertTrue(hasattr(socket, 'RCVALL_ON')) self.assertTrue(hasattr(socket, 'RCVALL_OFF')) self.assertTrue(hasattr(socket, 'SIO_KEEPALIVE_VALS')) s = socket.socket() self.addCleanup(s.close) self.assertRaises(ValueError, s.ioctl, -1, None) s.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 100, 100)) @unittest.skipUnless(os.name == "nt", "Windows specific") @unittest.skipUnless(hasattr(socket, 'SIO_LOOPBACK_FAST_PATH'), 'Loopback fast path support required for this test') def test_sio_loopback_fast_path(self): s = socket.socket() self.addCleanup(s.close) try: s.ioctl(socket.SIO_LOOPBACK_FAST_PATH, True) except OSError as exc: WSAEOPNOTSUPP = 10045 if exc.winerror == WSAEOPNOTSUPP: self.skipTest("SIO_LOOPBACK_FAST_PATH is defined but " "doesn't implemented in this Windows version") raise self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None) def testGetaddrinfo(self): try: socket.getaddrinfo('localhost', 80) except socket.gaierror as err: if err.errno == socket.EAI_SERVICE: # see http://bugs.python.org/issue1282647 self.skipTest("buggy libc version") raise # len of every sequence is supposed to be == 5 for info in socket.getaddrinfo(HOST, None): self.assertEqual(len(info), 5) # host can be a domain name, a string representation of an # IPv4/v6 address or None socket.getaddrinfo('localhost', 80) socket.getaddrinfo('127.0.0.1', 80) socket.getaddrinfo(None, 80) if support.IPV6_ENABLED: socket.getaddrinfo('::1', 80) # port can be a string service name such as "http", a numeric # port number or None socket.getaddrinfo(HOST, "http") socket.getaddrinfo(HOST, 80) socket.getaddrinfo(HOST, None) # test family and socktype filters infos = socket.getaddrinfo(HOST, 80, socket.AF_INET, socket.SOCK_STREAM) for family, type, _, _, _ in infos: self.assertEqual(family, socket.AF_INET) self.assertEqual(str(family), 'AddressFamily.AF_INET') self.assertEqual(type, socket.SOCK_STREAM) self.assertEqual(str(type), 'SocketKind.SOCK_STREAM') infos = socket.getaddrinfo(HOST, None, 0, socket.SOCK_STREAM) for _, socktype, _, _, _ in infos: self.assertEqual(socktype, socket.SOCK_STREAM) # test proto and flags arguments socket.getaddrinfo(HOST, None, 0, 0, socket.SOL_TCP) socket.getaddrinfo(HOST, None, 0, 0, 0, socket.AI_PASSIVE) # a server willing to support both IPv4 and IPv6 will # usually do this socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE) # test keyword arguments a = socket.getaddrinfo(HOST, None) b = socket.getaddrinfo(host=HOST, port=None) self.assertEqual(a, b) a = socket.getaddrinfo(HOST, None, socket.AF_INET) b = socket.getaddrinfo(HOST, None, family=socket.AF_INET) self.assertEqual(a, b) a = socket.getaddrinfo(HOST, None, 0, socket.SOCK_STREAM) b = socket.getaddrinfo(HOST, None, type=socket.SOCK_STREAM) self.assertEqual(a, b) a = socket.getaddrinfo(HOST, None, 0, 0, socket.SOL_TCP) b = socket.getaddrinfo(HOST, None, proto=socket.SOL_TCP) self.assertEqual(a, b) a = socket.getaddrinfo(HOST, None, 0, 0, 0, socket.AI_PASSIVE) b = socket.getaddrinfo(HOST, None, flags=socket.AI_PASSIVE) self.assertEqual(a, b) a = socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE) b = socket.getaddrinfo(host=None, port=0, family=socket.AF_UNSPEC, type=socket.SOCK_STREAM, proto=0, flags=socket.AI_PASSIVE) self.assertEqual(a, b) # Issue #6697. self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800') # Issue 17269: test workaround for OS X platform bug segfault if hasattr(socket, 'AI_NUMERICSERV'): try: # The arguments here are undefined and the call may succeed # or fail. All we care here is that it doesn't segfault. socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV) except socket.gaierror: pass def test_getnameinfo(self): # only IP addresses are allowed self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0) @unittest.skipUnless(support.is_resource_enabled('network'), 'network is not enabled') def test_idna(self): # Check for internet access before running test # (issue #12804, issue #25138). with support.transient_internet('python.org'): socket.gethostbyname('python.org') # these should all be successful domain = 'испытание.pythontest.net' socket.gethostbyname(domain) socket.gethostbyname_ex(domain) socket.getaddrinfo(domain,0,socket.AF_UNSPEC,socket.SOCK_STREAM) # this may not work if the forward lookup chooses the IPv6 address, as that doesn't # have a reverse entry yet # socket.gethostbyaddr('испытание.python.org') def check_sendall_interrupted(self, with_timeout): # socketpair() is not strictly required, but it makes things easier. if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'): self.skipTest("signal.alarm and socket.socketpair required for this test") # Our signal handlers clobber the C errno by calling a math function # with an invalid domain value. def ok_handler(*args): self.assertRaises(ValueError, math.acosh, 0) def raising_handler(*args): self.assertRaises(ValueError, math.acosh, 0) 1 // 0 c, s = socket.socketpair() old_alarm = signal.signal(signal.SIGALRM, raising_handler) try: if with_timeout: # Just above the one second minimum for signal.alarm c.settimeout(1.5) with self.assertRaises(ZeroDivisionError): signal.alarm(1) c.sendall(b"x" * support.SOCK_MAX_SIZE) if with_timeout: signal.signal(signal.SIGALRM, ok_handler) signal.alarm(1) self.assertRaises(socket.timeout, c.sendall, b"x" * support.SOCK_MAX_SIZE) finally: signal.alarm(0) signal.signal(signal.SIGALRM, old_alarm) c.close() s.close() def test_sendall_interrupted(self): self.check_sendall_interrupted(False) def test_sendall_interrupted_with_timeout(self): self.check_sendall_interrupted(True) def test_dealloc_warn(self): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) r = repr(sock) with self.assertWarns(ResourceWarning) as cm: sock = None support.gc_collect() self.assertIn(r, str(cm.warning.args[0])) # An open socket file object gets dereferenced after the socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) f = sock.makefile('rb') r = repr(sock) sock = None support.gc_collect() with self.assertWarns(ResourceWarning): f = None support.gc_collect() def test_name_closed_socketio(self): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: fp = sock.makefile("rb") fp.close() self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>") def test_unusable_closed_socketio(self): with socket.socket() as sock: fp = sock.makefile("rb", buffering=0) self.assertTrue(fp.readable()) self.assertFalse(fp.writable()) self.assertFalse(fp.seekable()) fp.close() self.assertRaises(ValueError, fp.readable) self.assertRaises(ValueError, fp.writable) self.assertRaises(ValueError, fp.seekable) def test_makefile_mode(self): for mode in 'r', 'rb', 'rw', 'w', 'wb': with self.subTest(mode=mode): with socket.socket() as sock: with sock.makefile(mode) as fp: self.assertEqual(fp.mode, mode) def test_makefile_invalid_mode(self): for mode in 'rt', 'x', '+', 'a': with self.subTest(mode=mode): with socket.socket() as sock: with self.assertRaisesRegex(ValueError, 'invalid mode'): sock.makefile(mode) def test_pickle(self): sock = socket.socket() with sock: for protocol in range(pickle.HIGHEST_PROTOCOL + 1): self.assertRaises(TypeError, pickle.dumps, sock, protocol) for protocol in range(pickle.HIGHEST_PROTOCOL + 1): family = pickle.loads(pickle.dumps(socket.AF_INET, protocol)) self.assertEqual(family, socket.AF_INET) type = pickle.loads(pickle.dumps(socket.SOCK_STREAM, protocol)) self.assertEqual(type, socket.SOCK_STREAM) def test_listen_backlog(self): for backlog in 0, -1: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as srv: srv.bind((HOST, 0)) srv.listen(backlog) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as srv: srv.bind((HOST, 0)) srv.listen() @support.cpython_only def test_listen_backlog_overflow(self): # Issue 15989 import _testcapi srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') def test_flowinfo(self): self.assertRaises(OverflowError, socket.getnameinfo, (support.HOSTv6, 0, 0xffffffff), 0) with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s: self.assertRaises(OverflowError, s.bind, (support.HOSTv6, 0, -10)) def test_str_for_enums(self): # Make sure that the AF_* and SOCK_* constants have enum-like string # reprs. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: self.assertEqual(str(s.family), 'AddressFamily.AF_INET') self.assertEqual(str(s.type), 'SocketKind.SOCK_STREAM') @unittest.skipIf(os.name == 'nt', 'Will not work on Windows') def test_uknown_socket_family_repr(self): # Test that when created with a family that's not one of the known # AF_*/SOCK_* constants, socket.family just returns the number. # # To do this we fool socket.socket into believing it already has an # open fd because on this path it doesn't actually verify the family and # type and populates the socket object. # # On Windows this trick won't work, so the test is skipped. fd, path = tempfile.mkstemp() self.addCleanup(os.unlink, path) with socket.socket(family=42424, type=13331, fileno=fd) as s: self.assertEqual(s.family, 42424) self.assertEqual(s.type, 13331) @unittest.skipUnless(hasattr(os, 'sendfile'), 'test needs os.sendfile()') def test__sendfile_use_sendfile(self): class File: def __init__(self, fd): self.fd = fd def fileno(self): return self.fd with socket.socket() as sock: fd = os.open(os.curdir, os.O_RDONLY) os.close(fd) with self.assertRaises(socket._GiveupOnSendfile): sock._sendfile_use_sendfile(File(fd)) with self.assertRaises(OverflowError): sock._sendfile_use_sendfile(File(2**1000)) with self.assertRaises(TypeError): sock._sendfile_use_sendfile(File(None)) @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') class BasicCANTest(unittest.TestCase): def testCrucialConstants(self): socket.AF_CAN socket.PF_CAN socket.CAN_RAW @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def testBCMConstants(self): socket.CAN_BCM # opcodes socket.CAN_BCM_TX_SETUP # create (cyclic) transmission task socket.CAN_BCM_TX_DELETE # remove (cyclic) transmission task socket.CAN_BCM_TX_READ # read properties of (cyclic) transmission task socket.CAN_BCM_TX_SEND # send one CAN frame socket.CAN_BCM_RX_SETUP # create RX content filter subscription socket.CAN_BCM_RX_DELETE # remove RX content filter subscription socket.CAN_BCM_RX_READ # read properties of RX content filter subscription socket.CAN_BCM_TX_STATUS # reply to TX_READ request socket.CAN_BCM_TX_EXPIRED # notification on performed transmissions (count=0) socket.CAN_BCM_RX_STATUS # reply to RX_READ request socket.CAN_BCM_RX_TIMEOUT # cyclic message is absent socket.CAN_BCM_RX_CHANGED # updated CAN frame (detected content change) def testCreateSocket(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: pass @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def testCreateBCMSocket(self): with socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM) as s: pass def testBindAny(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: s.bind(('', )) def testTooLongInterfaceName(self): # most systems limit IFNAMSIZ to 16, take 1024 to be sure with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: self.assertRaisesRegex(OSError, 'interface name too long', s.bind, ('x' * 1024,)) @unittest.skipUnless(hasattr(socket, "CAN_RAW_LOOPBACK"), 'socket.CAN_RAW_LOOPBACK required for this test.') def testLoopback(self): with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: for loopback in (0, 1): s.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_LOOPBACK, loopback) self.assertEqual(loopback, s.getsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_LOOPBACK)) @unittest.skipUnless(hasattr(socket, "CAN_RAW_FILTER"), 'socket.CAN_RAW_FILTER required for this test.') def testFilter(self): can_id, can_mask = 0x200, 0x700 can_filter = struct.pack("=II", can_id, can_mask) with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s: s.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, can_filter) self.assertEqual(can_filter, s.getsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, 8)) s.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, bytearray(can_filter)) @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') @unittest.skipUnless(thread, 'Threading required for this test.') class CANTest(ThreadedCANSocketTest): def __init__(self, methodName='runTest'): ThreadedCANSocketTest.__init__(self, methodName=methodName) @classmethod def build_can_frame(cls, can_id, data): """Build a CAN frame.""" can_dlc = len(data) data = data.ljust(8, b'\x00') return struct.pack(cls.can_frame_fmt, can_id, can_dlc, data) @classmethod def dissect_can_frame(cls, frame): """Dissect a CAN frame.""" can_id, can_dlc, data = struct.unpack(cls.can_frame_fmt, frame) return (can_id, can_dlc, data[:can_dlc]) def testSendFrame(self): cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf, cf) self.assertEqual(addr[0], self.interface) self.assertEqual(addr[1], socket.AF_CAN) def _testSendFrame(self): self.cf = self.build_can_frame(0x00, b'\x01\x02\x03\x04\x05') self.cli.send(self.cf) def testSendMaxFrame(self): cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf, cf) def _testSendMaxFrame(self): self.cf = self.build_can_frame(0x00, b'\x07' * 8) self.cli.send(self.cf) def testSendMultiFrames(self): cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf1, cf) cf, addr = self.s.recvfrom(self.bufsize) self.assertEqual(self.cf2, cf) def _testSendMultiFrames(self): self.cf1 = self.build_can_frame(0x07, b'\x44\x33\x22\x11') self.cli.send(self.cf1) self.cf2 = self.build_can_frame(0x12, b'\x99\x22\x33') self.cli.send(self.cf2) @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def _testBCM(self): cf, addr = self.cli.recvfrom(self.bufsize) self.assertEqual(self.cf, cf) can_id, can_dlc, data = self.dissect_can_frame(cf) self.assertEqual(self.can_id, can_id) self.assertEqual(self.data, data) @unittest.skipUnless(hasattr(socket, "CAN_BCM"), 'socket.CAN_BCM required for this test.') def testBCM(self): bcm = socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM) self.addCleanup(bcm.close) bcm.connect((self.interface,)) self.can_id = 0x123 self.data = bytes([0xc0, 0xff, 0xee]) self.cf = self.build_can_frame(self.can_id, self.data) opcode = socket.CAN_BCM_TX_SEND flags = 0 count = 0 ival1_seconds = ival1_usec = ival2_seconds = ival2_usec = 0 bcm_can_id = 0x0222 nframes = 1 assert len(self.cf) == 16 header = struct.pack(self.bcm_cmd_msg_fmt, opcode, flags, count, ival1_seconds, ival1_usec, ival2_seconds, ival2_usec, bcm_can_id, nframes, ) header_plus_frame = header + self.cf bytes_sent = bcm.send(header_plus_frame) self.assertEqual(bytes_sent, len(header_plus_frame)) @unittest.skipUnless(HAVE_SOCKET_RDS, 'RDS sockets required for this test.') class BasicRDSTest(unittest.TestCase): def testCrucialConstants(self): socket.PF_RDS def testCreateSocket(self): with socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) as s: pass def testSocketBufferSize(self): bufsize = 16384 with socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0) as s: s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, bufsize) s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, bufsize) @unittest.skipUnless(HAVE_SOCKET_RDS, 'RDS sockets required for this test.') @unittest.skipUnless(thread, 'Threading required for this test.') class RDSTest(ThreadedRDSSocketTest): def __init__(self, methodName='runTest'): ThreadedRDSSocketTest.__init__(self, methodName=methodName) def setUp(self): super().setUp() self.evt = threading.Event() def testSendAndRecv(self): data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data, data) self.assertEqual(self.cli_addr, addr) def _testSendAndRecv(self): self.data = b'spam' self.cli.sendto(self.data, 0, (HOST, self.port)) def testPeek(self): data, addr = self.serv.recvfrom(self.bufsize, socket.MSG_PEEK) self.assertEqual(self.data, data) data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data, data) def _testPeek(self): self.data = b'spam' self.cli.sendto(self.data, 0, (HOST, self.port)) @requireAttrs(socket.socket, 'recvmsg') def testSendAndRecvMsg(self): data, ancdata, msg_flags, addr = self.serv.recvmsg(self.bufsize) self.assertEqual(self.data, data) @requireAttrs(socket.socket, 'sendmsg') def _testSendAndRecvMsg(self): self.data = b'hello ' * 10 self.cli.sendmsg([self.data], (), 0, (HOST, self.port)) def testSendAndRecvMulti(self): data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data1, data) data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data2, data) def _testSendAndRecvMulti(self): self.data1 = b'bacon' self.cli.sendto(self.data1, 0, (HOST, self.port)) self.data2 = b'egg' self.cli.sendto(self.data2, 0, (HOST, self.port)) def testSelect(self): r, w, x = select.select([self.serv], [], [], 3.0) self.assertIn(self.serv, r) data, addr = self.serv.recvfrom(self.bufsize) self.assertEqual(self.data, data) def _testSelect(self): self.data = b'select' self.cli.sendto(self.data, 0, (HOST, self.port)) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicTCPTest(SocketConnectedTest): def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecv(self): # Testing large receive over TCP msg = self.cli_conn.recv(1024) self.assertEqual(msg, MSG) def _testRecv(self): self.serv_conn.send(MSG) def testOverFlowRecv(self): # Testing receive in chunks over TCP seg1 = self.cli_conn.recv(len(MSG) - 3) seg2 = self.cli_conn.recv(1024) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testOverFlowRecv(self): self.serv_conn.send(MSG) def testRecvFrom(self): # Testing large recvfrom() over TCP msg, addr = self.cli_conn.recvfrom(1024) self.assertEqual(msg, MSG) def _testRecvFrom(self): self.serv_conn.send(MSG) def testOverFlowRecvFrom(self): # Testing recvfrom() in chunks over TCP seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) seg2, addr = self.cli_conn.recvfrom(1024) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testOverFlowRecvFrom(self): self.serv_conn.send(MSG) def testSendAll(self): # Testing sendall() with a 2048 byte string over TCP msg = b'' while 1: read = self.cli_conn.recv(1024) if not read: break msg += read self.assertEqual(msg, b'f' * 2048) def _testSendAll(self): big_chunk = b'f' * 2048 self.serv_conn.sendall(big_chunk) def testFromFd(self): # Testing fromfd() fd = self.cli_conn.fileno() sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) self.assertIsInstance(sock, socket.socket) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testFromFd(self): self.serv_conn.send(MSG) def testDup(self): # Testing dup() sock = self.cli_conn.dup() self.addCleanup(sock.close) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testDup(self): self.serv_conn.send(MSG) def testShutdown(self): # Testing shutdown() msg = self.cli_conn.recv(1024) self.assertEqual(msg, MSG) # wait for _testShutdown to finish: on OS X, when the server # closes the connection the client also becomes disconnected, # and the client's shutdown call will fail. (Issue #4397.) self.done.wait() def _testShutdown(self): self.serv_conn.send(MSG) self.serv_conn.shutdown(2) testShutdown_overflow = support.cpython_only(testShutdown) @support.cpython_only def _testShutdown_overflow(self): import _testcapi self.serv_conn.send(MSG) # Issue 15989 self.assertRaises(OverflowError, self.serv_conn.shutdown, _testcapi.INT_MAX + 1) self.assertRaises(OverflowError, self.serv_conn.shutdown, 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) def testDetach(self): # Testing detach() fileno = self.cli_conn.fileno() f = self.cli_conn.detach() self.assertEqual(f, fileno) # cli_conn cannot be used anymore... self.assertTrue(self.cli_conn._closed) self.assertRaises(OSError, self.cli_conn.recv, 1024) self.cli_conn.close() # ...but we can create another socket using the (still open) # file descriptor sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f) self.addCleanup(sock.close) msg = sock.recv(1024) self.assertEqual(msg, MSG) def _testDetach(self): self.serv_conn.send(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicUDPTest(ThreadedUDPSocketTest): def __init__(self, methodName='runTest'): ThreadedUDPSocketTest.__init__(self, methodName=methodName) def testSendtoAndRecv(self): # Testing sendto() and Recv() over UDP msg = self.serv.recv(len(MSG)) self.assertEqual(msg, MSG) def _testSendtoAndRecv(self): self.cli.sendto(MSG, 0, (HOST, self.port)) def testRecvFrom(self): # Testing recvfrom() over UDP msg, addr = self.serv.recvfrom(len(MSG)) self.assertEqual(msg, MSG) def _testRecvFrom(self): self.cli.sendto(MSG, 0, (HOST, self.port)) def testRecvFromNegative(self): # Negative lengths passed to recvfrom should give ValueError. self.assertRaises(ValueError, self.serv.recvfrom, -1) def _testRecvFromNegative(self): self.cli.sendto(MSG, 0, (HOST, self.port)) # Tests for the sendmsg()/recvmsg() interface. Where possible, the # same test code is used with different families and types of socket # (e.g. stream, datagram), and tests using recvmsg() are repeated # using recvmsg_into(). # # The generic test classes such as SendmsgTests and # RecvmsgGenericTests inherit from SendrecvmsgBase and expect to be # supplied with sockets cli_sock and serv_sock representing the # client's and the server's end of the connection respectively, and # attributes cli_addr and serv_addr holding their (numeric where # appropriate) addresses. # # The final concrete test classes combine these with subclasses of # SocketTestBase which set up client and server sockets of a specific # type, and with subclasses of SendrecvmsgBase such as # SendrecvmsgDgramBase and SendrecvmsgConnectedBase which map these # sockets to cli_sock and serv_sock and override the methods and # attributes of SendrecvmsgBase to fill in destination addresses if # needed when sending, check for specific flags in msg_flags, etc. # # RecvmsgIntoMixin provides a version of doRecvmsg() implemented using # recvmsg_into(). # XXX: like the other datagram (UDP) tests in this module, the code # here assumes that datagram delivery on the local machine will be # reliable. class SendrecvmsgBase(ThreadSafeCleanupTestCase): # Base class for sendmsg()/recvmsg() tests. # Time in seconds to wait before considering a test failed, or # None for no timeout. Not all tests actually set a timeout. fail_timeout = 3.0 def setUp(self): self.misc_event = threading.Event() super().setUp() def sendToServer(self, msg): # Send msg to the server. return self.cli_sock.send(msg) # Tuple of alternative default arguments for sendmsg() when called # via sendmsgToServer() (e.g. to include a destination address). sendmsg_to_server_defaults = () def sendmsgToServer(self, *args): # Call sendmsg() on self.cli_sock with the given arguments, # filling in any arguments which are not supplied with the # corresponding items of self.sendmsg_to_server_defaults, if # any. return self.cli_sock.sendmsg( *(args + self.sendmsg_to_server_defaults[len(args):])) def doRecvmsg(self, sock, bufsize, *args): # Call recvmsg() on sock with given arguments and return its # result. Should be used for tests which can use either # recvmsg() or recvmsg_into() - RecvmsgIntoMixin overrides # this method with one which emulates it using recvmsg_into(), # thus allowing the same test to be used for both methods. result = sock.recvmsg(bufsize, *args) self.registerRecvmsgResult(result) return result def registerRecvmsgResult(self, result): # Called by doRecvmsg() with the return value of recvmsg() or # recvmsg_into(). Can be overridden to arrange cleanup based # on the returned ancillary data, for instance. pass def checkRecvmsgAddress(self, addr1, addr2): # Called to compare the received address with the address of # the peer. self.assertEqual(addr1, addr2) # Flags that are normally unset in msg_flags msg_flags_common_unset = 0 for name in ("MSG_CTRUNC", "MSG_OOB"): msg_flags_common_unset |= getattr(socket, name, 0) # Flags that are normally set msg_flags_common_set = 0 # Flags set when a complete record has been received (e.g. MSG_EOR # for SCTP) msg_flags_eor_indicator = 0 # Flags set when a complete record has not been received # (e.g. MSG_TRUNC for datagram sockets) msg_flags_non_eor_indicator = 0 def checkFlags(self, flags, eor=None, checkset=0, checkunset=0, ignore=0): # Method to check the value of msg_flags returned by recvmsg[_into](). # # Checks that all bits in msg_flags_common_set attribute are # set in "flags" and all bits in msg_flags_common_unset are # unset. # # The "eor" argument specifies whether the flags should # indicate that a full record (or datagram) has been received. # If "eor" is None, no checks are done; otherwise, checks # that: # # * if "eor" is true, all bits in msg_flags_eor_indicator are # set and all bits in msg_flags_non_eor_indicator are unset # # * if "eor" is false, all bits in msg_flags_non_eor_indicator # are set and all bits in msg_flags_eor_indicator are unset # # If "checkset" and/or "checkunset" are supplied, they require # the given bits to be set or unset respectively, overriding # what the attributes require for those bits. # # If any bits are set in "ignore", they will not be checked, # regardless of the other inputs. # # Will raise Exception if the inputs require a bit to be both # set and unset, and it is not ignored. defaultset = self.msg_flags_common_set defaultunset = self.msg_flags_common_unset if eor: defaultset |= self.msg_flags_eor_indicator defaultunset |= self.msg_flags_non_eor_indicator elif eor is not None: defaultset |= self.msg_flags_non_eor_indicator defaultunset |= self.msg_flags_eor_indicator # Function arguments override defaults defaultset &= ~checkunset defaultunset &= ~checkset # Merge arguments with remaining defaults, and check for conflicts checkset |= defaultset checkunset |= defaultunset inboth = checkset & checkunset & ~ignore if inboth: raise Exception("contradictory set, unset requirements for flags " "{0:#x}".format(inboth)) # Compare with given msg_flags value mask = (checkset | checkunset) & ~ignore self.assertEqual(flags & mask, checkset & mask) class RecvmsgIntoMixin(SendrecvmsgBase): # Mixin to implement doRecvmsg() using recvmsg_into(). def doRecvmsg(self, sock, bufsize, *args): buf = bytearray(bufsize) result = sock.recvmsg_into([buf], *args) self.registerRecvmsgResult(result) self.assertGreaterEqual(result[0], 0) self.assertLessEqual(result[0], bufsize) return (bytes(buf[:result[0]]),) + result[1:] class SendrecvmsgDgramFlagsBase(SendrecvmsgBase): # Defines flags to be checked in msg_flags for datagram sockets. @property def msg_flags_non_eor_indicator(self): return super().msg_flags_non_eor_indicator | socket.MSG_TRUNC class SendrecvmsgSCTPFlagsBase(SendrecvmsgBase): # Defines flags to be checked in msg_flags for SCTP sockets. @property def msg_flags_eor_indicator(self): return super().msg_flags_eor_indicator | socket.MSG_EOR class SendrecvmsgConnectionlessBase(SendrecvmsgBase): # Base class for tests on connectionless-mode sockets. Users must # supply sockets on attributes cli and serv to be mapped to # cli_sock and serv_sock respectively. @property def serv_sock(self): return self.serv @property def cli_sock(self): return self.cli @property def sendmsg_to_server_defaults(self): return ([], [], 0, self.serv_addr) def sendToServer(self, msg): return self.cli_sock.sendto(msg, self.serv_addr) class SendrecvmsgConnectedBase(SendrecvmsgBase): # Base class for tests on connected sockets. Users must supply # sockets on attributes serv_conn and cli_conn (representing the # connections *to* the server and the client), to be mapped to # cli_sock and serv_sock respectively. @property def serv_sock(self): return self.cli_conn @property def cli_sock(self): return self.serv_conn def checkRecvmsgAddress(self, addr1, addr2): # Address is currently "unspecified" for a connected socket, # so we don't examine it pass class SendrecvmsgServerTimeoutBase(SendrecvmsgBase): # Base class to set a timeout on server's socket. def setUp(self): super().setUp() self.serv_sock.settimeout(self.fail_timeout) class SendmsgTests(SendrecvmsgServerTimeoutBase): # Tests for sendmsg() which can use any socket type and do not # involve recvmsg() or recvmsg_into(). def testSendmsg(self): # Send a simple message with sendmsg(). self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsg(self): self.assertEqual(self.sendmsgToServer([MSG]), len(MSG)) def testSendmsgDataGenerator(self): # Send from buffer obtained from a generator (not a sequence). self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgDataGenerator(self): self.assertEqual(self.sendmsgToServer((o for o in [MSG])), len(MSG)) def testSendmsgAncillaryGenerator(self): # Gather (empty) ancillary data from a generator. self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgAncillaryGenerator(self): self.assertEqual(self.sendmsgToServer([MSG], (o for o in [])), len(MSG)) def testSendmsgArray(self): # Send data from an array instead of the usual bytes object. self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgArray(self): self.assertEqual(self.sendmsgToServer([array.array("B", MSG)]), len(MSG)) def testSendmsgGather(self): # Send message data from more than one buffer (gather write). self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgGather(self): self.assertEqual(self.sendmsgToServer([MSG[:3], MSG[3:]]), len(MSG)) def testSendmsgBadArgs(self): # Check that sendmsg() rejects invalid arguments. self.assertEqual(self.serv_sock.recv(1000), b"done") def _testSendmsgBadArgs(self): self.assertRaises(TypeError, self.cli_sock.sendmsg) self.assertRaises(TypeError, self.sendmsgToServer, b"not in an iterable") self.assertRaises(TypeError, self.sendmsgToServer, object()) self.assertRaises(TypeError, self.sendmsgToServer, [object()]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG, object()]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], object()) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [], object()) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [], 0, object()) self.sendToServer(b"done") def testSendmsgBadCmsg(self): # Check that invalid ancillary data items are rejected. self.assertEqual(self.serv_sock.recv(1000), b"done") def _testSendmsgBadCmsg(self): self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [object()]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(object(), 0, b"data")]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, object(), b"data")]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0, object())]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0)]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0, b"data", 42)]) self.sendToServer(b"done") @requireAttrs(socket, "CMSG_SPACE") def testSendmsgBadMultiCmsg(self): # Check that invalid ancillary data items are rejected when # more than one item is present. self.assertEqual(self.serv_sock.recv(1000), b"done") @testSendmsgBadMultiCmsg.client_skip def _testSendmsgBadMultiCmsg(self): self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [0, 0, b""]) self.assertRaises(TypeError, self.sendmsgToServer, [MSG], [(0, 0, b""), object()]) self.sendToServer(b"done") def testSendmsgExcessCmsgReject(self): # Check that sendmsg() rejects excess ancillary data items # when the number that can be sent is limited. self.assertEqual(self.serv_sock.recv(1000), b"done") def _testSendmsgExcessCmsgReject(self): if not hasattr(socket, "CMSG_SPACE"): # Can only send one item with self.assertRaises(OSError) as cm: self.sendmsgToServer([MSG], [(0, 0, b""), (0, 0, b"")]) self.assertIsNone(cm.exception.errno) self.sendToServer(b"done") def testSendmsgAfterClose(self): # Check that sendmsg() fails on a closed socket. pass def _testSendmsgAfterClose(self): self.cli_sock.close() self.assertRaises(OSError, self.sendmsgToServer, [MSG]) class SendmsgStreamTests(SendmsgTests): # Tests for sendmsg() which require a stream socket and do not # involve recvmsg() or recvmsg_into(). def testSendmsgExplicitNoneAddr(self): # Check that peer address can be specified as None. self.assertEqual(self.serv_sock.recv(len(MSG)), MSG) def _testSendmsgExplicitNoneAddr(self): self.assertEqual(self.sendmsgToServer([MSG], [], 0, None), len(MSG)) def testSendmsgTimeout(self): # Check that timeout works with sendmsg(). self.assertEqual(self.serv_sock.recv(512), b"a"*512) self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) def _testSendmsgTimeout(self): try: self.cli_sock.settimeout(0.03) try: while True: self.sendmsgToServer([b"a"*512]) except socket.timeout: pass except OSError as exc: if exc.errno != errno.ENOMEM: raise # bpo-33937 the test randomly fails on Travis CI with # "OSError: [Errno 12] Cannot allocate memory" else: self.fail("socket.timeout not raised") finally: self.misc_event.set() # XXX: would be nice to have more tests for sendmsg flags argument. # Linux supports MSG_DONTWAIT when sending, but in general, it # only works when receiving. Could add other platforms if they # support it too. @skipWithClientIf(sys.platform not in {"linux"}, "MSG_DONTWAIT not known to work on this platform when " "sending") def testSendmsgDontWait(self): # Check that MSG_DONTWAIT in flags causes non-blocking behaviour. self.assertEqual(self.serv_sock.recv(512), b"a"*512) self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) @testSendmsgDontWait.client_skip def _testSendmsgDontWait(self): try: with self.assertRaises(OSError) as cm: while True: self.sendmsgToServer([b"a"*512], [], socket.MSG_DONTWAIT) # bpo-33937: catch also ENOMEM, the test randomly fails on Travis CI # with "OSError: [Errno 12] Cannot allocate memory" self.assertIn(cm.exception.errno, (errno.EAGAIN, errno.EWOULDBLOCK, errno.ENOMEM)) finally: self.misc_event.set() class SendmsgConnectionlessTests(SendmsgTests): # Tests for sendmsg() which require a connectionless-mode # (e.g. datagram) socket, and do not involve recvmsg() or # recvmsg_into(). def testSendmsgNoDestAddr(self): # Check that sendmsg() fails when no destination address is # given for unconnected socket. pass def _testSendmsgNoDestAddr(self): self.assertRaises(OSError, self.cli_sock.sendmsg, [MSG]) self.assertRaises(OSError, self.cli_sock.sendmsg, [MSG], [], 0, None) class RecvmsgGenericTests(SendrecvmsgBase): # Tests for recvmsg() which can also be emulated using # recvmsg_into(), and can use any socket type. def testRecvmsg(self): # Receive a simple message with recvmsg[_into](). msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsg(self): self.sendToServer(MSG) def testRecvmsgExplicitDefaults(self): # Test recvmsg[_into]() with default arguments provided explicitly. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 0, 0) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgExplicitDefaults(self): self.sendToServer(MSG) def testRecvmsgShorter(self): # Receive a message smaller than buffer. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) + 42) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgShorter(self): self.sendToServer(MSG) # FreeBSD < 8 doesn't always set the MSG_TRUNC flag when a truncated # datagram is received (issue #13001). @support.requires_freebsd_version(8) def testRecvmsgTrunc(self): # Receive part of message, check for truncation indicators. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) - 3) self.assertEqual(msg, MSG[:-3]) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=False) @support.requires_freebsd_version(8) def _testRecvmsgTrunc(self): self.sendToServer(MSG) def testRecvmsgShortAncillaryBuf(self): # Test ancillary data buffer too small to hold any ancillary data. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 1) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgShortAncillaryBuf(self): self.sendToServer(MSG) def testRecvmsgLongAncillaryBuf(self): # Test large ancillary data buffer. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 10240) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgLongAncillaryBuf(self): self.sendToServer(MSG) def testRecvmsgAfterClose(self): # Check that recvmsg[_into]() fails on a closed socket. self.serv_sock.close() self.assertRaises(OSError, self.doRecvmsg, self.serv_sock, 1024) def _testRecvmsgAfterClose(self): pass def testRecvmsgTimeout(self): # Check that timeout works. try: self.serv_sock.settimeout(0.03) self.assertRaises(socket.timeout, self.doRecvmsg, self.serv_sock, len(MSG)) finally: self.misc_event.set() def _testRecvmsgTimeout(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) @requireAttrs(socket, "MSG_PEEK") def testRecvmsgPeek(self): # Check that MSG_PEEK in flags enables examination of pending # data without consuming it. # Receive part of data with MSG_PEEK. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) - 3, 0, socket.MSG_PEEK) self.assertEqual(msg, MSG[:-3]) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) # Ignoring MSG_TRUNC here (so this test is the same for stream # and datagram sockets). Some wording in POSIX seems to # suggest that it needn't be set when peeking, but that may # just be a slip. self.checkFlags(flags, eor=False, ignore=getattr(socket, "MSG_TRUNC", 0)) # Receive all data with MSG_PEEK. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 0, socket.MSG_PEEK) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) # Check that the same data can still be received normally. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) @testRecvmsgPeek.client_skip def _testRecvmsgPeek(self): self.sendToServer(MSG) @requireAttrs(socket.socket, "sendmsg") def testRecvmsgFromSendmsg(self): # Test receiving with recvmsg[_into]() when message is sent # using sendmsg(). self.serv_sock.settimeout(self.fail_timeout) msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) @testRecvmsgFromSendmsg.client_skip def _testRecvmsgFromSendmsg(self): self.assertEqual(self.sendmsgToServer([MSG[:3], MSG[3:]]), len(MSG)) class RecvmsgGenericStreamTests(RecvmsgGenericTests): # Tests which require a stream socket and can use either recvmsg() # or recvmsg_into(). def testRecvmsgEOF(self): # Receive end-of-stream indicator (b"", peer socket closed). msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, 1024) self.assertEqual(msg, b"") self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=None) # Might not have end-of-record marker def _testRecvmsgEOF(self): self.cli_sock.close() def testRecvmsgOverflow(self): # Receive a message in more than one chunk. seg1, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG) - 3) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=False) seg2, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, 1024) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) msg = seg1 + seg2 self.assertEqual(msg, MSG) def _testRecvmsgOverflow(self): self.sendToServer(MSG) class RecvmsgTests(RecvmsgGenericTests): # Tests for recvmsg() which can use any socket type. def testRecvmsgBadArgs(self): # Check that recvmsg() rejects invalid arguments. self.assertRaises(TypeError, self.serv_sock.recvmsg) self.assertRaises(ValueError, self.serv_sock.recvmsg, -1, 0, 0) self.assertRaises(ValueError, self.serv_sock.recvmsg, len(MSG), -1, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, [bytearray(10)], 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, object(), 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, len(MSG), object(), 0) self.assertRaises(TypeError, self.serv_sock.recvmsg, len(MSG), 0, object()) msg, ancdata, flags, addr = self.serv_sock.recvmsg(len(MSG), 0, 0) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgBadArgs(self): self.sendToServer(MSG) class RecvmsgIntoTests(RecvmsgIntoMixin, RecvmsgGenericTests): # Tests for recvmsg_into() which can use any socket type. def testRecvmsgIntoBadArgs(self): # Check that recvmsg_into() rejects invalid arguments. buf = bytearray(len(MSG)) self.assertRaises(TypeError, self.serv_sock.recvmsg_into) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, len(MSG), 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, buf, 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [object()], 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [b"I'm not writable"], 0, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [buf, object()], 0, 0) self.assertRaises(ValueError, self.serv_sock.recvmsg_into, [buf], -1, 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [buf], object(), 0) self.assertRaises(TypeError, self.serv_sock.recvmsg_into, [buf], 0, object()) nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into([buf], 0, 0) self.assertEqual(nbytes, len(MSG)) self.assertEqual(buf, bytearray(MSG)) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoBadArgs(self): self.sendToServer(MSG) def testRecvmsgIntoGenerator(self): # Receive into buffer obtained from a generator (not a sequence). buf = bytearray(len(MSG)) nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into( (o for o in [buf])) self.assertEqual(nbytes, len(MSG)) self.assertEqual(buf, bytearray(MSG)) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoGenerator(self): self.sendToServer(MSG) def testRecvmsgIntoArray(self): # Receive into an array rather than the usual bytearray. buf = array.array("B", [0] * len(MSG)) nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into([buf]) self.assertEqual(nbytes, len(MSG)) self.assertEqual(buf.tobytes(), MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoArray(self): self.sendToServer(MSG) def testRecvmsgIntoScatter(self): # Receive into multiple buffers (scatter write). b1 = bytearray(b"----") b2 = bytearray(b"0123456789") b3 = bytearray(b"--------------") nbytes, ancdata, flags, addr = self.serv_sock.recvmsg_into( [b1, memoryview(b2)[2:9], b3]) self.assertEqual(nbytes, len(b"Mary had a little lamb")) self.assertEqual(b1, bytearray(b"Mary")) self.assertEqual(b2, bytearray(b"01 had a 9")) self.assertEqual(b3, bytearray(b"little lamb---")) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True) def _testRecvmsgIntoScatter(self): self.sendToServer(b"Mary had a little lamb") class CmsgMacroTests(unittest.TestCase): # Test the functions CMSG_LEN() and CMSG_SPACE(). Tests # assumptions used by sendmsg() and recvmsg[_into](), which share # code with these functions. # Match the definition in socketmodule.c try: import _testcapi except ImportError: socklen_t_limit = 0x7fffffff else: socklen_t_limit = min(0x7fffffff, _testcapi.INT_MAX) @requireAttrs(socket, "CMSG_LEN") def testCMSG_LEN(self): # Test CMSG_LEN() with various valid and invalid values, # checking the assumptions used by recvmsg() and sendmsg(). toobig = self.socklen_t_limit - socket.CMSG_LEN(0) + 1 values = list(range(257)) + list(range(toobig - 257, toobig)) # struct cmsghdr has at least three members, two of which are ints self.assertGreater(socket.CMSG_LEN(0), array.array("i").itemsize * 2) for n in values: ret = socket.CMSG_LEN(n) # This is how recvmsg() calculates the data size self.assertEqual(ret - socket.CMSG_LEN(0), n) self.assertLessEqual(ret, self.socklen_t_limit) self.assertRaises(OverflowError, socket.CMSG_LEN, -1) # sendmsg() shares code with these functions, and requires # that it reject values over the limit. self.assertRaises(OverflowError, socket.CMSG_LEN, toobig) self.assertRaises(OverflowError, socket.CMSG_LEN, sys.maxsize) @requireAttrs(socket, "CMSG_SPACE") def testCMSG_SPACE(self): # Test CMSG_SPACE() with various valid and invalid values, # checking the assumptions used by sendmsg(). toobig = self.socklen_t_limit - socket.CMSG_SPACE(1) + 1 values = list(range(257)) + list(range(toobig - 257, toobig)) last = socket.CMSG_SPACE(0) # struct cmsghdr has at least three members, two of which are ints self.assertGreater(last, array.array("i").itemsize * 2) for n in values: ret = socket.CMSG_SPACE(n) self.assertGreaterEqual(ret, last) self.assertGreaterEqual(ret, socket.CMSG_LEN(n)) self.assertGreaterEqual(ret, n + socket.CMSG_LEN(0)) self.assertLessEqual(ret, self.socklen_t_limit) last = ret self.assertRaises(OverflowError, socket.CMSG_SPACE, -1) # sendmsg() shares code with these functions, and requires # that it reject values over the limit. self.assertRaises(OverflowError, socket.CMSG_SPACE, toobig) self.assertRaises(OverflowError, socket.CMSG_SPACE, sys.maxsize) class SCMRightsTest(SendrecvmsgServerTimeoutBase): # Tests for file descriptor passing on Unix-domain sockets. # Invalid file descriptor value that's unlikely to evaluate to a # real FD even if one of its bytes is replaced with a different # value (which shouldn't actually happen). badfd = -0x5555 def newFDs(self, n): # Return a list of n file descriptors for newly-created files # containing their list indices as ASCII numbers. fds = [] for i in range(n): fd, path = tempfile.mkstemp() self.addCleanup(os.unlink, path) self.addCleanup(os.close, fd) os.write(fd, str(i).encode()) fds.append(fd) return fds def checkFDs(self, fds): # Check that the file descriptors in the given list contain # their correct list indices as ASCII numbers. for n, fd in enumerate(fds): os.lseek(fd, 0, os.SEEK_SET) self.assertEqual(os.read(fd, 1024), str(n).encode()) def registerRecvmsgResult(self, result): self.addCleanup(self.closeRecvmsgFDs, result) def closeRecvmsgFDs(self, recvmsg_result): # Close all file descriptors specified in the ancillary data # of the given return value from recvmsg() or recvmsg_into(). for cmsg_level, cmsg_type, cmsg_data in recvmsg_result[1]: if (cmsg_level == socket.SOL_SOCKET and cmsg_type == socket.SCM_RIGHTS): fds = array.array("i") fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) for fd in fds: os.close(fd) def createAndSendFDs(self, n): # Send n new file descriptors created by newFDs() to the # server, with the constant MSG as the non-ancillary data. self.assertEqual( self.sendmsgToServer([MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", self.newFDs(n)))]), len(MSG)) def checkRecvmsgFDs(self, numfds, result, maxcmsgs=1, ignoreflags=0): # Check that constant MSG was received with numfds file # descriptors in a maximum of maxcmsgs control messages (which # must contain only complete integers). By default, check # that MSG_CTRUNC is unset, but ignore any flags in # ignoreflags. msg, ancdata, flags, addr = result self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertIsInstance(ancdata, list) self.assertLessEqual(len(ancdata), maxcmsgs) fds = array.array("i") for item in ancdata: self.assertIsInstance(item, tuple) cmsg_level, cmsg_type, cmsg_data = item self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) self.assertIsInstance(cmsg_data, bytes) self.assertEqual(len(cmsg_data) % SIZEOF_INT, 0) fds.frombytes(cmsg_data) self.assertEqual(len(fds), numfds) self.checkFDs(fds) def testFDPassSimple(self): # Pass a single FD (array read from bytes object). self.checkRecvmsgFDs(1, self.doRecvmsg(self.serv_sock, len(MSG), 10240)) def _testFDPassSimple(self): self.assertEqual( self.sendmsgToServer( [MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", self.newFDs(1)).tobytes())]), len(MSG)) def testMultipleFDPass(self): # Pass multiple FDs in a single array. self.checkRecvmsgFDs(4, self.doRecvmsg(self.serv_sock, len(MSG), 10240)) def _testMultipleFDPass(self): self.createAndSendFDs(4) @requireAttrs(socket, "CMSG_SPACE") def testFDPassCMSG_SPACE(self): # Test using CMSG_SPACE() to calculate ancillary buffer size. self.checkRecvmsgFDs( 4, self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_SPACE(4 * SIZEOF_INT))) @testFDPassCMSG_SPACE.client_skip def _testFDPassCMSG_SPACE(self): self.createAndSendFDs(4) def testFDPassCMSG_LEN(self): # Test using CMSG_LEN() to calculate ancillary buffer size. self.checkRecvmsgFDs(1, self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_LEN(4 * SIZEOF_INT)), # RFC 3542 says implementations may set # MSG_CTRUNC if there isn't enough space # for trailing padding. ignoreflags=socket.MSG_CTRUNC) def _testFDPassCMSG_LEN(self): self.createAndSendFDs(1) @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparate(self): # Pass two FDs in two separate arrays. Arrays may be combined # into a single control message by the OS. self.checkRecvmsgFDs(2, self.doRecvmsg(self.serv_sock, len(MSG), 10240), maxcmsgs=2) @testFDPassSeparate.client_skip @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") def _testFDPassSeparate(self): fd0, fd1 = self.newFDs(2) self.assertEqual( self.sendmsgToServer([MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd0])), (socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd1]))]), len(MSG)) @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparateMinSpace(self): # Pass two FDs in two separate arrays, receiving them into the # minimum space for two arrays. num_fds = 2 self.checkRecvmsgFDs(num_fds, self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT * num_fds)), maxcmsgs=2, ignoreflags=socket.MSG_CTRUNC) @testFDPassSeparateMinSpace.client_skip @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397") def _testFDPassSeparateMinSpace(self): fd0, fd1 = self.newFDs(2) self.assertEqual( self.sendmsgToServer([MSG], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd0])), (socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd1]))]), len(MSG)) def sendAncillaryIfPossible(self, msg, ancdata): # Try to send msg and ancdata to server, but if the system # call fails, just send msg with no ancillary data. try: nbytes = self.sendmsgToServer([msg], ancdata) except OSError as e: # Check that it was the system call that failed self.assertIsInstance(e.errno, int) nbytes = self.sendmsgToServer([msg]) self.assertEqual(nbytes, len(msg)) @unittest.skipIf(sys.platform == "darwin", "see issue #24725") def testFDPassEmpty(self): # Try to pass an empty FD array. Can receive either no array # or an empty array. self.checkRecvmsgFDs(0, self.doRecvmsg(self.serv_sock, len(MSG), 10240), ignoreflags=socket.MSG_CTRUNC) def _testFDPassEmpty(self): self.sendAncillaryIfPossible(MSG, [(socket.SOL_SOCKET, socket.SCM_RIGHTS, b"")]) def testFDPassPartialInt(self): # Try to pass a truncated FD array. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 10240) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, ignore=socket.MSG_CTRUNC) self.assertLessEqual(len(ancdata), 1) for cmsg_level, cmsg_type, cmsg_data in ancdata: self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) self.assertLess(len(cmsg_data), SIZEOF_INT) def _testFDPassPartialInt(self): self.sendAncillaryIfPossible( MSG, [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [self.badfd]).tobytes()[:-1])]) @requireAttrs(socket, "CMSG_SPACE") def testFDPassPartialIntInMiddle(self): # Try to pass two FD arrays, the first of which is truncated. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), 10240) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, ignore=socket.MSG_CTRUNC) self.assertLessEqual(len(ancdata), 2) fds = array.array("i") # Arrays may have been combined in a single control message for cmsg_level, cmsg_type, cmsg_data in ancdata: self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) self.assertLessEqual(len(fds), 2) self.checkFDs(fds) @testFDPassPartialIntInMiddle.client_skip def _testFDPassPartialIntInMiddle(self): fd0, fd1 = self.newFDs(2) self.sendAncillaryIfPossible( MSG, [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd0, self.badfd]).tobytes()[:-1]), (socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", [fd1]))]) def checkTruncatedHeader(self, result, ignoreflags=0): # Check that no ancillary data items are returned when data is # truncated inside the cmsghdr structure. msg, ancdata, flags, addr = result self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, ignore=ignoreflags) def testCmsgTruncNoBufSize(self): # Check that no ancillary data is received when no buffer size # is specified. self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG)), # BSD seems to set MSG_CTRUNC only # if an item has been partially # received. ignoreflags=socket.MSG_CTRUNC) def _testCmsgTruncNoBufSize(self): self.createAndSendFDs(1) def testCmsgTrunc0(self): # Check that no ancillary data is received when buffer size is 0. self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 0), ignoreflags=socket.MSG_CTRUNC) def _testCmsgTrunc0(self): self.createAndSendFDs(1) # Check that no ancillary data is returned for various non-zero # (but still too small) buffer sizes. def testCmsgTrunc1(self): self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 1)) def _testCmsgTrunc1(self): self.createAndSendFDs(1) def testCmsgTrunc2Int(self): # The cmsghdr structure has at least three members, two of # which are ints, so we still shouldn't see any ancillary # data. self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), SIZEOF_INT * 2)) def _testCmsgTrunc2Int(self): self.createAndSendFDs(1) def testCmsgTruncLen0Minus1(self): self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_LEN(0) - 1)) def _testCmsgTruncLen0Minus1(self): self.createAndSendFDs(1) # The following tests try to truncate the control message in the # middle of the FD array. def checkTruncatedArray(self, ancbuf, maxdata, mindata=0): # Check that file descriptor data is truncated to between # mindata and maxdata bytes when received with buffer size # ancbuf, and that any complete file descriptor numbers are # valid. msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbuf) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC) if mindata == 0 and ancdata == []: return self.assertEqual(len(ancdata), 1) cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.SOL_SOCKET) self.assertEqual(cmsg_type, socket.SCM_RIGHTS) self.assertGreaterEqual(len(cmsg_data), mindata) self.assertLessEqual(len(cmsg_data), maxdata) fds = array.array("i") fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) self.checkFDs(fds) def testCmsgTruncLen0(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0) def _testCmsgTruncLen0(self): self.createAndSendFDs(1) def testCmsgTruncLen0Plus1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1) def _testCmsgTruncLen0Plus1(self): self.createAndSendFDs(2) def testCmsgTruncLen1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT), maxdata=SIZEOF_INT) def _testCmsgTruncLen1(self): self.createAndSendFDs(2) def testCmsgTruncLen2Minus1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1, maxdata=(2 * SIZEOF_INT) - 1) def _testCmsgTruncLen2Minus1(self): self.createAndSendFDs(2) class RFC3542AncillaryTest(SendrecvmsgServerTimeoutBase): # Test sendmsg() and recvmsg[_into]() using the ancillary data # features of the RFC 3542 Advanced Sockets API for IPv6. # Currently we can only handle certain data items (e.g. traffic # class, hop limit, MTU discovery and fragmentation settings) # without resorting to unportable means such as the struct module, # but the tests here are aimed at testing the ancillary data # handling in sendmsg() and recvmsg() rather than the IPv6 API # itself. # Test value to use when setting hop limit of packet hop_limit = 2 # Test value to use when setting traffic class of packet. # -1 means "use kernel default". traffic_class = -1 def ancillaryMapping(self, ancdata): # Given ancillary data list ancdata, return a mapping from # pairs (cmsg_level, cmsg_type) to corresponding cmsg_data. # Check that no (level, type) pair appears more than once. d = {} for cmsg_level, cmsg_type, cmsg_data in ancdata: self.assertNotIn((cmsg_level, cmsg_type), d) d[(cmsg_level, cmsg_type)] = cmsg_data return d def checkHopLimit(self, ancbufsize, maxhop=255, ignoreflags=0): # Receive hop limit into ancbufsize bytes of ancillary data # space. Check that data is MSG, ancillary data is not # truncated (but ignore any flags in ignoreflags), and hop # limit is between 0 and maxhop inclusive. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbufsize) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertEqual(len(ancdata), 1) self.assertIsInstance(ancdata[0], tuple) cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) self.assertEqual(cmsg_type, socket.IPV6_HOPLIMIT) self.assertIsInstance(cmsg_data, bytes) self.assertEqual(len(cmsg_data), SIZEOF_INT) a = array.array("i") a.frombytes(cmsg_data) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], maxhop) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testRecvHopLimit(self): # Test receiving the packet hop limit as ancillary data. self.checkHopLimit(ancbufsize=10240) @testRecvHopLimit.client_skip def _testRecvHopLimit(self): # Need to wait until server has asked to receive ancillary # data, as implementations are not required to buffer it # otherwise. self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testRecvHopLimitCMSG_SPACE(self): # Test receiving hop limit, using CMSG_SPACE to calculate buffer size. self.checkHopLimit(ancbufsize=socket.CMSG_SPACE(SIZEOF_INT)) @testRecvHopLimitCMSG_SPACE.client_skip def _testRecvHopLimitCMSG_SPACE(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) # Could test receiving into buffer sized using CMSG_LEN, but RFC # 3542 says portable applications must provide space for trailing # padding. Implementations may set MSG_CTRUNC if there isn't # enough space for the padding. @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSetHopLimit(self): # Test setting hop limit on outgoing packet and receiving it # at the other end. self.checkHopLimit(ancbufsize=10240, maxhop=self.hop_limit) @testSetHopLimit.client_skip def _testSetHopLimit(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.assertEqual( self.sendmsgToServer([MSG], [(socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]), len(MSG)) def checkTrafficClassAndHopLimit(self, ancbufsize, maxhop=255, ignoreflags=0): # Receive traffic class and hop limit into ancbufsize bytes of # ancillary data space. Check that data is MSG, ancillary # data is not truncated (but ignore any flags in ignoreflags), # and traffic class and hop limit are in range (hop limit no # more than maxhop). self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVTCLASS, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbufsize) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertEqual(len(ancdata), 2) ancmap = self.ancillaryMapping(ancdata) tcdata = ancmap[(socket.IPPROTO_IPV6, socket.IPV6_TCLASS)] self.assertEqual(len(tcdata), SIZEOF_INT) a = array.array("i") a.frombytes(tcdata) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], 255) hldata = ancmap[(socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT)] self.assertEqual(len(hldata), SIZEOF_INT) a = array.array("i") a.frombytes(hldata) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], maxhop) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testRecvTrafficClassAndHopLimit(self): # Test receiving traffic class and hop limit as ancillary data. self.checkTrafficClassAndHopLimit(ancbufsize=10240) @testRecvTrafficClassAndHopLimit.client_skip def _testRecvTrafficClassAndHopLimit(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testRecvTrafficClassAndHopLimitCMSG_SPACE(self): # Test receiving traffic class and hop limit, using # CMSG_SPACE() to calculate buffer size. self.checkTrafficClassAndHopLimit( ancbufsize=socket.CMSG_SPACE(SIZEOF_INT) * 2) @testRecvTrafficClassAndHopLimitCMSG_SPACE.client_skip def _testRecvTrafficClassAndHopLimitCMSG_SPACE(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSetTrafficClassAndHopLimit(self): # Test setting traffic class and hop limit on outgoing packet, # and receiving them at the other end. self.checkTrafficClassAndHopLimit(ancbufsize=10240, maxhop=self.hop_limit) @testSetTrafficClassAndHopLimit.client_skip def _testSetTrafficClassAndHopLimit(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.assertEqual( self.sendmsgToServer([MSG], [(socket.IPPROTO_IPV6, socket.IPV6_TCLASS, array.array("i", [self.traffic_class])), (socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]), len(MSG)) @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testOddCmsgSize(self): # Try to send ancillary data with first item one byte too # long. Fall back to sending with correct size if this fails, # and check that second item was handled correctly. self.checkTrafficClassAndHopLimit(ancbufsize=10240, maxhop=self.hop_limit) @testOddCmsgSize.client_skip def _testOddCmsgSize(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) try: nbytes = self.sendmsgToServer( [MSG], [(socket.IPPROTO_IPV6, socket.IPV6_TCLASS, array.array("i", [self.traffic_class]).tobytes() + b"\x00"), (socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]) except OSError as e: self.assertIsInstance(e.errno, int) nbytes = self.sendmsgToServer( [MSG], [(socket.IPPROTO_IPV6, socket.IPV6_TCLASS, array.array("i", [self.traffic_class])), (socket.IPPROTO_IPV6, socket.IPV6_HOPLIMIT, array.array("i", [self.hop_limit]))]) self.assertEqual(nbytes, len(MSG)) # Tests for proper handling of truncated ancillary data def checkHopLimitTruncatedHeader(self, ancbufsize, ignoreflags=0): # Receive hop limit into ancbufsize bytes of ancillary data # space, which should be too small to contain the ancillary # data header (if ancbufsize is None, pass no second argument # to recvmsg()). Check that data is MSG, MSG_CTRUNC is set # (unless included in ignoreflags), and no ancillary data is # returned. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.misc_event.set() args = () if ancbufsize is None else (ancbufsize,) msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), *args) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.assertEqual(ancdata, []) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, ignore=ignoreflags) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testCmsgTruncNoBufSize(self): # Check that no ancillary data is received when no ancillary # buffer size is provided. self.checkHopLimitTruncatedHeader(ancbufsize=None, # BSD seems to set # MSG_CTRUNC only if an item # has been partially # received. ignoreflags=socket.MSG_CTRUNC) @testCmsgTruncNoBufSize.client_skip def _testCmsgTruncNoBufSize(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTrunc0(self): # Check that no ancillary data is received when ancillary # buffer size is zero. self.checkHopLimitTruncatedHeader(ancbufsize=0, ignoreflags=socket.MSG_CTRUNC) @testSingleCmsgTrunc0.client_skip def _testSingleCmsgTrunc0(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) # Check that no ancillary data is returned for various non-zero # (but still too small) buffer sizes. @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTrunc1(self): self.checkHopLimitTruncatedHeader(ancbufsize=1) @testSingleCmsgTrunc1.client_skip def _testSingleCmsgTrunc1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTrunc2Int(self): self.checkHopLimitTruncatedHeader(ancbufsize=2 * SIZEOF_INT) @testSingleCmsgTrunc2Int.client_skip def _testSingleCmsgTrunc2Int(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTruncLen0Minus1(self): self.checkHopLimitTruncatedHeader(ancbufsize=socket.CMSG_LEN(0) - 1) @testSingleCmsgTruncLen0Minus1.client_skip def _testSingleCmsgTruncLen0Minus1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") def testSingleCmsgTruncInData(self): # Test truncation of a control message inside its associated # data. The message may be returned with its data truncated, # or not returned at all. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg( self.serv_sock, len(MSG), socket.CMSG_LEN(SIZEOF_INT) - 1) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC) self.assertLessEqual(len(ancdata), 1) if ancdata: cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) self.assertEqual(cmsg_type, socket.IPV6_HOPLIMIT) self.assertLess(len(cmsg_data), SIZEOF_INT) @testSingleCmsgTruncInData.client_skip def _testSingleCmsgTruncInData(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) def checkTruncatedSecondHeader(self, ancbufsize, ignoreflags=0): # Receive traffic class and hop limit into ancbufsize bytes of # ancillary data space, which should be large enough to # contain the first item, but too small to contain the header # of the second. Check that data is MSG, MSG_CTRUNC is set # (unless included in ignoreflags), and only one ancillary # data item is returned. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVTCLASS, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG), ancbufsize) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, ignore=ignoreflags) self.assertEqual(len(ancdata), 1) cmsg_level, cmsg_type, cmsg_data = ancdata[0] self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) self.assertIn(cmsg_type, {socket.IPV6_TCLASS, socket.IPV6_HOPLIMIT}) self.assertEqual(len(cmsg_data), SIZEOF_INT) a = array.array("i") a.frombytes(cmsg_data) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], 255) # Try the above test with various buffer sizes. @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTrunc0(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT), ignoreflags=socket.MSG_CTRUNC) @testSecondCmsgTrunc0.client_skip def _testSecondCmsgTrunc0(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTrunc1(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 1) @testSecondCmsgTrunc1.client_skip def _testSecondCmsgTrunc1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTrunc2Int(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 2 * SIZEOF_INT) @testSecondCmsgTrunc2Int.client_skip def _testSecondCmsgTrunc2Int(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecondCmsgTruncLen0Minus1(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(0) - 1) @testSecondCmsgTruncLen0Minus1.client_skip def _testSecondCmsgTruncLen0Minus1(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") def testSecomdCmsgTruncInData(self): # Test truncation of the second of two control messages inside # its associated data. self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVHOPLIMIT, 1) self.serv_sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVTCLASS, 1) self.misc_event.set() msg, ancdata, flags, addr = self.doRecvmsg( self.serv_sock, len(MSG), socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT) - 1) self.assertEqual(msg, MSG) self.checkRecvmsgAddress(addr, self.cli_addr) self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC) cmsg_types = {socket.IPV6_TCLASS, socket.IPV6_HOPLIMIT} cmsg_level, cmsg_type, cmsg_data = ancdata.pop(0) self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) cmsg_types.remove(cmsg_type) self.assertEqual(len(cmsg_data), SIZEOF_INT) a = array.array("i") a.frombytes(cmsg_data) self.assertGreaterEqual(a[0], 0) self.assertLessEqual(a[0], 255) if ancdata: cmsg_level, cmsg_type, cmsg_data = ancdata.pop(0) self.assertEqual(cmsg_level, socket.IPPROTO_IPV6) cmsg_types.remove(cmsg_type) self.assertLess(len(cmsg_data), SIZEOF_INT) self.assertEqual(ancdata, []) @testSecomdCmsgTruncInData.client_skip def _testSecomdCmsgTruncInData(self): self.assertTrue(self.misc_event.wait(timeout=self.fail_timeout)) self.sendToServer(MSG) # Derive concrete test classes for different socket types. class SendrecvmsgUDPTestBase(SendrecvmsgDgramFlagsBase, SendrecvmsgConnectionlessBase, ThreadedSocketTestMixin, UDPTestBase): pass @requireAttrs(socket.socket, "sendmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgUDPTest(SendmsgConnectionlessTests, SendrecvmsgUDPTestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgUDPTest(RecvmsgTests, SendrecvmsgUDPTestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoUDPTest(RecvmsgIntoTests, SendrecvmsgUDPTestBase): pass class SendrecvmsgUDP6TestBase(SendrecvmsgDgramFlagsBase, SendrecvmsgConnectionlessBase, ThreadedSocketTestMixin, UDP6TestBase): def checkRecvmsgAddress(self, addr1, addr2): # Called to compare the received address with the address of # the peer, ignoring scope ID self.assertEqual(addr1[:-1], addr2[:-1]) @requireAttrs(socket.socket, "sendmsg") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgUDP6Test(SendmsgConnectionlessTests, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgUDP6Test(RecvmsgTests, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoUDP6Test(RecvmsgIntoTests, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireAttrs(socket, "IPPROTO_IPV6") @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgRFC3542AncillaryUDP6Test(RFC3542AncillaryTest, SendrecvmsgUDP6TestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @requireAttrs(socket, "IPPROTO_IPV6") @requireSocket("AF_INET6", "SOCK_DGRAM") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoRFC3542AncillaryUDP6Test(RecvmsgIntoMixin, RFC3542AncillaryTest, SendrecvmsgUDP6TestBase): pass class SendrecvmsgTCPTestBase(SendrecvmsgConnectedBase, ConnectedStreamTestMixin, TCPTestBase): pass @requireAttrs(socket.socket, "sendmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgTCPTest(SendmsgStreamTests, SendrecvmsgTCPTestBase): pass @requireAttrs(socket.socket, "recvmsg") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgTCPTest(RecvmsgTests, RecvmsgGenericStreamTests, SendrecvmsgTCPTestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoTCPTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, SendrecvmsgTCPTestBase): pass class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase, SendrecvmsgConnectedBase, ConnectedStreamTestMixin, SCTPStreamBase): pass @requireAttrs(socket.socket, "sendmsg") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgSCTPStreamTest(SendmsgStreamTests, SendrecvmsgSCTPStreamTestBase): pass @requireAttrs(socket.socket, "recvmsg") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests, SendrecvmsgSCTPStreamTestBase): def testRecvmsgEOF(self): try: super(RecvmsgSCTPStreamTest, self).testRecvmsgEOF() except OSError as e: if e.errno != errno.ENOTCONN: raise self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876") @requireAttrs(socket.socket, "recvmsg_into") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, SendrecvmsgSCTPStreamTestBase): def testRecvmsgEOF(self): try: super(RecvmsgIntoSCTPStreamTest, self).testRecvmsgEOF() except OSError as e: if e.errno != errno.ENOTCONN: raise self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876") class SendrecvmsgUnixStreamTestBase(SendrecvmsgConnectedBase, ConnectedStreamTestMixin, UnixStreamBase): pass @requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket, "AF_UNIX") @unittest.skipUnless(thread, 'Threading required for this test.') class SendmsgUnixStreamTest(SendmsgStreamTests, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "recvmsg") @requireAttrs(socket, "AF_UNIX") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgUnixStreamTest(RecvmsgTests, RecvmsgGenericStreamTests, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "recvmsg_into") @requireAttrs(socket, "AF_UNIX") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoUnixStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "sendmsg", "recvmsg") @requireAttrs(socket, "AF_UNIX", "SOL_SOCKET", "SCM_RIGHTS") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgSCMRightsStreamTest(SCMRightsTest, SendrecvmsgUnixStreamTestBase): pass @requireAttrs(socket.socket, "sendmsg", "recvmsg_into") @requireAttrs(socket, "AF_UNIX", "SOL_SOCKET", "SCM_RIGHTS") @unittest.skipUnless(thread, 'Threading required for this test.') class RecvmsgIntoSCMRightsStreamTest(RecvmsgIntoMixin, SCMRightsTest, SendrecvmsgUnixStreamTestBase): pass # Test interrupting the interruptible send/receive methods with a # signal when a timeout is set. These tests avoid having multiple # threads alive during the test so that the OS cannot deliver the # signal to the wrong one. class InterruptedTimeoutBase(unittest.TestCase): # Base class for interrupted send/receive tests. Installs an # empty handler for SIGALRM and removes it on teardown, along with # any scheduled alarms. def setUp(self): super().setUp() orig_alrm_handler = signal.signal(signal.SIGALRM, lambda signum, frame: 1 / 0) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) # Timeout for socket operations timeout = 4.0 # Provide setAlarm() method to schedule delivery of SIGALRM after # given number of seconds, or cancel it if zero, and an # appropriate time value to use. Use setitimer() if available. if hasattr(signal, "setitimer"): alarm_time = 0.05 def setAlarm(self, seconds): signal.setitimer(signal.ITIMER_REAL, seconds) else: # Old systems may deliver the alarm up to one second early alarm_time = 2 def setAlarm(self, seconds): signal.alarm(seconds) # Require siginterrupt() in order to ensure that system calls are # interrupted by default. @requireAttrs(signal, "siginterrupt") @unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"), "Don't have signal.alarm or signal.setitimer") class InterruptedRecvTimeoutTest(InterruptedTimeoutBase, UDPTestBase): # Test interrupting the recv*() methods with signals when a # timeout is set. def setUp(self): super().setUp() self.serv.settimeout(self.timeout) def checkInterruptedRecv(self, func, *args, **kwargs): # Check that func(*args, **kwargs) raises # errno of EINTR when interrupted by a signal. try: self.setAlarm(self.alarm_time) with self.assertRaises(ZeroDivisionError) as cm: func(*args, **kwargs) finally: self.setAlarm(0) def testInterruptedRecvTimeout(self): self.checkInterruptedRecv(self.serv.recv, 1024) def testInterruptedRecvIntoTimeout(self): self.checkInterruptedRecv(self.serv.recv_into, bytearray(1024)) def testInterruptedRecvfromTimeout(self): self.checkInterruptedRecv(self.serv.recvfrom, 1024) def testInterruptedRecvfromIntoTimeout(self): self.checkInterruptedRecv(self.serv.recvfrom_into, bytearray(1024)) @requireAttrs(socket.socket, "recvmsg") def testInterruptedRecvmsgTimeout(self): self.checkInterruptedRecv(self.serv.recvmsg, 1024) @requireAttrs(socket.socket, "recvmsg_into") def testInterruptedRecvmsgIntoTimeout(self): self.checkInterruptedRecv(self.serv.recvmsg_into, [bytearray(1024)]) # Require siginterrupt() in order to ensure that system calls are # interrupted by default. @requireAttrs(signal, "siginterrupt") @unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"), "Don't have signal.alarm or signal.setitimer") @unittest.skipUnless(thread, 'Threading required for this test.') class InterruptedSendTimeoutTest(InterruptedTimeoutBase, ThreadSafeCleanupTestCase, SocketListeningTestMixin, TCPTestBase): # Test interrupting the interruptible send*() methods with signals # when a timeout is set. def setUp(self): super().setUp() self.serv_conn = self.newSocket() self.addCleanup(self.serv_conn.close) # Use a thread to complete the connection, but wait for it to # terminate before running the test, so that there is only one # thread to accept the signal. cli_thread = threading.Thread(target=self.doConnect) cli_thread.start() self.cli_conn, addr = self.serv.accept() self.addCleanup(self.cli_conn.close) cli_thread.join() self.serv_conn.settimeout(self.timeout) def doConnect(self): self.serv_conn.connect(self.serv_addr) def checkInterruptedSend(self, func, *args, **kwargs): # Check that func(*args, **kwargs), run in a loop, raises # OSError with an errno of EINTR when interrupted by a # signal. try: with self.assertRaises(ZeroDivisionError) as cm: while True: self.setAlarm(self.alarm_time) func(*args, **kwargs) finally: self.setAlarm(0) # Issue #12958: The following tests have problems on OS X prior to 10.7 @support.requires_mac_ver(10, 7) def testInterruptedSendTimeout(self): self.checkInterruptedSend(self.serv_conn.send, b"a"*512) @support.requires_mac_ver(10, 7) def testInterruptedSendtoTimeout(self): # Passing an actual address here as Python's wrapper for # sendto() doesn't allow passing a zero-length one; POSIX # requires that the address is ignored since the socket is # connection-mode, however. self.checkInterruptedSend(self.serv_conn.sendto, b"a"*512, self.serv_addr) @support.requires_mac_ver(10, 7) @requireAttrs(socket.socket, "sendmsg") def testInterruptedSendmsgTimeout(self): self.checkInterruptedSend(self.serv_conn.sendmsg, [b"a"*512]) @unittest.skipUnless(thread, 'Threading required for this test.') class TCPCloserTest(ThreadedTCPSocketTest): def testClose(self): conn, addr = self.serv.accept() conn.close() sd = self.cli read, write, err = select.select([sd], [], [], 1.0) self.assertEqual(read, [sd]) self.assertEqual(sd.recv(1), b'') # Calling close() many times should be safe. conn.close() conn.close() def _testClose(self): self.cli.connect((HOST, self.port)) time.sleep(1.0) @unittest.skipUnless(thread, 'Threading required for this test.') class BasicSocketPairTest(SocketPairTest): def __init__(self, methodName='runTest'): SocketPairTest.__init__(self, methodName=methodName) def _check_defaults(self, sock): self.assertIsInstance(sock, socket.socket) if hasattr(socket, 'AF_UNIX'): self.assertEqual(sock.family, socket.AF_UNIX) else: self.assertEqual(sock.family, socket.AF_INET) self.assertEqual(sock.type, socket.SOCK_STREAM) self.assertEqual(sock.proto, 0) def _testDefaults(self): self._check_defaults(self.cli) def testDefaults(self): self._check_defaults(self.serv) def testRecv(self): msg = self.serv.recv(1024) self.assertEqual(msg, MSG) def _testRecv(self): self.cli.send(MSG) def testSend(self): self.serv.send(MSG) def _testSend(self): msg = self.cli.recv(1024) self.assertEqual(msg, MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class NonBlockingTCPTests(ThreadedTCPSocketTest): def __init__(self, methodName='runTest'): self.event = threading.Event() ThreadedTCPSocketTest.__init__(self, methodName=methodName) def testSetBlocking(self): # Testing whether set blocking works self.serv.setblocking(True) self.assertIsNone(self.serv.gettimeout()) self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() except OSError: pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") def _testSetBlocking(self): pass @support.cpython_only def testSetBlocking_overflow(self): # Issue 15989 import _testcapi if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX: self.skipTest('needs UINT_MAX < ULONG_MAX') self.serv.setblocking(False) self.assertEqual(self.serv.gettimeout(), 0.0) self.serv.setblocking(_testcapi.UINT_MAX + 1) self.assertIsNone(self.serv.gettimeout()) _testSetBlocking_overflow = support.cpython_only(_testSetBlocking) @unittest.skipUnless(hasattr(socket, 'SOCK_NONBLOCK'), 'test needs socket.SOCK_NONBLOCK') @support.requires_linux_version(2, 6, 28) def testInitNonBlocking(self): # reinit server socket self.serv.close() self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_NONBLOCK) self.port = support.bind_port(self.serv) self.serv.listen() # actual testing start = time.time() try: self.serv.accept() except OSError: pass end = time.time() self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.") def _testInitNonBlocking(self): pass def testInheritFlags(self): # Issue #7995: when calling accept() on a listening socket with a # timeout, the resulting socket should not be non-blocking. self.serv.settimeout(10) try: conn, addr = self.serv.accept() message = conn.recv(len(MSG)) finally: conn.close() self.serv.settimeout(None) def _testInheritFlags(self): time.sleep(0.1) self.cli.connect((HOST, self.port)) time.sleep(0.5) self.cli.send(MSG) def testAccept(self): # Testing non-blocking accept self.serv.setblocking(0) # connect() didn't start: non-blocking accept() fails with self.assertRaises(BlockingIOError): conn, addr = self.serv.accept() self.event.set() read, write, err = select.select([self.serv], [], [], MAIN_TIMEOUT) if self.serv not in read: self.fail("Error trying to do accept after select.") # connect() completed: non-blocking accept() doesn't block conn, addr = self.serv.accept() self.addCleanup(conn.close) self.assertIsNone(conn.gettimeout()) def _testAccept(self): # don't connect before event is set to check # that non-blocking accept() raises BlockingIOError self.event.wait() self.cli.connect((HOST, self.port)) def testConnect(self): # Testing non-blocking connect conn, addr = self.serv.accept() conn.close() def _testConnect(self): self.cli.settimeout(10) self.cli.connect((HOST, self.port)) def testRecv(self): # Testing non-blocking recv conn, addr = self.serv.accept() self.addCleanup(conn.close) conn.setblocking(0) # the server didn't send data yet: non-blocking recv() fails with self.assertRaises(BlockingIOError): msg = conn.recv(len(MSG)) self.event.set() read, write, err = select.select([conn], [], [], MAIN_TIMEOUT) if conn not in read: self.fail("Error during select call to non-blocking socket.") # the server sent data yet: non-blocking recv() doesn't block msg = conn.recv(len(MSG)) self.assertEqual(msg, MSG) def _testRecv(self): self.cli.connect((HOST, self.port)) # don't send anything before event is set to check # that non-blocking recv() raises BlockingIOError self.event.wait() # send data: recv() will no longer block self.cli.sendall(MSG) @unittest.skipUnless(thread, 'Threading required for this test.') class FileObjectClassTestCase(SocketConnectedTest): """Unit tests for the object returned by socket.makefile() self.read_file is the io object returned by makefile() on the client connection. You can read from this file to get output from the server. self.write_file is the io object returned by makefile() on the server connection. You can write to this file to send output to the client. """ bufsize = -1 # Use default buffer size encoding = 'utf-8' errors = 'strict' newline = None read_mode = 'rb' read_msg = MSG write_mode = 'wb' write_msg = MSG def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def setUp(self): self.evt1, self.evt2, self.serv_finished, self.cli_finished = [ threading.Event() for i in range(4)] SocketConnectedTest.setUp(self) self.read_file = self.cli_conn.makefile( self.read_mode, self.bufsize, encoding = self.encoding, errors = self.errors, newline = self.newline) def tearDown(self): self.serv_finished.set() self.read_file.close() self.assertTrue(self.read_file.closed) self.read_file = None SocketConnectedTest.tearDown(self) def clientSetUp(self): SocketConnectedTest.clientSetUp(self) self.write_file = self.serv_conn.makefile( self.write_mode, self.bufsize, encoding = self.encoding, errors = self.errors, newline = self.newline) def clientTearDown(self): self.cli_finished.set() self.write_file.close() self.assertTrue(self.write_file.closed) self.write_file = None SocketConnectedTest.clientTearDown(self) def testReadAfterTimeout(self): # Issue #7322: A file object must disallow further reads # after a timeout has occurred. self.cli_conn.settimeout(1) self.read_file.read(3) # First read raises a timeout self.assertRaises(socket.timeout, self.read_file.read, 1) # Second read is disallowed with self.assertRaises(OSError) as ctx: self.read_file.read(1) self.assertIn("cannot read from timed out object", str(ctx.exception)) def _testReadAfterTimeout(self): self.write_file.write(self.write_msg[0:3]) self.write_file.flush() self.serv_finished.wait() def testSmallRead(self): # Performing small file read test first_seg = self.read_file.read(len(self.read_msg)-3) second_seg = self.read_file.read(3) msg = first_seg + second_seg self.assertEqual(msg, self.read_msg) def _testSmallRead(self): self.write_file.write(self.write_msg) self.write_file.flush() def testFullRead(self): # read until EOF msg = self.read_file.read() self.assertEqual(msg, self.read_msg) def _testFullRead(self): self.write_file.write(self.write_msg) self.write_file.close() def testUnbufferedRead(self): # Performing unbuffered file read test buf = type(self.read_msg)() while 1: char = self.read_file.read(1) if not char: break buf += char self.assertEqual(buf, self.read_msg) def _testUnbufferedRead(self): self.write_file.write(self.write_msg) self.write_file.flush() def testReadline(self): # Performing file readline test line = self.read_file.readline() self.assertEqual(line, self.read_msg) def _testReadline(self): self.write_file.write(self.write_msg) self.write_file.flush() def testCloseAfterMakefile(self): # The file returned by makefile should keep the socket open. self.cli_conn.close() # read until EOF msg = self.read_file.read() self.assertEqual(msg, self.read_msg) def _testCloseAfterMakefile(self): self.write_file.write(self.write_msg) self.write_file.flush() def testMakefileAfterMakefileClose(self): self.read_file.close() msg = self.cli_conn.recv(len(MSG)) if isinstance(self.read_msg, str): msg = msg.decode() self.assertEqual(msg, self.read_msg) def _testMakefileAfterMakefileClose(self): self.write_file.write(self.write_msg) self.write_file.flush() def testClosedAttr(self): self.assertTrue(not self.read_file.closed) def _testClosedAttr(self): self.assertTrue(not self.write_file.closed) def testAttributes(self): self.assertEqual(self.read_file.mode, self.read_mode) self.assertEqual(self.read_file.name, self.cli_conn.fileno()) def _testAttributes(self): self.assertEqual(self.write_file.mode, self.write_mode) self.assertEqual(self.write_file.name, self.serv_conn.fileno()) def testRealClose(self): self.read_file.close() self.assertRaises(ValueError, self.read_file.fileno) self.cli_conn.close() self.assertRaises(OSError, self.cli_conn.getsockname) def _testRealClose(self): pass class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase): """Repeat the tests from FileObjectClassTestCase with bufsize==0. In this case (and in this case only), it should be possible to create a file object, read a line from it, create another file object, read another line from it, without loss of data in the first file object's buffer. Note that http.client relies on this when reading multiple requests from the same socket.""" bufsize = 0 # Use unbuffered mode def testUnbufferedReadline(self): # Read a line, create a new file object, read another line with it line = self.read_file.readline() # first line self.assertEqual(line, b"A. " + self.write_msg) # first line self.read_file = self.cli_conn.makefile('rb', 0) line = self.read_file.readline() # second line self.assertEqual(line, b"B. " + self.write_msg) # second line def _testUnbufferedReadline(self): self.write_file.write(b"A. " + self.write_msg) self.write_file.write(b"B. " + self.write_msg) self.write_file.flush() def testMakefileClose(self): # The file returned by makefile should keep the socket open... self.cli_conn.close() msg = self.cli_conn.recv(1024) self.assertEqual(msg, self.read_msg) # ...until the file is itself closed self.read_file.close() self.assertRaises(OSError, self.cli_conn.recv, 1024) def _testMakefileClose(self): self.write_file.write(self.write_msg) self.write_file.flush() def testMakefileCloseSocketDestroy(self): refcount_before = sys.getrefcount(self.cli_conn) self.read_file.close() refcount_after = sys.getrefcount(self.cli_conn) self.assertEqual(refcount_before - 1, refcount_after) def _testMakefileCloseSocketDestroy(self): pass # Non-blocking ops # NOTE: to set `read_file` as non-blocking, we must call # `cli_conn.setblocking` and vice-versa (see setUp / clientSetUp). def testSmallReadNonBlocking(self): self.cli_conn.setblocking(False) self.assertEqual(self.read_file.readinto(bytearray(10)), None) self.assertEqual(self.read_file.read(len(self.read_msg) - 3), None) self.evt1.set() self.evt2.wait(1.0) first_seg = self.read_file.read(len(self.read_msg) - 3) if first_seg is None: # Data not arrived (can happen under Windows), wait a bit time.sleep(0.5) first_seg = self.read_file.read(len(self.read_msg) - 3) buf = bytearray(10) n = self.read_file.readinto(buf) self.assertEqual(n, 3) msg = first_seg + buf[:n] self.assertEqual(msg, self.read_msg) self.assertEqual(self.read_file.readinto(bytearray(16)), None) self.assertEqual(self.read_file.read(1), None) def _testSmallReadNonBlocking(self): self.evt1.wait(1.0) self.write_file.write(self.write_msg) self.write_file.flush() self.evt2.set() # Avoid closing the socket before the server test has finished, # otherwise system recv() will return 0 instead of EWOULDBLOCK. self.serv_finished.wait(5.0) def testWriteNonBlocking(self): self.cli_finished.wait(5.0) # The client thread can't skip directly - the SkipTest exception # would appear as a failure. if self.serv_skipped: self.skipTest(self.serv_skipped) def _testWriteNonBlocking(self): self.serv_skipped = None self.serv_conn.setblocking(False) # Try to saturate the socket buffer pipe with repeated large writes. BIG = b"x" * support.SOCK_MAX_SIZE LIMIT = 10 # The first write() succeeds since a chunk of data can be buffered n = self.write_file.write(BIG) self.assertGreater(n, 0) for i in range(LIMIT): n = self.write_file.write(BIG) if n is None: # Succeeded break self.assertGreater(n, 0) else: # Let us know that this test didn't manage to establish # the expected conditions. This is not a failure in itself but, # if it happens repeatedly, the test should be fixed. self.serv_skipped = "failed to saturate the socket buffer" class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 1 # Default-buffered for reading; line-buffered for writing class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 2 # Exercise the buffering code class UnicodeReadFileObjectClassTestCase(FileObjectClassTestCase): """Tests for socket.makefile() in text mode (rather than binary)""" read_mode = 'r' read_msg = MSG.decode('utf-8') write_mode = 'wb' write_msg = MSG newline = '' class UnicodeWriteFileObjectClassTestCase(FileObjectClassTestCase): """Tests for socket.makefile() in text mode (rather than binary)""" read_mode = 'rb' read_msg = MSG write_mode = 'w' write_msg = MSG.decode('utf-8') newline = '' class UnicodeReadWriteFileObjectClassTestCase(FileObjectClassTestCase): """Tests for socket.makefile() in text mode (rather than binary)""" read_mode = 'r' read_msg = MSG.decode('utf-8') write_mode = 'w' write_msg = MSG.decode('utf-8') newline = '' class NetworkConnectionTest(object): """Prove network connection.""" def clientSetUp(self): # We're inherited below by BasicTCPTest2, which also inherits # BasicTCPTest, which defines self.port referenced below. self.cli = socket.create_connection((HOST, self.port)) self.serv_conn = self.cli class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): """Tests that NetworkConnection does not break existing TCP functionality. """ class NetworkConnectionNoServer(unittest.TestCase): class MockSocket(socket.socket): def connect(self, *args): raise socket.timeout('timed out') @contextlib.contextmanager def mocked_socket_module(self): """Return a socket which times out on connect""" old_socket = socket.socket socket.socket = self.MockSocket try: yield finally: socket.socket = old_socket def test_connect(self): port = support.find_unused_port() cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(cli.close) with self.assertRaises(OSError) as cm: cli.connect((HOST, port)) self.assertEqual(cm.exception.errno, errno.ECONNREFUSED) def test_create_connection(self): # Issue #9792: errors raised by create_connection() should have # a proper errno attribute. port = support.find_unused_port() with self.assertRaises(OSError) as cm: socket.create_connection((HOST, port)) # Issue #16257: create_connection() calls getaddrinfo() against # 'localhost'. This may result in an IPV6 addr being returned # as well as an IPV4 one: # >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM) # >>> [(2, 2, 0, '', ('127.0.0.1', 41230)), # (26, 2, 0, '', ('::1', 41230, 0, 0))] # # create_connection() enumerates through all the addresses returned # and if it doesn't successfully bind to any of them, it propagates # the last exception it encountered. # # On Solaris, ENETUNREACH is returned in this circumstance instead # of ECONNREFUSED. So, if that errno exists, add it to our list of # expected errnos. expected_errnos = [ errno.ECONNREFUSED, ] if hasattr(errno, 'ENETUNREACH'): expected_errnos.append(errno.ENETUNREACH) if hasattr(errno, 'EADDRNOTAVAIL'): # bpo-31910: socket.create_connection() fails randomly # with EADDRNOTAVAIL on Travis CI expected_errnos.append(errno.EADDRNOTAVAIL) self.assertIn(cm.exception.errno, expected_errnos) def test_create_connection_timeout(self): # Issue #9792: create_connection() should not recast timeout errors # as generic socket errors. with self.mocked_socket_module(): with self.assertRaises(socket.timeout): socket.create_connection((HOST, 1234)) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): self.source_port = support.find_unused_port() def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def _justAccept(self): conn, addr = self.serv.accept() conn.close() testFamily = _justAccept def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.family, 2) testSourceAddress = _justAccept def _testSourceAddress(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.addCleanup(self.cli.close) self.assertEqual(self.cli.getsockname()[1], self.source_port) # The port number being used is sufficient to show that the bind() # call happened. testTimeoutDefault = _justAccept def _testTimeoutDefault(self): # passing no explicit timeout uses socket's global default self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(42) try: self.cli = socket.create_connection((HOST, self.port)) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), 42) testTimeoutNone = _justAccept def _testTimeoutNone(self): # None timeout means the same as sock.settimeout(None) self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: self.cli = socket.create_connection((HOST, self.port), timeout=None) self.addCleanup(self.cli.close) finally: socket.setdefaulttimeout(None) self.assertEqual(self.cli.gettimeout(), None) testTimeoutValueNamed = _justAccept def _testTimeoutValueNamed(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.gettimeout(), 30) testTimeoutValueNonamed = _justAccept def _testTimeoutValueNonamed(self): self.cli = socket.create_connection((HOST, self.port), 30) self.addCleanup(self.cli.close) self.assertEqual(self.cli.gettimeout(), 30) @unittest.skipUnless(thread, 'Threading required for this test.') class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest): def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) ThreadableTest.__init__(self) def clientSetUp(self): pass def clientTearDown(self): self.cli.close() self.cli = None ThreadableTest.clientTearDown(self) def testInsideTimeout(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send(b"done!") testOutsideTimeout = testInsideTimeout def _testInsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port)) data = sock.recv(5) self.assertEqual(data, b"done!") def _testOutsideTimeout(self): self.cli = sock = socket.create_connection((HOST, self.port), timeout=1) self.assertRaises(socket.timeout, lambda: sock.recv(5)) class TCPTimeoutTest(SocketTCPTest): def testTCPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.accept() self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (TCP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of error (TCP)") except OSError: ok = True except: self.fail("caught unexpected exception (TCP)") if not ok: self.fail("accept() returned success when we did not expect it") @unittest.skipUnless(hasattr(signal, 'alarm'), 'test needs signal.alarm()') def testInterruptedTimeout(self): # XXX I don't know how to do this test on MSWindows or any other # plaform that doesn't support signal.alarm() or os.kill(), though # the bug should have existed on all platforms. self.serv.settimeout(5.0) # must be longer than alarm class Alarm(Exception): pass def alarm_handler(signal, frame): raise Alarm old_alarm = signal.signal(signal.SIGALRM, alarm_handler) try: try: signal.alarm(2) # POSIX allows alarm to be up to 1 second early foo = self.serv.accept() except socket.timeout: self.fail("caught timeout instead of Alarm") except Alarm: pass except: self.fail("caught other exception instead of Alarm:" " %s(%s):\n%s" % (sys.exc_info()[:2] + (traceback.format_exc(),))) else: self.fail("nothing caught") finally: signal.alarm(0) # shut off alarm except Alarm: self.fail("got Alarm in wrong place") finally: # no alarm can be pending. Safe to restore old handler. signal.signal(signal.SIGALRM, old_alarm) class UDPTimeoutTest(SocketUDPTest): def testUDPTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.recv(1024) self.assertRaises(socket.timeout, raise_timeout, "Error generating a timeout exception (UDP)") def testTimeoutZero(self): ok = False try: self.serv.settimeout(0.0) foo = self.serv.recv(1024) except socket.timeout: self.fail("caught timeout instead of error (UDP)") except OSError: ok = True except: self.fail("caught unexpected exception (UDP)") if not ok: self.fail("recv() returned success when we did not expect it") class TestExceptions(unittest.TestCase): def testExceptionTree(self): self.assertTrue(issubclass(OSError, Exception)) self.assertTrue(issubclass(socket.herror, OSError)) self.assertTrue(issubclass(socket.gaierror, OSError)) self.assertTrue(issubclass(socket.timeout, OSError)) def test_setblocking_invalidfd(self): # Regression test for issue #28471 sock0 = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM, 0, sock0.fileno()) sock0.close() self.addCleanup(sock.detach) with self.assertRaises(OSError): sock.setblocking(False) @unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') class TestLinuxAbstractNamespace(unittest.TestCase): UNIX_PATH_MAX = 108 def testLinuxAbstractNamespace(self): address = b"\x00python-test-hello\x00\xff" with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1: s1.bind(address) s1.listen() with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s2: s2.connect(s1.getsockname()) with s1.accept()[0] as s3: self.assertEqual(s1.getsockname(), address) self.assertEqual(s2.getpeername(), address) def testMaxName(self): address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1) with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: s.bind(address) self.assertEqual(s.getsockname(), address) def testNameOverflow(self): address = "\x00" + "h" * self.UNIX_PATH_MAX with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: self.assertRaises(OSError, s.bind, address) def testStrName(self): # Check that an abstract name can be passed as a string. s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: s.bind("\x00python\x00test\x00") self.assertEqual(s.getsockname(), b"\x00python\x00test\x00") finally: s.close() def testBytearrayName(self): # Check that an abstract name can be passed as a bytearray. with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: s.bind(bytearray(b"\x00python\x00test\x00")) self.assertEqual(s.getsockname(), b"\x00python\x00test\x00") @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'test needs socket.AF_UNIX') class TestUnixDomain(unittest.TestCase): def setUp(self): self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) def tearDown(self): self.sock.close() def encoded(self, path): # Return the given path encoded in the file system encoding, # or skip the test if this is not possible. try: return os.fsencode(path) except UnicodeEncodeError: self.skipTest( "Pathname {0!a} cannot be represented in file " "system encoding {1!r}".format( path, sys.getfilesystemencoding())) def bind(self, sock, path): # Bind the socket try: support.bind_unix_socket(sock, path) except OSError as e: if str(e) == "AF_UNIX path too long": self.skipTest( "Pathname {0!a} is too long to serve as an AF_UNIX path" .format(path)) else: raise def testUnbound(self): # Issue #30205 self.assertIn(self.sock.getsockname(), ('', None)) def testStrAddr(self): # Test binding to and retrieving a normal string pathname. path = os.path.abspath(support.TESTFN) self.bind(self.sock, path) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testBytesAddr(self): # Test binding to a bytes pathname. path = os.path.abspath(support.TESTFN) self.bind(self.sock, self.encoded(path)) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testSurrogateescapeBind(self): # Test binding to a valid non-ASCII pathname, with the # non-ASCII bytes supplied using surrogateescape encoding. path = os.path.abspath(support.TESTFN_UNICODE) b = self.encoded(path) self.bind(self.sock, b.decode("ascii", "surrogateescape")) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testUnencodableAddr(self): # Test binding to a pathname that cannot be encoded in the # file system encoding. if support.TESTFN_UNENCODABLE is None: self.skipTest("No unencodable filename available") path = os.path.abspath(support.TESTFN_UNENCODABLE) self.bind(self.sock, path) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) @unittest.skipUnless(thread, 'Threading required for this test.') class BufferIOTest(SocketConnectedTest): """ Test the buffer versions of socket.recv() and socket.send(). """ def __init__(self, methodName='runTest'): SocketConnectedTest.__init__(self, methodName=methodName) def testRecvIntoArray(self): buf = array.array("B", [0] * len(MSG)) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) buf = buf.tobytes() msg = buf[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvIntoArray(self): buf = bytes(MSG) self.serv_conn.send(buf) def testRecvIntoBytearray(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoBytearray = _testRecvIntoArray def testRecvIntoMemoryview(self): buf = bytearray(1024) nbytes = self.cli_conn.recv_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvIntoMemoryview = _testRecvIntoArray def testRecvFromIntoArray(self): buf = array.array("B", [0] * len(MSG)) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) buf = buf.tobytes() msg = buf[:len(MSG)] self.assertEqual(msg, MSG) def _testRecvFromIntoArray(self): buf = bytes(MSG) self.serv_conn.send(buf) def testRecvFromIntoBytearray(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(buf) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoBytearray = _testRecvFromIntoArray def testRecvFromIntoMemoryview(self): buf = bytearray(1024) nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf)) self.assertEqual(nbytes, len(MSG)) msg = buf[:len(MSG)] self.assertEqual(msg, MSG) _testRecvFromIntoMemoryview = _testRecvFromIntoArray def testRecvFromIntoSmallBuffer(self): # See issue #20246. buf = bytearray(8) self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) def _testRecvFromIntoSmallBuffer(self): self.serv_conn.send(MSG) def testRecvFromIntoEmptyBuffer(self): buf = bytearray() self.cli_conn.recvfrom_into(buf) self.cli_conn.recvfrom_into(buf, 0) _testRecvFromIntoEmptyBuffer = _testRecvFromIntoArray TIPC_STYPE = 2000 TIPC_LOWER = 200 TIPC_UPPER = 210 def isTipcAvailable(): """Check if the TIPC module is loaded The TIPC module is not loaded automatically on Ubuntu and probably other Linux distros. """ if not hasattr(socket, "AF_TIPC"): return False try: f = open("/proc/modules") except (FileNotFoundError, IsADirectoryError, PermissionError): # It's ok if the file does not exist, is a directory or if we # have not the permission to read it. return False with f: for line in f: if line.startswith("tipc "): return True return False @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCTest(unittest.TestCase): def testRDM(self): srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) self.addCleanup(srv.close) self.addCleanup(cli.close) srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) srv.bind(srvaddr) sendaddr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0) cli.sendto(MSG, sendaddr) msg, recvaddr = srv.recvfrom(1024) self.assertEqual(cli.getsockname(), recvaddr) self.assertEqual(msg, MSG) @unittest.skipUnless(isTipcAvailable(), "TIPC module is not loaded, please 'sudo modprobe tipc'") class TIPCThreadableTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName = 'runTest'): unittest.TestCase.__init__(self, methodName = methodName) ThreadableTest.__init__(self) def setUp(self): self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.addCleanup(self.srv.close) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE, TIPC_LOWER, TIPC_UPPER) self.srv.bind(srvaddr) self.srv.listen() self.serverExplicitReady() self.conn, self.connaddr = self.srv.accept() self.addCleanup(self.conn.close) def clientSetUp(self): # There is a hittable race between serverExplicitReady() and the # accept() call; sleep a little while to avoid it, otherwise # we could get an exception time.sleep(0.1) self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM) self.addCleanup(self.cli.close) addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE, TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0) self.cli.connect(addr) self.cliaddr = self.cli.getsockname() def testStream(self): msg = self.conn.recv(1024) self.assertEqual(msg, MSG) self.assertEqual(self.cliaddr, self.connaddr) def _testStream(self): self.cli.send(MSG) self.cli.close() @unittest.skipUnless(thread, 'Threading required for this test.') class ContextManagersTest(ThreadedTCPSocketTest): def _testSocketClass(self): # base test with socket.socket() as sock: self.assertFalse(sock._closed) self.assertTrue(sock._closed) # close inside with block with socket.socket() as sock: sock.close() self.assertTrue(sock._closed) # exception inside with block with socket.socket() as sock: self.assertRaises(OSError, sock.sendall, b'foo') self.assertTrue(sock._closed) def testCreateConnectionBase(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) data = conn.recv(1024) conn.sendall(data) def _testCreateConnectionBase(self): address = self.serv.getsockname() with socket.create_connection(address) as sock: self.assertFalse(sock._closed) sock.sendall(b'foo') self.assertEqual(sock.recv(1024), b'foo') self.assertTrue(sock._closed) def testCreateConnectionClose(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) data = conn.recv(1024) conn.sendall(data) def _testCreateConnectionClose(self): address = self.serv.getsockname() with socket.create_connection(address) as sock: sock.close() self.assertTrue(sock._closed) self.assertRaises(OSError, sock.sendall, b'foo') class InheritanceTest(unittest.TestCase): @unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"), "SOCK_CLOEXEC not defined") @support.requires_linux_version(2, 6, 28) def test_SOCK_CLOEXEC(self): with socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_CLOEXEC) as s: self.assertTrue(s.type & socket.SOCK_CLOEXEC) self.assertFalse(s.get_inheritable()) def test_default_inheritable(self): sock = socket.socket() with sock: self.assertEqual(sock.get_inheritable(), False) def test_dup(self): sock = socket.socket() with sock: newsock = sock.dup() sock.close() with newsock: self.assertEqual(newsock.get_inheritable(), False) def test_set_inheritable(self): sock = socket.socket() with sock: sock.set_inheritable(True) self.assertEqual(sock.get_inheritable(), True) sock.set_inheritable(False) self.assertEqual(sock.get_inheritable(), False) @unittest.skipIf(fcntl is None, "need fcntl") def test_get_inheritable_cloexec(self): sock = socket.socket() with sock: fd = sock.fileno() self.assertEqual(sock.get_inheritable(), False) # clear FD_CLOEXEC flag flags = fcntl.fcntl(fd, fcntl.F_GETFD) flags &= ~fcntl.FD_CLOEXEC fcntl.fcntl(fd, fcntl.F_SETFD, flags) self.assertEqual(sock.get_inheritable(), True) @unittest.skipIf(fcntl is None, "need fcntl") def test_set_inheritable_cloexec(self): sock = socket.socket() with sock: fd = sock.fileno() self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC, fcntl.FD_CLOEXEC) sock.set_inheritable(True) self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC, 0) @unittest.skipUnless(hasattr(socket, "socketpair"), "need socket.socketpair()") def test_socketpair(self): s1, s2 = socket.socketpair() self.addCleanup(s1.close) self.addCleanup(s2.close) self.assertEqual(s1.get_inheritable(), False) self.assertEqual(s2.get_inheritable(), False) @unittest.skipUnless(hasattr(socket, "SOCK_NONBLOCK"), "SOCK_NONBLOCK not defined") class NonblockConstantTest(unittest.TestCase): def checkNonblock(self, s, nonblock=True, timeout=0.0): if nonblock: self.assertTrue(s.type & socket.SOCK_NONBLOCK) self.assertEqual(s.gettimeout(), timeout) else: self.assertFalse(s.type & socket.SOCK_NONBLOCK) self.assertEqual(s.gettimeout(), None) @support.requires_linux_version(2, 6, 28) def test_SOCK_NONBLOCK(self): # a lot of it seems silly and redundant, but I wanted to test that # changing back and forth worked ok with socket.socket(socket.AF_INET, socket.SOCK_STREAM | socket.SOCK_NONBLOCK) as s: self.checkNonblock(s) s.setblocking(1) self.checkNonblock(s, False) s.setblocking(0) self.checkNonblock(s) s.settimeout(None) self.checkNonblock(s, False) s.settimeout(2.0) self.checkNonblock(s, timeout=2.0) s.setblocking(1) self.checkNonblock(s, False) # defaulttimeout t = socket.getdefaulttimeout() socket.setdefaulttimeout(0.0) with socket.socket() as s: self.checkNonblock(s) socket.setdefaulttimeout(None) with socket.socket() as s: self.checkNonblock(s, False) socket.setdefaulttimeout(2.0) with socket.socket() as s: self.checkNonblock(s, timeout=2.0) socket.setdefaulttimeout(None) with socket.socket() as s: self.checkNonblock(s, False) socket.setdefaulttimeout(t) @unittest.skipUnless(os.name == "nt", "Windows specific") @unittest.skipUnless(multiprocessing, "need multiprocessing") class TestSocketSharing(SocketTCPTest): # This must be classmethod and not staticmethod or multiprocessing # won't be able to bootstrap it. @classmethod def remoteProcessServer(cls, q): # Recreate socket from shared data sdata = q.get() message = q.get() s = socket.fromshare(sdata) s2, c = s.accept() # Send the message s2.sendall(message) s2.close() s.close() def testShare(self): # Transfer the listening server socket to another process # and service it from there. # Create process: q = multiprocessing.Queue() p = multiprocessing.Process(target=self.remoteProcessServer, args=(q,)) p.start() # Get the shared socket data data = self.serv.share(p.pid) # Pass the shared socket to the other process addr = self.serv.getsockname() self.serv.close() q.put(data) # The data that the server will send us message = b"slapmahfro" q.put(message) # Connect s = socket.create_connection(addr) # listen for the data m = [] while True: data = s.recv(100) if not data: break m.append(data) s.close() received = b"".join(m) self.assertEqual(received, message) p.join() def testShareLength(self): data = self.serv.share(os.getpid()) self.assertRaises(ValueError, socket.fromshare, data[:-1]) self.assertRaises(ValueError, socket.fromshare, data+b"foo") def compareSockets(self, org, other): # socket sharing is expected to work only for blocking socket # since the internal python timeout value isn't transferred. self.assertEqual(org.gettimeout(), None) self.assertEqual(org.gettimeout(), other.gettimeout()) self.assertEqual(org.family, other.family) self.assertEqual(org.type, other.type) # If the user specified "0" for proto, then # internally windows will have picked the correct value. # Python introspection on the socket however will still return # 0. For the shared socket, the python value is recreated # from the actual value, so it may not compare correctly. if org.proto != 0: self.assertEqual(org.proto, other.proto) def testShareLocal(self): data = self.serv.share(os.getpid()) s = socket.fromshare(data) try: self.compareSockets(self.serv, s) finally: s.close() def testTypes(self): families = [socket.AF_INET, socket.AF_INET6] types = [socket.SOCK_STREAM, socket.SOCK_DGRAM] for f in families: for t in types: try: source = socket.socket(f, t) except OSError: continue # This combination is not supported try: data = source.share(os.getpid()) shared = socket.fromshare(data) try: self.compareSockets(source, shared) finally: shared.close() finally: source.close() @unittest.skipUnless(thread, 'Threading required for this test.') class SendfileUsingSendTest(ThreadedTCPSocketTest): """ Test the send() implementation of socket.sendfile(). """ FILESIZE = (10 * 1024 * 1024) # 10MB BUFSIZE = 8192 FILEDATA = b"" TIMEOUT = 2 @classmethod def setUpClass(cls): def chunks(total, step): assert total >= step while total > step: yield step total -= step if total: yield total chunk = b"".join([random.choice(string.ascii_letters).encode() for i in range(cls.BUFSIZE)]) with open(support.TESTFN, 'wb') as f: for csize in chunks(cls.FILESIZE, cls.BUFSIZE): f.write(chunk) with open(support.TESTFN, 'rb') as f: cls.FILEDATA = f.read() assert len(cls.FILEDATA) == cls.FILESIZE @classmethod def tearDownClass(cls): support.unlink(support.TESTFN) def accept_conn(self): self.serv.settimeout(self.TIMEOUT) conn, addr = self.serv.accept() conn.settimeout(self.TIMEOUT) self.addCleanup(conn.close) return conn def recv_data(self, conn): received = [] while True: chunk = conn.recv(self.BUFSIZE) if not chunk: break received.append(chunk) return b''.join(received) def meth_from_sock(self, sock): # Depending on the mixin class being run return either send() # or sendfile() method implementation. return getattr(sock, "_sendfile_use_send") # regular file def _testRegularFile(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file) self.assertEqual(sent, self.FILESIZE) self.assertEqual(file.tell(), self.FILESIZE) def testRegularFile(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE) self.assertEqual(data, self.FILEDATA) # non regular file def _testNonRegularFile(self): address = self.serv.getsockname() file = io.BytesIO(self.FILEDATA) with socket.create_connection(address) as sock, file as file: sent = sock.sendfile(file) self.assertEqual(sent, self.FILESIZE) self.assertEqual(file.tell(), self.FILESIZE) self.assertRaises(socket._GiveupOnSendfile, sock._sendfile_use_sendfile, file) def testNonRegularFile(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE) self.assertEqual(data, self.FILEDATA) # empty file def _testEmptyFileSend(self): address = self.serv.getsockname() filename = support.TESTFN + "2" with open(filename, 'wb'): self.addCleanup(support.unlink, filename) file = open(filename, 'rb') with socket.create_connection(address) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file) self.assertEqual(sent, 0) self.assertEqual(file.tell(), 0) def testEmptyFileSend(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(data, b"") # offset def _testOffset(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file, offset=5000) self.assertEqual(sent, self.FILESIZE - 5000) self.assertEqual(file.tell(), self.FILESIZE) def testOffset(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE - 5000) self.assertEqual(data, self.FILEDATA[5000:]) # count def _testCount(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: count = 5000007 meth = self.meth_from_sock(sock) sent = meth(file, count=count) self.assertEqual(sent, count) self.assertEqual(file.tell(), count) def testCount(self): count = 5000007 conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), count) self.assertEqual(data, self.FILEDATA[:count]) # count small def _testCountSmall(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: count = 1 meth = self.meth_from_sock(sock) sent = meth(file, count=count) self.assertEqual(sent, count) self.assertEqual(file.tell(), count) def testCountSmall(self): count = 1 conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), count) self.assertEqual(data, self.FILEDATA[:count]) # count + offset def _testCountWithOffset(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: count = 100007 meth = self.meth_from_sock(sock) sent = meth(file, offset=2007, count=count) self.assertEqual(sent, count) self.assertEqual(file.tell(), count + 2007) def testCountWithOffset(self): count = 100007 conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), count) self.assertEqual(data, self.FILEDATA[2007:count+2007]) # non blocking sockets are not supposed to work def _testNonBlocking(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address) as sock, file as file: sock.setblocking(False) meth = self.meth_from_sock(sock) self.assertRaises(ValueError, meth, file) self.assertRaises(ValueError, sock.sendfile, file) def testNonBlocking(self): conn = self.accept_conn() if conn.recv(8192): self.fail('was not supposed to receive any data') # timeout (non-triggered) def _testWithTimeout(self): address = self.serv.getsockname() file = open(support.TESTFN, 'rb') with socket.create_connection(address, timeout=2) as sock, file as file: meth = self.meth_from_sock(sock) sent = meth(file) self.assertEqual(sent, self.FILESIZE) def testWithTimeout(self): conn = self.accept_conn() data = self.recv_data(conn) self.assertEqual(len(data), self.FILESIZE) self.assertEqual(data, self.FILEDATA) # timeout (triggered) def _testWithTimeoutTriggeredSend(self): address = self.serv.getsockname() with open(support.TESTFN, 'rb') as file: with socket.create_connection(address, timeout=0.01) as sock: meth = self.meth_from_sock(sock) self.assertRaises(socket.timeout, meth, file) def testWithTimeoutTriggeredSend(self): conn = self.accept_conn() conn.recv(88192) # errors def _test_errors(self): pass def test_errors(self): with open(support.TESTFN, 'rb') as file: with socket.socket(type=socket.SOCK_DGRAM) as s: meth = self.meth_from_sock(s) self.assertRaisesRegex( ValueError, "SOCK_STREAM", meth, file) with open(support.TESTFN, 'rt') as file: with socket.socket() as s: meth = self.meth_from_sock(s) self.assertRaisesRegex( ValueError, "binary mode", meth, file) with open(support.TESTFN, 'rb') as file: with socket.socket() as s: meth = self.meth_from_sock(s) self.assertRaisesRegex(TypeError, "positive integer", meth, file, count='2') self.assertRaisesRegex(TypeError, "positive integer", meth, file, count=0.1) self.assertRaisesRegex(ValueError, "positive integer", meth, file, count=0) self.assertRaisesRegex(ValueError, "positive integer", meth, file, count=-1) @unittest.skipUnless(thread, 'Threading required for this test.') @unittest.skipUnless(hasattr(os, "sendfile"), 'os.sendfile() required for this test.') class SendfileUsingSendfileTest(SendfileUsingSendTest): """ Test the sendfile() implementation of socket.sendfile(). """ def meth_from_sock(self, sock): return getattr(sock, "_sendfile_use_sendfile") @unittest.skipUnless(HAVE_SOCKET_ALG, 'AF_ALG required') class LinuxKernelCryptoAPI(unittest.TestCase): # tests for AF_ALG def create_alg(self, typ, name): sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0) try: sock.bind((typ, name)) except FileNotFoundError as e: # type / algorithm is not available sock.close() raise unittest.SkipTest(str(e), typ, name) else: return sock # bpo-31705: On kernel older than 4.5, sendto() failed with ENOKEY, # at least on ppc64le architecture @support.requires_linux_version(4, 5) def test_sha256(self): expected = bytes.fromhex("ba7816bf8f01cfea414140de5dae2223b00361a396" "177a9cb410ff61f20015ad") with self.create_alg('hash', 'sha256') as algo: op, _ = algo.accept() with op: op.sendall(b"abc") self.assertEqual(op.recv(512), expected) op, _ = algo.accept() with op: op.send(b'a', socket.MSG_MORE) op.send(b'b', socket.MSG_MORE) op.send(b'c', socket.MSG_MORE) op.send(b'') self.assertEqual(op.recv(512), expected) def test_hmac_sha1(self): expected = bytes.fromhex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79") with self.create_alg('hash', 'hmac(sha1)') as algo: algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, b"Jefe") op, _ = algo.accept() with op: op.sendall(b"what do ya want for nothing?") self.assertEqual(op.recv(512), expected) # Although it should work with 3.19 and newer the test blocks on # Ubuntu 15.10 with Kernel 4.2.0-19. @support.requires_linux_version(4, 3) def test_aes_cbc(self): key = bytes.fromhex('06a9214036b8a15b512e03d534120006') iv = bytes.fromhex('3dafba429d9eb430b422da802c9fac41') msg = b"Single block msg" ciphertext = bytes.fromhex('e353779c1079aeb82708942dbe77181a') msglen = len(msg) with self.create_alg('skcipher', 'cbc(aes)') as algo: algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, key) op, _ = algo.accept() with op: op.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, iv=iv, flags=socket.MSG_MORE) op.sendall(msg) self.assertEqual(op.recv(msglen), ciphertext) op, _ = algo.accept() with op: op.sendmsg_afalg([ciphertext], op=socket.ALG_OP_DECRYPT, iv=iv) self.assertEqual(op.recv(msglen), msg) # long message multiplier = 1024 longmsg = [msg] * multiplier op, _ = algo.accept() with op: op.sendmsg_afalg(longmsg, op=socket.ALG_OP_ENCRYPT, iv=iv) enc = op.recv(msglen * multiplier) self.assertEqual(len(enc), msglen * multiplier) self.assertEqual(enc[:msglen], ciphertext) op, _ = algo.accept() with op: op.sendmsg_afalg([enc], op=socket.ALG_OP_DECRYPT, iv=iv) dec = op.recv(msglen * multiplier) self.assertEqual(len(dec), msglen * multiplier) self.assertEqual(dec, msg * multiplier) @support.requires_linux_version(4, 9) # see issue29324 def test_aead_aes_gcm(self): key = bytes.fromhex('c939cc13397c1d37de6ae0e1cb7c423c') iv = bytes.fromhex('b3d8cc017cbb89b39e0f67e2') plain = bytes.fromhex('c3b3c41f113a31b73d9a5cd432103069') assoc = bytes.fromhex('24825602bd12a984e0092d3e448eda5f') expected_ct = bytes.fromhex('93fe7d9e9bfd10348a5606e5cafa7354') expected_tag = bytes.fromhex('0032a1dc85f1c9786925a2e71d8272dd') taglen = len(expected_tag) assoclen = len(assoc) with self.create_alg('aead', 'gcm(aes)') as algo: algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, key) algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_AEAD_AUTHSIZE, None, taglen) # send assoc, plain and tag buffer in separate steps op, _ = algo.accept() with op: op.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, iv=iv, assoclen=assoclen, flags=socket.MSG_MORE) op.sendall(assoc, socket.MSG_MORE) op.sendall(plain) res = op.recv(assoclen + len(plain) + taglen) self.assertEqual(expected_ct, res[assoclen:-taglen]) self.assertEqual(expected_tag, res[-taglen:]) # now with msg op, _ = algo.accept() with op: msg = assoc + plain op.sendmsg_afalg([msg], op=socket.ALG_OP_ENCRYPT, iv=iv, assoclen=assoclen) res = op.recv(assoclen + len(plain) + taglen) self.assertEqual(expected_ct, res[assoclen:-taglen]) self.assertEqual(expected_tag, res[-taglen:]) # create anc data manually pack_uint32 = struct.Struct('I').pack op, _ = algo.accept() with op: msg = assoc + plain op.sendmsg( [msg], ([socket.SOL_ALG, socket.ALG_SET_OP, pack_uint32(socket.ALG_OP_ENCRYPT)], [socket.SOL_ALG, socket.ALG_SET_IV, pack_uint32(len(iv)) + iv], [socket.SOL_ALG, socket.ALG_SET_AEAD_ASSOCLEN, pack_uint32(assoclen)], ) ) res = op.recv(len(msg) + taglen) self.assertEqual(expected_ct, res[assoclen:-taglen]) self.assertEqual(expected_tag, res[-taglen:]) # decrypt and verify op, _ = algo.accept() with op: msg = assoc + expected_ct + expected_tag op.sendmsg_afalg([msg], op=socket.ALG_OP_DECRYPT, iv=iv, assoclen=assoclen) res = op.recv(len(msg) - taglen) self.assertEqual(plain, res[assoclen:]) @support.requires_linux_version(4, 3) # see test_aes_cbc def test_drbg_pr_sha256(self): # deterministic random bit generator, prediction resistance, sha256 with self.create_alg('rng', 'drbg_pr_sha256') as algo: extra_seed = os.urandom(32) algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, extra_seed) op, _ = algo.accept() with op: rn = op.recv(32) self.assertEqual(len(rn), 32) def test_sendmsg_afalg_args(self): sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0) with sock: with self.assertRaises(TypeError): sock.sendmsg_afalg() with self.assertRaises(TypeError): sock.sendmsg_afalg(op=None) with self.assertRaises(TypeError): sock.sendmsg_afalg(1) with self.assertRaises(TypeError): sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=None) with self.assertRaises(TypeError): sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1) def test_length_restriction(self): # bpo-35050, off-by-one error in length check sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0) self.addCleanup(sock.close) # salg_type[14] with self.assertRaises(FileNotFoundError): sock.bind(("t" * 13, "name")) with self.assertRaisesRegex(ValueError, "type too long"): sock.bind(("t" * 14, "name")) # salg_name[64] with self.assertRaises(FileNotFoundError): sock.bind(("type", "n" * 63)) with self.assertRaisesRegex(ValueError, "name too long"): sock.bind(("type", "n" * 64)) @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows") class TestMSWindowsTCPFlags(unittest.TestCase): knownTCPFlags = { # available since long time ago 'TCP_MAXSEG', 'TCP_NODELAY', # available starting with Windows 10 1607 'TCP_FASTOPEN', # available starting with Windows 10 1703 'TCP_KEEPCNT', } def test_new_tcp_flags(self): provided = [s for s in dir(socket) if s.startswith('TCP')] unknown = [s for s in provided if s not in self.knownTCPFlags] self.assertEqual([], unknown, "New TCP flags were discovered. See bpo-32394 for more information") def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, UnicodeReadFileObjectClassTestCase, UnicodeWriteFileObjectClassTestCase, UnicodeReadWriteFileObjectClassTestCase, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ContextManagersTest, InheritanceTest, NonblockConstantTest ]) tests.append(BasicSocketPairTest) tests.append(TestUnixDomain) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) tests.extend([BasicCANTest, CANTest]) tests.extend([BasicRDSTest, RDSTest]) tests.append(LinuxKernelCryptoAPI) tests.extend([ CmsgMacroTests, SendmsgUDPTest, RecvmsgUDPTest, RecvmsgIntoUDPTest, SendmsgUDP6Test, RecvmsgUDP6Test, RecvmsgRFC3542AncillaryUDP6Test, RecvmsgIntoRFC3542AncillaryUDP6Test, RecvmsgIntoUDP6Test, SendmsgTCPTest, RecvmsgTCPTest, RecvmsgIntoTCPTest, SendmsgSCTPStreamTest, RecvmsgSCTPStreamTest, RecvmsgIntoSCTPStreamTest, SendmsgUnixStreamTest, RecvmsgUnixStreamTest, RecvmsgIntoUnixStreamTest, RecvmsgSCMRightsStreamTest, RecvmsgIntoSCMRightsStreamTest, # These are slow when setitimer() is not available InterruptedRecvTimeoutTest, InterruptedSendTimeoutTest, TestSocketSharing, SendfileUsingSendTest, SendfileUsingSendfileTest, ]) tests.append(TestMSWindowsTCPFlags) thread_info = support.threading_setup() support.run_unittest(*tests) support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main()
215,352
5,692
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_getpass.py
import getpass import os import unittest from io import BytesIO, StringIO, TextIOWrapper from unittest import mock from test import support try: import termios except ImportError: termios = None try: import pwd except ImportError: pwd = None @mock.patch('os.environ') class GetpassGetuserTest(unittest.TestCase): def test_username_takes_username_from_env(self, environ): expected_name = 'some_name' environ.get.return_value = expected_name self.assertEqual(expected_name, getpass.getuser()) def test_username_priorities_of_env_values(self, environ): environ.get.return_value = None try: getpass.getuser() except ImportError: # in case there's no pwd module pass self.assertEqual( environ.get.call_args_list, [mock.call(x) for x in ('LOGNAME', 'USER', 'LNAME', 'USERNAME')]) def test_username_falls_back_to_pwd(self, environ): expected_name = 'some_name' environ.get.return_value = None if pwd: with mock.patch('os.getuid') as uid, \ mock.patch('pwd.getpwuid') as getpw: uid.return_value = 42 getpw.return_value = [expected_name] self.assertEqual(expected_name, getpass.getuser()) getpw.assert_called_once_with(42) else: self.assertRaises(ImportError, getpass.getuser) class GetpassRawinputTest(unittest.TestCase): def test_flushes_stream_after_prompt(self): # see issue 1703 stream = mock.Mock(spec=StringIO) input = StringIO('input_string') getpass._raw_input('some_prompt', stream, input=input) stream.flush.assert_called_once_with() def test_uses_stderr_as_default(self): input = StringIO('input_string') prompt = 'some_prompt' with mock.patch('sys.stderr') as stderr: getpass._raw_input(prompt, input=input) stderr.write.assert_called_once_with(prompt) @mock.patch('sys.stdin') def test_uses_stdin_as_default_input(self, mock_input): mock_input.readline.return_value = 'input_string' getpass._raw_input(stream=StringIO()) mock_input.readline.assert_called_once_with() @mock.patch('sys.stdin') def test_uses_stdin_as_different_locale(self, mock_input): stream = TextIOWrapper(BytesIO(), encoding="ascii") mock_input.readline.return_value = "Hasło: " getpass._raw_input(prompt="Hasło: ",stream=stream) mock_input.readline.assert_called_once_with() def test_raises_on_empty_input(self): input = StringIO('') self.assertRaises(EOFError, getpass._raw_input, input=input) def test_trims_trailing_newline(self): input = StringIO('test\n') self.assertEqual('test', getpass._raw_input(input=input)) # Some of these tests are a bit white-box. The functional requirement is that # the password input be taken directly from the tty, and that it not be echoed # on the screen, unless we are falling back to stderr/stdin. # Some of these might run on platforms without termios, but play it safe. @unittest.skipUnless(termios, 'tests require system with termios') class UnixGetpassTest(unittest.TestCase): def test_uses_tty_directly(self): with mock.patch('os.open') as open, \ mock.patch('io.FileIO') as fileio, \ mock.patch('io.TextIOWrapper') as textio: # By setting open's return value to None the implementation will # skip code we don't care about in this test. We can mock this out # fully if an alternate implementation works differently. open.return_value = None getpass.unix_getpass() open.assert_called_once_with('/dev/tty', os.O_RDWR | os.O_NOCTTY) fileio.assert_called_once_with(open.return_value, 'w+') textio.assert_called_once_with(fileio.return_value) def test_resets_termios(self): with mock.patch('os.open') as open, \ mock.patch('io.FileIO'), \ mock.patch('io.TextIOWrapper'), \ mock.patch('termios.tcgetattr') as tcgetattr, \ mock.patch('termios.tcsetattr') as tcsetattr: open.return_value = 3 fake_attrs = [255, 255, 255, 255, 255] tcgetattr.return_value = list(fake_attrs) getpass.unix_getpass() tcsetattr.assert_called_with(3, mock.ANY, fake_attrs) def test_falls_back_to_fallback_if_termios_raises(self): with mock.patch('os.open') as open, \ mock.patch('io.FileIO') as fileio, \ mock.patch('io.TextIOWrapper') as textio, \ mock.patch('termios.tcgetattr'), \ mock.patch('termios.tcsetattr') as tcsetattr, \ mock.patch('getpass.fallback_getpass') as fallback: open.return_value = 3 fileio.return_value = BytesIO() tcsetattr.side_effect = termios.error getpass.unix_getpass() fallback.assert_called_once_with('Password: ', textio.return_value) def test_flushes_stream_after_input(self): # issue 7208 with mock.patch('os.open') as open, \ mock.patch('io.FileIO'), \ mock.patch('io.TextIOWrapper'), \ mock.patch('termios.tcgetattr'), \ mock.patch('termios.tcsetattr'): open.return_value = 3 mock_stream = mock.Mock(spec=StringIO) getpass.unix_getpass(stream=mock_stream) mock_stream.flush.assert_called_with() def test_falls_back_to_stdin(self): with mock.patch('os.open') as os_open, \ mock.patch('sys.stdin', spec=StringIO) as stdin: os_open.side_effect = IOError stdin.fileno.side_effect = AttributeError with support.captured_stderr() as stderr: with self.assertWarns(getpass.GetPassWarning): getpass.unix_getpass() stdin.readline.assert_called_once_with() self.assertIn('Warning', stderr.getvalue()) self.assertIn('Password:', stderr.getvalue()) if __name__ == "__main__": unittest.main()
6,437
164
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_bz2.py
from test import support from test.support import bigmemtest, _4G import unittest from io import BytesIO, DEFAULT_BUFFER_SIZE import os import cosmo import pickle import glob import pathlib import random import shutil import subprocess import sys from test.support import unlink import _compression import sys from encodings import utf_16_le try: import _thread import threading except ImportError: threading = None import bz2 from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor has_cmdline_bunzip2 = False def ext_decompress(data): global has_cmdline_bunzip2 if has_cmdline_bunzip2 is None: has_cmdline_bunzip2 = bool(shutil.which('bunzip2')) if has_cmdline_bunzip2: return subprocess.check_output(['bunzip2'], input=data) else: return bz2.decompress(data) class BaseTest(unittest.TestCase): "Base for other testcases." TEXT_LINES = [ b'root:x:0:0:root:/root:/bin/bash\n', b'bin:x:1:1:bin:/bin:\n', b'daemon:x:2:2:daemon:/sbin:\n', b'adm:x:3:4:adm:/var/adm:\n', b'lp:x:4:7:lp:/var/spool/lpd:\n', b'sync:x:5:0:sync:/sbin:/bin/sync\n', b'shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\n', b'halt:x:7:0:halt:/sbin:/sbin/halt\n', b'mail:x:8:12:mail:/var/spool/mail:\n', b'news:x:9:13:news:/var/spool/news:\n', b'uucp:x:10:14:uucp:/var/spool/uucp:\n', b'operator:x:11:0:operator:/root:\n', b'games:x:12:100:games:/usr/games:\n', b'gopher:x:13:30:gopher:/usr/lib/gopher-data:\n', b'ftp:x:14:50:FTP User:/var/ftp:/bin/bash\n', b'nobody:x:65534:65534:Nobody:/home:\n', b'postfix:x:100:101:postfix:/var/spool/postfix:\n', b'niemeyer:x:500:500::/home/niemeyer:/bin/bash\n', b'postgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\n', b'mysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\n', b'www:x:103:104::/var/www:/bin/false\n', ] TEXT = b''.join(TEXT_LINES) DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2<Q\xb5\x0fH\xd3\xd4\xdd\xd5\x87\xbb\xf8\x94\r\x8f\xafI\x12\xe1\xc9\xf8/E\x00pu\x89\x12]\xc9\xbbDL\nQ\x0e\t1\x12\xdf\xa0\xc0\x97\xac2O9\x89\x13\x94\x0e\x1c7\x0ed\x95I\x0c\xaaJ\xa4\x18L\x10\x05#\x9c\xaf\xba\xbc/\x97\x8a#C\xc8\xe1\x8cW\xf9\xe2\xd0\xd6M\xa7\x8bXa<e\x84t\xcbL\xb3\xa7\xd9\xcd\xd1\xcb\x84.\xaf\xb3\xab\xab\xad`n}\xa0lh\tE,\x8eZ\x15\x17VH>\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' EMPTY_DATA = b'BZh9\x17rE8P\x90\x00\x00\x00\x00' BAD_DATA = b'this is not a valid bzip2 file' # Some tests need more than one block of uncompressed data. Since one block # is at least 100 kB, we gather some data dynamically and compress it. # Note that this assumes that compression works correctly, so we cannot # simply use the bigger test data for all tests. test_size = 0 BIG_TEXT = bytearray(128*1024) for fname in glob.glob(os.path.join(os.path.dirname(__file__), '*.py')): with open(fname, 'rb') as fh: test_size += fh.readinto(memoryview(BIG_TEXT)[test_size:]) if test_size > 128*1024: break BIG_DATA = bz2.compress(BIG_TEXT, compresslevel=1) def setUp(self): self.filename = support.TESTFN def tearDown(self): if os.path.isfile(self.filename): os.unlink(self.filename) class BZ2FileTest(BaseTest): "Test the BZ2File class." def createTempFile(self, streams=1, suffix=b""): with open(self.filename, "wb") as f: f.write(self.DATA * streams) f.write(suffix) def testBadArgs(self): self.assertRaises(TypeError, BZ2File, 123.456) self.assertRaises(ValueError, BZ2File, os.devnull, "z") self.assertRaises(ValueError, BZ2File, os.devnull, "rx") self.assertRaises(ValueError, BZ2File, os.devnull, "rbt") self.assertRaises(ValueError, BZ2File, os.devnull, compresslevel=0) self.assertRaises(ValueError, BZ2File, os.devnull, compresslevel=10) def testRead(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.read, float()) self.assertEqual(bz2f.read(), self.TEXT) def testReadBadFile(self): self.createTempFile(streams=0, suffix=self.BAD_DATA) with BZ2File(self.filename) as bz2f: self.assertRaises(OSError, bz2f.read) def testReadMultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.read, float()) self.assertEqual(bz2f.read(), self.TEXT * 5) def testReadMonkeyMultiStream(self): # Test BZ2File.read() on a multi-stream archive where a stream # boundary coincides with the end of the raw read buffer. buffer_size = _compression.BUFFER_SIZE _compression.BUFFER_SIZE = len(self.DATA) try: self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.read, float()) self.assertEqual(bz2f.read(), self.TEXT * 5) finally: _compression.BUFFER_SIZE = buffer_size def testReadTrailingJunk(self): self.createTempFile(suffix=self.BAD_DATA) with BZ2File(self.filename) as bz2f: self.assertEqual(bz2f.read(), self.TEXT) def testReadMultiStreamTrailingJunk(self): self.createTempFile(streams=5, suffix=self.BAD_DATA) with BZ2File(self.filename) as bz2f: self.assertEqual(bz2f.read(), self.TEXT * 5) def testRead0(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.read, float()) self.assertEqual(bz2f.read(0), b"") def testReadChunk10(self): self.createTempFile() with BZ2File(self.filename) as bz2f: text = b'' while True: str = bz2f.read(10) if not str: break text += str self.assertEqual(text, self.TEXT) def testReadChunk10MultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: text = b'' while True: str = bz2f.read(10) if not str: break text += str self.assertEqual(text, self.TEXT * 5) def testRead100(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertEqual(bz2f.read(100), self.TEXT[:100]) def testPeek(self): self.createTempFile() with BZ2File(self.filename) as bz2f: pdata = bz2f.peek() self.assertNotEqual(len(pdata), 0) self.assertTrue(self.TEXT.startswith(pdata)) self.assertEqual(bz2f.read(), self.TEXT) def testReadInto(self): self.createTempFile() with BZ2File(self.filename) as bz2f: n = 128 b = bytearray(n) self.assertEqual(bz2f.readinto(b), n) self.assertEqual(b, self.TEXT[:n]) n = len(self.TEXT) - n b = bytearray(len(self.TEXT)) self.assertEqual(bz2f.readinto(b), n) self.assertEqual(b[:n], self.TEXT[-n:]) def testReadLine(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.readline, None) for line in self.TEXT_LINES: self.assertEqual(bz2f.readline(), line) def testReadLineMultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.readline, None) for line in self.TEXT_LINES * 5: self.assertEqual(bz2f.readline(), line) def testReadLines(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.readlines, None) self.assertEqual(bz2f.readlines(), self.TEXT_LINES) def testReadLinesMultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.readlines, None) self.assertEqual(bz2f.readlines(), self.TEXT_LINES * 5) def testIterator(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertEqual(list(iter(bz2f)), self.TEXT_LINES) def testIteratorMultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: self.assertEqual(list(iter(bz2f)), self.TEXT_LINES * 5) def testClosedIteratorDeadlock(self): # Issue #3309: Iteration on a closed BZ2File should release the lock. self.createTempFile() bz2f = BZ2File(self.filename) bz2f.close() self.assertRaises(ValueError, next, bz2f) # This call will deadlock if the above call failed to release the lock. self.assertRaises(ValueError, bz2f.readlines) def testWrite(self): with BZ2File(self.filename, "w") as bz2f: self.assertRaises(TypeError, bz2f.write) bz2f.write(self.TEXT) with open(self.filename, 'rb') as f: self.assertEqual(ext_decompress(f.read()), self.TEXT) def testWriteChunks10(self): with BZ2File(self.filename, "w") as bz2f: n = 0 while True: str = self.TEXT[n*10:(n+1)*10] if not str: break bz2f.write(str) n += 1 with open(self.filename, 'rb') as f: self.assertEqual(ext_decompress(f.read()), self.TEXT) def testWriteNonDefaultCompressLevel(self): expected = bz2.compress(self.TEXT, compresslevel=5) with BZ2File(self.filename, "w", compresslevel=5) as bz2f: bz2f.write(self.TEXT) with open(self.filename, "rb") as f: self.assertEqual(f.read(), expected) def testWriteLines(self): with BZ2File(self.filename, "w") as bz2f: self.assertRaises(TypeError, bz2f.writelines) bz2f.writelines(self.TEXT_LINES) # Issue #1535500: Calling writelines() on a closed BZ2File # should raise an exception. self.assertRaises(ValueError, bz2f.writelines, ["a"]) with open(self.filename, 'rb') as f: self.assertEqual(ext_decompress(f.read()), self.TEXT) def testWriteMethodsOnReadOnlyFile(self): with BZ2File(self.filename, "w") as bz2f: bz2f.write(b"abc") with BZ2File(self.filename, "r") as bz2f: self.assertRaises(OSError, bz2f.write, b"a") self.assertRaises(OSError, bz2f.writelines, [b"a"]) def testAppend(self): with BZ2File(self.filename, "w") as bz2f: self.assertRaises(TypeError, bz2f.write) bz2f.write(self.TEXT) with BZ2File(self.filename, "a") as bz2f: self.assertRaises(TypeError, bz2f.write) bz2f.write(self.TEXT) with open(self.filename, 'rb') as f: self.assertEqual(ext_decompress(f.read()), self.TEXT * 2) def testSeekForward(self): self.createTempFile() with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.seek) bz2f.seek(150) self.assertEqual(bz2f.read(), self.TEXT[150:]) def testSeekForwardAcrossStreams(self): self.createTempFile(streams=2) with BZ2File(self.filename) as bz2f: self.assertRaises(TypeError, bz2f.seek) bz2f.seek(len(self.TEXT) + 150) self.assertEqual(bz2f.read(), self.TEXT[150:]) def testSeekBackwards(self): self.createTempFile() with BZ2File(self.filename) as bz2f: bz2f.read(500) bz2f.seek(-150, 1) self.assertEqual(bz2f.read(), self.TEXT[500-150:]) def testSeekBackwardsAcrossStreams(self): self.createTempFile(streams=2) with BZ2File(self.filename) as bz2f: readto = len(self.TEXT) + 100 while readto > 0: readto -= len(bz2f.read(readto)) bz2f.seek(-150, 1) self.assertEqual(bz2f.read(), self.TEXT[100-150:] + self.TEXT) def testSeekBackwardsFromEnd(self): self.createTempFile() with BZ2File(self.filename) as bz2f: bz2f.seek(-150, 2) self.assertEqual(bz2f.read(), self.TEXT[len(self.TEXT)-150:]) def testSeekBackwardsFromEndAcrossStreams(self): self.createTempFile(streams=2) with BZ2File(self.filename) as bz2f: bz2f.seek(-1000, 2) self.assertEqual(bz2f.read(), (self.TEXT * 2)[-1000:]) def testSeekPostEnd(self): self.createTempFile() with BZ2File(self.filename) as bz2f: bz2f.seek(150000) self.assertEqual(bz2f.tell(), len(self.TEXT)) self.assertEqual(bz2f.read(), b"") def testSeekPostEndMultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: bz2f.seek(150000) self.assertEqual(bz2f.tell(), len(self.TEXT) * 5) self.assertEqual(bz2f.read(), b"") def testSeekPostEndTwice(self): self.createTempFile() with BZ2File(self.filename) as bz2f: bz2f.seek(150000) bz2f.seek(150000) self.assertEqual(bz2f.tell(), len(self.TEXT)) self.assertEqual(bz2f.read(), b"") def testSeekPostEndTwiceMultiStream(self): self.createTempFile(streams=5) with BZ2File(self.filename) as bz2f: bz2f.seek(150000) bz2f.seek(150000) self.assertEqual(bz2f.tell(), len(self.TEXT) * 5) self.assertEqual(bz2f.read(), b"") def testSeekPreStart(self): self.createTempFile() with BZ2File(self.filename) as bz2f: bz2f.seek(-150) self.assertEqual(bz2f.tell(), 0) self.assertEqual(bz2f.read(), self.TEXT) def testSeekPreStartMultiStream(self): self.createTempFile(streams=2) with BZ2File(self.filename) as bz2f: bz2f.seek(-150) self.assertEqual(bz2f.tell(), 0) self.assertEqual(bz2f.read(), self.TEXT * 2) def testFileno(self): self.createTempFile() with open(self.filename, 'rb') as rawf: bz2f = BZ2File(rawf) try: self.assertEqual(bz2f.fileno(), rawf.fileno()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.fileno) def testSeekable(self): bz2f = BZ2File(BytesIO(self.DATA)) try: self.assertTrue(bz2f.seekable()) bz2f.read() self.assertTrue(bz2f.seekable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.seekable) bz2f = BZ2File(BytesIO(), "w") try: self.assertFalse(bz2f.seekable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.seekable) src = BytesIO(self.DATA) src.seekable = lambda: False bz2f = BZ2File(src) try: self.assertFalse(bz2f.seekable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.seekable) def testReadable(self): bz2f = BZ2File(BytesIO(self.DATA)) try: self.assertTrue(bz2f.readable()) bz2f.read() self.assertTrue(bz2f.readable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.readable) bz2f = BZ2File(BytesIO(), "w") try: self.assertFalse(bz2f.readable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.readable) def testWritable(self): bz2f = BZ2File(BytesIO(self.DATA)) try: self.assertFalse(bz2f.writable()) bz2f.read() self.assertFalse(bz2f.writable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.writable) bz2f = BZ2File(BytesIO(), "w") try: self.assertTrue(bz2f.writable()) finally: bz2f.close() self.assertRaises(ValueError, bz2f.writable) def testOpenDel(self): self.createTempFile() for i in range(10000): o = BZ2File(self.filename) del o def testOpenNonexistent(self): self.assertRaises(OSError, BZ2File, "/non/existent") def testReadlinesNoNewline(self): # Issue #1191043: readlines() fails on a file containing no newline. data = b'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t' with open(self.filename, "wb") as f: f.write(data) with BZ2File(self.filename) as bz2f: lines = bz2f.readlines() self.assertEqual(lines, [b'Test']) with BZ2File(self.filename) as bz2f: xlines = list(bz2f.readlines()) self.assertEqual(xlines, [b'Test']) def testContextProtocol(self): f = None with BZ2File(self.filename, "wb") as f: f.write(b"xxx") f = BZ2File(self.filename, "rb") f.close() try: with f: pass except ValueError: pass else: self.fail("__enter__ on a closed file didn't raise an exception") try: with BZ2File(self.filename, "wb") as f: 1/0 except ZeroDivisionError: pass else: self.fail("1/0 didn't raise an exception") @unittest.skipUnless(threading, 'Threading required for this test.') def testThreading(self): # Issue #7205: Using a BZ2File from several threads shouldn't deadlock. data = b"1" * 2**20 nthreads = 10 with BZ2File(self.filename, 'wb') as f: def comp(): for i in range(5): f.write(data) threads = [threading.Thread(target=comp) for i in range(nthreads)] with support.start_threads(threads): pass def testWithoutThreading(self): module = support.import_fresh_module("bz2", blocked=("threading",)) with module.BZ2File(self.filename, "wb") as f: f.write(b"abc") with module.BZ2File(self.filename, "rb") as f: self.assertEqual(f.read(), b"abc") def testMixedIterationAndReads(self): self.createTempFile() linelen = len(self.TEXT_LINES[0]) halflen = linelen // 2 with BZ2File(self.filename) as bz2f: bz2f.read(halflen) self.assertEqual(next(bz2f), self.TEXT_LINES[0][halflen:]) self.assertEqual(bz2f.read(), self.TEXT[linelen:]) with BZ2File(self.filename) as bz2f: bz2f.readline() self.assertEqual(next(bz2f), self.TEXT_LINES[1]) self.assertEqual(bz2f.readline(), self.TEXT_LINES[2]) with BZ2File(self.filename) as bz2f: bz2f.readlines() self.assertRaises(StopIteration, next, bz2f) self.assertEqual(bz2f.readlines(), []) def testMultiStreamOrdering(self): # Test the ordering of streams when reading a multi-stream archive. data1 = b"foo" * 1000 data2 = b"bar" * 1000 with BZ2File(self.filename, "w") as bz2f: bz2f.write(data1) with BZ2File(self.filename, "a") as bz2f: bz2f.write(data2) with BZ2File(self.filename) as bz2f: self.assertEqual(bz2f.read(), data1 + data2) def testOpenBytesFilename(self): str_filename = self.filename try: bytes_filename = str_filename.encode("ascii") except UnicodeEncodeError: self.skipTest("Temporary file name needs to be ASCII") with BZ2File(bytes_filename, "wb") as f: f.write(self.DATA) with BZ2File(bytes_filename, "rb") as f: self.assertEqual(f.read(), self.DATA) # Sanity check that we are actually operating on the right file. with BZ2File(str_filename, "rb") as f: self.assertEqual(f.read(), self.DATA) def testOpenPathLikeFilename(self): filename = pathlib.Path(self.filename) with BZ2File(filename, "wb") as f: f.write(self.DATA) with BZ2File(filename, "rb") as f: self.assertEqual(f.read(), self.DATA) def testDecompressLimited(self): """Decompressed data buffering should be limited""" bomb = bz2.compress(b'\0' * int(2e6), compresslevel=9) self.assertLess(len(bomb), _compression.BUFFER_SIZE) decomp = BZ2File(BytesIO(bomb)) self.assertEqual(decomp.read(1), b'\0') max_decomp = 1 + DEFAULT_BUFFER_SIZE self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp, "Excessive amount of data was decompressed") # Tests for a BZ2File wrapping another file object: def testReadBytesIO(self): with BytesIO(self.DATA) as bio: with BZ2File(bio) as bz2f: self.assertRaises(TypeError, bz2f.read, float()) self.assertEqual(bz2f.read(), self.TEXT) self.assertFalse(bio.closed) def testPeekBytesIO(self): with BytesIO(self.DATA) as bio: with BZ2File(bio) as bz2f: pdata = bz2f.peek() self.assertNotEqual(len(pdata), 0) self.assertTrue(self.TEXT.startswith(pdata)) self.assertEqual(bz2f.read(), self.TEXT) def testWriteBytesIO(self): with BytesIO() as bio: with BZ2File(bio, "w") as bz2f: self.assertRaises(TypeError, bz2f.write) bz2f.write(self.TEXT) self.assertEqual(ext_decompress(bio.getvalue()), self.TEXT) self.assertFalse(bio.closed) def testSeekForwardBytesIO(self): with BytesIO(self.DATA) as bio: with BZ2File(bio) as bz2f: self.assertRaises(TypeError, bz2f.seek) bz2f.seek(150) self.assertEqual(bz2f.read(), self.TEXT[150:]) def testSeekBackwardsBytesIO(self): with BytesIO(self.DATA) as bio: with BZ2File(bio) as bz2f: bz2f.read(500) bz2f.seek(-150, 1) self.assertEqual(bz2f.read(), self.TEXT[500-150:]) def test_read_truncated(self): # Drop the eos_magic field (6 bytes) and CRC (4 bytes). truncated = self.DATA[:-10] with BZ2File(BytesIO(truncated)) as f: self.assertRaises(EOFError, f.read) with BZ2File(BytesIO(truncated)) as f: self.assertEqual(f.read(len(self.TEXT)), self.TEXT) self.assertRaises(EOFError, f.read, 1) # Incomplete 4-byte file header, and block header of at least 146 bits. for i in range(22): with BZ2File(BytesIO(truncated[:i])) as f: self.assertRaises(EOFError, f.read, 1) class BZ2CompressorTest(BaseTest): def testCompress(self): bz2c = BZ2Compressor() self.assertRaises(TypeError, bz2c.compress) data = bz2c.compress(self.TEXT) data += bz2c.flush() self.assertEqual(ext_decompress(data), self.TEXT) def testCompressEmptyString(self): bz2c = BZ2Compressor() data = bz2c.compress(b'') data += bz2c.flush() self.assertEqual(data, self.EMPTY_DATA) def testCompressChunks10(self): bz2c = BZ2Compressor() n = 0 data = b'' while True: str = self.TEXT[n*10:(n+1)*10] if not str: break data += bz2c.compress(str) n += 1 data += bz2c.flush() self.assertEqual(ext_decompress(data), self.TEXT) @bigmemtest(size=_4G + 100, memuse=2) def testCompress4G(self, size): # "Test BZ2Compressor.compress()/flush() with >4GiB input" bz2c = BZ2Compressor() data = b"x" * size try: compressed = bz2c.compress(data) compressed += bz2c.flush() finally: data = None # Release memory data = bz2.decompress(compressed) try: self.assertEqual(len(data), size) self.assertEqual(len(data.strip(b"x")), 0) finally: data = None def testPickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises(TypeError): pickle.dumps(BZ2Compressor(), proto) class BZ2DecompressorTest(BaseTest): def test_Constructor(self): self.assertRaises(TypeError, BZ2Decompressor, 42) def testDecompress(self): bz2d = BZ2Decompressor() self.assertRaises(TypeError, bz2d.decompress) text = bz2d.decompress(self.DATA) self.assertEqual(text, self.TEXT) def testDecompressChunks10(self): bz2d = BZ2Decompressor() text = b'' n = 0 while True: str = self.DATA[n*10:(n+1)*10] if not str: break text += bz2d.decompress(str) n += 1 self.assertEqual(text, self.TEXT) def testDecompressUnusedData(self): bz2d = BZ2Decompressor() unused_data = b"this is unused data" text = bz2d.decompress(self.DATA+unused_data) self.assertEqual(text, self.TEXT) self.assertEqual(bz2d.unused_data, unused_data) def testEOFError(self): bz2d = BZ2Decompressor() text = bz2d.decompress(self.DATA) self.assertRaises(EOFError, bz2d.decompress, b"anything") self.assertRaises(EOFError, bz2d.decompress, b"") @bigmemtest(size=_4G + 100, memuse=3.3) def testDecompress4G(self, size): # "Test BZ2Decompressor.decompress() with >4GiB input" blocksize = 10 * 1024 * 1024 block = random.getrandbits(blocksize * 8).to_bytes(blocksize, 'little') try: data = block * (size // blocksize + 1) compressed = bz2.compress(data) bz2d = BZ2Decompressor() decompressed = bz2d.decompress(compressed) self.assertTrue(decompressed == data) finally: data = None compressed = None decompressed = None def testPickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises(TypeError): pickle.dumps(BZ2Decompressor(), proto) @unittest.skipIf(cosmo.MODE.startswith("tiny"), "TODO(jart): what's going on here?") def testDecompressorChunksMaxsize(self): bzd = BZ2Decompressor() max_length = 100 out = [] # Feed some input len_ = len(self.BIG_DATA) - 64 out.append(bzd.decompress(self.BIG_DATA[:len_], max_length=max_length)) self.assertFalse(bzd.needs_input) self.assertEqual(len(out[-1]), max_length) # Retrieve more data without providing more input out.append(bzd.decompress(b'', max_length=max_length)) self.assertFalse(bzd.needs_input) self.assertEqual(len(out[-1]), max_length) # Retrieve more data while providing more input out.append(bzd.decompress(self.BIG_DATA[len_:], max_length=max_length)) self.assertLessEqual(len(out[-1]), max_length) # Retrieve remaining uncompressed data while not bzd.eof: out.append(bzd.decompress(b'', max_length=max_length)) self.assertLessEqual(len(out[-1]), max_length) out = b"".join(out) self.assertEqual(out, self.BIG_TEXT) self.assertEqual(bzd.unused_data, b"") def test_decompressor_inputbuf_1(self): # Test reusing input buffer after moving existing # contents to beginning bzd = BZ2Decompressor() out = [] # Create input buffer and fill it self.assertEqual(bzd.decompress(self.DATA[:100], max_length=0), b'') # Retrieve some results, freeing capacity at beginning # of input buffer out.append(bzd.decompress(b'', 2)) # Add more data that fits into input buffer after # moving existing data to beginning out.append(bzd.decompress(self.DATA[100:105], 15)) # Decompress rest of data out.append(bzd.decompress(self.DATA[105:])) self.assertEqual(b''.join(out), self.TEXT) def test_decompressor_inputbuf_2(self): # Test reusing input buffer by appending data at the # end right away bzd = BZ2Decompressor() out = [] # Create input buffer and empty it self.assertEqual(bzd.decompress(self.DATA[:200], max_length=0), b'') out.append(bzd.decompress(b'')) # Fill buffer with new data out.append(bzd.decompress(self.DATA[200:280], 2)) # Append some more data, not enough to require resize out.append(bzd.decompress(self.DATA[280:300], 2)) # Decompress rest of data out.append(bzd.decompress(self.DATA[300:])) self.assertEqual(b''.join(out), self.TEXT) def test_decompressor_inputbuf_3(self): # Test reusing input buffer after extending it bzd = BZ2Decompressor() out = [] # Create almost full input buffer out.append(bzd.decompress(self.DATA[:200], 5)) # Add even more data to it, requiring resize out.append(bzd.decompress(self.DATA[200:300], 5)) # Decompress rest of data out.append(bzd.decompress(self.DATA[300:])) self.assertEqual(b''.join(out), self.TEXT) def test_failure(self): bzd = BZ2Decompressor() self.assertRaises(Exception, bzd.decompress, self.BAD_DATA * 30) # Previously, a second call could crash due to internal inconsistency self.assertRaises(Exception, bzd.decompress, self.BAD_DATA * 30) @support.refcount_test def test_refleaks_in___init__(self): gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') bzd = BZ2Decompressor() refs_before = gettotalrefcount() for i in range(100): bzd.__init__() self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) class CompressDecompressTest(BaseTest): def testCompress(self): data = bz2.compress(self.TEXT) self.assertEqual(ext_decompress(data), self.TEXT) def testCompressEmptyString(self): text = bz2.compress(b'') self.assertEqual(text, self.EMPTY_DATA) def testDecompress(self): text = bz2.decompress(self.DATA) self.assertEqual(text, self.TEXT) def testDecompressEmpty(self): text = bz2.decompress(b"") self.assertEqual(text, b"") def testDecompressToEmptyString(self): text = bz2.decompress(self.EMPTY_DATA) self.assertEqual(text, b'') def testDecompressIncomplete(self): self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) def testDecompressBadData(self): self.assertRaises(OSError, bz2.decompress, self.BAD_DATA) def testDecompressMultiStream(self): text = bz2.decompress(self.DATA * 5) self.assertEqual(text, self.TEXT * 5) def testDecompressTrailingJunk(self): text = bz2.decompress(self.DATA + self.BAD_DATA) self.assertEqual(text, self.TEXT) def testDecompressMultiStreamTrailingJunk(self): text = bz2.decompress(self.DATA * 5 + self.BAD_DATA) self.assertEqual(text, self.TEXT * 5) class OpenTest(BaseTest): "Test the open function." def open(self, *args, **kwargs): return bz2.open(*args, **kwargs) def test_binary_modes(self): for mode in ("wb", "xb"): if mode == "xb": unlink(self.filename) with self.open(self.filename, mode) as f: f.write(self.TEXT) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()) self.assertEqual(file_data, self.TEXT) with self.open(self.filename, "rb") as f: self.assertEqual(f.read(), self.TEXT) with self.open(self.filename, "ab") as f: f.write(self.TEXT) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()) self.assertEqual(file_data, self.TEXT * 2) def test_implicit_binary_modes(self): # Test implicit binary modes (no "b" or "t" in mode string). for mode in ("w", "x"): if mode == "x": unlink(self.filename) with self.open(self.filename, mode) as f: f.write(self.TEXT) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()) self.assertEqual(file_data, self.TEXT) with self.open(self.filename, "r") as f: self.assertEqual(f.read(), self.TEXT) with self.open(self.filename, "a") as f: f.write(self.TEXT) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()) self.assertEqual(file_data, self.TEXT * 2) def test_text_modes(self): text = self.TEXT.decode("ascii") text_native_eol = text.replace("\n", os.linesep) for mode in ("wt", "xt"): if mode == "xt": unlink(self.filename) with self.open(self.filename, mode) as f: f.write(text) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()).decode("ascii") self.assertEqual(file_data, text_native_eol) with self.open(self.filename, "rt") as f: self.assertEqual(f.read(), text) with self.open(self.filename, "at") as f: f.write(text) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()).decode("ascii") self.assertEqual(file_data, text_native_eol * 2) def test_x_mode(self): for mode in ("x", "xb", "xt"): unlink(self.filename) with self.open(self.filename, mode) as f: pass with self.assertRaises(FileExistsError): with self.open(self.filename, mode) as f: pass def test_fileobj(self): with self.open(BytesIO(self.DATA), "r") as f: self.assertEqual(f.read(), self.TEXT) with self.open(BytesIO(self.DATA), "rb") as f: self.assertEqual(f.read(), self.TEXT) text = self.TEXT.decode("ascii") with self.open(BytesIO(self.DATA), "rt") as f: self.assertEqual(f.read(), text) def test_bad_params(self): # Test invalid parameter combinations. self.assertRaises(ValueError, self.open, self.filename, "wbt") self.assertRaises(ValueError, self.open, self.filename, "xbt") self.assertRaises(ValueError, self.open, self.filename, "rb", encoding="utf-8") self.assertRaises(ValueError, self.open, self.filename, "rb", errors="ignore") self.assertRaises(ValueError, self.open, self.filename, "rb", newline="\n") def test_encoding(self): # Test non-default encoding. text = self.TEXT.decode("ascii") text_native_eol = text.replace("\n", os.linesep) with self.open(self.filename, "wt", encoding="utf-16-le") as f: f.write(text) with open(self.filename, "rb") as f: file_data = ext_decompress(f.read()).decode("utf-16-le") self.assertEqual(file_data, text_native_eol) with self.open(self.filename, "rt", encoding="utf-16-le") as f: self.assertEqual(f.read(), text) def test_encoding_error_handler(self): # Test with non-default encoding error handler. with self.open(self.filename, "wb") as f: f.write(b"foo\xffbar") with self.open(self.filename, "rt", encoding="ascii", errors="ignore") \ as f: self.assertEqual(f.read(), "foobar") def test_newline(self): # Test with explicit newline (universal newline mode disabled). text = self.TEXT.decode("ascii") with self.open(self.filename, "wt", newline="\n") as f: f.write(text) with self.open(self.filename, "rt", newline="\r") as f: self.assertEqual(f.readlines(), [text]) def test_main(): support.run_unittest( BZ2FileTest, BZ2CompressorTest, BZ2DecompressorTest, CompressDecompressTest, OpenTest, ) support.reap_children() if __name__ == '__main__': test_main()
38,104
1,017
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_codecmaps_hk.py
# # test_codecmaps_hk.py # Codec mapping tests for HongKong encodings # from test import multibytecodec_support import unittest class TestBig5HKSCSMap(multibytecodec_support.TestBase_Mapping, unittest.TestCase): encoding = 'big5hkscs' mapfileurl = '/zip/.python/test/BIG5HKSCS-2004.TXT' if __name__ == "__main__": unittest.main()
370
16
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_dtrace.py
import dis import os.path import re import subprocess import sys import types import unittest from test.support import findfile, run_unittest def abspath(filename): return os.path.abspath(findfile(filename, subdir="dtracedata")) def normalize_trace_output(output): """Normalize DTrace output for comparison. DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers are concatenated. So if the operating system moves our thread around, the straight result can be "non-causal". So we add timestamps to the probe firing, sort by that field, then strip it from the output""" # When compiling with '--with-pydebug', strip '[# refs]' debug output. output = re.sub(r"\[[0-9]+ refs\]", "", output) try: result = [ row.split("\t") for row in output.splitlines() if row and not row.startswith('#') ] result.sort(key=lambda row: int(row[0])) result = [row[1] for row in result] return "\n".join(result) except (IndexError, ValueError): raise AssertionError( "tracer produced unparseable output:\n{}".format(output) ) class TraceBackend: EXTENSION = None COMMAND = None COMMAND_ARGS = [] def run_case(self, name, optimize_python=None): actual_output = normalize_trace_output(self.trace_python( script_file=abspath(name + self.EXTENSION), python_file=abspath(name + ".py"), optimize_python=optimize_python)) with open(abspath(name + self.EXTENSION + ".expected")) as f: expected_output = f.read().rstrip() return (expected_output, actual_output) def generate_trace_command(self, script_file, subcommand=None): command = self.COMMAND + [script_file] if subcommand: command += ["-c", subcommand] return command def trace(self, script_file, subcommand=None): command = self.generate_trace_command(script_file, subcommand) stdout, _ = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True).communicate() return stdout def trace_python(self, script_file, python_file, optimize_python=None): python_flags = [] if optimize_python: python_flags.extend(["-O"] * optimize_python) subcommand = " ".join([sys.executable] + python_flags + [python_file]) return self.trace(script_file, subcommand) def assert_usable(self): try: output = self.trace(abspath("assert_usable" + self.EXTENSION)) output = output.strip() except (FileNotFoundError, NotADirectoryError, PermissionError) as fnfe: output = str(fnfe) if output != "probe: success": raise unittest.SkipTest( "{}(1) failed: {}".format(self.COMMAND[0], output) ) class DTraceBackend(TraceBackend): EXTENSION = ".d" COMMAND = ["dtrace", "-q", "-s"] class SystemTapBackend(TraceBackend): EXTENSION = ".stp" COMMAND = ["stap", "-g"] class TraceTests(unittest.TestCase): # unittest.TestCase options maxDiff = None # TraceTests options backend = None optimize_python = 0 @classmethod def setUpClass(self): self.backend.assert_usable() def run_case(self, name): actual_output, expected_output = self.backend.run_case( name, optimize_python=self.optimize_python) self.assertEqual(actual_output, expected_output) def test_function_entry_return(self): self.run_case("call_stack") def test_verify_call_opcodes(self): """Ensure our call stack test hits all function call opcodes""" opcodes = set(["CALL_FUNCTION", "CALL_FUNCTION_EX", "CALL_FUNCTION_KW"]) with open(abspath("call_stack.py")) as f: code_string = f.read() def get_function_instructions(funcname): # Recompile with appropriate optimization setting code = compile(source=code_string, filename="<string>", mode="exec", optimize=self.optimize_python) for c in code.co_consts: if isinstance(c, types.CodeType) and c.co_name == funcname: return dis.get_instructions(c) return [] for instruction in get_function_instructions('start'): opcodes.discard(instruction.opname) self.assertEqual(set(), opcodes) def test_gc(self): self.run_case("gc") def test_line(self): self.run_case("line") class DTraceNormalTests(TraceTests): backend = DTraceBackend() optimize_python = 0 class DTraceOptimizedTests(TraceTests): backend = DTraceBackend() optimize_python = 2 class SystemTapNormalTests(TraceTests): backend = SystemTapBackend() optimize_python = 0 class SystemTapOptimizedTests(TraceTests): backend = SystemTapBackend() optimize_python = 2 def test_main(): run_unittest(DTraceNormalTests, DTraceOptimizedTests, SystemTapNormalTests, SystemTapOptimizedTests) if __name__ == '__main__': test_main()
5,356
179
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_buffer.py
# # The ndarray object from _testbuffer.c is a complete implementation of # a PEP-3118 buffer provider. It is independent from NumPy's ndarray # and the tests don't require NumPy. # # If NumPy is present, some tests check both ndarray implementations # against each other. # # Most ndarray tests also check that memoryview(ndarray) behaves in # the same way as the original. Thus, a substantial part of the # memoryview tests is now in this module. # import contextlib import unittest from test import support from itertools import permutations, product from random import randrange, sample, choice import warnings import sys, array, io, os from decimal import Decimal from fractions import Fraction try: from _testbuffer import * except ImportError: ndarray = None try: import struct except ImportError: struct = None try: import ctypes except ImportError: ctypes = None try: with support.EnvironmentVarGuard() as os.environ, \ warnings.catch_warnings(): from numpy import ndarray as numpy_array except ImportError: numpy_array = None SHORT_TEST = True # ====================================================================== # Random lists by format specifier # ====================================================================== # Native format chars and their ranges. NATIVE = { '?':0, 'c':0, 'b':0, 'B':0, 'h':0, 'H':0, 'i':0, 'I':0, 'l':0, 'L':0, 'n':0, 'N':0, 'f':0, 'd':0, 'P':0 } # NumPy does not have 'n' or 'N': if numpy_array: del NATIVE['n'] del NATIVE['N'] if struct: try: # Add "qQ" if present in native mode. struct.pack('Q', 2**64-1) NATIVE['q'] = 0 NATIVE['Q'] = 0 except struct.error: pass # Standard format chars and their ranges. STANDARD = { '?':(0, 2), 'c':(0, 1<<8), 'b':(-(1<<7), 1<<7), 'B':(0, 1<<8), 'h':(-(1<<15), 1<<15), 'H':(0, 1<<16), 'i':(-(1<<31), 1<<31), 'I':(0, 1<<32), 'l':(-(1<<31), 1<<31), 'L':(0, 1<<32), 'q':(-(1<<63), 1<<63), 'Q':(0, 1<<64), 'f':(-(1<<63), 1<<63), 'd':(-(1<<1023), 1<<1023) } def native_type_range(fmt): """Return range of a native type.""" if fmt == 'c': lh = (0, 256) elif fmt == '?': lh = (0, 2) elif fmt == 'f': lh = (-(1<<63), 1<<63) elif fmt == 'd': lh = (-(1<<1023), 1<<1023) else: for exp in (128, 127, 64, 63, 32, 31, 16, 15, 8, 7): try: struct.pack(fmt, (1<<exp)-1) break except struct.error: pass lh = (-(1<<exp), 1<<exp) if exp & 1 else (0, 1<<exp) return lh fmtdict = { '':NATIVE, '@':NATIVE, '<':STANDARD, '>':STANDARD, '=':STANDARD, '!':STANDARD } if struct: for fmt in fmtdict['@']: fmtdict['@'][fmt] = native_type_range(fmt) MEMORYVIEW = NATIVE.copy() ARRAY = NATIVE.copy() for k in NATIVE: if not k in "bBhHiIlLfd": del ARRAY[k] BYTEFMT = NATIVE.copy() for k in NATIVE: if not k in "Bbc": del BYTEFMT[k] fmtdict['m'] = MEMORYVIEW fmtdict['@m'] = MEMORYVIEW fmtdict['a'] = ARRAY fmtdict['b'] = BYTEFMT fmtdict['@b'] = BYTEFMT # Capabilities of the test objects: MODE = 0 MULT = 1 cap = { # format chars # multiplier 'ndarray': (['', '@', '<', '>', '=', '!'], ['', '1', '2', '3']), 'array': (['a'], ['']), 'numpy': ([''], ['']), 'memoryview': (['@m', 'm'], ['']), 'bytefmt': (['@b', 'b'], ['']), } def randrange_fmt(mode, char, obj): """Return random item for a type specified by a mode and a single format character.""" x = randrange(*fmtdict[mode][char]) if char == 'c': x = bytes([x]) if obj == 'numpy' and x == b'\x00': # http://projects.scipy.org/numpy/ticket/1925 x = b'\x01' if char == '?': x = bool(x) if char == 'f' or char == 'd': x = struct.pack(char, x) x = struct.unpack(char, x)[0] return x def gen_item(fmt, obj): """Return single random item.""" mode, chars = fmt.split('#') x = [] for c in chars: x.append(randrange_fmt(mode, c, obj)) return x[0] if len(x) == 1 else tuple(x) def gen_items(n, fmt, obj): """Return a list of random items (or a scalar).""" if n == 0: return gen_item(fmt, obj) lst = [0] * n for i in range(n): lst[i] = gen_item(fmt, obj) return lst def struct_items(n, obj): mode = choice(cap[obj][MODE]) xfmt = mode + '#' fmt = mode.strip('amb') nmemb = randrange(2, 10) # number of struct members for _ in range(nmemb): char = choice(tuple(fmtdict[mode])) multiplier = choice(cap[obj][MULT]) xfmt += (char * int(multiplier if multiplier else 1)) fmt += (multiplier + char) items = gen_items(n, xfmt, obj) item = gen_item(xfmt, obj) return fmt, items, item def randitems(n, obj='ndarray', mode=None, char=None): """Return random format, items, item.""" if mode is None: mode = choice(cap[obj][MODE]) if char is None: char = choice(tuple(fmtdict[mode])) multiplier = choice(cap[obj][MULT]) fmt = mode + '#' + char * int(multiplier if multiplier else 1) items = gen_items(n, fmt, obj) item = gen_item(fmt, obj) fmt = mode.strip('amb') + multiplier + char return fmt, items, item def iter_mode(n, obj='ndarray'): """Iterate through supported mode/char combinations.""" for mode in cap[obj][MODE]: for char in fmtdict[mode]: yield randitems(n, obj, mode, char) def iter_format(nitems, testobj='ndarray'): """Yield (format, items, item) for all possible modes and format characters plus one random compound format string.""" for t in iter_mode(nitems, testobj): yield t if testobj != 'ndarray': return yield struct_items(nitems, testobj) def is_byte_format(fmt): return 'c' in fmt or 'b' in fmt or 'B' in fmt def is_memoryview_format(fmt): """format suitable for memoryview""" x = len(fmt) return ((x == 1 or (x == 2 and fmt[0] == '@')) and fmt[x-1] in MEMORYVIEW) NON_BYTE_FORMAT = [c for c in fmtdict['@'] if not is_byte_format(c)] # ====================================================================== # Multi-dimensional tolist(), slicing and slice assignments # ====================================================================== def atomp(lst): """Tuple items (representing structs) are regarded as atoms.""" return not isinstance(lst, list) def listp(lst): return isinstance(lst, list) def prod(lst): """Product of list elements.""" if len(lst) == 0: return 0 x = lst[0] for v in lst[1:]: x *= v return x def strides_from_shape(ndim, shape, itemsize, layout): """Calculate strides of a contiguous array. Layout is 'C' or 'F' (Fortran).""" if ndim == 0: return () if layout == 'C': strides = list(shape[1:]) + [itemsize] for i in range(ndim-2, -1, -1): strides[i] *= strides[i+1] else: strides = [itemsize] + list(shape[:-1]) for i in range(1, ndim): strides[i] *= strides[i-1] return strides def _ca(items, s): """Convert flat item list to the nested list representation of a multidimensional C array with shape 's'.""" if atomp(items): return items if len(s) == 0: return items[0] lst = [0] * s[0] stride = len(items) // s[0] if s[0] else 0 for i in range(s[0]): start = i*stride lst[i] = _ca(items[start:start+stride], s[1:]) return lst def _fa(items, s): """Convert flat item list to the nested list representation of a multidimensional Fortran array with shape 's'.""" if atomp(items): return items if len(s) == 0: return items[0] lst = [0] * s[0] stride = s[0] for i in range(s[0]): lst[i] = _fa(items[i::stride], s[1:]) return lst def carray(items, shape): if listp(items) and not 0 in shape and prod(shape) != len(items): raise ValueError("prod(shape) != len(items)") return _ca(items, shape) def farray(items, shape): if listp(items) and not 0 in shape and prod(shape) != len(items): raise ValueError("prod(shape) != len(items)") return _fa(items, shape) def indices(shape): """Generate all possible tuples of indices.""" iterables = [range(v) for v in shape] return product(*iterables) def getindex(ndim, ind, strides): """Convert multi-dimensional index to the position in the flat list.""" ret = 0 for i in range(ndim): ret += strides[i] * ind[i] return ret def transpose(src, shape): """Transpose flat item list that is regarded as a multi-dimensional matrix defined by shape: dest...[k][j][i] = src[i][j][k]... """ if not shape: return src ndim = len(shape) sstrides = strides_from_shape(ndim, shape, 1, 'C') dstrides = strides_from_shape(ndim, shape[::-1], 1, 'C') dest = [0] * len(src) for ind in indices(shape): fr = getindex(ndim, ind, sstrides) to = getindex(ndim, ind[::-1], dstrides) dest[to] = src[fr] return dest def _flatten(lst): """flatten list""" if lst == []: return lst if atomp(lst): return [lst] return _flatten(lst[0]) + _flatten(lst[1:]) def flatten(lst): """flatten list or return scalar""" if atomp(lst): # scalar return lst return _flatten(lst) def slice_shape(lst, slices): """Get the shape of lst after slicing: slices is a list of slice objects.""" if atomp(lst): return [] return [len(lst[slices[0]])] + slice_shape(lst[0], slices[1:]) def multislice(lst, slices): """Multi-dimensional slicing: slices is a list of slice objects.""" if atomp(lst): return lst return [multislice(sublst, slices[1:]) for sublst in lst[slices[0]]] def m_assign(llst, rlst, lslices, rslices): """Multi-dimensional slice assignment: llst and rlst are the operands, lslices and rslices are lists of slice objects. llst and rlst must have the same structure. For a two-dimensional example, this is not implemented in Python: llst[0:3:2, 0:3:2] = rlst[1:3:1, 1:3:1] Instead we write: lslices = [slice(0,3,2), slice(0,3,2)] rslices = [slice(1,3,1), slice(1,3,1)] multislice_assign(llst, rlst, lslices, rslices) """ if atomp(rlst): return rlst rlst = [m_assign(l, r, lslices[1:], rslices[1:]) for l, r in zip(llst[lslices[0]], rlst[rslices[0]])] llst[lslices[0]] = rlst return llst def cmp_structure(llst, rlst, lslices, rslices): """Compare the structure of llst[lslices] and rlst[rslices].""" lshape = slice_shape(llst, lslices) rshape = slice_shape(rlst, rslices) if (len(lshape) != len(rshape)): return -1 for i in range(len(lshape)): if lshape[i] != rshape[i]: return -1 if lshape[i] == 0: return 0 return 0 def multislice_assign(llst, rlst, lslices, rslices): """Return llst after assigning: llst[lslices] = rlst[rslices]""" if cmp_structure(llst, rlst, lslices, rslices) < 0: raise ValueError("lvalue and rvalue have different structures") return m_assign(llst, rlst, lslices, rslices) # ====================================================================== # Random structures # ====================================================================== # # PEP-3118 is very permissive with respect to the contents of a # Py_buffer. In particular: # # - shape can be zero # - strides can be any integer, including zero # - offset can point to any location in the underlying # memory block, provided that it is a multiple of # itemsize. # # The functions in this section test and verify random structures # in full generality. A structure is valid iff it fits in the # underlying memory block. # # The structure 't' (short for 'tuple') is fully defined by: # # t = (memlen, itemsize, ndim, shape, strides, offset) # def verify_structure(memlen, itemsize, ndim, shape, strides, offset): """Verify that the parameters represent a valid array within the bounds of the allocated memory: char *mem: start of the physical memory block memlen: length of the physical memory block offset: (char *)buf - mem """ if offset % itemsize: return False if offset < 0 or offset+itemsize > memlen: return False if any(v % itemsize for v in strides): return False if ndim <= 0: return ndim == 0 and not shape and not strides if 0 in shape: return True imin = sum(strides[j]*(shape[j]-1) for j in range(ndim) if strides[j] <= 0) imax = sum(strides[j]*(shape[j]-1) for j in range(ndim) if strides[j] > 0) return 0 <= offset+imin and offset+imax+itemsize <= memlen def get_item(lst, indices): for i in indices: lst = lst[i] return lst def memory_index(indices, t): """Location of an item in the underlying memory.""" memlen, itemsize, ndim, shape, strides, offset = t p = offset for i in range(ndim): p += strides[i]*indices[i] return p def is_overlapping(t): """The structure 't' is overlapping if at least one memory location is visited twice while iterating through all possible tuples of indices.""" memlen, itemsize, ndim, shape, strides, offset = t visited = 1<<memlen for ind in indices(shape): i = memory_index(ind, t) bit = 1<<i if visited & bit: return True visited |= bit return False def rand_structure(itemsize, valid, maxdim=5, maxshape=16, shape=()): """Return random structure: (memlen, itemsize, ndim, shape, strides, offset) If 'valid' is true, the returned structure is valid, otherwise invalid. If 'shape' is given, use that instead of creating a random shape. """ if not shape: ndim = randrange(maxdim+1) if (ndim == 0): if valid: return itemsize, itemsize, ndim, (), (), 0 else: nitems = randrange(1, 16+1) memlen = nitems * itemsize offset = -itemsize if randrange(2) == 0 else memlen return memlen, itemsize, ndim, (), (), offset minshape = 2 n = randrange(100) if n >= 95 and valid: minshape = 0 elif n >= 90: minshape = 1 shape = [0] * ndim for i in range(ndim): shape[i] = randrange(minshape, maxshape+1) else: ndim = len(shape) maxstride = 5 n = randrange(100) zero_stride = True if n >= 95 and n & 1 else False strides = [0] * ndim strides[ndim-1] = itemsize * randrange(-maxstride, maxstride+1) if not zero_stride and strides[ndim-1] == 0: strides[ndim-1] = itemsize for i in range(ndim-2, -1, -1): maxstride *= shape[i+1] if shape[i+1] else 1 if zero_stride: strides[i] = itemsize * randrange(-maxstride, maxstride+1) else: strides[i] = ((1,-1)[randrange(2)] * itemsize * randrange(1, maxstride+1)) imin = imax = 0 if not 0 in shape: imin = sum(strides[j]*(shape[j]-1) for j in range(ndim) if strides[j] <= 0) imax = sum(strides[j]*(shape[j]-1) for j in range(ndim) if strides[j] > 0) nitems = imax - imin if valid: offset = -imin * itemsize memlen = offset + (imax+1) * itemsize else: memlen = (-imin + imax) * itemsize offset = -imin-itemsize if randrange(2) == 0 else memlen return memlen, itemsize, ndim, shape, strides, offset def randslice_from_slicelen(slicelen, listlen): """Create a random slice of len slicelen that fits into listlen.""" maxstart = listlen - slicelen start = randrange(maxstart+1) maxstep = (listlen - start) // slicelen if slicelen else 1 step = randrange(1, maxstep+1) stop = start + slicelen * step s = slice(start, stop, step) _, _, _, control = slice_indices(s, listlen) if control != slicelen: raise RuntimeError return s def randslice_from_shape(ndim, shape): """Create two sets of slices for an array x with shape 'shape' such that shapeof(x[lslices]) == shapeof(x[rslices]).""" lslices = [0] * ndim rslices = [0] * ndim for n in range(ndim): l = shape[n] slicelen = randrange(1, l+1) if l > 0 else 0 lslices[n] = randslice_from_slicelen(slicelen, l) rslices[n] = randslice_from_slicelen(slicelen, l) return tuple(lslices), tuple(rslices) def rand_aligned_slices(maxdim=5, maxshape=16): """Create (lshape, rshape, tuple(lslices), tuple(rslices)) such that shapeof(x[lslices]) == shapeof(y[rslices]), where x is an array with shape 'lshape' and y is an array with shape 'rshape'.""" ndim = randrange(1, maxdim+1) minshape = 2 n = randrange(100) if n >= 95: minshape = 0 elif n >= 90: minshape = 1 all_random = True if randrange(100) >= 80 else False lshape = [0]*ndim; rshape = [0]*ndim lslices = [0]*ndim; rslices = [0]*ndim for n in range(ndim): small = randrange(minshape, maxshape+1) big = randrange(minshape, maxshape+1) if big < small: big, small = small, big # Create a slice that fits the smaller value. if all_random: start = randrange(-small, small+1) stop = randrange(-small, small+1) step = (1,-1)[randrange(2)] * randrange(1, small+2) s_small = slice(start, stop, step) _, _, _, slicelen = slice_indices(s_small, small) else: slicelen = randrange(1, small+1) if small > 0 else 0 s_small = randslice_from_slicelen(slicelen, small) # Create a slice of the same length for the bigger value. s_big = randslice_from_slicelen(slicelen, big) if randrange(2) == 0: rshape[n], lshape[n] = big, small rslices[n], lslices[n] = s_big, s_small else: rshape[n], lshape[n] = small, big rslices[n], lslices[n] = s_small, s_big return lshape, rshape, tuple(lslices), tuple(rslices) def randitems_from_structure(fmt, t): """Return a list of random items for structure 't' with format 'fmtchar'.""" memlen, itemsize, _, _, _, _ = t return gen_items(memlen//itemsize, '#'+fmt, 'numpy') def ndarray_from_structure(items, fmt, t, flags=0): """Return ndarray from the tuple returned by rand_structure()""" memlen, itemsize, ndim, shape, strides, offset = t return ndarray(items, shape=shape, strides=strides, format=fmt, offset=offset, flags=ND_WRITABLE|flags) def numpy_array_from_structure(items, fmt, t): """Return numpy_array from the tuple returned by rand_structure()""" memlen, itemsize, ndim, shape, strides, offset = t buf = bytearray(memlen) for j, v in enumerate(items): struct.pack_into(fmt, buf, j*itemsize, v) return numpy_array(buffer=buf, shape=shape, strides=strides, dtype=fmt, offset=offset) # ====================================================================== # memoryview casts # ====================================================================== def cast_items(exporter, fmt, itemsize, shape=None): """Interpret the raw memory of 'exporter' as a list of items with size 'itemsize'. If shape=None, the new structure is assumed to be 1-D with n * itemsize = bytelen. If shape is given, the usual constraint for contiguous arrays prod(shape) * itemsize = bytelen applies. On success, return (items, shape). If the constraints cannot be met, return (None, None). If a chunk of bytes is interpreted as NaN as a result of float conversion, return ('nan', None).""" bytelen = exporter.nbytes if shape: if prod(shape) * itemsize != bytelen: return None, shape elif shape == []: if exporter.ndim == 0 or itemsize != bytelen: return None, shape else: n, r = divmod(bytelen, itemsize) shape = [n] if r != 0: return None, shape mem = exporter.tobytes() byteitems = [mem[i:i+itemsize] for i in range(0, len(mem), itemsize)] items = [] for v in byteitems: item = struct.unpack(fmt, v)[0] if item != item: return 'nan', shape items.append(item) return (items, shape) if shape != [] else (items[0], shape) def gencastshapes(): """Generate shapes to test casting.""" for n in range(32): yield [n] ndim = randrange(4, 6) minshape = 1 if randrange(100) > 80 else 2 yield [randrange(minshape, 5) for _ in range(ndim)] ndim = randrange(2, 4) minshape = 1 if randrange(100) > 80 else 2 yield [randrange(minshape, 5) for _ in range(ndim)] # ====================================================================== # Actual tests # ====================================================================== def genslices(n): """Generate all possible slices for a single dimension.""" return product(range(-n, n+1), range(-n, n+1), range(-n, n+1)) def genslices_ndim(ndim, shape): """Generate all possible slice tuples for 'shape'.""" iterables = [genslices(shape[n]) for n in range(ndim)] return product(*iterables) def rslice(n, allow_empty=False): """Generate random slice for a single dimension of length n. If zero=True, the slices may be empty, otherwise they will be non-empty.""" minlen = 0 if allow_empty or n == 0 else 1 slicelen = randrange(minlen, n+1) return randslice_from_slicelen(slicelen, n) def rslices(n, allow_empty=False): """Generate random slices for a single dimension.""" for _ in range(5): yield rslice(n, allow_empty) def rslices_ndim(ndim, shape, iterations=5): """Generate random slice tuples for 'shape'.""" # non-empty slices for _ in range(iterations): yield tuple(rslice(shape[n]) for n in range(ndim)) # possibly empty slices for _ in range(iterations): yield tuple(rslice(shape[n], allow_empty=True) for n in range(ndim)) # invalid slices yield tuple(slice(0,1,0) for _ in range(ndim)) def rpermutation(iterable, r=None): pool = tuple(iterable) r = len(pool) if r is None else r yield tuple(sample(pool, r)) def ndarray_print(nd): """Print ndarray for debugging.""" try: x = nd.tolist() except (TypeError, NotImplementedError): x = nd.tobytes() if isinstance(nd, ndarray): offset = nd.offset flags = nd.flags else: offset = 'unknown' flags = 'unknown' print("ndarray(%s, shape=%s, strides=%s, suboffsets=%s, offset=%s, " "format='%s', itemsize=%s, flags=%s)" % (x, nd.shape, nd.strides, nd.suboffsets, offset, nd.format, nd.itemsize, flags)) sys.stdout.flush() ITERATIONS = 100 MAXDIM = 5 MAXSHAPE = 10 if SHORT_TEST: ITERATIONS = 10 MAXDIM = 3 MAXSHAPE = 4 genslices = rslices genslices_ndim = rslices_ndim permutations = rpermutation @unittest.skipUnless(struct, 'struct module required for this test.') @unittest.skipUnless(ndarray, 'ndarray object required for this test') class TestBufferProtocol(unittest.TestCase): def setUp(self): # The suboffsets tests need sizeof(void *). self.sizeof_void_p = get_sizeof_void_p() def verify(self, result, obj=-1, itemsize={1}, fmt=-1, readonly={1}, ndim={1}, shape=-1, strides=-1, lst=-1, sliced=False, cast=False): # Verify buffer contents against expected values. Default values # are deliberately initialized to invalid types. if shape: expected_len = prod(shape)*itemsize else: if not fmt: # array has been implicitly cast to unsigned bytes expected_len = len(lst) else: # ndim = 0 expected_len = itemsize # Reconstruct suboffsets from strides. Support for slicing # could be added, but is currently only needed for test_getbuf(). suboffsets = () if result.suboffsets: self.assertGreater(ndim, 0) suboffset0 = 0 for n in range(1, ndim): if shape[n] == 0: break if strides[n] <= 0: suboffset0 += -strides[n] * (shape[n]-1) suboffsets = [suboffset0] + [-1 for v in range(ndim-1)] # Not correct if slicing has occurred in the first dimension. stride0 = self.sizeof_void_p if strides[0] < 0: stride0 = -stride0 strides = [stride0] + list(strides[1:]) self.assertIs(result.obj, obj) self.assertEqual(result.nbytes, expected_len) self.assertEqual(result.itemsize, itemsize) self.assertEqual(result.format, fmt) self.assertEqual(result.readonly, readonly) self.assertEqual(result.ndim, ndim) self.assertEqual(result.shape, tuple(shape)) if not (sliced and suboffsets): self.assertEqual(result.strides, tuple(strides)) self.assertEqual(result.suboffsets, tuple(suboffsets)) if isinstance(result, ndarray) or is_memoryview_format(fmt): rep = result.tolist() if fmt else result.tobytes() self.assertEqual(rep, lst) if not fmt: # array has been cast to unsigned bytes, return # the remaining tests won't work. # PyBuffer_GetPointer() is the definition how to access an item. # If PyBuffer_GetPointer(indices) is correct for all possible # combinations of indices, the buffer is correct. # # Also test tobytes() against the flattened 'lst', with all items # packed to bytes. if not cast: # casts chop up 'lst' in different ways b = bytearray() buf_err = None for ind in indices(shape): try: item1 = get_pointer(result, ind) item2 = get_item(lst, ind) if isinstance(item2, tuple): x = struct.pack(fmt, *item2) else: x = struct.pack(fmt, item2) b.extend(x) except BufferError: buf_err = True # re-exporter does not provide full buffer break self.assertEqual(item1, item2) if not buf_err: # test tobytes() self.assertEqual(result.tobytes(), b) # test hex() m = memoryview(result) h = "".join("%02x" % c for c in b) self.assertEqual(m.hex(), h) # lst := expected multi-dimensional logical representation # flatten(lst) := elements in C-order ff = fmt if fmt else 'B' flattened = flatten(lst) # Rules for 'A': if the array is already contiguous, return # the array unaltered. Otherwise, return a contiguous 'C' # representation. for order in ['C', 'F', 'A']: expected = result if order == 'F': if not is_contiguous(result, 'A') or \ is_contiguous(result, 'C'): # For constructing the ndarray, convert the # flattened logical representation to Fortran order. trans = transpose(flattened, shape) expected = ndarray(trans, shape=shape, format=ff, flags=ND_FORTRAN) else: # 'C', 'A' if not is_contiguous(result, 'A') or \ is_contiguous(result, 'F') and order == 'C': # The flattened list is already in C-order. expected = ndarray(flattened, shape=shape, format=ff) contig = get_contiguous(result, PyBUF_READ, order) self.assertEqual(contig.tobytes(), b) self.assertTrue(cmp_contig(contig, expected)) if ndim == 0: continue nmemb = len(flattened) ro = 0 if readonly else ND_WRITABLE ### See comment in test_py_buffer_to_contiguous for an ### explanation why these tests are valid. # To 'C' contig = py_buffer_to_contiguous(result, 'C', PyBUF_FULL_RO) self.assertEqual(len(contig), nmemb * itemsize) initlst = [struct.unpack_from(fmt, contig, n*itemsize) for n in range(nmemb)] if len(initlst[0]) == 1: initlst = [v[0] for v in initlst] y = ndarray(initlst, shape=shape, flags=ro, format=fmt) self.assertEqual(memoryview(y), memoryview(result)) # To 'F' contig = py_buffer_to_contiguous(result, 'F', PyBUF_FULL_RO) self.assertEqual(len(contig), nmemb * itemsize) initlst = [struct.unpack_from(fmt, contig, n*itemsize) for n in range(nmemb)] if len(initlst[0]) == 1: initlst = [v[0] for v in initlst] y = ndarray(initlst, shape=shape, flags=ro|ND_FORTRAN, format=fmt) self.assertEqual(memoryview(y), memoryview(result)) # To 'A' contig = py_buffer_to_contiguous(result, 'A', PyBUF_FULL_RO) self.assertEqual(len(contig), nmemb * itemsize) initlst = [struct.unpack_from(fmt, contig, n*itemsize) for n in range(nmemb)] if len(initlst[0]) == 1: initlst = [v[0] for v in initlst] f = ND_FORTRAN if is_contiguous(result, 'F') else 0 y = ndarray(initlst, shape=shape, flags=f|ro, format=fmt) self.assertEqual(memoryview(y), memoryview(result)) if is_memoryview_format(fmt): try: m = memoryview(result) except BufferError: # re-exporter does not provide full information return ex = result.obj if isinstance(result, memoryview) else result self.assertIs(m.obj, ex) self.assertEqual(m.nbytes, expected_len) self.assertEqual(m.itemsize, itemsize) self.assertEqual(m.format, fmt) self.assertEqual(m.readonly, readonly) self.assertEqual(m.ndim, ndim) self.assertEqual(m.shape, tuple(shape)) if not (sliced and suboffsets): self.assertEqual(m.strides, tuple(strides)) self.assertEqual(m.suboffsets, tuple(suboffsets)) n = 1 if ndim == 0 else len(lst) self.assertEqual(len(m), n) rep = result.tolist() if fmt else result.tobytes() self.assertEqual(rep, lst) self.assertEqual(m, result) def verify_getbuf(self, orig_ex, ex, req, sliced=False): def simple_fmt(ex): return ex.format == '' or ex.format == 'B' def match(req, flag): return ((req&flag) == flag) if (# writable request to read-only exporter (ex.readonly and match(req, PyBUF_WRITABLE)) or # cannot match explicit contiguity request (match(req, PyBUF_C_CONTIGUOUS) and not ex.c_contiguous) or (match(req, PyBUF_F_CONTIGUOUS) and not ex.f_contiguous) or (match(req, PyBUF_ANY_CONTIGUOUS) and not ex.contiguous) or # buffer needs suboffsets (not match(req, PyBUF_INDIRECT) and ex.suboffsets) or # buffer without strides must be C-contiguous (not match(req, PyBUF_STRIDES) and not ex.c_contiguous) or # PyBUF_SIMPLE|PyBUF_FORMAT and PyBUF_WRITABLE|PyBUF_FORMAT (not match(req, PyBUF_ND) and match(req, PyBUF_FORMAT))): self.assertRaises(BufferError, ndarray, ex, getbuf=req) return if isinstance(ex, ndarray) or is_memoryview_format(ex.format): lst = ex.tolist() else: nd = ndarray(ex, getbuf=PyBUF_FULL_RO) lst = nd.tolist() # The consumer may have requested default values or a NULL format. ro = 0 if match(req, PyBUF_WRITABLE) else ex.readonly fmt = ex.format itemsize = ex.itemsize ndim = ex.ndim if not match(req, PyBUF_FORMAT): # itemsize refers to the original itemsize before the cast. # The equality product(shape) * itemsize = len still holds. # The equality calcsize(format) = itemsize does _not_ hold. fmt = '' lst = orig_ex.tobytes() # Issue 12834 if not match(req, PyBUF_ND): ndim = 1 shape = orig_ex.shape if match(req, PyBUF_ND) else () strides = orig_ex.strides if match(req, PyBUF_STRIDES) else () nd = ndarray(ex, getbuf=req) self.verify(nd, obj=ex, itemsize=itemsize, fmt=fmt, readonly=ro, ndim=ndim, shape=shape, strides=strides, lst=lst, sliced=sliced) def test_ndarray_getbuf(self): requests = ( # distinct flags PyBUF_INDIRECT, PyBUF_STRIDES, PyBUF_ND, PyBUF_SIMPLE, PyBUF_C_CONTIGUOUS, PyBUF_F_CONTIGUOUS, PyBUF_ANY_CONTIGUOUS, # compound requests PyBUF_FULL, PyBUF_FULL_RO, PyBUF_RECORDS, PyBUF_RECORDS_RO, PyBUF_STRIDED, PyBUF_STRIDED_RO, PyBUF_CONTIG, PyBUF_CONTIG_RO, ) # items and format items_fmt = ( ([True if x % 2 else False for x in range(12)], '?'), ([1,2,3,4,5,6,7,8,9,10,11,12], 'b'), ([1,2,3,4,5,6,7,8,9,10,11,12], 'B'), ([(2**31-x) if x % 2 else (-2**31+x) for x in range(12)], 'l') ) # shape, strides, offset structure = ( ([], [], 0), ([1,3,1], [], 0), ([12], [], 0), ([12], [-1], 11), ([6], [2], 0), ([6], [-2], 11), ([3, 4], [], 0), ([3, 4], [-4, -1], 11), ([2, 2], [4, 1], 4), ([2, 2], [-4, -1], 8) ) # ndarray creation flags ndflags = ( 0, ND_WRITABLE, ND_FORTRAN, ND_FORTRAN|ND_WRITABLE, ND_PIL, ND_PIL|ND_WRITABLE ) # flags that can actually be used as flags real_flags = (0, PyBUF_WRITABLE, PyBUF_FORMAT, PyBUF_WRITABLE|PyBUF_FORMAT) for items, fmt in items_fmt: itemsize = struct.calcsize(fmt) for shape, strides, offset in structure: strides = [v * itemsize for v in strides] offset *= itemsize for flags in ndflags: if strides and (flags&ND_FORTRAN): continue if not shape and (flags&ND_PIL): continue _items = items if shape else items[0] ex1 = ndarray(_items, format=fmt, flags=flags, shape=shape, strides=strides, offset=offset) ex2 = ex1[::-2] if shape else None m1 = memoryview(ex1) if ex2: m2 = memoryview(ex2) if ex1.ndim == 0 or (ex1.ndim == 1 and shape and strides): self.assertEqual(m1, ex1) if ex2 and ex2.ndim == 1 and shape and strides: self.assertEqual(m2, ex2) for req in requests: for bits in real_flags: self.verify_getbuf(ex1, ex1, req|bits) self.verify_getbuf(ex1, m1, req|bits) if ex2: self.verify_getbuf(ex2, ex2, req|bits, sliced=True) self.verify_getbuf(ex2, m2, req|bits, sliced=True) items = [1,2,3,4,5,6,7,8,9,10,11,12] # ND_GETBUF_FAIL ex = ndarray(items, shape=[12], flags=ND_GETBUF_FAIL) self.assertRaises(BufferError, ndarray, ex) # Request complex structure from a simple exporter. In this # particular case the test object is not PEP-3118 compliant. base = ndarray([9], [1]) ex = ndarray(base, getbuf=PyBUF_SIMPLE) self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_WRITABLE) self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_ND) self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_STRIDES) self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_C_CONTIGUOUS) self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_F_CONTIGUOUS) self.assertRaises(BufferError, ndarray, ex, getbuf=PyBUF_ANY_CONTIGUOUS) nd = ndarray(ex, getbuf=PyBUF_SIMPLE) # Issue #22445: New precise contiguity definition. for shape in [1,12,1], [7,0,7]: for order in 0, ND_FORTRAN: ex = ndarray(items, shape=shape, flags=order|ND_WRITABLE) self.assertTrue(is_contiguous(ex, 'F')) self.assertTrue(is_contiguous(ex, 'C')) for flags in requests: nd = ndarray(ex, getbuf=flags) self.assertTrue(is_contiguous(nd, 'F')) self.assertTrue(is_contiguous(nd, 'C')) def test_ndarray_exceptions(self): nd = ndarray([9], [1]) ndm = ndarray([9], [1], flags=ND_VAREXPORT) # Initialization of a new ndarray or mutation of an existing array. for c in (ndarray, nd.push, ndm.push): # Invalid types. self.assertRaises(TypeError, c, {1,2,3}) self.assertRaises(TypeError, c, [1,2,'3']) self.assertRaises(TypeError, c, [1,2,(3,4)]) self.assertRaises(TypeError, c, [1,2,3], shape={3}) self.assertRaises(TypeError, c, [1,2,3], shape=[3], strides={1}) self.assertRaises(TypeError, c, [1,2,3], shape=[3], offset=[]) self.assertRaises(TypeError, c, [1], shape=[1], format={}) self.assertRaises(TypeError, c, [1], shape=[1], flags={}) self.assertRaises(TypeError, c, [1], shape=[1], getbuf={}) # ND_FORTRAN flag is only valid without strides. self.assertRaises(TypeError, c, [1], shape=[1], strides=[1], flags=ND_FORTRAN) # ND_PIL flag is only valid with ndim > 0. self.assertRaises(TypeError, c, [1], shape=[], flags=ND_PIL) # Invalid items. self.assertRaises(ValueError, c, [], shape=[1]) self.assertRaises(ValueError, c, ['XXX'], shape=[1], format="L") # Invalid combination of items and format. self.assertRaises(struct.error, c, [1000], shape=[1], format="B") self.assertRaises(ValueError, c, [1,(2,3)], shape=[2], format="B") self.assertRaises(ValueError, c, [1,2,3], shape=[3], format="QL") # Invalid ndim. n = ND_MAX_NDIM+1 self.assertRaises(ValueError, c, [1]*n, shape=[1]*n) # Invalid shape. self.assertRaises(ValueError, c, [1], shape=[-1]) self.assertRaises(ValueError, c, [1,2,3], shape=['3']) self.assertRaises(OverflowError, c, [1], shape=[2**128]) # prod(shape) * itemsize != len(items) self.assertRaises(ValueError, c, [1,2,3,4,5], shape=[2,2], offset=3) # Invalid strides. self.assertRaises(ValueError, c, [1,2,3], shape=[3], strides=['1']) self.assertRaises(OverflowError, c, [1], shape=[1], strides=[2**128]) # Invalid combination of strides and shape. self.assertRaises(ValueError, c, [1,2], shape=[2,1], strides=[1]) # Invalid combination of strides and format. self.assertRaises(ValueError, c, [1,2,3,4], shape=[2], strides=[3], format="L") # Invalid offset. self.assertRaises(ValueError, c, [1,2,3], shape=[3], offset=4) self.assertRaises(ValueError, c, [1,2,3], shape=[1], offset=3, format="L") # Invalid format. self.assertRaises(ValueError, c, [1,2,3], shape=[3], format="") self.assertRaises(struct.error, c, [(1,2,3)], shape=[1], format="@#$") # Striding out of the memory bounds. items = [1,2,3,4,5,6,7,8,9,10] self.assertRaises(ValueError, c, items, shape=[2,3], strides=[-3, -2], offset=5) # Constructing consumer: format argument invalid. self.assertRaises(TypeError, c, bytearray(), format="Q") # Constructing original base object: getbuf argument invalid. self.assertRaises(TypeError, c, [1], shape=[1], getbuf=PyBUF_FULL) # Shape argument is mandatory for original base objects. self.assertRaises(TypeError, c, [1]) # PyBUF_WRITABLE request to read-only provider. self.assertRaises(BufferError, ndarray, b'123', getbuf=PyBUF_WRITABLE) # ND_VAREXPORT can only be specified during construction. nd = ndarray([9], [1], flags=ND_VAREXPORT) self.assertRaises(ValueError, nd.push, [1], [1], flags=ND_VAREXPORT) # Invalid operation for consumers: push/pop nd = ndarray(b'123') self.assertRaises(BufferError, nd.push, [1], [1]) self.assertRaises(BufferError, nd.pop) # ND_VAREXPORT not set: push/pop fail with exported buffers nd = ndarray([9], [1]) nd.push([1], [1]) m = memoryview(nd) self.assertRaises(BufferError, nd.push, [1], [1]) self.assertRaises(BufferError, nd.pop) m.release() nd.pop() # Single remaining buffer: pop fails self.assertRaises(BufferError, nd.pop) del nd # get_pointer() self.assertRaises(TypeError, get_pointer, {}, [1,2,3]) self.assertRaises(TypeError, get_pointer, b'123', {}) nd = ndarray(list(range(100)), shape=[1]*100) self.assertRaises(ValueError, get_pointer, nd, [5]) nd = ndarray(list(range(12)), shape=[3,4]) self.assertRaises(ValueError, get_pointer, nd, [2,3,4]) self.assertRaises(ValueError, get_pointer, nd, [3,3]) self.assertRaises(ValueError, get_pointer, nd, [-3,3]) self.assertRaises(OverflowError, get_pointer, nd, [1<<64,3]) # tolist() needs format ex = ndarray([1,2,3], shape=[3], format='L') nd = ndarray(ex, getbuf=PyBUF_SIMPLE) self.assertRaises(ValueError, nd.tolist) # memoryview_from_buffer() ex1 = ndarray([1,2,3], shape=[3], format='L') ex2 = ndarray(ex1) nd = ndarray(ex2) self.assertRaises(TypeError, nd.memoryview_from_buffer) nd = ndarray([(1,)*200], shape=[1], format='L'*200) self.assertRaises(TypeError, nd.memoryview_from_buffer) n = ND_MAX_NDIM nd = ndarray(list(range(n)), shape=[1]*n) self.assertRaises(ValueError, nd.memoryview_from_buffer) # get_contiguous() nd = ndarray([1], shape=[1]) self.assertRaises(TypeError, get_contiguous, 1, 2, 3, 4, 5) self.assertRaises(TypeError, get_contiguous, nd, "xyz", 'C') self.assertRaises(OverflowError, get_contiguous, nd, 2**64, 'C') self.assertRaises(TypeError, get_contiguous, nd, PyBUF_READ, 961) self.assertRaises(UnicodeEncodeError, get_contiguous, nd, PyBUF_READ, '\u2007') self.assertRaises(ValueError, get_contiguous, nd, PyBUF_READ, 'Z') self.assertRaises(ValueError, get_contiguous, nd, 255, 'A') # cmp_contig() nd = ndarray([1], shape=[1]) self.assertRaises(TypeError, cmp_contig, 1, 2, 3, 4, 5) self.assertRaises(TypeError, cmp_contig, {}, nd) self.assertRaises(TypeError, cmp_contig, nd, {}) # is_contiguous() nd = ndarray([1], shape=[1]) self.assertRaises(TypeError, is_contiguous, 1, 2, 3, 4, 5) self.assertRaises(TypeError, is_contiguous, {}, 'A') self.assertRaises(TypeError, is_contiguous, nd, 201) def test_ndarray_linked_list(self): for perm in permutations(range(5)): m = [0]*5 nd = ndarray([1,2,3], shape=[3], flags=ND_VAREXPORT) m[0] = memoryview(nd) for i in range(1, 5): nd.push([1,2,3], shape=[3]) m[i] = memoryview(nd) for i in range(5): m[perm[i]].release() self.assertRaises(BufferError, nd.pop) del nd def test_ndarray_format_scalar(self): # ndim = 0: scalar for fmt, scalar, _ in iter_format(0): itemsize = struct.calcsize(fmt) nd = ndarray(scalar, shape=(), format=fmt) self.verify(nd, obj=None, itemsize=itemsize, fmt=fmt, readonly=1, ndim=0, shape=(), strides=(), lst=scalar) def test_ndarray_format_shape(self): # ndim = 1, shape = [n] nitems = randrange(1, 10) for fmt, items, _ in iter_format(nitems): itemsize = struct.calcsize(fmt) for flags in (0, ND_PIL): nd = ndarray(items, shape=[nitems], format=fmt, flags=flags) self.verify(nd, obj=None, itemsize=itemsize, fmt=fmt, readonly=1, ndim=1, shape=(nitems,), strides=(itemsize,), lst=items) def test_ndarray_format_strides(self): # ndim = 1, strides nitems = randrange(1, 30) for fmt, items, _ in iter_format(nitems): itemsize = struct.calcsize(fmt) for step in range(-5, 5): if step == 0: continue shape = [len(items[::step])] strides = [step*itemsize] offset = itemsize*(nitems-1) if step < 0 else 0 for flags in (0, ND_PIL): nd = ndarray(items, shape=shape, strides=strides, format=fmt, offset=offset, flags=flags) self.verify(nd, obj=None, itemsize=itemsize, fmt=fmt, readonly=1, ndim=1, shape=shape, strides=strides, lst=items[::step]) def test_ndarray_fortran(self): items = [1,2,3,4,5,6,7,8,9,10,11,12] ex = ndarray(items, shape=(3, 4), strides=(1, 3)) nd = ndarray(ex, getbuf=PyBUF_F_CONTIGUOUS|PyBUF_FORMAT) self.assertEqual(nd.tolist(), farray(items, (3, 4))) def test_ndarray_multidim(self): for ndim in range(5): shape_t = [randrange(2, 10) for _ in range(ndim)] nitems = prod(shape_t) for shape in permutations(shape_t): fmt, items, _ = randitems(nitems) itemsize = struct.calcsize(fmt) for flags in (0, ND_PIL): if ndim == 0 and flags == ND_PIL: continue # C array nd = ndarray(items, shape=shape, format=fmt, flags=flags) strides = strides_from_shape(ndim, shape, itemsize, 'C') lst = carray(items, shape) self.verify(nd, obj=None, itemsize=itemsize, fmt=fmt, readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) if is_memoryview_format(fmt): # memoryview: reconstruct strides ex = ndarray(items, shape=shape, format=fmt) nd = ndarray(ex, getbuf=PyBUF_CONTIG_RO|PyBUF_FORMAT) self.assertTrue(nd.strides == ()) mv = nd.memoryview_from_buffer() self.verify(mv, obj=None, itemsize=itemsize, fmt=fmt, readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) # Fortran array nd = ndarray(items, shape=shape, format=fmt, flags=flags|ND_FORTRAN) strides = strides_from_shape(ndim, shape, itemsize, 'F') lst = farray(items, shape) self.verify(nd, obj=None, itemsize=itemsize, fmt=fmt, readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) def test_ndarray_index_invalid(self): # not writable nd = ndarray([1], shape=[1]) self.assertRaises(TypeError, nd.__setitem__, 1, 8) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertRaises(TypeError, mv.__setitem__, 1, 8) # cannot be deleted nd = ndarray([1], shape=[1], flags=ND_WRITABLE) self.assertRaises(TypeError, nd.__delitem__, 1) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertRaises(TypeError, mv.__delitem__, 1) # overflow nd = ndarray([1], shape=[1], flags=ND_WRITABLE) self.assertRaises(OverflowError, nd.__getitem__, 1<<64) self.assertRaises(OverflowError, nd.__setitem__, 1<<64, 8) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertRaises(IndexError, mv.__getitem__, 1<<64) self.assertRaises(IndexError, mv.__setitem__, 1<<64, 8) # format items = [1,2,3,4,5,6,7,8] nd = ndarray(items, shape=[len(items)], format="B", flags=ND_WRITABLE) self.assertRaises(struct.error, nd.__setitem__, 2, 300) self.assertRaises(ValueError, nd.__setitem__, 1, (100, 200)) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertRaises(ValueError, mv.__setitem__, 2, 300) self.assertRaises(TypeError, mv.__setitem__, 1, (100, 200)) items = [(1,2), (3,4), (5,6)] nd = ndarray(items, shape=[len(items)], format="LQ", flags=ND_WRITABLE) self.assertRaises(ValueError, nd.__setitem__, 2, 300) self.assertRaises(struct.error, nd.__setitem__, 1, (b'\x001', 200)) def test_ndarray_index_scalar(self): # scalar nd = ndarray(1, shape=(), flags=ND_WRITABLE) mv = memoryview(nd) self.assertEqual(mv, nd) x = nd[()]; self.assertEqual(x, 1) x = nd[...]; self.assertEqual(x.tolist(), nd.tolist()) x = mv[()]; self.assertEqual(x, 1) x = mv[...]; self.assertEqual(x.tolist(), nd.tolist()) self.assertRaises(TypeError, nd.__getitem__, 0) self.assertRaises(TypeError, mv.__getitem__, 0) self.assertRaises(TypeError, nd.__setitem__, 0, 8) self.assertRaises(TypeError, mv.__setitem__, 0, 8) self.assertEqual(nd.tolist(), 1) self.assertEqual(mv.tolist(), 1) nd[()] = 9; self.assertEqual(nd.tolist(), 9) mv[()] = 9; self.assertEqual(mv.tolist(), 9) nd[...] = 5; self.assertEqual(nd.tolist(), 5) mv[...] = 5; self.assertEqual(mv.tolist(), 5) def test_ndarray_index_null_strides(self): ex = ndarray(list(range(2*4)), shape=[2, 4], flags=ND_WRITABLE) nd = ndarray(ex, getbuf=PyBUF_CONTIG) # Sub-views are only possible for full exporters. self.assertRaises(BufferError, nd.__getitem__, 1) # Same for slices. self.assertRaises(BufferError, nd.__getitem__, slice(3,5,1)) def test_ndarray_index_getitem_single(self): # getitem for fmt, items, _ in iter_format(5): nd = ndarray(items, shape=[5], format=fmt) for i in range(-5, 5): self.assertEqual(nd[i], items[i]) self.assertRaises(IndexError, nd.__getitem__, -6) self.assertRaises(IndexError, nd.__getitem__, 5) if is_memoryview_format(fmt): mv = memoryview(nd) self.assertEqual(mv, nd) for i in range(-5, 5): self.assertEqual(mv[i], items[i]) self.assertRaises(IndexError, mv.__getitem__, -6) self.assertRaises(IndexError, mv.__getitem__, 5) # getitem with null strides for fmt, items, _ in iter_format(5): ex = ndarray(items, shape=[5], flags=ND_WRITABLE, format=fmt) nd = ndarray(ex, getbuf=PyBUF_CONTIG|PyBUF_FORMAT) for i in range(-5, 5): self.assertEqual(nd[i], items[i]) if is_memoryview_format(fmt): mv = nd.memoryview_from_buffer() self.assertIs(mv.__eq__(nd), NotImplemented) for i in range(-5, 5): self.assertEqual(mv[i], items[i]) # getitem with null format items = [1,2,3,4,5] ex = ndarray(items, shape=[5]) nd = ndarray(ex, getbuf=PyBUF_CONTIG_RO) for i in range(-5, 5): self.assertEqual(nd[i], items[i]) # getitem with null shape/strides/format items = [1,2,3,4,5] ex = ndarray(items, shape=[5]) nd = ndarray(ex, getbuf=PyBUF_SIMPLE) for i in range(-5, 5): self.assertEqual(nd[i], items[i]) def test_ndarray_index_setitem_single(self): # assign single value for fmt, items, single_item in iter_format(5): nd = ndarray(items, shape=[5], format=fmt, flags=ND_WRITABLE) for i in range(5): items[i] = single_item nd[i] = single_item self.assertEqual(nd.tolist(), items) self.assertRaises(IndexError, nd.__setitem__, -6, single_item) self.assertRaises(IndexError, nd.__setitem__, 5, single_item) if not is_memoryview_format(fmt): continue nd = ndarray(items, shape=[5], format=fmt, flags=ND_WRITABLE) mv = memoryview(nd) self.assertEqual(mv, nd) for i in range(5): items[i] = single_item mv[i] = single_item self.assertEqual(mv.tolist(), items) self.assertRaises(IndexError, mv.__setitem__, -6, single_item) self.assertRaises(IndexError, mv.__setitem__, 5, single_item) # assign single value: lobject = robject for fmt, items, single_item in iter_format(5): nd = ndarray(items, shape=[5], format=fmt, flags=ND_WRITABLE) for i in range(-5, 4): items[i] = items[i+1] nd[i] = nd[i+1] self.assertEqual(nd.tolist(), items) if not is_memoryview_format(fmt): continue nd = ndarray(items, shape=[5], format=fmt, flags=ND_WRITABLE) mv = memoryview(nd) self.assertEqual(mv, nd) for i in range(-5, 4): items[i] = items[i+1] mv[i] = mv[i+1] self.assertEqual(mv.tolist(), items) def test_ndarray_index_getitem_multidim(self): shape_t = (2, 3, 5) nitems = prod(shape_t) for shape in permutations(shape_t): fmt, items, _ = randitems(nitems) for flags in (0, ND_PIL): # C array nd = ndarray(items, shape=shape, format=fmt, flags=flags) lst = carray(items, shape) for i in range(-shape[0], shape[0]): self.assertEqual(lst[i], nd[i].tolist()) for j in range(-shape[1], shape[1]): self.assertEqual(lst[i][j], nd[i][j].tolist()) for k in range(-shape[2], shape[2]): self.assertEqual(lst[i][j][k], nd[i][j][k]) # Fortran array nd = ndarray(items, shape=shape, format=fmt, flags=flags|ND_FORTRAN) lst = farray(items, shape) for i in range(-shape[0], shape[0]): self.assertEqual(lst[i], nd[i].tolist()) for j in range(-shape[1], shape[1]): self.assertEqual(lst[i][j], nd[i][j].tolist()) for k in range(shape[2], shape[2]): self.assertEqual(lst[i][j][k], nd[i][j][k]) def test_ndarray_sequence(self): nd = ndarray(1, shape=()) self.assertRaises(TypeError, eval, "1 in nd", locals()) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertRaises(TypeError, eval, "1 in mv", locals()) for fmt, items, _ in iter_format(5): nd = ndarray(items, shape=[5], format=fmt) for i, v in enumerate(nd): self.assertEqual(v, items[i]) self.assertTrue(v in nd) if is_memoryview_format(fmt): mv = memoryview(nd) for i, v in enumerate(mv): self.assertEqual(v, items[i]) self.assertTrue(v in mv) def test_ndarray_slice_invalid(self): items = [1,2,3,4,5,6,7,8] # rvalue is not an exporter xl = ndarray(items, shape=[8], flags=ND_WRITABLE) ml = memoryview(xl) self.assertRaises(TypeError, xl.__setitem__, slice(0,8,1), items) self.assertRaises(TypeError, ml.__setitem__, slice(0,8,1), items) # rvalue is not a full exporter xl = ndarray(items, shape=[8], flags=ND_WRITABLE) ex = ndarray(items, shape=[8], flags=ND_WRITABLE) xr = ndarray(ex, getbuf=PyBUF_ND) self.assertRaises(BufferError, xl.__setitem__, slice(0,8,1), xr) # zero step nd = ndarray(items, shape=[8], format="L", flags=ND_WRITABLE) mv = memoryview(nd) self.assertRaises(ValueError, nd.__getitem__, slice(0,1,0)) self.assertRaises(ValueError, mv.__getitem__, slice(0,1,0)) nd = ndarray(items, shape=[2,4], format="L", flags=ND_WRITABLE) mv = memoryview(nd) self.assertRaises(ValueError, nd.__getitem__, (slice(0,1,1), slice(0,1,0))) self.assertRaises(ValueError, nd.__getitem__, (slice(0,1,0), slice(0,1,1))) self.assertRaises(TypeError, nd.__getitem__, "@%$") self.assertRaises(TypeError, nd.__getitem__, ("@%$", slice(0,1,1))) self.assertRaises(TypeError, nd.__getitem__, (slice(0,1,1), {})) # memoryview: not implemented self.assertRaises(NotImplementedError, mv.__getitem__, (slice(0,1,1), slice(0,1,0))) self.assertRaises(TypeError, mv.__getitem__, "@%$") # differing format xl = ndarray(items, shape=[8], format="B", flags=ND_WRITABLE) xr = ndarray(items, shape=[8], format="b") ml = memoryview(xl) mr = memoryview(xr) self.assertRaises(ValueError, xl.__setitem__, slice(0,1,1), xr[7:8]) self.assertEqual(xl.tolist(), items) self.assertRaises(ValueError, ml.__setitem__, slice(0,1,1), mr[7:8]) self.assertEqual(ml.tolist(), items) # differing itemsize xl = ndarray(items, shape=[8], format="B", flags=ND_WRITABLE) yr = ndarray(items, shape=[8], format="L") ml = memoryview(xl) mr = memoryview(xr) self.assertRaises(ValueError, xl.__setitem__, slice(0,1,1), xr[7:8]) self.assertEqual(xl.tolist(), items) self.assertRaises(ValueError, ml.__setitem__, slice(0,1,1), mr[7:8]) self.assertEqual(ml.tolist(), items) # differing ndim xl = ndarray(items, shape=[2, 4], format="b", flags=ND_WRITABLE) xr = ndarray(items, shape=[8], format="b") ml = memoryview(xl) mr = memoryview(xr) self.assertRaises(ValueError, xl.__setitem__, slice(0,1,1), xr[7:8]) self.assertEqual(xl.tolist(), [[1,2,3,4], [5,6,7,8]]) self.assertRaises(NotImplementedError, ml.__setitem__, slice(0,1,1), mr[7:8]) # differing shape xl = ndarray(items, shape=[8], format="b", flags=ND_WRITABLE) xr = ndarray(items, shape=[8], format="b") ml = memoryview(xl) mr = memoryview(xr) self.assertRaises(ValueError, xl.__setitem__, slice(0,2,1), xr[7:8]) self.assertEqual(xl.tolist(), items) self.assertRaises(ValueError, ml.__setitem__, slice(0,2,1), mr[7:8]) self.assertEqual(ml.tolist(), items) # _testbuffer.c module functions self.assertRaises(TypeError, slice_indices, slice(0,1,2), {}) self.assertRaises(TypeError, slice_indices, "###########", 1) self.assertRaises(ValueError, slice_indices, slice(0,1,0), 4) x = ndarray(items, shape=[8], format="b", flags=ND_PIL) self.assertRaises(TypeError, x.add_suboffsets) ex = ndarray(items, shape=[8], format="B") x = ndarray(ex, getbuf=PyBUF_SIMPLE) self.assertRaises(TypeError, x.add_suboffsets) def test_ndarray_slice_zero_shape(self): items = [1,2,3,4,5,6,7,8,9,10,11,12] x = ndarray(items, shape=[12], format="L", flags=ND_WRITABLE) y = ndarray(items, shape=[12], format="L") x[4:4] = y[9:9] self.assertEqual(x.tolist(), items) ml = memoryview(x) mr = memoryview(y) self.assertEqual(ml, x) self.assertEqual(ml, y) ml[4:4] = mr[9:9] self.assertEqual(ml.tolist(), items) x = ndarray(items, shape=[3, 4], format="L", flags=ND_WRITABLE) y = ndarray(items, shape=[4, 3], format="L") x[1:2, 2:2] = y[1:2, 3:3] self.assertEqual(x.tolist(), carray(items, [3, 4])) def test_ndarray_slice_multidim(self): shape_t = (2, 3, 5) ndim = len(shape_t) nitems = prod(shape_t) for shape in permutations(shape_t): fmt, items, _ = randitems(nitems) itemsize = struct.calcsize(fmt) for flags in (0, ND_PIL): nd = ndarray(items, shape=shape, format=fmt, flags=flags) lst = carray(items, shape) for slices in rslices_ndim(ndim, shape): listerr = None try: sliced = multislice(lst, slices) except Exception as e: listerr = e.__class__ nderr = None try: ndsliced = nd[slices] except Exception as e: nderr = e.__class__ if nderr or listerr: self.assertIs(nderr, listerr) else: self.assertEqual(ndsliced.tolist(), sliced) def test_ndarray_slice_redundant_suboffsets(self): shape_t = (2, 3, 5, 2) ndim = len(shape_t) nitems = prod(shape_t) for shape in permutations(shape_t): fmt, items, _ = randitems(nitems) itemsize = struct.calcsize(fmt) nd = ndarray(items, shape=shape, format=fmt) nd.add_suboffsets() ex = ndarray(items, shape=shape, format=fmt) ex.add_suboffsets() mv = memoryview(ex) lst = carray(items, shape) for slices in rslices_ndim(ndim, shape): listerr = None try: sliced = multislice(lst, slices) except Exception as e: listerr = e.__class__ nderr = None try: ndsliced = nd[slices] except Exception as e: nderr = e.__class__ if nderr or listerr: self.assertIs(nderr, listerr) else: self.assertEqual(ndsliced.tolist(), sliced) def test_ndarray_slice_assign_single(self): for fmt, items, _ in iter_format(5): for lslice in genslices(5): for rslice in genslices(5): for flags in (0, ND_PIL): f = flags|ND_WRITABLE nd = ndarray(items, shape=[5], format=fmt, flags=f) ex = ndarray(items, shape=[5], format=fmt, flags=f) mv = memoryview(ex) lsterr = None diff_structure = None lst = items[:] try: lval = lst[lslice] rval = lst[rslice] lst[lslice] = lst[rslice] diff_structure = len(lval) != len(rval) except Exception as e: lsterr = e.__class__ nderr = None try: nd[lslice] = nd[rslice] except Exception as e: nderr = e.__class__ if diff_structure: # ndarray cannot change shape self.assertIs(nderr, ValueError) else: self.assertEqual(nd.tolist(), lst) self.assertIs(nderr, lsterr) if not is_memoryview_format(fmt): continue mverr = None try: mv[lslice] = mv[rslice] except Exception as e: mverr = e.__class__ if diff_structure: # memoryview cannot change shape self.assertIs(mverr, ValueError) else: self.assertEqual(mv.tolist(), lst) self.assertEqual(mv, nd) self.assertIs(mverr, lsterr) self.verify(mv, obj=ex, itemsize=nd.itemsize, fmt=fmt, readonly=0, ndim=nd.ndim, shape=nd.shape, strides=nd.strides, lst=nd.tolist()) def test_ndarray_slice_assign_multidim(self): shape_t = (2, 3, 5) ndim = len(shape_t) nitems = prod(shape_t) for shape in permutations(shape_t): fmt, items, _ = randitems(nitems) for flags in (0, ND_PIL): for _ in range(ITERATIONS): lslices, rslices = randslice_from_shape(ndim, shape) nd = ndarray(items, shape=shape, format=fmt, flags=flags|ND_WRITABLE) lst = carray(items, shape) listerr = None try: result = multislice_assign(lst, lst, lslices, rslices) except Exception as e: listerr = e.__class__ nderr = None try: nd[lslices] = nd[rslices] except Exception as e: nderr = e.__class__ if nderr or listerr: self.assertIs(nderr, listerr) else: self.assertEqual(nd.tolist(), result) def test_ndarray_random(self): # construction of valid arrays for _ in range(ITERATIONS): for fmt in fmtdict['@']: itemsize = struct.calcsize(fmt) t = rand_structure(itemsize, True, maxdim=MAXDIM, maxshape=MAXSHAPE) self.assertTrue(verify_structure(*t)) items = randitems_from_structure(fmt, t) x = ndarray_from_structure(items, fmt, t) xlist = x.tolist() mv = memoryview(x) if is_memoryview_format(fmt): mvlist = mv.tolist() self.assertEqual(mvlist, xlist) if t[2] > 0: # ndim > 0: test against suboffsets representation. y = ndarray_from_structure(items, fmt, t, flags=ND_PIL) ylist = y.tolist() self.assertEqual(xlist, ylist) mv = memoryview(y) if is_memoryview_format(fmt): self.assertEqual(mv, y) mvlist = mv.tolist() self.assertEqual(mvlist, ylist) if numpy_array: shape = t[3] if 0 in shape: continue # http://projects.scipy.org/numpy/ticket/1910 z = numpy_array_from_structure(items, fmt, t) self.verify(x, obj=None, itemsize=z.itemsize, fmt=fmt, readonly=0, ndim=z.ndim, shape=z.shape, strides=z.strides, lst=z.tolist()) def test_ndarray_random_invalid(self): # exceptions during construction of invalid arrays for _ in range(ITERATIONS): for fmt in fmtdict['@']: itemsize = struct.calcsize(fmt) t = rand_structure(itemsize, False, maxdim=MAXDIM, maxshape=MAXSHAPE) self.assertFalse(verify_structure(*t)) items = randitems_from_structure(fmt, t) nderr = False try: x = ndarray_from_structure(items, fmt, t) except Exception as e: nderr = e.__class__ self.assertTrue(nderr) if numpy_array: numpy_err = False try: y = numpy_array_from_structure(items, fmt, t) except Exception as e: numpy_err = e.__class__ if 0: # http://projects.scipy.org/numpy/ticket/1910 self.assertTrue(numpy_err) def test_ndarray_random_slice_assign(self): # valid slice assignments for _ in range(ITERATIONS): for fmt in fmtdict['@']: itemsize = struct.calcsize(fmt) lshape, rshape, lslices, rslices = \ rand_aligned_slices(maxdim=MAXDIM, maxshape=MAXSHAPE) tl = rand_structure(itemsize, True, shape=lshape) tr = rand_structure(itemsize, True, shape=rshape) self.assertTrue(verify_structure(*tl)) self.assertTrue(verify_structure(*tr)) litems = randitems_from_structure(fmt, tl) ritems = randitems_from_structure(fmt, tr) xl = ndarray_from_structure(litems, fmt, tl) xr = ndarray_from_structure(ritems, fmt, tr) xl[lslices] = xr[rslices] xllist = xl.tolist() xrlist = xr.tolist() ml = memoryview(xl) mr = memoryview(xr) self.assertEqual(ml.tolist(), xllist) self.assertEqual(mr.tolist(), xrlist) if tl[2] > 0 and tr[2] > 0: # ndim > 0: test against suboffsets representation. yl = ndarray_from_structure(litems, fmt, tl, flags=ND_PIL) yr = ndarray_from_structure(ritems, fmt, tr, flags=ND_PIL) yl[lslices] = yr[rslices] yllist = yl.tolist() yrlist = yr.tolist() self.assertEqual(xllist, yllist) self.assertEqual(xrlist, yrlist) ml = memoryview(yl) mr = memoryview(yr) self.assertEqual(ml.tolist(), yllist) self.assertEqual(mr.tolist(), yrlist) if numpy_array: if 0 in lshape or 0 in rshape: continue # http://projects.scipy.org/numpy/ticket/1910 zl = numpy_array_from_structure(litems, fmt, tl) zr = numpy_array_from_structure(ritems, fmt, tr) zl[lslices] = zr[rslices] if not is_overlapping(tl) and not is_overlapping(tr): # Slice assignment of overlapping structures # is undefined in NumPy. self.verify(xl, obj=None, itemsize=zl.itemsize, fmt=fmt, readonly=0, ndim=zl.ndim, shape=zl.shape, strides=zl.strides, lst=zl.tolist()) self.verify(xr, obj=None, itemsize=zr.itemsize, fmt=fmt, readonly=0, ndim=zr.ndim, shape=zr.shape, strides=zr.strides, lst=zr.tolist()) def test_ndarray_re_export(self): items = [1,2,3,4,5,6,7,8,9,10,11,12] nd = ndarray(items, shape=[3,4], flags=ND_PIL) ex = ndarray(nd) self.assertTrue(ex.flags & ND_PIL) self.assertIs(ex.obj, nd) self.assertEqual(ex.suboffsets, (0, -1)) self.assertFalse(ex.c_contiguous) self.assertFalse(ex.f_contiguous) self.assertFalse(ex.contiguous) def test_ndarray_zero_shape(self): # zeros in shape for flags in (0, ND_PIL): nd = ndarray([1,2,3], shape=[0], flags=flags) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertEqual(nd.tolist(), []) self.assertEqual(mv.tolist(), []) nd = ndarray([1,2,3], shape=[0,3,3], flags=flags) self.assertEqual(nd.tolist(), []) nd = ndarray([1,2,3], shape=[3,0,3], flags=flags) self.assertEqual(nd.tolist(), [[], [], []]) nd = ndarray([1,2,3], shape=[3,3,0], flags=flags) self.assertEqual(nd.tolist(), [[[], [], []], [[], [], []], [[], [], []]]) def test_ndarray_zero_strides(self): # zero strides for flags in (0, ND_PIL): nd = ndarray([1], shape=[5], strides=[0], flags=flags) mv = memoryview(nd) self.assertEqual(mv, nd) self.assertEqual(nd.tolist(), [1, 1, 1, 1, 1]) self.assertEqual(mv.tolist(), [1, 1, 1, 1, 1]) def test_ndarray_offset(self): nd = ndarray(list(range(20)), shape=[3], offset=7) self.assertEqual(nd.offset, 7) self.assertEqual(nd.tolist(), [7,8,9]) def test_ndarray_memoryview_from_buffer(self): for flags in (0, ND_PIL): nd = ndarray(list(range(3)), shape=[3], flags=flags) m = nd.memoryview_from_buffer() self.assertEqual(m, nd) def test_ndarray_get_pointer(self): for flags in (0, ND_PIL): nd = ndarray(list(range(3)), shape=[3], flags=flags) for i in range(3): self.assertEqual(nd[i], get_pointer(nd, [i])) def test_ndarray_tolist_null_strides(self): ex = ndarray(list(range(20)), shape=[2,2,5]) nd = ndarray(ex, getbuf=PyBUF_ND|PyBUF_FORMAT) self.assertEqual(nd.tolist(), ex.tolist()) m = memoryview(ex) self.assertEqual(m.tolist(), ex.tolist()) def test_ndarray_cmp_contig(self): self.assertFalse(cmp_contig(b"123", b"456")) x = ndarray(list(range(12)), shape=[3,4]) y = ndarray(list(range(12)), shape=[4,3]) self.assertFalse(cmp_contig(x, y)) x = ndarray([1], shape=[1], format="B") self.assertTrue(cmp_contig(x, b'\x01')) self.assertTrue(cmp_contig(b'\x01', x)) def test_ndarray_hash(self): a = array.array('L', [1,2,3]) nd = ndarray(a) self.assertRaises(ValueError, hash, nd) # one-dimensional b = bytes(list(range(12))) nd = ndarray(list(range(12)), shape=[12]) self.assertEqual(hash(nd), hash(b)) # C-contiguous nd = ndarray(list(range(12)), shape=[3,4]) self.assertEqual(hash(nd), hash(b)) nd = ndarray(list(range(12)), shape=[3,2,2]) self.assertEqual(hash(nd), hash(b)) # Fortran contiguous b = bytes(transpose(list(range(12)), shape=[4,3])) nd = ndarray(list(range(12)), shape=[3,4], flags=ND_FORTRAN) self.assertEqual(hash(nd), hash(b)) b = bytes(transpose(list(range(12)), shape=[2,3,2])) nd = ndarray(list(range(12)), shape=[2,3,2], flags=ND_FORTRAN) self.assertEqual(hash(nd), hash(b)) # suboffsets b = bytes(list(range(12))) nd = ndarray(list(range(12)), shape=[2,2,3], flags=ND_PIL) self.assertEqual(hash(nd), hash(b)) # non-byte formats nd = ndarray(list(range(12)), shape=[2,2,3], format='L') self.assertEqual(hash(nd), hash(nd.tobytes())) def test_py_buffer_to_contiguous(self): # The requests are used in _testbuffer.c:py_buffer_to_contiguous # to generate buffers without full information for testing. requests = ( # distinct flags PyBUF_INDIRECT, PyBUF_STRIDES, PyBUF_ND, PyBUF_SIMPLE, # compound requests PyBUF_FULL, PyBUF_FULL_RO, PyBUF_RECORDS, PyBUF_RECORDS_RO, PyBUF_STRIDED, PyBUF_STRIDED_RO, PyBUF_CONTIG, PyBUF_CONTIG_RO, ) # no buffer interface self.assertRaises(TypeError, py_buffer_to_contiguous, {}, 'F', PyBUF_FULL_RO) # scalar, read-only request nd = ndarray(9, shape=(), format="L", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: for request in requests: b = py_buffer_to_contiguous(nd, order, request) self.assertEqual(b, nd.tobytes()) # zeros in shape nd = ndarray([1], shape=[0], format="L", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: for request in requests: b = py_buffer_to_contiguous(nd, order, request) self.assertEqual(b, b'') nd = ndarray(list(range(8)), shape=[2, 0, 7], format="L", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: for request in requests: b = py_buffer_to_contiguous(nd, order, request) self.assertEqual(b, b'') ### One-dimensional arrays are trivial, since Fortran and C order ### are the same. # one-dimensional for f in [0, ND_FORTRAN]: nd = ndarray([1], shape=[1], format="h", flags=f|ND_WRITABLE) ndbytes = nd.tobytes() for order in ['C', 'F', 'A']: for request in requests: b = py_buffer_to_contiguous(nd, order, request) self.assertEqual(b, ndbytes) nd = ndarray([1, 2, 3], shape=[3], format="b", flags=f|ND_WRITABLE) ndbytes = nd.tobytes() for order in ['C', 'F', 'A']: for request in requests: b = py_buffer_to_contiguous(nd, order, request) self.assertEqual(b, ndbytes) # one-dimensional, non-contiguous input nd = ndarray([1, 2, 3], shape=[2], strides=[2], flags=ND_WRITABLE) ndbytes = nd.tobytes() for order in ['C', 'F', 'A']: for request in [PyBUF_STRIDES, PyBUF_FULL]: b = py_buffer_to_contiguous(nd, order, request) self.assertEqual(b, ndbytes) nd = nd[::-1] ndbytes = nd.tobytes() for order in ['C', 'F', 'A']: for request in requests: try: b = py_buffer_to_contiguous(nd, order, request) except BufferError: continue self.assertEqual(b, ndbytes) ### ### Multi-dimensional arrays: ### ### The goal here is to preserve the logical representation of the ### input array but change the physical representation if necessary. ### ### _testbuffer example: ### ==================== ### ### C input array: ### -------------- ### >>> nd = ndarray(list(range(12)), shape=[3, 4]) ### >>> nd.tolist() ### [[0, 1, 2, 3], ### [4, 5, 6, 7], ### [8, 9, 10, 11]] ### ### Fortran output: ### --------------- ### >>> py_buffer_to_contiguous(nd, 'F', PyBUF_FULL_RO) ### >>> b'\x00\x04\x08\x01\x05\t\x02\x06\n\x03\x07\x0b' ### ### The return value corresponds to this input list for ### _testbuffer's ndarray: ### >>> nd = ndarray([0,4,8,1,5,9,2,6,10,3,7,11], shape=[3,4], ### flags=ND_FORTRAN) ### >>> nd.tolist() ### [[0, 1, 2, 3], ### [4, 5, 6, 7], ### [8, 9, 10, 11]] ### ### The logical array is the same, but the values in memory are now ### in Fortran order. ### ### NumPy example: ### ============== ### _testbuffer's ndarray takes lists to initialize the memory. ### Here's the same sequence in NumPy: ### ### C input: ### -------- ### >>> nd = ndarray(buffer=bytearray(list(range(12))), ### shape=[3, 4], dtype='B') ### >>> nd ### array([[ 0, 1, 2, 3], ### [ 4, 5, 6, 7], ### [ 8, 9, 10, 11]], dtype=uint8) ### ### Fortran output: ### --------------- ### >>> fortran_buf = nd.tostring(order='F') ### >>> fortran_buf ### b'\x00\x04\x08\x01\x05\t\x02\x06\n\x03\x07\x0b' ### ### >>> nd = ndarray(buffer=fortran_buf, shape=[3, 4], ### dtype='B', order='F') ### ### >>> nd ### array([[ 0, 1, 2, 3], ### [ 4, 5, 6, 7], ### [ 8, 9, 10, 11]], dtype=uint8) ### # multi-dimensional, contiguous input lst = list(range(12)) for f in [0, ND_FORTRAN]: nd = ndarray(lst, shape=[3, 4], flags=f|ND_WRITABLE) if numpy_array: na = numpy_array(buffer=bytearray(lst), shape=[3, 4], dtype='B', order='C' if f == 0 else 'F') # 'C' request if f == ND_FORTRAN: # 'F' to 'C' x = ndarray(transpose(lst, [4, 3]), shape=[3, 4], flags=ND_WRITABLE) expected = x.tobytes() else: expected = nd.tobytes() for request in requests: try: b = py_buffer_to_contiguous(nd, 'C', request) except BufferError: continue self.assertEqual(b, expected) # Check that output can be used as the basis for constructing # a C array that is logically identical to the input array. y = ndarray([v for v in b], shape=[3, 4], flags=ND_WRITABLE) self.assertEqual(memoryview(y), memoryview(nd)) if numpy_array: self.assertEqual(b, na.tostring(order='C')) # 'F' request if f == 0: # 'C' to 'F' x = ndarray(transpose(lst, [3, 4]), shape=[4, 3], flags=ND_WRITABLE) else: x = ndarray(lst, shape=[3, 4], flags=ND_WRITABLE) expected = x.tobytes() for request in [PyBUF_FULL, PyBUF_FULL_RO, PyBUF_INDIRECT, PyBUF_STRIDES, PyBUF_ND]: try: b = py_buffer_to_contiguous(nd, 'F', request) except BufferError: continue self.assertEqual(b, expected) # Check that output can be used as the basis for constructing # a Fortran array that is logically identical to the input array. y = ndarray([v for v in b], shape=[3, 4], flags=ND_FORTRAN|ND_WRITABLE) self.assertEqual(memoryview(y), memoryview(nd)) if numpy_array: self.assertEqual(b, na.tostring(order='F')) # 'A' request if f == ND_FORTRAN: x = ndarray(lst, shape=[3, 4], flags=ND_WRITABLE) expected = x.tobytes() else: expected = nd.tobytes() for request in [PyBUF_FULL, PyBUF_FULL_RO, PyBUF_INDIRECT, PyBUF_STRIDES, PyBUF_ND]: try: b = py_buffer_to_contiguous(nd, 'A', request) except BufferError: continue self.assertEqual(b, expected) # Check that output can be used as the basis for constructing # an array with order=f that is logically identical to the input # array. y = ndarray([v for v in b], shape=[3, 4], flags=f|ND_WRITABLE) self.assertEqual(memoryview(y), memoryview(nd)) if numpy_array: self.assertEqual(b, na.tostring(order='A')) # multi-dimensional, non-contiguous input nd = ndarray(list(range(12)), shape=[3, 4], flags=ND_WRITABLE|ND_PIL) # 'C' b = py_buffer_to_contiguous(nd, 'C', PyBUF_FULL_RO) self.assertEqual(b, nd.tobytes()) y = ndarray([v for v in b], shape=[3, 4], flags=ND_WRITABLE) self.assertEqual(memoryview(y), memoryview(nd)) # 'F' b = py_buffer_to_contiguous(nd, 'F', PyBUF_FULL_RO) x = ndarray(transpose(lst, [3, 4]), shape=[4, 3], flags=ND_WRITABLE) self.assertEqual(b, x.tobytes()) y = ndarray([v for v in b], shape=[3, 4], flags=ND_FORTRAN|ND_WRITABLE) self.assertEqual(memoryview(y), memoryview(nd)) # 'A' b = py_buffer_to_contiguous(nd, 'A', PyBUF_FULL_RO) self.assertEqual(b, nd.tobytes()) y = ndarray([v for v in b], shape=[3, 4], flags=ND_WRITABLE) self.assertEqual(memoryview(y), memoryview(nd)) def test_memoryview_construction(self): items_shape = [(9, []), ([1,2,3], [3]), (list(range(2*3*5)), [2,3,5])] # NumPy style, C-contiguous: for items, shape in items_shape: # From PEP-3118 compliant exporter: ex = ndarray(items, shape=shape) m = memoryview(ex) self.assertTrue(m.c_contiguous) self.assertTrue(m.contiguous) ndim = len(shape) strides = strides_from_shape(ndim, shape, 1, 'C') lst = carray(items, shape) self.verify(m, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) # From memoryview: m2 = memoryview(m) self.verify(m2, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) # PyMemoryView_FromBuffer(): no strides nd = ndarray(ex, getbuf=PyBUF_CONTIG_RO|PyBUF_FORMAT) self.assertEqual(nd.strides, ()) m = nd.memoryview_from_buffer() self.verify(m, obj=None, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) # PyMemoryView_FromBuffer(): no format, shape, strides nd = ndarray(ex, getbuf=PyBUF_SIMPLE) self.assertEqual(nd.format, '') self.assertEqual(nd.shape, ()) self.assertEqual(nd.strides, ()) m = nd.memoryview_from_buffer() lst = [items] if ndim == 0 else items self.verify(m, obj=None, itemsize=1, fmt='B', readonly=1, ndim=1, shape=[ex.nbytes], strides=(1,), lst=lst) # NumPy style, Fortran contiguous: for items, shape in items_shape: # From PEP-3118 compliant exporter: ex = ndarray(items, shape=shape, flags=ND_FORTRAN) m = memoryview(ex) self.assertTrue(m.f_contiguous) self.assertTrue(m.contiguous) ndim = len(shape) strides = strides_from_shape(ndim, shape, 1, 'F') lst = farray(items, shape) self.verify(m, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) # From memoryview: m2 = memoryview(m) self.verify(m2, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst) # PIL style: for items, shape in items_shape[1:]: # From PEP-3118 compliant exporter: ex = ndarray(items, shape=shape, flags=ND_PIL) m = memoryview(ex) ndim = len(shape) lst = carray(items, shape) self.verify(m, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=ex.strides, lst=lst) # From memoryview: m2 = memoryview(m) self.verify(m2, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=ndim, shape=shape, strides=ex.strides, lst=lst) # Invalid number of arguments: self.assertRaises(TypeError, memoryview, b'9', 'x') # Not a buffer provider: self.assertRaises(TypeError, memoryview, {}) # Non-compliant buffer provider: ex = ndarray([1,2,3], shape=[3]) nd = ndarray(ex, getbuf=PyBUF_SIMPLE) self.assertRaises(BufferError, memoryview, nd) nd = ndarray(ex, getbuf=PyBUF_CONTIG_RO|PyBUF_FORMAT) self.assertRaises(BufferError, memoryview, nd) # ndim > 64 nd = ndarray([1]*128, shape=[1]*128, format='L') self.assertRaises(ValueError, memoryview, nd) self.assertRaises(ValueError, nd.memoryview_from_buffer) self.assertRaises(ValueError, get_contiguous, nd, PyBUF_READ, 'C') self.assertRaises(ValueError, get_contiguous, nd, PyBUF_READ, 'F') self.assertRaises(ValueError, get_contiguous, nd[::-1], PyBUF_READ, 'C') def test_memoryview_cast_zero_shape(self): # Casts are undefined if buffer is multidimensional and shape # contains zeros. These arrays are regarded as C-contiguous by # Numpy and PyBuffer_GetContiguous(), so they are not caught by # the test for C-contiguity in memory_cast(). items = [1,2,3] for shape in ([0,3,3], [3,0,3], [0,3,3]): ex = ndarray(items, shape=shape) self.assertTrue(ex.c_contiguous) msrc = memoryview(ex) self.assertRaises(TypeError, msrc.cast, 'c') # Monodimensional empty view can be cast (issue #19014). for fmt, _, _ in iter_format(1, 'memoryview'): msrc = memoryview(b'') m = msrc.cast(fmt) self.assertEqual(m.tobytes(), b'') self.assertEqual(m.tolist(), []) check_sizeof = support.check_sizeof def test_memoryview_sizeof(self): check = self.check_sizeof vsize = support.calcvobjsize base_struct = 'Pnin 2P2n2i5P P' per_dim = '3n' items = list(range(8)) check(memoryview(b''), vsize(base_struct + 1 * per_dim)) a = ndarray(items, shape=[2, 4], format="b") check(memoryview(a), vsize(base_struct + 2 * per_dim)) a = ndarray(items, shape=[2, 2, 2], format="b") check(memoryview(a), vsize(base_struct + 3 * per_dim)) def test_memoryview_struct_module(self): class INT(object): def __init__(self, val): self.val = val def __int__(self): return self.val class IDX(object): def __init__(self, val): self.val = val def __index__(self): return self.val def f(): return 7 values = [INT(9), IDX(9), 2.2+3j, Decimal("-21.1"), 12.2, Fraction(5, 2), [1,2,3], {4,5,6}, {7:8}, (), (9,), True, False, None, NotImplemented, b'a', b'abc', bytearray(b'a'), bytearray(b'abc'), 'a', 'abc', r'a', r'abc', f, lambda x: x] for fmt, items, item in iter_format(10, 'memoryview'): ex = ndarray(items, shape=[10], format=fmt, flags=ND_WRITABLE) nd = ndarray(items, shape=[10], format=fmt, flags=ND_WRITABLE) m = memoryview(ex) struct.pack_into(fmt, nd, 0, item) m[0] = item self.assertEqual(m[0], nd[0]) itemsize = struct.calcsize(fmt) if 'P' in fmt: continue for v in values: struct_err = None try: struct.pack_into(fmt, nd, itemsize, v) except struct.error: struct_err = struct.error mv_err = None try: m[1] = v except (TypeError, ValueError) as e: mv_err = e.__class__ if struct_err or mv_err: self.assertIsNot(struct_err, None) self.assertIsNot(mv_err, None) else: self.assertEqual(m[1], nd[1]) def test_memoryview_cast_zero_strides(self): # Casts are undefined if strides contains zeros. These arrays are # (sometimes!) regarded as C-contiguous by Numpy, but not by # PyBuffer_GetContiguous(). ex = ndarray([1,2,3], shape=[3], strides=[0]) self.assertFalse(ex.c_contiguous) msrc = memoryview(ex) self.assertRaises(TypeError, msrc.cast, 'c') def test_memoryview_cast_invalid(self): # invalid format for sfmt in NON_BYTE_FORMAT: sformat = '@' + sfmt if randrange(2) else sfmt ssize = struct.calcsize(sformat) for dfmt in NON_BYTE_FORMAT: dformat = '@' + dfmt if randrange(2) else dfmt dsize = struct.calcsize(dformat) ex = ndarray(list(range(32)), shape=[32//ssize], format=sformat) msrc = memoryview(ex) self.assertRaises(TypeError, msrc.cast, dfmt, [32//dsize]) for sfmt, sitems, _ in iter_format(1): ex = ndarray(sitems, shape=[1], format=sfmt) msrc = memoryview(ex) for dfmt, _, _ in iter_format(1): if not is_memoryview_format(dfmt): self.assertRaises(ValueError, msrc.cast, dfmt, [32//dsize]) else: if not is_byte_format(sfmt) and not is_byte_format(dfmt): self.assertRaises(TypeError, msrc.cast, dfmt, [32//dsize]) # invalid shape size_h = struct.calcsize('h') size_d = struct.calcsize('d') ex = ndarray(list(range(2*2*size_d)), shape=[2,2,size_d], format='h') msrc = memoryview(ex) self.assertRaises(TypeError, msrc.cast, shape=[2,2,size_h], format='d') ex = ndarray(list(range(120)), shape=[1,2,3,4,5]) m = memoryview(ex) # incorrect number of args self.assertRaises(TypeError, m.cast) self.assertRaises(TypeError, m.cast, 1, 2, 3) # incorrect dest format type self.assertRaises(TypeError, m.cast, {}) # incorrect dest format self.assertRaises(ValueError, m.cast, "X") self.assertRaises(ValueError, m.cast, "@X") self.assertRaises(ValueError, m.cast, "@XY") # dest format not implemented self.assertRaises(ValueError, m.cast, "=B") self.assertRaises(ValueError, m.cast, "!L") self.assertRaises(ValueError, m.cast, "<P") self.assertRaises(ValueError, m.cast, ">l") self.assertRaises(ValueError, m.cast, "BI") self.assertRaises(ValueError, m.cast, "xBI") # src format not implemented ex = ndarray([(1,2), (3,4)], shape=[2], format="II") m = memoryview(ex) self.assertRaises(NotImplementedError, m.__getitem__, 0) self.assertRaises(NotImplementedError, m.__setitem__, 0, 8) self.assertRaises(NotImplementedError, m.tolist) # incorrect shape type ex = ndarray(list(range(120)), shape=[1,2,3,4,5]) m = memoryview(ex) self.assertRaises(TypeError, m.cast, "B", shape={}) # incorrect shape elements ex = ndarray(list(range(120)), shape=[2*3*4*5]) m = memoryview(ex) self.assertRaises(OverflowError, m.cast, "B", shape=[2**64]) self.assertRaises(ValueError, m.cast, "B", shape=[-1]) self.assertRaises(ValueError, m.cast, "B", shape=[2,3,4,5,6,7,-1]) self.assertRaises(ValueError, m.cast, "B", shape=[2,3,4,5,6,7,0]) self.assertRaises(TypeError, m.cast, "B", shape=[2,3,4,5,6,7,'x']) # N-D -> N-D cast ex = ndarray(list([9 for _ in range(3*5*7*11)]), shape=[3,5,7,11]) m = memoryview(ex) self.assertRaises(TypeError, m.cast, "I", shape=[2,3,4,5]) # cast with ndim > 64 nd = ndarray(list(range(128)), shape=[128], format='I') m = memoryview(nd) self.assertRaises(ValueError, m.cast, 'I', [1]*128) # view->len not a multiple of itemsize ex = ndarray(list([9 for _ in range(3*5*7*11)]), shape=[3*5*7*11]) m = memoryview(ex) self.assertRaises(TypeError, m.cast, "I", shape=[2,3,4,5]) # product(shape) * itemsize != buffer size ex = ndarray(list([9 for _ in range(3*5*7*11)]), shape=[3*5*7*11]) m = memoryview(ex) self.assertRaises(TypeError, m.cast, "B", shape=[2,3,4,5]) # product(shape) * itemsize overflow nd = ndarray(list(range(128)), shape=[128], format='I') m1 = memoryview(nd) nd = ndarray(list(range(128)), shape=[128], format='B') m2 = memoryview(nd) if sys.maxsize == 2**63-1: self.assertRaises(TypeError, m1.cast, 'B', [7, 7, 73, 127, 337, 92737, 649657]) self.assertRaises(ValueError, m1.cast, 'B', [2**20, 2**20, 2**10, 2**10, 2**3]) self.assertRaises(ValueError, m2.cast, 'I', [2**20, 2**20, 2**10, 2**10, 2**1]) else: self.assertRaises(TypeError, m1.cast, 'B', [1, 2147483647]) self.assertRaises(ValueError, m1.cast, 'B', [2**10, 2**10, 2**5, 2**5, 2**1]) self.assertRaises(ValueError, m2.cast, 'I', [2**10, 2**10, 2**5, 2**3, 2**1]) def test_memoryview_cast(self): bytespec = ( ('B', lambda ex: list(ex.tobytes())), ('b', lambda ex: [x-256 if x > 127 else x for x in list(ex.tobytes())]), ('c', lambda ex: [bytes(chr(x), 'latin-1') for x in list(ex.tobytes())]), ) def iter_roundtrip(ex, m, items, fmt): srcsize = struct.calcsize(fmt) for bytefmt, to_bytelist in bytespec: m2 = m.cast(bytefmt) lst = to_bytelist(ex) self.verify(m2, obj=ex, itemsize=1, fmt=bytefmt, readonly=0, ndim=1, shape=[31*srcsize], strides=(1,), lst=lst, cast=True) m3 = m2.cast(fmt) self.assertEqual(m3, ex) lst = ex.tolist() self.verify(m3, obj=ex, itemsize=srcsize, fmt=fmt, readonly=0, ndim=1, shape=[31], strides=(srcsize,), lst=lst, cast=True) # cast from ndim = 0 to ndim = 1 srcsize = struct.calcsize('I') ex = ndarray(9, shape=[], format='I') destitems, destshape = cast_items(ex, 'B', 1) m = memoryview(ex) m2 = m.cast('B') self.verify(m2, obj=ex, itemsize=1, fmt='B', readonly=1, ndim=1, shape=destshape, strides=(1,), lst=destitems, cast=True) # cast from ndim = 1 to ndim = 0 destsize = struct.calcsize('I') ex = ndarray([9]*destsize, shape=[destsize], format='B') destitems, destshape = cast_items(ex, 'I', destsize, shape=[]) m = memoryview(ex) m2 = m.cast('I', shape=[]) self.verify(m2, obj=ex, itemsize=destsize, fmt='I', readonly=1, ndim=0, shape=(), strides=(), lst=destitems, cast=True) # array.array: roundtrip to/from bytes for fmt, items, _ in iter_format(31, 'array'): ex = array.array(fmt, items) m = memoryview(ex) iter_roundtrip(ex, m, items, fmt) # ndarray: roundtrip to/from bytes for fmt, items, _ in iter_format(31, 'memoryview'): ex = ndarray(items, shape=[31], format=fmt, flags=ND_WRITABLE) m = memoryview(ex) iter_roundtrip(ex, m, items, fmt) def test_memoryview_cast_1D_ND(self): # Cast between C-contiguous buffers. At least one buffer must # be 1D, at least one format must be 'c', 'b' or 'B'. for _tshape in gencastshapes(): for char in fmtdict['@']: tfmt = ('', '@')[randrange(2)] + char tsize = struct.calcsize(tfmt) n = prod(_tshape) * tsize obj = 'memoryview' if is_byte_format(tfmt) else 'bytefmt' for fmt, items, _ in iter_format(n, obj): size = struct.calcsize(fmt) shape = [n] if n > 0 else [] tshape = _tshape + [size] ex = ndarray(items, shape=shape, format=fmt) m = memoryview(ex) titems, tshape = cast_items(ex, tfmt, tsize, shape=tshape) if titems is None: self.assertRaises(TypeError, m.cast, tfmt, tshape) continue if titems == 'nan': continue # NaNs in lists are a recipe for trouble. # 1D -> ND nd = ndarray(titems, shape=tshape, format=tfmt) m2 = m.cast(tfmt, shape=tshape) ndim = len(tshape) strides = nd.strides lst = nd.tolist() self.verify(m2, obj=ex, itemsize=tsize, fmt=tfmt, readonly=1, ndim=ndim, shape=tshape, strides=strides, lst=lst, cast=True) # ND -> 1D m3 = m2.cast(fmt) m4 = m2.cast(fmt, shape=shape) ndim = len(shape) strides = ex.strides lst = ex.tolist() self.verify(m3, obj=ex, itemsize=size, fmt=fmt, readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst, cast=True) self.verify(m4, obj=ex, itemsize=size, fmt=fmt, readonly=1, ndim=ndim, shape=shape, strides=strides, lst=lst, cast=True) if ctypes: # format: "T{>l:x:>d:y:}" class BEPoint(ctypes.BigEndianStructure): _fields_ = [("x", ctypes.c_long), ("y", ctypes.c_double)] point = BEPoint(100, 200.1) m1 = memoryview(point) m2 = m1.cast('B') self.assertEqual(m2.obj, point) self.assertEqual(m2.itemsize, 1) self.assertEqual(m2.readonly, 0) self.assertEqual(m2.ndim, 1) self.assertEqual(m2.shape, (m2.nbytes,)) self.assertEqual(m2.strides, (1,)) self.assertEqual(m2.suboffsets, ()) x = ctypes.c_double(1.2) m1 = memoryview(x) m2 = m1.cast('c') self.assertEqual(m2.obj, x) self.assertEqual(m2.itemsize, 1) self.assertEqual(m2.readonly, 0) self.assertEqual(m2.ndim, 1) self.assertEqual(m2.shape, (m2.nbytes,)) self.assertEqual(m2.strides, (1,)) self.assertEqual(m2.suboffsets, ()) def test_memoryview_tolist(self): # Most tolist() tests are in self.verify() etc. a = array.array('h', list(range(-6, 6))) m = memoryview(a) self.assertEqual(m, a) self.assertEqual(m.tolist(), a.tolist()) a = a[2::3] m = m[2::3] self.assertEqual(m, a) self.assertEqual(m.tolist(), a.tolist()) ex = ndarray(list(range(2*3*5*7*11)), shape=[11,2,7,3,5], format='L') m = memoryview(ex) self.assertEqual(m.tolist(), ex.tolist()) ex = ndarray([(2, 5), (7, 11)], shape=[2], format='lh') m = memoryview(ex) self.assertRaises(NotImplementedError, m.tolist) ex = ndarray([b'12345'], shape=[1], format="s") m = memoryview(ex) self.assertRaises(NotImplementedError, m.tolist) ex = ndarray([b"a",b"b",b"c",b"d",b"e",b"f"], shape=[2,3], format='s') m = memoryview(ex) self.assertRaises(NotImplementedError, m.tolist) def test_memoryview_repr(self): m = memoryview(bytearray(9)) r = m.__repr__() self.assertTrue(r.startswith("<memory")) m.release() r = m.__repr__() self.assertTrue(r.startswith("<released")) def test_memoryview_sequence(self): for fmt in ('d', 'f'): inf = float(3e400) ex = array.array(fmt, [1.0, inf, 3.0]) m = memoryview(ex) self.assertIn(1.0, m) self.assertIn(5e700, m) self.assertIn(3.0, m) ex = ndarray(9.0, [], format='f') m = memoryview(ex) self.assertRaises(TypeError, eval, "9.0 in m", locals()) @contextlib.contextmanager def assert_out_of_bounds_error(self, dim): with self.assertRaises(IndexError) as cm: yield self.assertEqual(str(cm.exception), "index out of bounds on dimension %d" % (dim,)) def test_memoryview_index(self): # ndim = 0 ex = ndarray(12.5, shape=[], format='d') m = memoryview(ex) self.assertEqual(m[()], 12.5) self.assertEqual(m[...], m) self.assertEqual(m[...], ex) self.assertRaises(TypeError, m.__getitem__, 0) ex = ndarray((1,2,3), shape=[], format='iii') m = memoryview(ex) self.assertRaises(NotImplementedError, m.__getitem__, ()) # range ex = ndarray(list(range(7)), shape=[7], flags=ND_WRITABLE) m = memoryview(ex) self.assertRaises(IndexError, m.__getitem__, 2**64) self.assertRaises(TypeError, m.__getitem__, 2.0) self.assertRaises(TypeError, m.__getitem__, 0.0) # out of bounds self.assertRaises(IndexError, m.__getitem__, -8) self.assertRaises(IndexError, m.__getitem__, 8) # multi-dimensional ex = ndarray(list(range(12)), shape=[3,4], flags=ND_WRITABLE) m = memoryview(ex) self.assertEqual(m[0, 0], 0) self.assertEqual(m[2, 0], 8) self.assertEqual(m[2, 3], 11) self.assertEqual(m[-1, -1], 11) self.assertEqual(m[-3, -4], 0) # out of bounds for index in (3, -4): with self.assert_out_of_bounds_error(dim=1): m[index, 0] for index in (4, -5): with self.assert_out_of_bounds_error(dim=2): m[0, index] self.assertRaises(IndexError, m.__getitem__, (2**64, 0)) self.assertRaises(IndexError, m.__getitem__, (0, 2**64)) self.assertRaises(TypeError, m.__getitem__, (0, 0, 0)) self.assertRaises(TypeError, m.__getitem__, (0.0, 0.0)) # Not implemented: multidimensional sub-views self.assertRaises(NotImplementedError, m.__getitem__, ()) self.assertRaises(NotImplementedError, m.__getitem__, 0) def test_memoryview_assign(self): # ndim = 0 ex = ndarray(12.5, shape=[], format='f', flags=ND_WRITABLE) m = memoryview(ex) m[()] = 22.5 self.assertEqual(m[()], 22.5) m[...] = 23.5 self.assertEqual(m[()], 23.5) self.assertRaises(TypeError, m.__setitem__, 0, 24.7) # read-only ex = ndarray(list(range(7)), shape=[7]) m = memoryview(ex) self.assertRaises(TypeError, m.__setitem__, 2, 10) # range ex = ndarray(list(range(7)), shape=[7], flags=ND_WRITABLE) m = memoryview(ex) self.assertRaises(IndexError, m.__setitem__, 2**64, 9) self.assertRaises(TypeError, m.__setitem__, 2.0, 10) self.assertRaises(TypeError, m.__setitem__, 0.0, 11) # out of bounds self.assertRaises(IndexError, m.__setitem__, -8, 20) self.assertRaises(IndexError, m.__setitem__, 8, 25) # pack_single() success: for fmt in fmtdict['@']: if fmt == 'c' or fmt == '?': continue ex = ndarray([1,2,3], shape=[3], format=fmt, flags=ND_WRITABLE) m = memoryview(ex) i = randrange(-3, 3) m[i] = 8 self.assertEqual(m[i], 8) self.assertEqual(m[i], ex[i]) ex = ndarray([b'1', b'2', b'3'], shape=[3], format='c', flags=ND_WRITABLE) m = memoryview(ex) m[2] = b'9' self.assertEqual(m[2], b'9') ex = ndarray([True, False, True], shape=[3], format='?', flags=ND_WRITABLE) m = memoryview(ex) m[1] = True self.assertEqual(m[1], True) # pack_single() exceptions: nd = ndarray([b'x'], shape=[1], format='c', flags=ND_WRITABLE) m = memoryview(nd) self.assertRaises(TypeError, m.__setitem__, 0, 100) ex = ndarray(list(range(120)), shape=[1,2,3,4,5], flags=ND_WRITABLE) m1 = memoryview(ex) for fmt, _range in fmtdict['@'].items(): if (fmt == '?'): # PyObject_IsTrue() accepts anything continue if fmt == 'c': # special case tested above continue m2 = m1.cast(fmt) lo, hi = _range if fmt == 'd' or fmt == 'f': lo, hi = -2**1024, 2**1024 if fmt != 'P': # PyLong_AsVoidPtr() accepts negative numbers self.assertRaises(ValueError, m2.__setitem__, 0, lo-1) self.assertRaises(TypeError, m2.__setitem__, 0, "xyz") self.assertRaises(ValueError, m2.__setitem__, 0, hi) # invalid item m2 = m1.cast('c') self.assertRaises(ValueError, m2.__setitem__, 0, b'\xff\xff') # format not implemented ex = ndarray(list(range(1)), shape=[1], format="xL", flags=ND_WRITABLE) m = memoryview(ex) self.assertRaises(NotImplementedError, m.__setitem__, 0, 1) ex = ndarray([b'12345'], shape=[1], format="s", flags=ND_WRITABLE) m = memoryview(ex) self.assertRaises(NotImplementedError, m.__setitem__, 0, 1) # multi-dimensional ex = ndarray(list(range(12)), shape=[3,4], flags=ND_WRITABLE) m = memoryview(ex) m[0,1] = 42 self.assertEqual(ex[0][1], 42) m[-1,-1] = 43 self.assertEqual(ex[2][3], 43) # errors for index in (3, -4): with self.assert_out_of_bounds_error(dim=1): m[index, 0] = 0 for index in (4, -5): with self.assert_out_of_bounds_error(dim=2): m[0, index] = 0 self.assertRaises(IndexError, m.__setitem__, (2**64, 0), 0) self.assertRaises(IndexError, m.__setitem__, (0, 2**64), 0) self.assertRaises(TypeError, m.__setitem__, (0, 0, 0), 0) self.assertRaises(TypeError, m.__setitem__, (0.0, 0.0), 0) # Not implemented: multidimensional sub-views self.assertRaises(NotImplementedError, m.__setitem__, 0, [2, 3]) def test_memoryview_slice(self): ex = ndarray(list(range(12)), shape=[12], flags=ND_WRITABLE) m = memoryview(ex) # zero step self.assertRaises(ValueError, m.__getitem__, slice(0,2,0)) self.assertRaises(ValueError, m.__setitem__, slice(0,2,0), bytearray([1,2])) # 0-dim slicing (identity function) self.assertRaises(NotImplementedError, m.__getitem__, ()) # multidimensional slices ex = ndarray(list(range(12)), shape=[12], flags=ND_WRITABLE) m = memoryview(ex) self.assertRaises(NotImplementedError, m.__getitem__, (slice(0,2,1), slice(0,2,1))) self.assertRaises(NotImplementedError, m.__setitem__, (slice(0,2,1), slice(0,2,1)), bytearray([1,2])) # invalid slice tuple self.assertRaises(TypeError, m.__getitem__, (slice(0,2,1), {})) self.assertRaises(TypeError, m.__setitem__, (slice(0,2,1), {}), bytearray([1,2])) # rvalue is not an exporter self.assertRaises(TypeError, m.__setitem__, slice(0,1,1), [1]) # non-contiguous slice assignment for flags in (0, ND_PIL): ex1 = ndarray(list(range(12)), shape=[12], strides=[-1], offset=11, flags=ND_WRITABLE|flags) ex2 = ndarray(list(range(24)), shape=[12], strides=[2], flags=flags) m1 = memoryview(ex1) m2 = memoryview(ex2) ex1[2:5] = ex1[2:5] m1[2:5] = m2[2:5] self.assertEqual(m1, ex1) self.assertEqual(m2, ex2) ex1[1:3][::-1] = ex2[0:2][::1] m1[1:3][::-1] = m2[0:2][::1] self.assertEqual(m1, ex1) self.assertEqual(m2, ex2) ex1[4:1:-2][::-1] = ex1[1:4:2][::1] m1[4:1:-2][::-1] = m1[1:4:2][::1] self.assertEqual(m1, ex1) self.assertEqual(m2, ex2) def test_memoryview_array(self): def cmptest(testcase, a, b, m, singleitem): for i, _ in enumerate(a): ai = a[i] mi = m[i] testcase.assertEqual(ai, mi) a[i] = singleitem if singleitem != ai: testcase.assertNotEqual(a, m) testcase.assertNotEqual(a, b) else: testcase.assertEqual(a, m) testcase.assertEqual(a, b) m[i] = singleitem testcase.assertEqual(a, m) testcase.assertEqual(b, m) a[i] = ai m[i] = mi for n in range(1, 5): for fmt, items, singleitem in iter_format(n, 'array'): for lslice in genslices(n): for rslice in genslices(n): a = array.array(fmt, items) b = array.array(fmt, items) m = memoryview(b) self.assertEqual(m, a) self.assertEqual(m.tolist(), a.tolist()) self.assertEqual(m.tobytes(), a.tobytes()) self.assertEqual(len(m), len(a)) cmptest(self, a, b, m, singleitem) array_err = None have_resize = None try: al = a[lslice] ar = a[rslice] a[lslice] = a[rslice] have_resize = len(al) != len(ar) except Exception as e: array_err = e.__class__ m_err = None try: m[lslice] = m[rslice] except Exception as e: m_err = e.__class__ if have_resize: # memoryview cannot change shape self.assertIs(m_err, ValueError) elif m_err or array_err: self.assertIs(m_err, array_err) else: self.assertEqual(m, a) self.assertEqual(m.tolist(), a.tolist()) self.assertEqual(m.tobytes(), a.tobytes()) cmptest(self, a, b, m, singleitem) def test_memoryview_compare_special_cases(self): a = array.array('L', [1, 2, 3]) b = array.array('L', [1, 2, 7]) # Ordering comparisons raise: v = memoryview(a) w = memoryview(b) for attr in ('__lt__', '__le__', '__gt__', '__ge__'): self.assertIs(getattr(v, attr)(w), NotImplemented) self.assertIs(getattr(a, attr)(v), NotImplemented) # Released views compare equal to themselves: v = memoryview(a) v.release() self.assertEqual(v, v) self.assertNotEqual(v, a) self.assertNotEqual(a, v) v = memoryview(a) w = memoryview(a) w.release() self.assertNotEqual(v, w) self.assertNotEqual(w, v) # Operand does not implement the buffer protocol: v = memoryview(a) self.assertNotEqual(v, [1, 2, 3]) # NaNs nd = ndarray([(0, 0)], shape=[1], format='l x d x', flags=ND_WRITABLE) nd[0] = (-1, float('nan')) self.assertNotEqual(memoryview(nd), nd) # Depends on issue #15625: the struct module does not understand 'u'. a = array.array('u', 'xyz') v = memoryview(a) self.assertNotEqual(a, v) self.assertNotEqual(v, a) # Some ctypes format strings are unknown to the struct module. if ctypes: # format: "T{>l:x:>l:y:}" class BEPoint(ctypes.BigEndianStructure): _fields_ = [("x", ctypes.c_long), ("y", ctypes.c_long)] point = BEPoint(100, 200) a = memoryview(point) b = memoryview(point) self.assertNotEqual(a, b) self.assertNotEqual(a, point) self.assertNotEqual(point, a) self.assertRaises(NotImplementedError, a.tolist) def test_memoryview_compare_ndim_zero(self): nd1 = ndarray(1729, shape=[], format='@L') nd2 = ndarray(1729, shape=[], format='L', flags=ND_WRITABLE) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, w) self.assertEqual(w, v) self.assertEqual(v, nd2) self.assertEqual(nd2, v) self.assertEqual(w, nd1) self.assertEqual(nd1, w) self.assertFalse(v.__ne__(w)) self.assertFalse(w.__ne__(v)) w[()] = 1728 self.assertNotEqual(v, w) self.assertNotEqual(w, v) self.assertNotEqual(v, nd2) self.assertNotEqual(nd2, v) self.assertNotEqual(w, nd1) self.assertNotEqual(nd1, w) self.assertFalse(v.__eq__(w)) self.assertFalse(w.__eq__(v)) nd = ndarray(list(range(12)), shape=[12], flags=ND_WRITABLE|ND_PIL) ex = ndarray(list(range(12)), shape=[12], flags=ND_WRITABLE|ND_PIL) m = memoryview(ex) self.assertEqual(m, nd) m[9] = 100 self.assertNotEqual(m, nd) # struct module: equal nd1 = ndarray((1729, 1.2, b'12345'), shape=[], format='Lf5s') nd2 = ndarray((1729, 1.2, b'12345'), shape=[], format='hf5s', flags=ND_WRITABLE) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, w) self.assertEqual(w, v) self.assertEqual(v, nd2) self.assertEqual(nd2, v) self.assertEqual(w, nd1) self.assertEqual(nd1, w) # struct module: not equal nd1 = ndarray((1729, 1.2, b'12345'), shape=[], format='Lf5s') nd2 = ndarray((-1729, 1.2, b'12345'), shape=[], format='hf5s', flags=ND_WRITABLE) v = memoryview(nd1) w = memoryview(nd2) self.assertNotEqual(v, w) self.assertNotEqual(w, v) self.assertNotEqual(v, nd2) self.assertNotEqual(nd2, v) self.assertNotEqual(w, nd1) self.assertNotEqual(nd1, w) self.assertEqual(v, nd1) self.assertEqual(w, nd2) def test_memoryview_compare_ndim_one(self): # contiguous nd1 = ndarray([-529, 576, -625, 676, -729], shape=[5], format='@h') nd2 = ndarray([-529, 576, -625, 676, 729], shape=[5], format='@h') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # contiguous, struct module nd1 = ndarray([-529, 576, -625, 676, -729], shape=[5], format='<i') nd2 = ndarray([-529, 576, -625, 676, 729], shape=[5], format='>h') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # non-contiguous nd1 = ndarray([-529, -625, -729], shape=[3], format='@h') nd2 = ndarray([-529, 576, -625, 676, -729], shape=[5], format='@h') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd2[::2]) self.assertEqual(w[::2], nd1) self.assertEqual(v, w[::2]) self.assertEqual(v[::-1], w[::-2]) # non-contiguous, struct module nd1 = ndarray([-529, -625, -729], shape=[3], format='!h') nd2 = ndarray([-529, 576, -625, 676, -729], shape=[5], format='<l') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd2[::2]) self.assertEqual(w[::2], nd1) self.assertEqual(v, w[::2]) self.assertEqual(v[::-1], w[::-2]) # non-contiguous, suboffsets nd1 = ndarray([-529, -625, -729], shape=[3], format='@h') nd2 = ndarray([-529, 576, -625, 676, -729], shape=[5], format='@h', flags=ND_PIL) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd2[::2]) self.assertEqual(w[::2], nd1) self.assertEqual(v, w[::2]) self.assertEqual(v[::-1], w[::-2]) # non-contiguous, suboffsets, struct module nd1 = ndarray([-529, -625, -729], shape=[3], format='h 0c') nd2 = ndarray([-529, 576, -625, 676, -729], shape=[5], format='> h', flags=ND_PIL) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd2[::2]) self.assertEqual(w[::2], nd1) self.assertEqual(v, w[::2]) self.assertEqual(v[::-1], w[::-2]) def test_memoryview_compare_zero_shape(self): # zeros in shape nd1 = ndarray([900, 961], shape=[0], format='@h') nd2 = ndarray([-900, -961], shape=[0], format='@h') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) # zeros in shape, struct module nd1 = ndarray([900, 961], shape=[0], format='= h0c') nd2 = ndarray([-900, -961], shape=[0], format='@ i') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) def test_memoryview_compare_zero_strides(self): # zero strides nd1 = ndarray([900, 900, 900, 900], shape=[4], format='@L') nd2 = ndarray([900], shape=[4], strides=[0], format='L') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) # zero strides, struct module nd1 = ndarray([(900, 900)]*4, shape=[4], format='@ Li') nd2 = ndarray([(900, 900)], shape=[4], strides=[0], format='!L h') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) def test_memoryview_compare_random_formats(self): # random single character native formats n = 10 for char in fmtdict['@m']: fmt, items, singleitem = randitems(n, 'memoryview', '@', char) for flags in (0, ND_PIL): nd = ndarray(items, shape=[n], format=fmt, flags=flags) m = memoryview(nd) self.assertEqual(m, nd) nd = nd[::-3] m = memoryview(nd) self.assertEqual(m, nd) # random formats n = 10 for _ in range(100): fmt, items, singleitem = randitems(n) for flags in (0, ND_PIL): nd = ndarray(items, shape=[n], format=fmt, flags=flags) m = memoryview(nd) self.assertEqual(m, nd) nd = nd[::-3] m = memoryview(nd) self.assertEqual(m, nd) def test_memoryview_compare_multidim_c(self): # C-contiguous, different values nd1 = ndarray(list(range(-15, 15)), shape=[3, 2, 5], format='@h') nd2 = ndarray(list(range(0, 30)), shape=[3, 2, 5], format='@h') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # C-contiguous, different values, struct module nd1 = ndarray([(0, 1, 2)]*30, shape=[3, 2, 5], format='=f q xxL') nd2 = ndarray([(-1.2, 1, 2)]*30, shape=[3, 2, 5], format='< f 2Q') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # C-contiguous, different shape nd1 = ndarray(list(range(30)), shape=[2, 3, 5], format='L') nd2 = ndarray(list(range(30)), shape=[3, 2, 5], format='L') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # C-contiguous, different shape, struct module nd1 = ndarray([(0, 1, 2)]*21, shape=[3, 7], format='! b B xL') nd2 = ndarray([(0, 1, 2)]*21, shape=[7, 3], format='= Qx l xxL') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # C-contiguous, different format, struct module nd1 = ndarray(list(range(30)), shape=[2, 3, 5], format='L') nd2 = ndarray(list(range(30)), shape=[2, 3, 5], format='l') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) def test_memoryview_compare_multidim_fortran(self): # Fortran-contiguous, different values nd1 = ndarray(list(range(-15, 15)), shape=[5, 2, 3], format='@h', flags=ND_FORTRAN) nd2 = ndarray(list(range(0, 30)), shape=[5, 2, 3], format='@h', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # Fortran-contiguous, different values, struct module nd1 = ndarray([(2**64-1, -1)]*6, shape=[2, 3], format='=Qq', flags=ND_FORTRAN) nd2 = ndarray([(-1, 2**64-1)]*6, shape=[2, 3], format='=qQ', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # Fortran-contiguous, different shape nd1 = ndarray(list(range(-15, 15)), shape=[2, 3, 5], format='l', flags=ND_FORTRAN) nd2 = ndarray(list(range(-15, 15)), shape=[3, 2, 5], format='l', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # Fortran-contiguous, different shape, struct module nd1 = ndarray(list(range(-15, 15)), shape=[2, 3, 5], format='0ll', flags=ND_FORTRAN) nd2 = ndarray(list(range(-15, 15)), shape=[3, 2, 5], format='l', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # Fortran-contiguous, different format, struct module nd1 = ndarray(list(range(30)), shape=[5, 2, 3], format='@h', flags=ND_FORTRAN) nd2 = ndarray(list(range(30)), shape=[5, 2, 3], format='@b', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) def test_memoryview_compare_multidim_mixed(self): # mixed C/Fortran contiguous lst1 = list(range(-15, 15)) lst2 = transpose(lst1, [3, 2, 5]) nd1 = ndarray(lst1, shape=[3, 2, 5], format='@l') nd2 = ndarray(lst2, shape=[3, 2, 5], format='l', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, w) # mixed C/Fortran contiguous, struct module lst1 = [(-3.3, -22, b'x')]*30 lst1[5] = (-2.2, -22, b'x') lst2 = transpose(lst1, [3, 2, 5]) nd1 = ndarray(lst1, shape=[3, 2, 5], format='d b c') nd2 = ndarray(lst2, shape=[3, 2, 5], format='d h c', flags=ND_FORTRAN) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, w) # different values, non-contiguous ex1 = ndarray(list(range(40)), shape=[5, 8], format='@I') nd1 = ex1[3:1:-1, ::-2] ex2 = ndarray(list(range(40)), shape=[5, 8], format='I') nd2 = ex2[1:3:1, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # same values, non-contiguous, struct module ex1 = ndarray([(2**31-1, -2**31)]*22, shape=[11, 2], format='=ii') nd1 = ex1[3:1:-1, ::-2] ex2 = ndarray([(2**31-1, -2**31)]*22, shape=[11, 2], format='>ii') nd2 = ex2[1:3:1, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) # different shape ex1 = ndarray(list(range(30)), shape=[2, 3, 5], format='b') nd1 = ex1[1:3:, ::-2] nd2 = ndarray(list(range(30)), shape=[3, 2, 5], format='b') nd2 = ex2[1:3:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # different shape, struct module ex1 = ndarray(list(range(30)), shape=[2, 3, 5], format='B') nd1 = ex1[1:3:, ::-2] nd2 = ndarray(list(range(30)), shape=[3, 2, 5], format='b') nd2 = ex2[1:3:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # different format, struct module ex1 = ndarray([(2, b'123')]*30, shape=[5, 3, 2], format='b3s') nd1 = ex1[1:3:, ::-2] nd2 = ndarray([(2, b'123')]*30, shape=[5, 3, 2], format='i3s') nd2 = ex2[1:3:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) def test_memoryview_compare_multidim_zero_shape(self): # zeros in shape nd1 = ndarray(list(range(30)), shape=[0, 3, 2], format='i') nd2 = ndarray(list(range(30)), shape=[5, 0, 2], format='@i') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # zeros in shape, struct module nd1 = ndarray(list(range(30)), shape=[0, 3, 2], format='i') nd2 = ndarray(list(range(30)), shape=[5, 0, 2], format='@i') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) def test_memoryview_compare_multidim_zero_strides(self): # zero strides nd1 = ndarray([900]*80, shape=[4, 5, 4], format='@L') nd2 = ndarray([900], shape=[4, 5, 4], strides=[0, 0, 0], format='L') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) self.assertEqual(v.tolist(), w.tolist()) # zero strides, struct module nd1 = ndarray([(1, 2)]*10, shape=[2, 5], format='=lQ') nd2 = ndarray([(1, 2)], shape=[2, 5], strides=[0, 0], format='<lQ') v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) def test_memoryview_compare_multidim_suboffsets(self): # suboffsets ex1 = ndarray(list(range(40)), shape=[5, 8], format='@I') nd1 = ex1[3:1:-1, ::-2] ex2 = ndarray(list(range(40)), shape=[5, 8], format='I', flags=ND_PIL) nd2 = ex2[1:3:1, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # suboffsets, struct module ex1 = ndarray([(2**64-1, -1)]*40, shape=[5, 8], format='=Qq', flags=ND_WRITABLE) ex1[2][7] = (1, -2) nd1 = ex1[3:1:-1, ::-2] ex2 = ndarray([(2**64-1, -1)]*40, shape=[5, 8], format='>Qq', flags=ND_PIL|ND_WRITABLE) ex2[2][7] = (1, -2) nd2 = ex2[1:3:1, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) # suboffsets, different shape ex1 = ndarray(list(range(30)), shape=[2, 3, 5], format='b', flags=ND_PIL) nd1 = ex1[1:3:, ::-2] nd2 = ndarray(list(range(30)), shape=[3, 2, 5], format='b') nd2 = ex2[1:3:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # suboffsets, different shape, struct module ex1 = ndarray([(2**8-1, -1)]*40, shape=[2, 3, 5], format='Bb', flags=ND_PIL|ND_WRITABLE) nd1 = ex1[1:2:, ::-2] ex2 = ndarray([(2**8-1, -1)]*40, shape=[3, 2, 5], format='Bb') nd2 = ex2[1:2:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # suboffsets, different format ex1 = ndarray(list(range(30)), shape=[5, 3, 2], format='i', flags=ND_PIL) nd1 = ex1[1:3:, ::-2] ex2 = ndarray(list(range(30)), shape=[5, 3, 2], format='@I', flags=ND_PIL) nd2 = ex2[1:3:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, nd2) self.assertEqual(w, nd1) self.assertEqual(v, w) # suboffsets, different format, struct module ex1 = ndarray([(b'hello', b'', 1)]*27, shape=[3, 3, 3], format='5s0sP', flags=ND_PIL|ND_WRITABLE) ex1[1][2][2] = (b'sushi', b'', 1) nd1 = ex1[1:3:, ::-2] ex2 = ndarray([(b'hello', b'', 1)]*27, shape=[3, 3, 3], format='5s0sP', flags=ND_PIL|ND_WRITABLE) ex1[1][2][2] = (b'sushi', b'', 1) nd2 = ex2[1:3:, ::-2] v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertNotEqual(v, nd2) self.assertNotEqual(w, nd1) self.assertNotEqual(v, w) # initialize mixed C/Fortran + suboffsets lst1 = list(range(-15, 15)) lst2 = transpose(lst1, [3, 2, 5]) nd1 = ndarray(lst1, shape=[3, 2, 5], format='@l', flags=ND_PIL) nd2 = ndarray(lst2, shape=[3, 2, 5], format='l', flags=ND_FORTRAN|ND_PIL) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, w) # initialize mixed C/Fortran + suboffsets, struct module lst1 = [(b'sashimi', b'sliced', 20.05)]*30 lst1[11] = (b'ramen', b'spicy', 9.45) lst2 = transpose(lst1, [3, 2, 5]) nd1 = ndarray(lst1, shape=[3, 2, 5], format='< 10p 9p d', flags=ND_PIL) nd2 = ndarray(lst2, shape=[3, 2, 5], format='> 10p 9p d', flags=ND_FORTRAN|ND_PIL) v = memoryview(nd1) w = memoryview(nd2) self.assertEqual(v, nd1) self.assertEqual(w, nd2) self.assertEqual(v, w) def test_memoryview_compare_not_equal(self): # items not equal for byteorder in ['=', '<', '>', '!']: x = ndarray([2**63]*120, shape=[3,5,2,2,2], format=byteorder+'Q') y = ndarray([2**63]*120, shape=[3,5,2,2,2], format=byteorder+'Q', flags=ND_WRITABLE|ND_FORTRAN) y[2][3][1][1][1] = 1 a = memoryview(x) b = memoryview(y) self.assertEqual(a, x) self.assertEqual(b, y) self.assertNotEqual(a, b) self.assertNotEqual(a, y) self.assertNotEqual(b, x) x = ndarray([(2**63, 2**31, 2**15)]*120, shape=[3,5,2,2,2], format=byteorder+'QLH') y = ndarray([(2**63, 2**31, 2**15)]*120, shape=[3,5,2,2,2], format=byteorder+'QLH', flags=ND_WRITABLE|ND_FORTRAN) y[2][3][1][1][1] = (1, 1, 1) a = memoryview(x) b = memoryview(y) self.assertEqual(a, x) self.assertEqual(b, y) self.assertNotEqual(a, b) self.assertNotEqual(a, y) self.assertNotEqual(b, x) def test_memoryview_check_released(self): a = array.array('d', [1.1, 2.2, 3.3]) m = memoryview(a) m.release() # PyMemoryView_FromObject() self.assertRaises(ValueError, memoryview, m) # memoryview.cast() self.assertRaises(ValueError, m.cast, 'c') # getbuffer() self.assertRaises(ValueError, ndarray, m) # memoryview.tolist() self.assertRaises(ValueError, m.tolist) # memoryview.tobytes() self.assertRaises(ValueError, m.tobytes) # sequence self.assertRaises(ValueError, eval, "1.0 in m", locals()) # subscript self.assertRaises(ValueError, m.__getitem__, 0) # assignment self.assertRaises(ValueError, m.__setitem__, 0, 1) for attr in ('obj', 'nbytes', 'readonly', 'itemsize', 'format', 'ndim', 'shape', 'strides', 'suboffsets', 'c_contiguous', 'f_contiguous', 'contiguous'): self.assertRaises(ValueError, m.__getattribute__, attr) # richcompare b = array.array('d', [1.1, 2.2, 3.3]) m1 = memoryview(a) m2 = memoryview(b) self.assertEqual(m1, m2) m1.release() self.assertNotEqual(m1, m2) self.assertNotEqual(m1, a) self.assertEqual(m1, m1) def test_memoryview_tobytes(self): # Many implicit tests are already in self.verify(). t = (-529, 576, -625, 676, -729) nd = ndarray(t, shape=[5], format='@h') m = memoryview(nd) self.assertEqual(m, nd) self.assertEqual(m.tobytes(), nd.tobytes()) nd = ndarray([t], shape=[1], format='>hQiLl') m = memoryview(nd) self.assertEqual(m, nd) self.assertEqual(m.tobytes(), nd.tobytes()) nd = ndarray([t for _ in range(12)], shape=[2,2,3], format='=hQiLl') m = memoryview(nd) self.assertEqual(m, nd) self.assertEqual(m.tobytes(), nd.tobytes()) nd = ndarray([t for _ in range(120)], shape=[5,2,2,3,2], format='<hQiLl') m = memoryview(nd) self.assertEqual(m, nd) self.assertEqual(m.tobytes(), nd.tobytes()) # Unknown formats are handled: tobytes() purely depends on itemsize. if ctypes: # format: "T{>l:x:>l:y:}" class BEPoint(ctypes.BigEndianStructure): _fields_ = [("x", ctypes.c_long), ("y", ctypes.c_long)] point = BEPoint(100, 200) a = memoryview(point) self.assertEqual(a.tobytes(), bytes(point)) def test_memoryview_get_contiguous(self): # Many implicit tests are already in self.verify(). # no buffer interface self.assertRaises(TypeError, get_contiguous, {}, PyBUF_READ, 'F') # writable request to read-only object self.assertRaises(BufferError, get_contiguous, b'x', PyBUF_WRITE, 'C') # writable request to non-contiguous object nd = ndarray([1, 2, 3], shape=[2], strides=[2]) self.assertRaises(BufferError, get_contiguous, nd, PyBUF_WRITE, 'A') # scalar, read-only request from read-only exporter nd = ndarray(9, shape=(), format="L") for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(m, nd) self.assertEqual(m[()], 9) # scalar, read-only request from writable exporter nd = ndarray(9, shape=(), format="L", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(m, nd) self.assertEqual(m[()], 9) # scalar, writable request for order in ['C', 'F', 'A']: nd[()] = 9 m = get_contiguous(nd, PyBUF_WRITE, order) self.assertEqual(m, nd) self.assertEqual(m[()], 9) m[()] = 10 self.assertEqual(m[()], 10) self.assertEqual(nd[()], 10) # zeros in shape nd = ndarray([1], shape=[0], format="L", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_READ, order) self.assertRaises(IndexError, m.__getitem__, 0) self.assertEqual(m, nd) self.assertEqual(m.tolist(), []) nd = ndarray(list(range(8)), shape=[2, 0, 7], format="L", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(ndarray(m).tolist(), [[], []]) # one-dimensional nd = ndarray([1], shape=[1], format="h", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_WRITE, order) self.assertEqual(m, nd) self.assertEqual(m.tolist(), nd.tolist()) nd = ndarray([1, 2, 3], shape=[3], format="b", flags=ND_WRITABLE) for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_WRITE, order) self.assertEqual(m, nd) self.assertEqual(m.tolist(), nd.tolist()) # one-dimensional, non-contiguous nd = ndarray([1, 2, 3], shape=[2], strides=[2], flags=ND_WRITABLE) for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(m, nd) self.assertEqual(m.tolist(), nd.tolist()) self.assertRaises(TypeError, m.__setitem__, 1, 20) self.assertEqual(m[1], 3) self.assertEqual(nd[1], 3) nd = nd[::-1] for order in ['C', 'F', 'A']: m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(m, nd) self.assertEqual(m.tolist(), nd.tolist()) self.assertRaises(TypeError, m.__setitem__, 1, 20) self.assertEqual(m[1], 1) self.assertEqual(nd[1], 1) # multi-dimensional, contiguous input nd = ndarray(list(range(12)), shape=[3, 4], flags=ND_WRITABLE) for order in ['C', 'A']: m = get_contiguous(nd, PyBUF_WRITE, order) self.assertEqual(ndarray(m).tolist(), nd.tolist()) self.assertRaises(BufferError, get_contiguous, nd, PyBUF_WRITE, 'F') m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(ndarray(m).tolist(), nd.tolist()) nd = ndarray(list(range(12)), shape=[3, 4], flags=ND_WRITABLE|ND_FORTRAN) for order in ['F', 'A']: m = get_contiguous(nd, PyBUF_WRITE, order) self.assertEqual(ndarray(m).tolist(), nd.tolist()) self.assertRaises(BufferError, get_contiguous, nd, PyBUF_WRITE, 'C') m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(ndarray(m).tolist(), nd.tolist()) # multi-dimensional, non-contiguous input nd = ndarray(list(range(12)), shape=[3, 4], flags=ND_WRITABLE|ND_PIL) for order in ['C', 'F', 'A']: self.assertRaises(BufferError, get_contiguous, nd, PyBUF_WRITE, order) m = get_contiguous(nd, PyBUF_READ, order) self.assertEqual(ndarray(m).tolist(), nd.tolist()) # flags nd = ndarray([1,2,3,4,5], shape=[3], strides=[2]) m = get_contiguous(nd, PyBUF_READ, 'C') self.assertTrue(m.c_contiguous) def test_memoryview_serializing(self): # C-contiguous size = struct.calcsize('i') a = array.array('i', [1,2,3,4,5]) m = memoryview(a) buf = io.BytesIO(m) b = bytearray(5*size) buf.readinto(b) self.assertEqual(m.tobytes(), b) # C-contiguous, multi-dimensional size = struct.calcsize('L') nd = ndarray(list(range(12)), shape=[2,3,2], format="L") m = memoryview(nd) buf = io.BytesIO(m) b = bytearray(2*3*2*size) buf.readinto(b) self.assertEqual(m.tobytes(), b) # Fortran contiguous, multi-dimensional #size = struct.calcsize('L') #nd = ndarray(list(range(12)), shape=[2,3,2], format="L", # flags=ND_FORTRAN) #m = memoryview(nd) #buf = io.BytesIO(m) #b = bytearray(2*3*2*size) #buf.readinto(b) #self.assertEqual(m.tobytes(), b) def test_memoryview_hash(self): # bytes exporter b = bytes(list(range(12))) m = memoryview(b) self.assertEqual(hash(b), hash(m)) # C-contiguous mc = m.cast('c', shape=[3,4]) self.assertEqual(hash(mc), hash(b)) # non-contiguous mx = m[::-2] b = bytes(list(range(12))[::-2]) self.assertEqual(hash(mx), hash(b)) # Fortran contiguous nd = ndarray(list(range(30)), shape=[3,2,5], flags=ND_FORTRAN) m = memoryview(nd) self.assertEqual(hash(m), hash(nd)) # multi-dimensional slice nd = ndarray(list(range(30)), shape=[3,2,5]) x = nd[::2, ::, ::-1] m = memoryview(x) self.assertEqual(hash(m), hash(x)) # multi-dimensional slice with suboffsets nd = ndarray(list(range(30)), shape=[2,5,3], flags=ND_PIL) x = nd[::2, ::, ::-1] m = memoryview(x) self.assertEqual(hash(m), hash(x)) # equality-hash invariant x = ndarray(list(range(12)), shape=[12], format='B') a = memoryview(x) y = ndarray(list(range(12)), shape=[12], format='b') b = memoryview(y) self.assertEqual(a, b) self.assertEqual(hash(a), hash(b)) # non-byte formats nd = ndarray(list(range(12)), shape=[2,2,3], format='L') m = memoryview(nd) self.assertRaises(ValueError, m.__hash__) nd = ndarray(list(range(-6, 6)), shape=[2,2,3], format='h') m = memoryview(nd) self.assertRaises(ValueError, m.__hash__) nd = ndarray(list(range(12)), shape=[2,2,3], format='= L') m = memoryview(nd) self.assertRaises(ValueError, m.__hash__) nd = ndarray(list(range(-6, 6)), shape=[2,2,3], format='< h') m = memoryview(nd) self.assertRaises(ValueError, m.__hash__) def test_memoryview_release(self): # Create re-exporter from getbuffer(memoryview), then release the view. a = bytearray([1,2,3]) m = memoryview(a) nd = ndarray(m) # re-exporter self.assertRaises(BufferError, m.release) del nd m.release() a = bytearray([1,2,3]) m = memoryview(a) nd1 = ndarray(m, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) nd2 = ndarray(nd1, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) self.assertIs(nd2.obj, m) self.assertRaises(BufferError, m.release) del nd1, nd2 m.release() # chained views a = bytearray([1,2,3]) m1 = memoryview(a) m2 = memoryview(m1) nd = ndarray(m2) # re-exporter m1.release() self.assertRaises(BufferError, m2.release) del nd m2.release() a = bytearray([1,2,3]) m1 = memoryview(a) m2 = memoryview(m1) nd1 = ndarray(m2, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) nd2 = ndarray(nd1, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) self.assertIs(nd2.obj, m2) m1.release() self.assertRaises(BufferError, m2.release) del nd1, nd2 m2.release() # Allow changing layout while buffers are exported. nd = ndarray([1,2,3], shape=[3], flags=ND_VAREXPORT) m1 = memoryview(nd) nd.push([4,5,6,7,8], shape=[5]) # mutate nd m2 = memoryview(nd) x = memoryview(m1) self.assertEqual(x.tolist(), m1.tolist()) y = memoryview(m2) self.assertEqual(y.tolist(), m2.tolist()) self.assertEqual(y.tolist(), nd.tolist()) m2.release() y.release() nd.pop() # pop the current view self.assertEqual(x.tolist(), nd.tolist()) del nd m1.release() x.release() # If multiple memoryviews share the same managed buffer, implicit # release() in the context manager's __exit__() method should still # work. def catch22(b): with memoryview(b) as m2: pass x = bytearray(b'123') with memoryview(x) as m1: catch22(m1) self.assertEqual(m1[0], ord(b'1')) x = ndarray(list(range(12)), shape=[2,2,3], format='l') y = ndarray(x, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) z = ndarray(y, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) self.assertIs(z.obj, x) with memoryview(z) as m: catch22(m) self.assertEqual(m[0:1].tolist(), [[[0, 1, 2], [3, 4, 5]]]) # Test garbage collection. for flags in (0, ND_REDIRECT): x = bytearray(b'123') with memoryview(x) as m1: del x y = ndarray(m1, getbuf=PyBUF_FULL_RO, flags=flags) with memoryview(y) as m2: del y z = ndarray(m2, getbuf=PyBUF_FULL_RO, flags=flags) with memoryview(z) as m3: del z catch22(m3) catch22(m2) catch22(m1) self.assertEqual(m1[0], ord(b'1')) self.assertEqual(m2[1], ord(b'2')) self.assertEqual(m3[2], ord(b'3')) del m3 del m2 del m1 x = bytearray(b'123') with memoryview(x) as m1: del x y = ndarray(m1, getbuf=PyBUF_FULL_RO, flags=flags) with memoryview(y) as m2: del y z = ndarray(m2, getbuf=PyBUF_FULL_RO, flags=flags) with memoryview(z) as m3: del z catch22(m1) catch22(m2) catch22(m3) self.assertEqual(m1[0], ord(b'1')) self.assertEqual(m2[1], ord(b'2')) self.assertEqual(m3[2], ord(b'3')) del m1, m2, m3 # memoryview.release() fails if the view has exported buffers. x = bytearray(b'123') with self.assertRaises(BufferError): with memoryview(x) as m: ex = ndarray(m) m[0] == ord(b'1') def test_memoryview_redirect(self): nd = ndarray([1.0 * x for x in range(12)], shape=[12], format='d') a = array.array('d', [1.0 * x for x in range(12)]) for x in (nd, a): y = ndarray(x, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) z = ndarray(y, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) m = memoryview(z) self.assertIs(y.obj, x) self.assertIs(z.obj, x) self.assertIs(m.obj, x) self.assertEqual(m, x) self.assertEqual(m, y) self.assertEqual(m, z) self.assertEqual(m[1:3], x[1:3]) self.assertEqual(m[1:3], y[1:3]) self.assertEqual(m[1:3], z[1:3]) del y, z self.assertEqual(m[1:3], x[1:3]) def test_memoryview_from_static_exporter(self): fmt = 'B' lst = [0,1,2,3,4,5,6,7,8,9,10,11] # exceptions self.assertRaises(TypeError, staticarray, 1, 2, 3) # view.obj==x x = staticarray() y = memoryview(x) self.verify(y, obj=x, itemsize=1, fmt=fmt, readonly=1, ndim=1, shape=[12], strides=[1], lst=lst) for i in range(12): self.assertEqual(y[i], i) del x del y x = staticarray() y = memoryview(x) del y del x x = staticarray() y = ndarray(x, getbuf=PyBUF_FULL_RO) z = ndarray(y, getbuf=PyBUF_FULL_RO) m = memoryview(z) self.assertIs(y.obj, x) self.assertIs(m.obj, z) self.verify(m, obj=z, itemsize=1, fmt=fmt, readonly=1, ndim=1, shape=[12], strides=[1], lst=lst) del x, y, z, m x = staticarray() y = ndarray(x, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) z = ndarray(y, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) m = memoryview(z) self.assertIs(y.obj, x) self.assertIs(z.obj, x) self.assertIs(m.obj, x) self.verify(m, obj=x, itemsize=1, fmt=fmt, readonly=1, ndim=1, shape=[12], strides=[1], lst=lst) del x, y, z, m # view.obj==NULL x = staticarray(legacy_mode=True) y = memoryview(x) self.verify(y, obj=None, itemsize=1, fmt=fmt, readonly=1, ndim=1, shape=[12], strides=[1], lst=lst) for i in range(12): self.assertEqual(y[i], i) del x del y x = staticarray(legacy_mode=True) y = memoryview(x) del y del x x = staticarray(legacy_mode=True) y = ndarray(x, getbuf=PyBUF_FULL_RO) z = ndarray(y, getbuf=PyBUF_FULL_RO) m = memoryview(z) self.assertIs(y.obj, None) self.assertIs(m.obj, z) self.verify(m, obj=z, itemsize=1, fmt=fmt, readonly=1, ndim=1, shape=[12], strides=[1], lst=lst) del x, y, z, m x = staticarray(legacy_mode=True) y = ndarray(x, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) z = ndarray(y, getbuf=PyBUF_FULL_RO, flags=ND_REDIRECT) m = memoryview(z) # Clearly setting view.obj==NULL is inferior, since it # messes up the redirection chain: self.assertIs(y.obj, None) self.assertIs(z.obj, y) self.assertIs(m.obj, y) self.verify(m, obj=y, itemsize=1, fmt=fmt, readonly=1, ndim=1, shape=[12], strides=[1], lst=lst) del x, y, z, m def test_memoryview_getbuffer_undefined(self): # getbufferproc does not adhere to the new documentation nd = ndarray([1,2,3], [3], flags=ND_GETBUF_FAIL|ND_GETBUF_UNDEFINED) self.assertRaises(BufferError, memoryview, nd) def test_issue_7385(self): x = ndarray([1,2,3], shape=[3], flags=ND_GETBUF_FAIL) self.assertRaises(BufferError, memoryview, x) if __name__ == "__main__": unittest.main()
162,663
4,397
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_osx_env.py
""" Test suite for OS X interpreter environment variables. """ from test.support import EnvironmentVarGuard import subprocess import sys import sysconfig import unittest @unittest.skipUnless(sys.platform == 'darwin' and sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'), 'unnecessary on this platform') class OSXEnvironmentVariableTestCase(unittest.TestCase): def _check_sys(self, ev, cond, sv, val = sys.executable + 'dummy'): with EnvironmentVarGuard() as evg: subpc = [str(sys.executable), '-c', 'import sys; sys.exit(2 if "%s" %s %s else 3)' % (val, cond, sv)] # ensure environment variable does not exist evg.unset(ev) # test that test on sys.xxx normally fails rc = subprocess.call(subpc) self.assertEqual(rc, 3, "expected %s not %s %s" % (ev, cond, sv)) # set environ variable evg.set(ev, val) # test that sys.xxx has been influenced by the environ value rc = subprocess.call(subpc) self.assertEqual(rc, 2, "expected %s %s %s" % (ev, cond, sv)) def test_pythonexecutable_sets_sys_executable(self): self._check_sys('PYTHONEXECUTABLE', '==', 'sys.executable') if __name__ == "__main__": unittest.main()
1,328
35
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_codecs.py
import codecs import contextlib import io import locale import sys import unittest import encodings from test import support from encodings import ( aliases, base64_codec, big5, big5hkscs, bz2_codec, charmap, cp037, cp1006, cp1026, cp1125, cp1140, cp1250, cp1251, cp1252, cp1253, cp1254, cp1255, cp1256, cp1257, cp1258, cp273, cp424, cp437, cp500, cp720, cp737, cp775, cp850, cp852, cp855, cp856, cp857, cp858, cp860, cp861, cp862, cp863, cp864, cp865, cp866, cp869, cp874, cp875, cp932, cp949, cp950, euc_jis_2004, euc_jisx0213, euc_jp, euc_kr, gb18030, gb2312, gbk, hex_codec, hp_roman8, hz, idna, iso2022_jp, iso2022_jp_1, iso2022_jp_2, iso2022_jp_2004, iso2022_jp_3, iso2022_jp_ext, iso2022_kr, iso8859_1, iso8859_10, iso8859_11, iso8859_13, iso8859_14, iso8859_15, iso8859_16, iso8859_2, iso8859_3, iso8859_4, iso8859_5, iso8859_6, iso8859_7, iso8859_8, iso8859_9, johab, koi8_r, koi8_t, koi8_u, kz1048, latin_1, mac_arabic, mac_centeuro, mac_croatian, mac_cyrillic, mac_farsi, mac_greek, mac_iceland, mac_latin2, mac_roman, mac_romanian, mac_turkish, palmos, ptcp154, punycode, quopri_codec, raw_unicode_escape, rot_13, shift_jis, shift_jis_2004, shift_jisx0213, tis_620, undefined, unicode_escape, unicode_internal, utf_16, utf_16_be, utf_16_le, utf_32, utf_32_be, utf_32_le, utf_7, utf_8, utf_8_sig, uu_codec, zlib_codec, ) try: import ctypes except ImportError: ctypes = None SIZEOF_WCHAR_T = 4 else: SIZEOF_WCHAR_T = ctypes.sizeof(ctypes.c_wchar) def coding_checker(self, coder): def check(input, expect): self.assertEqual(coder(input), (expect, len(input))) return check class Queue(object): """ queue: write bytes at one end, read bytes from the other end """ def __init__(self, buffer): self._buffer = buffer def write(self, chars): self._buffer += chars def read(self, size=-1): if size<0: s = self._buffer self._buffer = self._buffer[:0] # make empty return s else: s = self._buffer[:size] self._buffer = self._buffer[size:] return s class MixInCheckStateHandling: def check_state_handling_decode(self, encoding, u, s): for i in range(len(s)+1): d = codecs.getincrementaldecoder(encoding)() part1 = d.decode(s[:i]) state = d.getstate() self.assertIsInstance(state[1], int) # Check that the condition stated in the documentation for # IncrementalDecoder.getstate() holds if not state[1]: # reset decoder to the default state without anything buffered d.setstate((state[0][:0], 0)) # Feeding the previous input may not produce any output self.assertTrue(not d.decode(state[0])) # The decoder must return to the same state self.assertEqual(state, d.getstate()) # Create a new decoder and set it to the state # we extracted from the old one d = codecs.getincrementaldecoder(encoding)() d.setstate(state) part2 = d.decode(s[i:], True) self.assertEqual(u, part1+part2) def check_state_handling_encode(self, encoding, u, s): for i in range(len(u)+1): d = codecs.getincrementalencoder(encoding)() part1 = d.encode(u[:i]) state = d.getstate() d = codecs.getincrementalencoder(encoding)() d.setstate(state) part2 = d.encode(u[i:], True) self.assertEqual(s, part1+part2) class ReadTest(MixInCheckStateHandling): def check_partial(self, input, partialresults): # get a StreamReader for the encoding and feed the bytestring version # of input to the reader byte by byte. Read everything available from # the StreamReader and check that the results equal the appropriate # entries from partialresults. q = Queue(b"") r = codecs.getreader(self.encoding)(q) result = "" for (c, partialresult) in zip(input.encode(self.encoding), partialresults): q.write(bytes([c])) result += r.read() self.assertEqual(result, partialresult) # check that there's nothing left in the buffers self.assertEqual(r.read(), "") self.assertEqual(r.bytebuffer, b"") # do the check again, this time using an incremental decoder d = codecs.getincrementaldecoder(self.encoding)() result = "" for (c, partialresult) in zip(input.encode(self.encoding), partialresults): result += d.decode(bytes([c])) self.assertEqual(result, partialresult) # check that there's nothing left in the buffers self.assertEqual(d.decode(b"", True), "") self.assertEqual(d.buffer, b"") # Check whether the reset method works properly d.reset() result = "" for (c, partialresult) in zip(input.encode(self.encoding), partialresults): result += d.decode(bytes([c])) self.assertEqual(result, partialresult) # check that there's nothing left in the buffers self.assertEqual(d.decode(b"", True), "") self.assertEqual(d.buffer, b"") # check iterdecode() encoded = input.encode(self.encoding) self.assertEqual( input, "".join(codecs.iterdecode([bytes([c]) for c in encoded], self.encoding)) ) def test_readline(self): def getreader(input): stream = io.BytesIO(input.encode(self.encoding)) return codecs.getreader(self.encoding)(stream) def readalllines(input, keepends=True, size=None): reader = getreader(input) lines = [] while True: line = reader.readline(size=size, keepends=keepends) if not line: break lines.append(line) return "|".join(lines) s = "foo\nbar\r\nbaz\rspam\u2028eggs" sexpected = "foo\n|bar\r\n|baz\r|spam\u2028|eggs" sexpectednoends = "foo|bar|baz|spam|eggs" self.assertEqual(readalllines(s, True), sexpected) self.assertEqual(readalllines(s, False), sexpectednoends) self.assertEqual(readalllines(s, True, 10), sexpected) self.assertEqual(readalllines(s, False, 10), sexpectednoends) lineends = ("\n", "\r\n", "\r", "\u2028") # Test long lines (multiple calls to read() in readline()) vw = [] vwo = [] for (i, lineend) in enumerate(lineends): vw.append((i*200+200)*"\u3042" + lineend) vwo.append((i*200+200)*"\u3042") self.assertEqual(readalllines("".join(vw), True), "|".join(vw)) self.assertEqual(readalllines("".join(vw), False), "|".join(vwo)) # Test lines where the first read might end with \r, so the # reader has to look ahead whether this is a lone \r or a \r\n for size in range(80): for lineend in lineends: s = 10*(size*"a" + lineend + "xxx\n") reader = getreader(s) for i in range(10): self.assertEqual( reader.readline(keepends=True), size*"a" + lineend, ) self.assertEqual( reader.readline(keepends=True), "xxx\n", ) reader = getreader(s) for i in range(10): self.assertEqual( reader.readline(keepends=False), size*"a", ) self.assertEqual( reader.readline(keepends=False), "xxx", ) def test_mixed_readline_and_read(self): lines = ["Humpty Dumpty sat on a wall,\n", "Humpty Dumpty had a great fall.\r\n", "All the king's horses and all the king's men\r", "Couldn't put Humpty together again."] data = ''.join(lines) def getreader(): stream = io.BytesIO(data.encode(self.encoding)) return codecs.getreader(self.encoding)(stream) # Issue #8260: Test readline() followed by read() f = getreader() self.assertEqual(f.readline(), lines[0]) self.assertEqual(f.read(), ''.join(lines[1:])) self.assertEqual(f.read(), '') # Issue #32110: Test readline() followed by read(n) f = getreader() self.assertEqual(f.readline(), lines[0]) self.assertEqual(f.read(1), lines[1][0]) self.assertEqual(f.read(0), '') self.assertEqual(f.read(100), data[len(lines[0]) + 1:][:100]) # Issue #16636: Test readline() followed by readlines() f = getreader() self.assertEqual(f.readline(), lines[0]) self.assertEqual(f.readlines(), lines[1:]) self.assertEqual(f.read(), '') # Test read(n) followed by read() f = getreader() self.assertEqual(f.read(size=40, chars=5), data[:5]) self.assertEqual(f.read(), data[5:]) self.assertEqual(f.read(), '') # Issue #32110: Test read(n) followed by read(n) f = getreader() self.assertEqual(f.read(size=40, chars=5), data[:5]) self.assertEqual(f.read(1), data[5]) self.assertEqual(f.read(0), '') self.assertEqual(f.read(100), data[6:106]) # Issue #12446: Test read(n) followed by readlines() f = getreader() self.assertEqual(f.read(size=40, chars=5), data[:5]) self.assertEqual(f.readlines(), [lines[0][5:]] + lines[1:]) self.assertEqual(f.read(), '') def test_bug1175396(self): s = [ '<%!--===================================================\r\n', ' BLOG index page: show recent articles,\r\n', ' today\'s articles, or articles of a specific date.\r\n', '========================================================--%>\r\n', '<%@inputencoding="ISO-8859-1"%>\r\n', '<%@pagetemplate=TEMPLATE.y%>\r\n', '<%@import=import frog.util, frog%>\r\n', '<%@import=import frog.objects%>\r\n', '<%@import=from frog.storageerrors import StorageError%>\r\n', '<%\r\n', '\r\n', 'import logging\r\n', 'log=logging.getLogger("Snakelets.logger")\r\n', '\r\n', '\r\n', 'user=self.SessionCtx.user\r\n', 'storageEngine=self.SessionCtx.storageEngine\r\n', '\r\n', '\r\n', 'def readArticlesFromDate(date, count=None):\r\n', ' entryids=storageEngine.listBlogEntries(date)\r\n', ' entryids.reverse() # descending\r\n', ' if count:\r\n', ' entryids=entryids[:count]\r\n', ' try:\r\n', ' return [ frog.objects.BlogEntry.load(storageEngine, date, Id) for Id in entryids ]\r\n', ' except StorageError,x:\r\n', ' log.error("Error loading articles: "+str(x))\r\n', ' self.abort("cannot load articles")\r\n', '\r\n', 'showdate=None\r\n', '\r\n', 'arg=self.Request.getArg()\r\n', 'if arg=="today":\r\n', ' #-------------------- TODAY\'S ARTICLES\r\n', ' self.write("<h2>Today\'s articles</h2>")\r\n', ' showdate = frog.util.isodatestr() \r\n', ' entries = readArticlesFromDate(showdate)\r\n', 'elif arg=="active":\r\n', ' #-------------------- ACTIVE ARTICLES redirect\r\n', ' self.Yredirect("active.y")\r\n', 'elif arg=="login":\r\n', ' #-------------------- LOGIN PAGE redirect\r\n', ' self.Yredirect("login.y")\r\n', 'elif arg=="date":\r\n', ' #-------------------- ARTICLES OF A SPECIFIC DATE\r\n', ' showdate = self.Request.getParameter("date")\r\n', ' self.write("<h2>Articles written on %s</h2>"% frog.util.mediumdatestr(showdate))\r\n', ' entries = readArticlesFromDate(showdate)\r\n', 'else:\r\n', ' #-------------------- RECENT ARTICLES\r\n', ' self.write("<h2>Recent articles</h2>")\r\n', ' dates=storageEngine.listBlogEntryDates()\r\n', ' if dates:\r\n', ' entries=[]\r\n', ' SHOWAMOUNT=10\r\n', ' for showdate in dates:\r\n', ' entries.extend( readArticlesFromDate(showdate, SHOWAMOUNT-len(entries)) )\r\n', ' if len(entries)>=SHOWAMOUNT:\r\n', ' break\r\n', ' \r\n', ] stream = io.BytesIO("".join(s).encode(self.encoding)) reader = codecs.getreader(self.encoding)(stream) for (i, line) in enumerate(reader): self.assertEqual(line, s[i]) def test_readlinequeue(self): q = Queue(b"") writer = codecs.getwriter(self.encoding)(q) reader = codecs.getreader(self.encoding)(q) # No lineends writer.write("foo\r") self.assertEqual(reader.readline(keepends=False), "foo") writer.write("\nbar\r") self.assertEqual(reader.readline(keepends=False), "") self.assertEqual(reader.readline(keepends=False), "bar") writer.write("baz") self.assertEqual(reader.readline(keepends=False), "baz") self.assertEqual(reader.readline(keepends=False), "") # Lineends writer.write("foo\r") self.assertEqual(reader.readline(keepends=True), "foo\r") writer.write("\nbar\r") self.assertEqual(reader.readline(keepends=True), "\n") self.assertEqual(reader.readline(keepends=True), "bar\r") writer.write("baz") self.assertEqual(reader.readline(keepends=True), "baz") self.assertEqual(reader.readline(keepends=True), "") writer.write("foo\r\n") self.assertEqual(reader.readline(keepends=True), "foo\r\n") def test_bug1098990_a(self): s1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n" s2 = "offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n" s3 = "next line.\r\n" s = (s1+s2+s3).encode(self.encoding) stream = io.BytesIO(s) reader = codecs.getreader(self.encoding)(stream) self.assertEqual(reader.readline(), s1) self.assertEqual(reader.readline(), s2) self.assertEqual(reader.readline(), s3) self.assertEqual(reader.readline(), "") def test_bug1098990_b(self): s1 = "aaaaaaaaaaaaaaaaaaaaaaaa\r\n" s2 = "bbbbbbbbbbbbbbbbbbbbbbbb\r\n" s3 = "stillokay:bbbbxx\r\n" s4 = "broken!!!!badbad\r\n" s5 = "againokay.\r\n" s = (s1+s2+s3+s4+s5).encode(self.encoding) stream = io.BytesIO(s) reader = codecs.getreader(self.encoding)(stream) self.assertEqual(reader.readline(), s1) self.assertEqual(reader.readline(), s2) self.assertEqual(reader.readline(), s3) self.assertEqual(reader.readline(), s4) self.assertEqual(reader.readline(), s5) self.assertEqual(reader.readline(), "") ill_formed_sequence_replace = "\ufffd" def test_lone_surrogates(self): self.assertRaises(UnicodeEncodeError, "\ud800".encode, self.encoding) self.assertEqual("[\uDC80]".encode(self.encoding, "backslashreplace"), "[\\udc80]".encode(self.encoding)) self.assertEqual("[\uDC80]".encode(self.encoding, "namereplace"), "[\\udc80]".encode(self.encoding)) self.assertEqual("[\uDC80]".encode(self.encoding, "xmlcharrefreplace"), "[&#56448;]".encode(self.encoding)) self.assertEqual("[\uDC80]".encode(self.encoding, "ignore"), "[]".encode(self.encoding)) self.assertEqual("[\uDC80]".encode(self.encoding, "replace"), "[?]".encode(self.encoding)) # sequential surrogate characters self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "ignore"), "[]".encode(self.encoding)) self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "replace"), "[??]".encode(self.encoding)) bom = "".encode(self.encoding) for before, after in [("\U00010fff", "A"), ("[", "]"), ("A", "\U00010fff")]: before_sequence = before.encode(self.encoding)[len(bom):] after_sequence = after.encode(self.encoding)[len(bom):] test_string = before + "\uDC80" + after test_sequence = (bom + before_sequence + self.ill_formed_sequence + after_sequence) self.assertRaises(UnicodeDecodeError, test_sequence.decode, self.encoding) self.assertEqual(test_string.encode(self.encoding, "surrogatepass"), test_sequence) self.assertEqual(test_sequence.decode(self.encoding, "surrogatepass"), test_string) self.assertEqual(test_sequence.decode(self.encoding, "ignore"), before + after) self.assertEqual(test_sequence.decode(self.encoding, "replace"), before + self.ill_formed_sequence_replace + after) backslashreplace = ''.join('\\x%02x' % b for b in self.ill_formed_sequence) self.assertEqual(test_sequence.decode(self.encoding, "backslashreplace"), before + backslashreplace + after) class UTF32Test(ReadTest, unittest.TestCase): encoding = "utf-32" if sys.byteorder == 'little': ill_formed_sequence = b"\x80\xdc\x00\x00" else: ill_formed_sequence = b"\x00\x00\xdc\x80" spamle = (b'\xff\xfe\x00\x00' b's\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m\x00\x00\x00' b's\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m\x00\x00\x00') spambe = (b'\x00\x00\xfe\xff' b'\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m' b'\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m') def test_only_one_bom(self): _,_,reader,writer = codecs.lookup(self.encoding) # encode some stream s = io.BytesIO() f = writer(s) f.write("spam") f.write("spam") d = s.getvalue() # check whether there is exactly one BOM in it self.assertTrue(d == self.spamle or d == self.spambe) # try to read it back s = io.BytesIO(d) f = reader(s) self.assertEqual(f.read(), "spamspam") def test_badbom(self): s = io.BytesIO(4*b"\xff") f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) s = io.BytesIO(8*b"\xff") f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) def test_partial(self): self.check_partial( "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read "", # third byte of BOM read "", # fourth byte of BOM read => byteorder known "", "", "", "\x00", "\x00", "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff", "\x00\xff", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff\U00010000", ] ) def test_handlers(self): self.assertEqual(('\ufffd', 1), codecs.utf_32_decode(b'\x01', 'replace', True)) self.assertEqual(('', 1), codecs.utf_32_decode(b'\x01', 'ignore', True)) def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode, b"\xff", "strict", True) def test_decoder_state(self): self.check_state_handling_decode(self.encoding, "spamspam", self.spamle) self.check_state_handling_decode(self.encoding, "spamspam", self.spambe) def test_issue8941(self): # Issue #8941: insufficient result allocation when decoding into # surrogate pairs on UCS-2 builds. encoded_le = b'\xff\xfe\x00\x00' + b'\x00\x00\x01\x00' * 1024 self.assertEqual('\U00010000' * 1024, codecs.utf_32_decode(encoded_le)[0]) encoded_be = b'\x00\x00\xfe\xff' + b'\x00\x01\x00\x00' * 1024 self.assertEqual('\U00010000' * 1024, codecs.utf_32_decode(encoded_be)[0]) class UTF32LETest(ReadTest, unittest.TestCase): encoding = "utf-32-le" ill_formed_sequence = b"\x80\xdc\x00\x00" def test_partial(self): self.check_partial( "\x00\xff\u0100\uffff\U00010000", [ "", "", "", "\x00", "\x00", "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff", "\x00\xff", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff\U00010000", ] ) def test_simple(self): self.assertEqual("\U00010203".encode(self.encoding), b"\x03\x02\x01\x00") def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_32_le_decode, b"\xff", "strict", True) def test_issue8941(self): # Issue #8941: insufficient result allocation when decoding into # surrogate pairs on UCS-2 builds. encoded = b'\x00\x00\x01\x00' * 1024 self.assertEqual('\U00010000' * 1024, codecs.utf_32_le_decode(encoded)[0]) class UTF32BETest(ReadTest, unittest.TestCase): encoding = "utf-32-be" ill_formed_sequence = b"\x00\x00\xdc\x80" def test_partial(self): self.check_partial( "\x00\xff\u0100\uffff\U00010000", [ "", "", "", "\x00", "\x00", "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff", "\x00\xff", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff\U00010000", ] ) def test_simple(self): self.assertEqual("\U00010203".encode(self.encoding), b"\x00\x01\x02\x03") def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_32_be_decode, b"\xff", "strict", True) def test_issue8941(self): # Issue #8941: insufficient result allocation when decoding into # surrogate pairs on UCS-2 builds. encoded = b'\x00\x01\x00\x00' * 1024 self.assertEqual('\U00010000' * 1024, codecs.utf_32_be_decode(encoded)[0]) class UTF16Test(ReadTest, unittest.TestCase): encoding = "utf-16" if sys.byteorder == 'little': ill_formed_sequence = b"\x80\xdc" else: ill_formed_sequence = b"\xdc\x80" spamle = b'\xff\xfes\x00p\x00a\x00m\x00s\x00p\x00a\x00m\x00' spambe = b'\xfe\xff\x00s\x00p\x00a\x00m\x00s\x00p\x00a\x00m' def test_only_one_bom(self): _,_,reader,writer = codecs.lookup(self.encoding) # encode some stream s = io.BytesIO() f = writer(s) f.write("spam") f.write("spam") d = s.getvalue() # check whether there is exactly one BOM in it self.assertTrue(d == self.spamle or d == self.spambe) # try to read it back s = io.BytesIO(d) f = reader(s) self.assertEqual(f.read(), "spamspam") def test_badbom(self): s = io.BytesIO(b"\xff\xff") f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) s = io.BytesIO(b"\xff\xff\xff\xff") f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) def test_partial(self): self.check_partial( "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read => byteorder known "", "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff\U00010000", ] ) def test_handlers(self): self.assertEqual(('\ufffd', 1), codecs.utf_16_decode(b'\x01', 'replace', True)) self.assertEqual(('', 1), codecs.utf_16_decode(b'\x01', 'ignore', True)) def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, b"\xff", "strict", True) def test_decoder_state(self): self.check_state_handling_decode(self.encoding, "spamspam", self.spamle) self.check_state_handling_decode(self.encoding, "spamspam", self.spambe) def test_bug691291(self): # Files are always opened in binary mode, even if no binary mode was # specified. This means that no automatic conversion of '\n' is done # on reading and writing. s1 = 'Hello\r\nworld\r\n' s = s1.encode(self.encoding) self.addCleanup(support.unlink, support.TESTFN) with open(support.TESTFN, 'wb') as fp: fp.write(s) with support.check_warnings(('', DeprecationWarning)): reader = codecs.open(support.TESTFN, 'U', encoding=self.encoding) with reader: self.assertEqual(reader.read(), s1) class UTF16LETest(ReadTest, unittest.TestCase): encoding = "utf-16-le" ill_formed_sequence = b"\x80\xdc" def test_partial(self): self.check_partial( "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff\U00010000", ] ) def test_errors(self): tests = [ (b'\xff', '\ufffd'), (b'A\x00Z', 'A\ufffd'), (b'A\x00B\x00C\x00D\x00Z', 'ABCD\ufffd'), (b'\x00\xd8', '\ufffd'), (b'\x00\xd8A', '\ufffd'), (b'\x00\xd8A\x00', '\ufffdA'), (b'\x00\xdcA\x00', '\ufffdA'), ] for raw, expected in tests: self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode, raw, 'strict', True) self.assertEqual(raw.decode('utf-16le', 'replace'), expected) def test_nonbmp(self): self.assertEqual("\U00010203".encode(self.encoding), b'\x00\xd8\x03\xde') self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding), "\U00010203") class UTF16BETest(ReadTest, unittest.TestCase): encoding = "utf-16-be" ill_formed_sequence = b"\xdc\x80" def test_partial(self): self.check_partial( "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff", "\x00\xff\u0100\uffff\U00010000", ] ) def test_errors(self): tests = [ (b'\xff', '\ufffd'), (b'\x00A\xff', 'A\ufffd'), (b'\x00A\x00B\x00C\x00DZ', 'ABCD\ufffd'), (b'\xd8\x00', '\ufffd'), (b'\xd8\x00\xdc', '\ufffd'), (b'\xd8\x00\x00A', '\ufffdA'), (b'\xdc\x00\x00A', '\ufffdA'), ] for raw, expected in tests: self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode, raw, 'strict', True) self.assertEqual(raw.decode('utf-16be', 'replace'), expected) def test_nonbmp(self): self.assertEqual("\U00010203".encode(self.encoding), b'\xd8\x00\xde\x03') self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding), "\U00010203") class UTF8Test(ReadTest, unittest.TestCase): encoding = "utf-8" ill_formed_sequence = b"\xed\xb2\x80" ill_formed_sequence_replace = "\ufffd" * 3 BOM = b'' def test_partial(self): self.check_partial( "\x00\xff\u07ff\u0800\uffff\U00010000", [ "\x00", "\x00", "\x00\xff", "\x00\xff", "\x00\xff\u07ff", "\x00\xff\u07ff", "\x00\xff\u07ff", "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800\uffff", "\x00\xff\u07ff\u0800\uffff", "\x00\xff\u07ff\u0800\uffff", "\x00\xff\u07ff\u0800\uffff", "\x00\xff\u07ff\u0800\uffff\U00010000", ] ) def test_decoder_state(self): u = "\x00\x7f\x80\xff\u0100\u07ff\u0800\uffff\U0010ffff" self.check_state_handling_decode(self.encoding, u, u.encode(self.encoding)) def test_decode_error(self): for data, error_handler, expected in ( (b'[\x80\xff]', 'ignore', '[]'), (b'[\x80\xff]', 'replace', '[\ufffd\ufffd]'), (b'[\x80\xff]', 'surrogateescape', '[\udc80\udcff]'), (b'[\x80\xff]', 'backslashreplace', '[\\x80\\xff]'), ): with self.subTest(data=data, error_handler=error_handler, expected=expected): self.assertEqual(data.decode(self.encoding, error_handler), expected) def test_lone_surrogates(self): super().test_lone_surrogates() # not sure if this is making sense for # UTF-16 and UTF-32 self.assertEqual("[\uDC80]".encode(self.encoding, "surrogateescape"), self.BOM + b'[\x80]') with self.assertRaises(UnicodeEncodeError) as cm: "[\uDC80\uD800\uDFFF]".encode(self.encoding, "surrogateescape") exc = cm.exception self.assertEqual(exc.object[exc.start:exc.end], '\uD800\uDFFF') def test_surrogatepass_handler(self): self.assertEqual("abc\ud800def".encode(self.encoding, "surrogatepass"), self.BOM + b"abc\xed\xa0\x80def") self.assertEqual("\U00010fff\uD800".encode(self.encoding, "surrogatepass"), self.BOM + b"\xf0\x90\xbf\xbf\xed\xa0\x80") self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "surrogatepass"), self.BOM + b'[\xed\xa0\x80\xed\xb2\x80]') self.assertEqual(b"abc\xed\xa0\x80def".decode(self.encoding, "surrogatepass"), "abc\ud800def") self.assertEqual(b"\xf0\x90\xbf\xbf\xed\xa0\x80".decode(self.encoding, "surrogatepass"), "\U00010fff\uD800") self.assertTrue(codecs.lookup_error("surrogatepass")) with self.assertRaises(UnicodeDecodeError): b"abc\xed\xa0".decode(self.encoding, "surrogatepass") with self.assertRaises(UnicodeDecodeError): b"abc\xed\xa0z".decode(self.encoding, "surrogatepass") @unittest.skipUnless(sys.platform == 'win32', 'cp65001 is a Windows-only codec') class CP65001Test(ReadTest, unittest.TestCase): encoding = "cp65001" def test_encode(self): tests = [ ('abc', 'strict', b'abc'), ('\xe9\u20ac', 'strict', b'\xc3\xa9\xe2\x82\xac'), ('\U0010ffff', 'strict', b'\xf4\x8f\xbf\xbf'), ('\udc80', 'strict', None), ('\udc80', 'ignore', b''), ('\udc80', 'replace', b'?'), ('\udc80', 'backslashreplace', b'\\udc80'), ('\udc80', 'namereplace', b'\\udc80'), ('\udc80', 'surrogatepass', b'\xed\xb2\x80'), ] for text, errors, expected in tests: if expected is not None: try: encoded = text.encode('cp65001', errors) except UnicodeEncodeError as err: self.fail('Unable to encode %a to cp65001 with ' 'errors=%r: %s' % (text, errors, err)) self.assertEqual(encoded, expected, '%a.encode("cp65001", %r)=%a != %a' % (text, errors, encoded, expected)) else: self.assertRaises(UnicodeEncodeError, text.encode, "cp65001", errors) def test_decode(self): tests = [ (b'abc', 'strict', 'abc'), (b'\xc3\xa9\xe2\x82\xac', 'strict', '\xe9\u20ac'), (b'\xf4\x8f\xbf\xbf', 'strict', '\U0010ffff'), (b'\xef\xbf\xbd', 'strict', '\ufffd'), (b'[\xc3\xa9]', 'strict', '[\xe9]'), # invalid bytes (b'[\xff]', 'strict', None), (b'[\xff]', 'ignore', '[]'), (b'[\xff]', 'replace', '[\ufffd]'), (b'[\xff]', 'surrogateescape', '[\udcff]'), (b'[\xed\xb2\x80]', 'strict', None), (b'[\xed\xb2\x80]', 'ignore', '[]'), (b'[\xed\xb2\x80]', 'replace', '[\ufffd\ufffd\ufffd]'), ] for raw, errors, expected in tests: if expected is not None: try: decoded = raw.decode('cp65001', errors) except UnicodeDecodeError as err: self.fail('Unable to decode %a from cp65001 with ' 'errors=%r: %s' % (raw, errors, err)) self.assertEqual(decoded, expected, '%a.decode("cp65001", %r)=%a != %a' % (raw, errors, decoded, expected)) else: self.assertRaises(UnicodeDecodeError, raw.decode, 'cp65001', errors) def test_lone_surrogates(self): self.assertRaises(UnicodeEncodeError, "\ud800".encode, "cp65001") self.assertRaises(UnicodeDecodeError, b"\xed\xa0\x80".decode, "cp65001") self.assertEqual("[\uDC80]".encode("cp65001", "backslashreplace"), b'[\\udc80]') self.assertEqual("[\uDC80]".encode("cp65001", "namereplace"), b'[\\udc80]') self.assertEqual("[\uDC80]".encode("cp65001", "xmlcharrefreplace"), b'[&#56448;]') self.assertEqual("[\uDC80]".encode("cp65001", "surrogateescape"), b'[\x80]') self.assertEqual("[\uDC80]".encode("cp65001", "ignore"), b'[]') self.assertEqual("[\uDC80]".encode("cp65001", "replace"), b'[?]') def test_surrogatepass_handler(self): self.assertEqual("abc\ud800def".encode("cp65001", "surrogatepass"), b"abc\xed\xa0\x80def") self.assertEqual(b"abc\xed\xa0\x80def".decode("cp65001", "surrogatepass"), "abc\ud800def") self.assertEqual("\U00010fff\uD800".encode("cp65001", "surrogatepass"), b"\xf0\x90\xbf\xbf\xed\xa0\x80") self.assertEqual(b"\xf0\x90\xbf\xbf\xed\xa0\x80".decode("cp65001", "surrogatepass"), "\U00010fff\uD800") self.assertTrue(codecs.lookup_error("surrogatepass")) class UTF7Test(ReadTest, unittest.TestCase): encoding = "utf-7" def test_ascii(self): # Set D (directly encoded characters) set_d = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' '0123456789' '\'(),-./:?') self.assertEqual(set_d.encode(self.encoding), set_d.encode('ascii')) self.assertEqual(set_d.encode('ascii').decode(self.encoding), set_d) # Set O (optional direct characters) set_o = ' !"#$%&*;<=>@[]^_`{|}' self.assertEqual(set_o.encode(self.encoding), set_o.encode('ascii')) self.assertEqual(set_o.encode('ascii').decode(self.encoding), set_o) # + self.assertEqual('a+b'.encode(self.encoding), b'a+-b') self.assertEqual(b'a+-b'.decode(self.encoding), 'a+b') # White spaces ws = ' \t\n\r' self.assertEqual(ws.encode(self.encoding), ws.encode('ascii')) self.assertEqual(ws.encode('ascii').decode(self.encoding), ws) # Other ASCII characters other_ascii = ''.join(sorted(set(bytes(range(0x80)).decode()) - set(set_d + set_o + '+' + ws))) self.assertEqual(other_ascii.encode(self.encoding), b'+AAAAAQACAAMABAAFAAYABwAIAAsADAAOAA8AEAARABIAEwAU' b'ABUAFgAXABgAGQAaABsAHAAdAB4AHwBcAH4Afw-') def test_partial(self): self.check_partial( 'a+-b\x00c\x80d\u0100e\U00010000f', [ 'a', 'a', 'a+', 'a+-', 'a+-b', 'a+-b', 'a+-b', 'a+-b', 'a+-b', 'a+-b\x00', 'a+-b\x00c', 'a+-b\x00c', 'a+-b\x00c', 'a+-b\x00c', 'a+-b\x00c', 'a+-b\x00c\x80', 'a+-b\x00c\x80d', 'a+-b\x00c\x80d', 'a+-b\x00c\x80d', 'a+-b\x00c\x80d', 'a+-b\x00c\x80d', 'a+-b\x00c\x80d\u0100', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e', 'a+-b\x00c\x80d\u0100e\U00010000', 'a+-b\x00c\x80d\u0100e\U00010000f', ] ) def test_errors(self): tests = [ (b'\xffb', '\ufffdb'), (b'a\xffb', 'a\ufffdb'), (b'a\xff\xffb', 'a\ufffd\ufffdb'), (b'a+IK', 'a\ufffd'), (b'a+IK-b', 'a\ufffdb'), (b'a+IK,b', 'a\ufffdb'), (b'a+IKx', 'a\u20ac\ufffd'), (b'a+IKx-b', 'a\u20ac\ufffdb'), (b'a+IKwgr', 'a\u20ac\ufffd'), (b'a+IKwgr-b', 'a\u20ac\ufffdb'), (b'a+IKwgr,', 'a\u20ac\ufffd'), (b'a+IKwgr,-b', 'a\u20ac\ufffd-b'), (b'a+IKwgrB', 'a\u20ac\u20ac\ufffd'), (b'a+IKwgrB-b', 'a\u20ac\u20ac\ufffdb'), (b'a+/,+IKw-b', 'a\ufffd\u20acb'), (b'a+//,+IKw-b', 'a\ufffd\u20acb'), (b'a+///,+IKw-b', 'a\uffff\ufffd\u20acb'), (b'a+////,+IKw-b', 'a\uffff\ufffd\u20acb'), (b'a+IKw-b\xff', 'a\u20acb\ufffd'), (b'a+IKw\xffb', 'a\u20ac\ufffdb'), ] for raw, expected in tests: with self.subTest(raw=raw): self.assertRaises(UnicodeDecodeError, codecs.utf_7_decode, raw, 'strict', True) self.assertEqual(raw.decode('utf-7', 'replace'), expected) def test_nonbmp(self): self.assertEqual('\U000104A0'.encode(self.encoding), b'+2AHcoA-') self.assertEqual('\ud801\udca0'.encode(self.encoding), b'+2AHcoA-') self.assertEqual(b'+2AHcoA-'.decode(self.encoding), '\U000104A0') self.assertEqual(b'+2AHcoA'.decode(self.encoding), '\U000104A0') self.assertEqual('\u20ac\U000104A0'.encode(self.encoding), b'+IKzYAdyg-') self.assertEqual(b'+IKzYAdyg-'.decode(self.encoding), '\u20ac\U000104A0') self.assertEqual(b'+IKzYAdyg'.decode(self.encoding), '\u20ac\U000104A0') self.assertEqual('\u20ac\u20ac\U000104A0'.encode(self.encoding), b'+IKwgrNgB3KA-') self.assertEqual(b'+IKwgrNgB3KA-'.decode(self.encoding), '\u20ac\u20ac\U000104A0') self.assertEqual(b'+IKwgrNgB3KA'.decode(self.encoding), '\u20ac\u20ac\U000104A0') def test_lone_surrogates(self): tests = [ (b'a+2AE-b', 'a\ud801b'), (b'a+2AE\xffb', 'a\ufffdb'), (b'a+2AE', 'a\ufffd'), (b'a+2AEA-b', 'a\ufffdb'), (b'a+2AH-b', 'a\ufffdb'), (b'a+IKzYAQ-b', 'a\u20ac\ud801b'), (b'a+IKzYAQ\xffb', 'a\u20ac\ufffdb'), (b'a+IKzYAQA-b', 'a\u20ac\ufffdb'), (b'a+IKzYAd-b', 'a\u20ac\ufffdb'), (b'a+IKwgrNgB-b', 'a\u20ac\u20ac\ud801b'), (b'a+IKwgrNgB\xffb', 'a\u20ac\u20ac\ufffdb'), (b'a+IKwgrNgB', 'a\u20ac\u20ac\ufffd'), (b'a+IKwgrNgBA-b', 'a\u20ac\u20ac\ufffdb'), ] for raw, expected in tests: with self.subTest(raw=raw): self.assertEqual(raw.decode('utf-7', 'replace'), expected) class UTF16ExTest(unittest.TestCase): def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_16_ex_decode, b"\xff", "strict", 0, True) def test_bad_args(self): self.assertRaises(TypeError, codecs.utf_16_ex_decode) class ReadBufferTest(unittest.TestCase): def test_array(self): import array self.assertEqual( codecs.readbuffer_encode(array.array("b", b"spam")), (b"spam", 4) ) def test_empty(self): self.assertEqual(codecs.readbuffer_encode(""), (b"", 0)) def test_bad_args(self): self.assertRaises(TypeError, codecs.readbuffer_encode) self.assertRaises(TypeError, codecs.readbuffer_encode, 42) class UTF8SigTest(UTF8Test, unittest.TestCase): encoding = "utf-8-sig" BOM = codecs.BOM_UTF8 def test_partial(self): self.check_partial( "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", [ "", "", "", # First BOM has been read and skipped "", "", "\ufeff", # Second BOM has been read and emitted "\ufeff\x00", # "\x00" read and emitted "\ufeff\x00", # First byte of encoded "\xff" read "\ufeff\x00\xff", # Second byte of encoded "\xff" read "\ufeff\x00\xff", # First byte of encoded "\u07ff" read "\ufeff\x00\xff\u07ff", # Second byte of encoded "\u07ff" read "\ufeff\x00\xff\u07ff", "\ufeff\x00\xff\u07ff", "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800\uffff", "\ufeff\x00\xff\u07ff\u0800\uffff", "\ufeff\x00\xff\u07ff\u0800\uffff", "\ufeff\x00\xff\u07ff\u0800\uffff", "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", ] ) def test_bug1601501(self): # SF bug #1601501: check that the codec works with a buffer self.assertEqual(str(b"\xef\xbb\xbf", "utf-8-sig"), "") def test_bom(self): d = codecs.getincrementaldecoder("utf-8-sig")() s = "spam" self.assertEqual(d.decode(s.encode("utf-8-sig")), s) def test_stream_bom(self): unistring = "ABC\u00A1\u2200XYZ" bytestring = codecs.BOM_UTF8 + b"ABC\xC2\xA1\xE2\x88\x80XYZ" reader = codecs.getreader("utf-8-sig") for sizehint in [None] + list(range(1, 11)) + \ [64, 128, 256, 512, 1024]: istream = reader(io.BytesIO(bytestring)) ostream = io.StringIO() while 1: if sizehint is not None: data = istream.read(sizehint) else: data = istream.read() if not data: break ostream.write(data) got = ostream.getvalue() self.assertEqual(got, unistring) def test_stream_bare(self): unistring = "ABC\u00A1\u2200XYZ" bytestring = b"ABC\xC2\xA1\xE2\x88\x80XYZ" reader = codecs.getreader("utf-8-sig") for sizehint in [None] + list(range(1, 11)) + \ [64, 128, 256, 512, 1024]: istream = reader(io.BytesIO(bytestring)) ostream = io.StringIO() while 1: if sizehint is not None: data = istream.read(sizehint) else: data = istream.read() if not data: break ostream.write(data) got = ostream.getvalue() self.assertEqual(got, unistring) class EscapeDecodeTest(unittest.TestCase): def test_empty(self): self.assertEqual(codecs.escape_decode(b""), (b"", 0)) self.assertEqual(codecs.escape_decode(bytearray()), (b"", 0)) def test_raw(self): decode = codecs.escape_decode for b in range(256): b = bytes([b]) if b != b'\\': self.assertEqual(decode(b + b'0'), (b + b'0', 2)) def test_escape(self): decode = codecs.escape_decode check = coding_checker(self, decode) check(b"[\\\n]", b"[]") check(br'[\"]', b'["]') check(br"[\']", b"[']") check(br"[\\]", b"[\\]") check(br"[\a]", b"[\x07]") check(br"[\b]", b"[\x08]") check(br"[\t]", b"[\x09]") check(br"[\n]", b"[\x0a]") check(br"[\v]", b"[\x0b]") check(br"[\f]", b"[\x0c]") check(br"[\r]", b"[\x0d]") check(br"[\7]", b"[\x07]") check(br"[\78]", b"[\x078]") check(br"[\41]", b"[!]") check(br"[\418]", b"[!8]") check(br"[\101]", b"[A]") check(br"[\1010]", b"[A0]") check(br"[\501]", b"[A]") check(br"[\x41]", b"[A]") check(br"[\x410]", b"[A0]") for i in range(97, 123): b = bytes([i]) if b not in b'abfnrtvxe': # [jart] support \e with self.assertWarns(DeprecationWarning): check(b"\\" + b, b"\\" + b) with self.assertWarns(DeprecationWarning): check(b"\\" + b.upper(), b"\\" + b.upper()) with self.assertWarns(DeprecationWarning): check(br"\8", b"\\8") with self.assertWarns(DeprecationWarning): check(br"\9", b"\\9") with self.assertWarns(DeprecationWarning): check(b"\\\xfa", b"\\\xfa") def test_errors(self): decode = codecs.escape_decode self.assertRaises(ValueError, decode, br"\x") self.assertRaises(ValueError, decode, br"[\x]") self.assertEqual(decode(br"[\x]\x", "ignore"), (b"[]", 6)) self.assertEqual(decode(br"[\x]\x", "replace"), (b"[?]?", 6)) self.assertRaises(ValueError, decode, br"\x0") self.assertRaises(ValueError, decode, br"[\x0]") self.assertEqual(decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) self.assertEqual(decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) class RecodingTest(unittest.TestCase): def test_recoding(self): f = io.BytesIO() f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8") f2.write("a") f2.close() # Python used to crash on this at exit because of a refcount # bug in _codecsmodule.c self.assertTrue(f.closed) # From RFC 3492 punycode_testcases = [ # A Arabic (Egyptian): ("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F", b"egbpdaj6bu4bxfgehfvwxn"), # B Chinese (simplified): ("\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587", b"ihqwcrb4cv8a8dqg056pqjye"), # C Chinese (traditional): ("\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587", b"ihqwctvzc91f659drss3x8bo0yb"), # D Czech: Pro<ccaron>prost<ecaron>nemluv<iacute><ccaron>esky ("\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074" "\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D" "\u0065\u0073\u006B\u0079", b"Proprostnemluvesky-uyb24dma41a"), # E Hebrew: ("\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8" "\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2" "\u05D1\u05E8\u05D9\u05EA", b"4dbcagdahymbxekheh6e0a7fei0b"), # F Hindi (Devanagari): ("\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D" "\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939" "\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947" "\u0939\u0948\u0902", b"i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd"), #(G) Japanese (kanji and hiragana): ("\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092" "\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B", b"n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa"), # (H) Korean (Hangul syllables): ("\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774" "\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74" "\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C", b"989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5j" b"psd879ccm6fea98c"), # (I) Russian (Cyrillic): ("\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E" "\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440" "\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A" "\u0438", b"b1abfaaepdrnnbgefbaDotcwatmq2g4l"), # (J) Spanish: Porqu<eacute>nopuedensimplementehablarenEspa<ntilde>ol ("\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070" "\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070" "\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061" "\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070" "\u0061\u00F1\u006F\u006C", b"PorqunopuedensimplementehablarenEspaol-fmd56a"), # (K) Vietnamese: # T<adotbelow>isaoh<odotbelow>kh<ocirc>ngth<ecirchookabove>ch\ # <ihookabove>n<oacute>iti<ecircacute>ngVi<ecircdotbelow>t ("\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B" "\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068" "\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067" "\u0056\u0069\u1EC7\u0074", b"TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g"), #(L) 3<nen>B<gumi><kinpachi><sensei> ("\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F", b"3B-ww4c5e180e575a65lsy2b"), # (M) <amuro><namie>-with-SUPER-MONKEYS ("\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074" "\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D" "\u004F\u004E\u004B\u0045\u0059\u0053", b"-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n"), # (N) Hello-Another-Way-<sorezore><no><basho> ("\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F" "\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D" "\u305D\u308C\u305E\u308C\u306E\u5834\u6240", b"Hello-Another-Way--fc4qua05auwb3674vfr0b"), # (O) <hitotsu><yane><no><shita>2 ("\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032", b"2-u9tlzr9756bt3uc0v"), # (P) Maji<de>Koi<suru>5<byou><mae> ("\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" "\u308B\u0035\u79D2\u524D", b"MajiKoi5-783gue6qz075azm5e"), # (Q) <pafii>de<runba> ("\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0", b"de-jg4avhby1noc0d"), # (R) <sono><supiido><de> ("\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067", b"d9juau41awczczp"), # (S) -> $1.00 <- ("\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020" "\u003C\u002D", b"-> $1.00 <--") ] for i in punycode_testcases: if len(i)!=2: print(repr(i)) class PunycodeTest(unittest.TestCase): def test_encode(self): for uni, puny in punycode_testcases: # Need to convert both strings to lower case, since # some of the extended encodings use upper case, but our # code produces only lower case. Converting just puny to # lower is also insufficient, since some of the input characters # are upper case. self.assertEqual( str(uni.encode("punycode"), "ascii").lower(), str(puny, "ascii").lower() ) def test_decode(self): for uni, puny in punycode_testcases: self.assertEqual(uni, puny.decode("punycode")) puny = puny.decode("ascii").encode("ascii") self.assertEqual(uni, puny.decode("punycode")) class UnicodeInternalTest(unittest.TestCase): @unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t') def test_bug1251300(self): # Decoding with unicode_internal used to not correctly handle "code # points" above 0x10ffff on UCS-4 builds. ok = [ (b"\x00\x10\xff\xff", "\U0010ffff"), (b"\x00\x00\x01\x01", "\U00000101"), (b"", ""), ] not_ok = [ b"\x7f\xff\xff\xff", b"\x80\x00\x00\x00", b"\x81\x00\x00\x00", b"\x00", b"\x00\x00\x00\x00\x00", ] for internal, uni in ok: if sys.byteorder == "little": internal = bytes(reversed(internal)) with support.check_warnings(): self.assertEqual(uni, internal.decode("unicode_internal")) for internal in not_ok: if sys.byteorder == "little": internal = bytes(reversed(internal)) with support.check_warnings(('unicode_internal codec has been ' 'deprecated', DeprecationWarning)): self.assertRaises(UnicodeDecodeError, internal.decode, "unicode_internal") if sys.byteorder == "little": invalid = b"\x00\x00\x11\x00" invalid_backslashreplace = r"\x00\x00\x11\x00" else: invalid = b"\x00\x11\x00\x00" invalid_backslashreplace = r"\x00\x11\x00\x00" with support.check_warnings(): self.assertRaises(UnicodeDecodeError, invalid.decode, "unicode_internal") with support.check_warnings(): self.assertEqual(invalid.decode("unicode_internal", "replace"), '\ufffd') with support.check_warnings(): self.assertEqual(invalid.decode("unicode_internal", "backslashreplace"), invalid_backslashreplace) @unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t') def test_decode_error_attributes(self): try: with support.check_warnings(('unicode_internal codec has been ' 'deprecated', DeprecationWarning)): b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal") except UnicodeDecodeError as ex: self.assertEqual("unicode_internal", ex.encoding) self.assertEqual(b"\x00\x00\x00\x00\x00\x11\x11\x00", ex.object) self.assertEqual(4, ex.start) self.assertEqual(8, ex.end) else: self.fail() @unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t') def test_decode_callback(self): codecs.register_error("UnicodeInternalTest", codecs.ignore_errors) decoder = codecs.getdecoder("unicode_internal") with support.check_warnings(('unicode_internal codec has been ' 'deprecated', DeprecationWarning)): ab = "ab".encode("unicode_internal").decode() ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]), "ascii"), "UnicodeInternalTest") self.assertEqual(("ab", 12), ignored) def test_encode_length(self): with support.check_warnings(('unicode_internal codec has been ' 'deprecated', DeprecationWarning)): # Issue 3739 encoder = codecs.getencoder("unicode_internal") self.assertEqual(encoder("a")[1], 1) self.assertEqual(encoder("\xe9\u0142")[1], 2) self.assertEqual(codecs.escape_encode(br'\x00')[1], 4) # From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html nameprep_tests = [ # 3.1 Map to nothing. (b'foo\xc2\xad\xcd\x8f\xe1\xa0\x86\xe1\xa0\x8bbar' b'\xe2\x80\x8b\xe2\x81\xa0baz\xef\xb8\x80\xef\xb8\x88\xef' b'\xb8\x8f\xef\xbb\xbf', b'foobarbaz'), # 3.2 Case folding ASCII U+0043 U+0041 U+0046 U+0045. (b'CAFE', b'cafe'), # 3.3 Case folding 8bit U+00DF (german sharp s). # The original test case is bogus; it says \xc3\xdf (b'\xc3\x9f', b'ss'), # 3.4 Case folding U+0130 (turkish capital I with dot). (b'\xc4\xb0', b'i\xcc\x87'), # 3.5 Case folding multibyte U+0143 U+037A. (b'\xc5\x83\xcd\xba', b'\xc5\x84 \xce\xb9'), # 3.6 Case folding U+2121 U+33C6 U+1D7BB. # XXX: skip this as it fails in UCS-2 mode #('\xe2\x84\xa1\xe3\x8f\x86\xf0\x9d\x9e\xbb', # 'telc\xe2\x88\x95kg\xcf\x83'), (None, None), # 3.7 Normalization of U+006a U+030c U+00A0 U+00AA. (b'j\xcc\x8c\xc2\xa0\xc2\xaa', b'\xc7\xb0 a'), # 3.8 Case folding U+1FB7 and normalization. (b'\xe1\xbe\xb7', b'\xe1\xbe\xb6\xce\xb9'), # 3.9 Self-reverting case folding U+01F0 and normalization. # The original test case is bogus, it says `\xc7\xf0' (b'\xc7\xb0', b'\xc7\xb0'), # 3.10 Self-reverting case folding U+0390 and normalization. (b'\xce\x90', b'\xce\x90'), # 3.11 Self-reverting case folding U+03B0 and normalization. (b'\xce\xb0', b'\xce\xb0'), # 3.12 Self-reverting case folding U+1E96 and normalization. (b'\xe1\xba\x96', b'\xe1\xba\x96'), # 3.13 Self-reverting case folding U+1F56 and normalization. (b'\xe1\xbd\x96', b'\xe1\xbd\x96'), # 3.14 ASCII space character U+0020. (b' ', b' '), # 3.15 Non-ASCII 8bit space character U+00A0. (b'\xc2\xa0', b' '), # 3.16 Non-ASCII multibyte space character U+1680. (b'\xe1\x9a\x80', None), # 3.17 Non-ASCII multibyte space character U+2000. (b'\xe2\x80\x80', b' '), # 3.18 Zero Width Space U+200b. (b'\xe2\x80\x8b', b''), # 3.19 Non-ASCII multibyte space character U+3000. (b'\xe3\x80\x80', b' '), # 3.20 ASCII control characters U+0010 U+007F. (b'\x10\x7f', b'\x10\x7f'), # 3.21 Non-ASCII 8bit control character U+0085. (b'\xc2\x85', None), # 3.22 Non-ASCII multibyte control character U+180E. (b'\xe1\xa0\x8e', None), # 3.23 Zero Width No-Break Space U+FEFF. (b'\xef\xbb\xbf', b''), # 3.24 Non-ASCII control character U+1D175. (b'\xf0\x9d\x85\xb5', None), # 3.25 Plane 0 private use character U+F123. (b'\xef\x84\xa3', None), # 3.26 Plane 15 private use character U+F1234. (b'\xf3\xb1\x88\xb4', None), # 3.27 Plane 16 private use character U+10F234. (b'\xf4\x8f\x88\xb4', None), # 3.28 Non-character code point U+8FFFE. (b'\xf2\x8f\xbf\xbe', None), # 3.29 Non-character code point U+10FFFF. (b'\xf4\x8f\xbf\xbf', None), # 3.30 Surrogate code U+DF42. (b'\xed\xbd\x82', None), # 3.31 Non-plain text character U+FFFD. (b'\xef\xbf\xbd', None), # 3.32 Ideographic description character U+2FF5. (b'\xe2\xbf\xb5', None), # 3.33 Display property character U+0341. (b'\xcd\x81', b'\xcc\x81'), # 3.34 Left-to-right mark U+200E. (b'\xe2\x80\x8e', None), # 3.35 Deprecated U+202A. (b'\xe2\x80\xaa', None), # 3.36 Language tagging character U+E0001. (b'\xf3\xa0\x80\x81', None), # 3.37 Language tagging character U+E0042. (b'\xf3\xa0\x81\x82', None), # 3.38 Bidi: RandALCat character U+05BE and LCat characters. (b'foo\xd6\xbebar', None), # 3.39 Bidi: RandALCat character U+FD50 and LCat characters. (b'foo\xef\xb5\x90bar', None), # 3.40 Bidi: RandALCat character U+FB38 and LCat characters. (b'foo\xef\xb9\xb6bar', b'foo \xd9\x8ebar'), # 3.41 Bidi: RandALCat without trailing RandALCat U+0627 U+0031. (b'\xd8\xa71', None), # 3.42 Bidi: RandALCat character U+0627 U+0031 U+0628. (b'\xd8\xa71\xd8\xa8', b'\xd8\xa71\xd8\xa8'), # 3.43 Unassigned code point U+E0002. # Skip this test as we allow unassigned #(b'\xf3\xa0\x80\x82', # None), (None, None), # 3.44 Larger test (shrinking). # Original test case reads \xc3\xdf (b'X\xc2\xad\xc3\x9f\xc4\xb0\xe2\x84\xa1j\xcc\x8c\xc2\xa0\xc2' b'\xaa\xce\xb0\xe2\x80\x80', b'xssi\xcc\x87tel\xc7\xb0 a\xce\xb0 '), # 3.45 Larger test (expanding). # Original test case reads \xc3\x9f (b'X\xc3\x9f\xe3\x8c\x96\xc4\xb0\xe2\x84\xa1\xe2\x92\x9f\xe3\x8c' b'\x80', b'xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3' b'\x83\x88\xe3\x83\xabi\xcc\x87tel\x28d\x29\xe3\x82' b'\xa2\xe3\x83\x91\xe3\x83\xbc\xe3\x83\x88') ] class NameprepTest(unittest.TestCase): def test_nameprep(self): from encodings.idna import nameprep for pos, (orig, prepped) in enumerate(nameprep_tests): if orig is None: # Skipped continue # The Unicode strings are given in UTF-8 orig = str(orig, "utf-8", "surrogatepass") if prepped is None: # Input contains prohibited characters self.assertRaises(UnicodeError, nameprep, orig) else: prepped = str(prepped, "utf-8", "surrogatepass") try: self.assertEqual(nameprep(orig), prepped) except Exception as e: raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e))) class IDNACodecTest(unittest.TestCase): def test_builtin_decode(self): self.assertEqual(str(b"python.org", "idna"), "python.org") self.assertEqual(str(b"python.org.", "idna"), "python.org.") self.assertEqual(str(b"xn--pythn-mua.org", "idna"), "pyth\xf6n.org") self.assertEqual(str(b"xn--pythn-mua.org.", "idna"), "pyth\xf6n.org.") def test_builtin_encode(self): self.assertEqual("python.org".encode("idna"), b"python.org") self.assertEqual("python.org.".encode("idna"), b"python.org.") self.assertEqual("pyth\xf6n.org".encode("idna"), b"xn--pythn-mua.org") self.assertEqual("pyth\xf6n.org.".encode("idna"), b"xn--pythn-mua.org.") def test_stream(self): r = codecs.getreader("idna")(io.BytesIO(b"abc")) r.read(3) self.assertEqual(r.read(), "") def test_incremental_decode(self): self.assertEqual( "".join(codecs.iterdecode((bytes([c]) for c in b"python.org"), "idna")), "python.org" ) self.assertEqual( "".join(codecs.iterdecode((bytes([c]) for c in b"python.org."), "idna")), "python.org." ) self.assertEqual( "".join(codecs.iterdecode((bytes([c]) for c in b"xn--pythn-mua.org."), "idna")), "pyth\xf6n.org." ) self.assertEqual( "".join(codecs.iterdecode((bytes([c]) for c in b"xn--pythn-mua.org."), "idna")), "pyth\xf6n.org." ) decoder = codecs.getincrementaldecoder("idna")() self.assertEqual(decoder.decode(b"xn--xam", ), "") self.assertEqual(decoder.decode(b"ple-9ta.o", ), "\xe4xample.") self.assertEqual(decoder.decode(b"rg"), "") self.assertEqual(decoder.decode(b"", True), "org") decoder.reset() self.assertEqual(decoder.decode(b"xn--xam", ), "") self.assertEqual(decoder.decode(b"ple-9ta.o", ), "\xe4xample.") self.assertEqual(decoder.decode(b"rg."), "org.") self.assertEqual(decoder.decode(b"", True), "") def test_incremental_encode(self): self.assertEqual( b"".join(codecs.iterencode("python.org", "idna")), b"python.org" ) self.assertEqual( b"".join(codecs.iterencode("python.org.", "idna")), b"python.org." ) self.assertEqual( b"".join(codecs.iterencode("pyth\xf6n.org.", "idna")), b"xn--pythn-mua.org." ) self.assertEqual( b"".join(codecs.iterencode("pyth\xf6n.org.", "idna")), b"xn--pythn-mua.org." ) encoder = codecs.getincrementalencoder("idna")() self.assertEqual(encoder.encode("\xe4x"), b"") self.assertEqual(encoder.encode("ample.org"), b"xn--xample-9ta.") self.assertEqual(encoder.encode("", True), b"org") encoder.reset() self.assertEqual(encoder.encode("\xe4x"), b"") self.assertEqual(encoder.encode("ample.org."), b"xn--xample-9ta.org.") self.assertEqual(encoder.encode("", True), b"") def test_errors(self): """Only supports "strict" error handler""" "python.org".encode("idna", "strict") b"python.org".decode("idna", "strict") for errors in ("ignore", "replace", "backslashreplace", "surrogateescape"): self.assertRaises(Exception, "python.org".encode, "idna", errors) self.assertRaises(Exception, b"python.org".decode, "idna", errors) class CodecsModuleTest(unittest.TestCase): def test_decode(self): self.assertEqual(codecs.decode(b'\xe4\xf6\xfc', 'latin-1'), '\xe4\xf6\xfc') self.assertRaises(TypeError, codecs.decode) self.assertEqual(codecs.decode(b'abc'), 'abc') self.assertRaises(UnicodeDecodeError, codecs.decode, b'\xff', 'ascii') # test keywords self.assertEqual(codecs.decode(obj=b'\xe4\xf6\xfc', encoding='latin-1'), '\xe4\xf6\xfc') self.assertEqual(codecs.decode(b'[\xff]', 'ascii', errors='ignore'), '[]') def test_encode(self): self.assertEqual(codecs.encode('\xe4\xf6\xfc', 'latin-1'), b'\xe4\xf6\xfc') self.assertRaises(TypeError, codecs.encode) self.assertRaises(LookupError, codecs.encode, "foo", "__spam__") self.assertEqual(codecs.encode('abc'), b'abc') self.assertRaises(UnicodeEncodeError, codecs.encode, '\xffff', 'ascii') # test keywords self.assertEqual(codecs.encode(obj='\xe4\xf6\xfc', encoding='latin-1'), b'\xe4\xf6\xfc') self.assertEqual(codecs.encode('[\xff]', 'ascii', errors='ignore'), b'[]') def test_register(self): self.assertRaises(TypeError, codecs.register) self.assertRaises(TypeError, codecs.register, 42) def test_lookup(self): self.assertRaises(TypeError, codecs.lookup) self.assertRaises(LookupError, codecs.lookup, "__spam__") self.assertRaises(LookupError, codecs.lookup, " ") def test_getencoder(self): self.assertRaises(TypeError, codecs.getencoder) self.assertRaises(LookupError, codecs.getencoder, "__spam__") def test_getdecoder(self): self.assertRaises(TypeError, codecs.getdecoder) self.assertRaises(LookupError, codecs.getdecoder, "__spam__") def test_getreader(self): self.assertRaises(TypeError, codecs.getreader) self.assertRaises(LookupError, codecs.getreader, "__spam__") def test_getwriter(self): self.assertRaises(TypeError, codecs.getwriter) self.assertRaises(LookupError, codecs.getwriter, "__spam__") def test_lookup_issue1813(self): # Issue #1813: under Turkish locales, lookup of some codecs failed # because 'I' is lowercased as "ı" (dotless i) oldlocale = locale.setlocale(locale.LC_CTYPE) self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale) try: locale.setlocale(locale.LC_CTYPE, 'tr_TR') except locale.Error: # Unsupported locale on this system self.skipTest('test needs Turkish locale') c = codecs.lookup('ASCII') self.assertEqual(c.name, 'ascii') def test_all(self): api = ( "encode", "decode", "register", "CodecInfo", "Codec", "IncrementalEncoder", "IncrementalDecoder", "StreamReader", "StreamWriter", "lookup", "getencoder", "getdecoder", "getincrementalencoder", "getincrementaldecoder", "getreader", "getwriter", "register_error", "lookup_error", "strict_errors", "replace_errors", "ignore_errors", "xmlcharrefreplace_errors", "backslashreplace_errors", "namereplace_errors", "open", "EncodedFile", "iterencode", "iterdecode", "BOM", "BOM_BE", "BOM_LE", "BOM_UTF8", "BOM_UTF16", "BOM_UTF16_BE", "BOM_UTF16_LE", "BOM_UTF32", "BOM_UTF32_BE", "BOM_UTF32_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE", # Undocumented "StreamReaderWriter", "StreamRecoder", ) self.assertCountEqual(api, codecs.__all__) for api in codecs.__all__: getattr(codecs, api) def test_open(self): self.addCleanup(support.unlink, support.TESTFN) for mode in ('w', 'r', 'r+', 'w+', 'a', 'a+'): with self.subTest(mode), \ codecs.open(support.TESTFN, mode, 'ascii') as file: self.assertIsInstance(file, codecs.StreamReaderWriter) def test_undefined(self): self.assertRaises(UnicodeError, codecs.encode, 'abc', 'undefined') self.assertRaises(UnicodeError, codecs.decode, b'abc', 'undefined') self.assertRaises(UnicodeError, codecs.encode, '', 'undefined') self.assertRaises(UnicodeError, codecs.decode, b'', 'undefined') for errors in ('strict', 'ignore', 'replace', 'backslashreplace'): self.assertRaises(UnicodeError, codecs.encode, 'abc', 'undefined', errors) self.assertRaises(UnicodeError, codecs.decode, b'abc', 'undefined', errors) class StreamReaderTest(unittest.TestCase): def setUp(self): self.reader = codecs.getreader('utf-8') self.stream = io.BytesIO(b'\xed\x95\x9c\n\xea\xb8\x80') def test_readlines(self): f = self.reader(self.stream) self.assertEqual(f.readlines(), ['\ud55c\n', '\uae00']) class EncodedFileTest(unittest.TestCase): def test_basic(self): f = io.BytesIO(b'\xed\x95\x9c\n\xea\xb8\x80') ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8') self.assertEqual(ef.read(), b'\\\xd5\n\x00\x00\xae') f = io.BytesIO() ef = codecs.EncodedFile(f, 'utf-8', 'latin-1') ef.write(b'\xc3\xbc') self.assertEqual(f.getvalue(), b'\xfc') all_unicode_encodings = [ "ascii", "big5", "big5hkscs", "charmap", "cp037", "cp1006", "cp1026", "cp1125", "cp1140", "cp1250", "cp1251", "cp1252", "cp1253", "cp1254", "cp1255", "cp1256", "cp1257", "cp1258", "cp424", "cp437", "cp500", "cp720", "cp737", "cp775", "cp850", "cp852", "cp855", "cp856", "cp857", "cp858", "cp860", "cp861", "cp862", "cp863", "cp864", "cp865", "cp866", "cp869", "cp874", "cp875", "cp932", "cp949", "cp950", "euc_jis_2004", "euc_jisx0213", "euc_jp", "euc_kr", "gb18030", "gb2312", "gbk", "hp_roman8", "hz", "idna", "iso2022_jp", "iso2022_jp_1", "iso2022_jp_2", "iso2022_jp_2004", "iso2022_jp_3", "iso2022_jp_ext", "iso2022_kr", "iso8859_1", "iso8859_10", "iso8859_11", "iso8859_13", "iso8859_14", "iso8859_15", "iso8859_16", "iso8859_2", "iso8859_3", "iso8859_4", "iso8859_5", "iso8859_6", "iso8859_7", "iso8859_8", "iso8859_9", "johab", "koi8_r", "koi8_t", "koi8_u", "kz1048", "latin_1", "mac_cyrillic", "mac_greek", "mac_iceland", "mac_latin2", "mac_roman", "mac_turkish", "palmos", "ptcp154", "punycode", "raw_unicode_escape", "shift_jis", "shift_jis_2004", "shift_jisx0213", "tis_620", "unicode_escape", "unicode_internal", "utf_16", "utf_16_be", "utf_16_le", "utf_7", "utf_8", ] if hasattr(codecs, "mbcs_encode"): all_unicode_encodings.append("mbcs") if hasattr(codecs, "oem_encode"): all_unicode_encodings.append("oem") # The following encoding is not tested, because it's not supposed # to work: # "undefined" # The following encodings don't work in stateful mode broken_unicode_with_stateful = [ "punycode", "unicode_internal" ] class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling): def test_basics(self): s = "abc123" # all codecs should be able to encode these for encoding in all_unicode_encodings: name = codecs.lookup(encoding).name if encoding.endswith("_codec"): name += "_codec" elif encoding == "latin_1": name = "latin_1" self.assertEqual(encoding.replace("_", "-"), name.replace("_", "-")) with support.check_warnings(): # unicode-internal has been deprecated (b, size) = codecs.getencoder(encoding)(s) self.assertEqual(size, len(s), "encoding=%r" % encoding) (chars, size) = codecs.getdecoder(encoding)(b) self.assertEqual(chars, s, "encoding=%r" % encoding) if encoding not in broken_unicode_with_stateful: # check stream reader/writer q = Queue(b"") writer = codecs.getwriter(encoding)(q) encodedresult = b"" for c in s: writer.write(c) chunk = q.read() self.assertTrue(type(chunk) is bytes, type(chunk)) encodedresult += chunk q = Queue(b"") reader = codecs.getreader(encoding)(q) decodedresult = "" for c in encodedresult: q.write(bytes([c])) decodedresult += reader.read() self.assertEqual(decodedresult, s, "encoding=%r" % encoding) if encoding not in broken_unicode_with_stateful: # check incremental decoder/encoder and iterencode()/iterdecode() try: encoder = codecs.getincrementalencoder(encoding)() except LookupError: # no IncrementalEncoder pass else: # check incremental decoder/encoder encodedresult = b"" for c in s: encodedresult += encoder.encode(c) encodedresult += encoder.encode("", True) decoder = codecs.getincrementaldecoder(encoding)() decodedresult = "" for c in encodedresult: decodedresult += decoder.decode(bytes([c])) decodedresult += decoder.decode(b"", True) self.assertEqual(decodedresult, s, "encoding=%r" % encoding) # check iterencode()/iterdecode() result = "".join(codecs.iterdecode( codecs.iterencode(s, encoding), encoding)) self.assertEqual(result, s, "encoding=%r" % encoding) # check iterencode()/iterdecode() with empty string result = "".join(codecs.iterdecode( codecs.iterencode("", encoding), encoding)) self.assertEqual(result, "") if encoding not in ("idna", "mbcs"): # check incremental decoder/encoder with errors argument try: encoder = codecs.getincrementalencoder(encoding)("ignore") except LookupError: # no IncrementalEncoder pass else: encodedresult = b"".join(encoder.encode(c) for c in s) decoder = codecs.getincrementaldecoder(encoding)("ignore") decodedresult = "".join(decoder.decode(bytes([c])) for c in encodedresult) self.assertEqual(decodedresult, s, "encoding=%r" % encoding) @support.cpython_only def test_basics_capi(self): from _testcapi import codec_incrementalencoder, codec_incrementaldecoder s = "abc123" # all codecs should be able to encode these for encoding in all_unicode_encodings: if encoding not in broken_unicode_with_stateful: # check incremental decoder/encoder (fetched via the C API) try: cencoder = codec_incrementalencoder(encoding) except LookupError: # no IncrementalEncoder pass else: # check C API encodedresult = b"" for c in s: encodedresult += cencoder.encode(c) encodedresult += cencoder.encode("", True) cdecoder = codec_incrementaldecoder(encoding) decodedresult = "" for c in encodedresult: decodedresult += cdecoder.decode(bytes([c])) decodedresult += cdecoder.decode(b"", True) self.assertEqual(decodedresult, s, "encoding=%r" % encoding) if encoding not in ("idna", "mbcs"): # check incremental decoder/encoder with errors argument try: cencoder = codec_incrementalencoder(encoding, "ignore") except LookupError: # no IncrementalEncoder pass else: encodedresult = b"".join(cencoder.encode(c) for c in s) cdecoder = codec_incrementaldecoder(encoding, "ignore") decodedresult = "".join(cdecoder.decode(bytes([c])) for c in encodedresult) self.assertEqual(decodedresult, s, "encoding=%r" % encoding) def test_seek(self): # all codecs should be able to encode these s = "%s\n%s\n" % (100*"abc123", 100*"def456") for encoding in all_unicode_encodings: if encoding == "idna": # FIXME: See SF bug #1163178 continue if encoding in broken_unicode_with_stateful: continue reader = codecs.getreader(encoding)(io.BytesIO(s.encode(encoding))) for t in range(5): # Test that calling seek resets the internal codec state and buffers reader.seek(0, 0) data = reader.read() self.assertEqual(s, data) def test_bad_decode_args(self): for encoding in all_unicode_encodings: decoder = codecs.getdecoder(encoding) self.assertRaises(TypeError, decoder) if encoding not in ("idna", "punycode"): self.assertRaises(TypeError, decoder, 42) def test_bad_encode_args(self): for encoding in all_unicode_encodings: encoder = codecs.getencoder(encoding) with support.check_warnings(): # unicode-internal has been deprecated self.assertRaises(TypeError, encoder) def test_encoding_map_type_initialized(self): from encodings import cp1140 # This used to crash, we are only verifying there's no crash. table_type = type(cp1140.encoding_table) self.assertEqual(table_type, table_type) def test_decoder_state(self): # Check that getstate() and setstate() handle the state properly u = "abc123" for encoding in all_unicode_encodings: if encoding not in broken_unicode_with_stateful: self.check_state_handling_decode(encoding, u, u.encode(encoding)) self.check_state_handling_encode(encoding, u, u.encode(encoding)) class CharmapTest(unittest.TestCase): def test_decode_with_string_map(self): self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", "abc"), ("abc", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", "\U0010FFFFbc"), ("\U0010FFFFbc", 3) ) self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab" ) self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab\ufffe" ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"), ("ab\ufffd", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab\ufffe"), ("ab\ufffd", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", "ab"), ("ab\\x02", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", "ab\ufffe"), ("ab\\x02", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", "ab"), ("ab", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", "ab\ufffe"), ("ab", 3) ) allbytes = bytes(range(256)) self.assertEqual( codecs.charmap_decode(allbytes, "ignore", ""), ("", len(allbytes)) ) def test_decode_with_int2str_map(self): self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: 'a', 1: 'b', 2: 'c'}), ("abc", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: 'Aa', 1: 'Bb', 2: 'Cc'}), ("AaBbCc", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: '\U0010FFFF', 1: 'b', 2: 'c'}), ("\U0010FFFFbc", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: 'a', 1: 'b', 2: ''}), ("ab", 3) ) self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", {0: 'a', 1: 'b'} ) self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", {0: 'a', 1: 'b', 2: None} ) # Issue #14850 self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", {0: 'a', 1: 'b', 2: '\ufffe'} ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: 'a', 1: 'b'}), ("ab\ufffd", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: 'a', 1: 'b', 2: None}), ("ab\ufffd", 3) ) # Issue #14850 self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: 'a', 1: 'b', 2: '\ufffe'}), ("ab\ufffd", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", {0: 'a', 1: 'b'}), ("ab\\x02", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", {0: 'a', 1: 'b', 2: None}), ("ab\\x02", 3) ) # Issue #14850 self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", {0: 'a', 1: 'b', 2: '\ufffe'}), ("ab\\x02", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: 'a', 1: 'b'}), ("ab", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: 'a', 1: 'b', 2: None}), ("ab", 3) ) # Issue #14850 self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: 'a', 1: 'b', 2: '\ufffe'}), ("ab", 3) ) allbytes = bytes(range(256)) self.assertEqual( codecs.charmap_decode(allbytes, "ignore", {}), ("", len(allbytes)) ) def test_decode_with_int2int_map(self): a = ord('a') b = ord('b') c = ord('c') self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: a, 1: b, 2: c}), ("abc", 3) ) # Issue #15379 self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: 0x10FFFF, 1: b, 2: c}), ("\U0010FFFFbc", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "strict", {0: sys.maxunicode, 1: b, 2: c}), (chr(sys.maxunicode) + "bc", 3) ) self.assertRaises(TypeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", {0: sys.maxunicode + 1, 1: b, 2: c} ) self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", {0: a, 1: b}, ) self.assertRaises(UnicodeDecodeError, codecs.charmap_decode, b"\x00\x01\x02", "strict", {0: a, 1: b, 2: 0xFFFE}, ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: a, 1: b}), ("ab\ufffd", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: a, 1: b, 2: 0xFFFE}), ("ab\ufffd", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", {0: a, 1: b}), ("ab\\x02", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "backslashreplace", {0: a, 1: b, 2: 0xFFFE}), ("ab\\x02", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: a, 1: b}), ("ab", 3) ) self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: a, 1: b, 2: 0xFFFE}), ("ab", 3) ) class WithStmtTest(unittest.TestCase): def test_encodedfile(self): f = io.BytesIO(b"\xc3\xbc") with codecs.EncodedFile(f, "latin-1", "utf-8") as ef: self.assertEqual(ef.read(), b"\xfc") self.assertTrue(f.closed) def test_streamreaderwriter(self): f = io.BytesIO(b"\xc3\xbc") info = codecs.lookup("utf-8") with codecs.StreamReaderWriter(f, info.streamreader, info.streamwriter, 'strict') as srw: self.assertEqual(srw.read(), "\xfc") class TypesTest(unittest.TestCase): def test_decode_unicode(self): # Most decoders don't accept unicode input decoders = [ codecs.utf_7_decode, codecs.utf_8_decode, codecs.utf_16_le_decode, codecs.utf_16_be_decode, codecs.utf_16_ex_decode, codecs.utf_32_decode, codecs.utf_32_le_decode, codecs.utf_32_be_decode, codecs.utf_32_ex_decode, codecs.latin_1_decode, codecs.ascii_decode, codecs.charmap_decode, ] if hasattr(codecs, "mbcs_decode"): decoders.append(codecs.mbcs_decode) for decoder in decoders: self.assertRaises(TypeError, decoder, "xxx") def test_unicode_escape(self): # Escape-decoding a unicode string is supported and gives the same # result as decoding the equivalent ASCII bytes string. self.assertEqual(codecs.unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.unicode_escape_decode(br"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(br"\u1234"), ("\u1234", 6)) self.assertRaises(UnicodeDecodeError, codecs.unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) self.assertEqual(codecs.unicode_escape_decode(r"\U00110000", "backslashreplace"), (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30", 10)) self.assertRaises(UnicodeDecodeError, codecs.raw_unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "backslashreplace"), (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30", 10)) class UnicodeEscapeTest(unittest.TestCase): def test_empty(self): self.assertEqual(codecs.unicode_escape_encode(""), (b"", 0)) self.assertEqual(codecs.unicode_escape_decode(b""), ("", 0)) def test_raw_encode(self): encode = codecs.unicode_escape_encode for b in range(32, 127): if b != b'\\'[0]: self.assertEqual(encode(chr(b)), (bytes([b]), 1)) def test_raw_decode(self): decode = codecs.unicode_escape_decode for b in range(256): if b != b'\\'[0]: self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) def test_escape_encode(self): encode = codecs.unicode_escape_encode check = coding_checker(self, encode) check('\t', br'\t') check('\n', br'\n') check('\r', br'\r') check('\\', br'\\') for b in range(32): if chr(b) not in '\t\n\r': check(chr(b), ('\\x%02x' % b).encode()) for b in range(127, 256): check(chr(b), ('\\x%02x' % b).encode()) check('\u20ac', br'\u20ac') check('\U0001d120', br'\U0001d120') def test_escape_decode(self): decode = codecs.unicode_escape_decode check = coding_checker(self, decode) check(b"[\\\n]", "[]") check(br'[\"]', '["]') check(br"[\']", "[']") check(br"[\\]", r"[\]") check(br"[\a]", "[\x07]") check(br"[\b]", "[\x08]") check(br"[\t]", "[\x09]") check(br"[\n]", "[\x0a]") check(br"[\v]", "[\x0b]") check(br"[\f]", "[\x0c]") check(br"[\r]", "[\x0d]") check(br"[\7]", "[\x07]") check(br"[\78]", "[\x078]") check(br"[\41]", "[!]") check(br"[\418]", "[!8]") check(br"[\101]", "[A]") check(br"[\1010]", "[A0]") check(br"[\x41]", "[A]") check(br"[\x410]", "[A0]") check(br"\u20ac", "\u20ac") check(br"\U0001d120", "\U0001d120") for i in range(97, 123): b = bytes([i]) if b not in b'abfnrtuvxe': # [jart] support \e with self.assertWarns(DeprecationWarning): check(b"\\" + b, "\\" + chr(i)) if b.upper() not in b'UN': with self.assertWarns(DeprecationWarning): check(b"\\" + b.upper(), "\\" + chr(i-32)) with self.assertWarns(DeprecationWarning): check(br"\8", "\\8") with self.assertWarns(DeprecationWarning): check(br"\9", "\\9") with self.assertWarns(DeprecationWarning): check(b"\\\xfa", "\\\xfa") def test_decode_errors(self): decode = codecs.unicode_escape_decode for c, d in (b'x', 2), (b'u', 4), (b'U', 4): for i in range(d): self.assertRaises(UnicodeDecodeError, decode, b"\\" + c + b"0"*i) self.assertRaises(UnicodeDecodeError, decode, b"[\\" + c + b"0"*i + b"]") data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i self.assertEqual(decode(data, "ignore"), ("[]", len(data))) self.assertEqual(decode(data, "replace"), ("[\ufffd]\ufffd", len(data))) self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) class RawUnicodeEscapeTest(unittest.TestCase): def test_empty(self): self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0)) self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0)) def test_raw_encode(self): encode = codecs.raw_unicode_escape_encode for b in range(256): self.assertEqual(encode(chr(b)), (bytes([b]), 1)) def test_raw_decode(self): decode = codecs.raw_unicode_escape_decode for b in range(256): self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) def test_escape_encode(self): encode = codecs.raw_unicode_escape_encode check = coding_checker(self, encode) for b in range(256): if b not in b'uU': check('\\' + chr(b), b'\\' + bytes([b])) check('\u20ac', br'\u20ac') check('\U0001d120', br'\U0001d120') def test_escape_decode(self): decode = codecs.raw_unicode_escape_decode check = coding_checker(self, decode) for b in range(256): if b not in b'uU': check(b'\\' + bytes([b]), '\\' + chr(b)) check(br"\u20ac", "\u20ac") check(br"\U0001d120", "\U0001d120") def test_decode_errors(self): decode = codecs.raw_unicode_escape_decode for c, d in (b'u', 4), (b'U', 4): for i in range(d): self.assertRaises(UnicodeDecodeError, decode, b"\\" + c + b"0"*i) self.assertRaises(UnicodeDecodeError, decode, b"[\\" + c + b"0"*i + b"]") data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i self.assertEqual(decode(data, "ignore"), ("[]", len(data))) self.assertEqual(decode(data, "replace"), ("[\ufffd]\ufffd", len(data))) self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) class EscapeEncodeTest(unittest.TestCase): def test_escape_encode(self): tests = [ (b'', (b'', 0)), (b'foobar', (b'foobar', 6)), (b'spam\0eggs', (b'spam\\x00eggs', 9)), (b'a\'b', (b"a\\'b", 3)), (b'b\\c', (b'b\\\\c', 3)), (b'c\nd', (b'c\\nd', 3)), (b'd\re', (b'd\\re', 3)), (b'f\x7fg', (b'f\\x7fg', 3)), ] for data, output in tests: with self.subTest(data=data): self.assertEqual(codecs.escape_encode(data), output) self.assertRaises(TypeError, codecs.escape_encode, 'spam') self.assertRaises(TypeError, codecs.escape_encode, bytearray(b'spam')) class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): # Bad byte self.assertEqual(b"foo\x80bar".decode("utf-8", "surrogateescape"), "foo\udc80bar") self.assertEqual("foo\udc80bar".encode("utf-8", "surrogateescape"), b"foo\x80bar") # bad-utf-8 encoded surrogate self.assertEqual(b"\xed\xb0\x80".decode("utf-8", "surrogateescape"), "\udced\udcb0\udc80") self.assertEqual("\udced\udcb0\udc80".encode("utf-8", "surrogateescape"), b"\xed\xb0\x80") def test_ascii(self): # bad byte self.assertEqual(b"foo\x80bar".decode("ascii", "surrogateescape"), "foo\udc80bar") self.assertEqual("foo\udc80bar".encode("ascii", "surrogateescape"), b"foo\x80bar") def test_charmap(self): # bad byte: \xa5 is unmapped in iso-8859-3 self.assertEqual(b"foo\xa5bar".decode("iso-8859-3", "surrogateescape"), "foo\udca5bar") self.assertEqual("foo\udca5bar".encode("iso-8859-3", "surrogateescape"), b"foo\xa5bar") def test_latin1(self): # Issue6373 self.assertEqual("\udce4\udceb\udcef\udcf6\udcfc".encode("latin-1", "surrogateescape"), b"\xe4\xeb\xef\xf6\xfc") class BomTest(unittest.TestCase): def test_seek0(self): data = "1234567890" tests = ("utf-16", "utf-16-le", "utf-16-be", "utf-32", "utf-32-le", "utf-32-be") self.addCleanup(support.unlink, support.TESTFN) for encoding in tests: # Check if the BOM is written only once with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f: f.write(data) f.write(data) f.seek(0) self.assertEqual(f.read(), data * 2) f.seek(0) self.assertEqual(f.read(), data * 2) # Check that the BOM is written after a seek(0) with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f: f.write(data[0]) self.assertNotEqual(f.tell(), 0) f.seek(0) f.write(data) f.seek(0) self.assertEqual(f.read(), data) # (StreamWriter) Check that the BOM is written after a seek(0) with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f: f.writer.write(data[0]) self.assertNotEqual(f.writer.tell(), 0) f.writer.seek(0) f.writer.write(data) f.seek(0) self.assertEqual(f.read(), data) # Check that the BOM is not written after a seek() at a position # different than the start with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f: f.write(data) f.seek(f.tell()) f.write(data) f.seek(0) self.assertEqual(f.read(), data * 2) # (StreamWriter) Check that the BOM is not written after a seek() # at a position different than the start with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f: f.writer.write(data) f.writer.seek(f.writer.tell()) f.writer.write(data) f.seek(0) self.assertEqual(f.read(), data * 2) bytes_transform_encodings = [ "base64_codec", "uu_codec", "quopri_codec", "hex_codec", ] transform_aliases = { "base64_codec": ["base64", "base_64"], "uu_codec": ["uu"], "quopri_codec": ["quopri", "quoted_printable", "quotedprintable"], "hex_codec": ["hex"], "rot_13": ["rot13"], } try: import zlib except ImportError: zlib = None else: bytes_transform_encodings.append("zlib_codec") transform_aliases["zlib_codec"] = ["zip", "zlib"] try: import bz2 except ImportError: pass else: bytes_transform_encodings.append("bz2_codec") transform_aliases["bz2_codec"] = ["bz2"] class TransformCodecTest(unittest.TestCase): def test_basics(self): binput = bytes(range(256)) for encoding in bytes_transform_encodings: with self.subTest(encoding=encoding): # generic codecs interface (o, size) = codecs.getencoder(encoding)(binput) self.assertEqual(size, len(binput)) (i, size) = codecs.getdecoder(encoding)(o) self.assertEqual(size, len(o)) self.assertEqual(i, binput) def test_read(self): for encoding in bytes_transform_encodings: with self.subTest(encoding=encoding): sin = codecs.encode(b"\x80", encoding) reader = codecs.getreader(encoding)(io.BytesIO(sin)) sout = reader.read() self.assertEqual(sout, b"\x80") def test_readline(self): for encoding in bytes_transform_encodings: with self.subTest(encoding=encoding): sin = codecs.encode(b"\x80", encoding) reader = codecs.getreader(encoding)(io.BytesIO(sin)) sout = reader.readline() self.assertEqual(sout, b"\x80") def test_buffer_api_usage(self): # We check all the transform codecs accept memoryview input # for encoding and decoding # and also that they roundtrip correctly original = b"12345\x80" for encoding in bytes_transform_encodings: with self.subTest(encoding=encoding): data = original view = memoryview(data) data = codecs.encode(data, encoding) view_encoded = codecs.encode(view, encoding) self.assertEqual(view_encoded, data) view = memoryview(data) data = codecs.decode(data, encoding) self.assertEqual(data, original) view_decoded = codecs.decode(view, encoding) self.assertEqual(view_decoded, data) def test_text_to_binary_blacklists_binary_transforms(self): # Check binary -> binary codecs give a good error for str input bad_input = "bad input type" for encoding in bytes_transform_encodings: with self.subTest(encoding=encoding): fmt = (r"{!r} is not a text encoding; " r"use codecs.encode\(\) to handle arbitrary codecs") msg = fmt.format(encoding) with self.assertRaisesRegex(LookupError, msg) as failure: bad_input.encode(encoding) self.assertIsNone(failure.exception.__cause__) def test_text_to_binary_blacklists_text_transforms(self): # Check str.encode gives a good error message for str -> str codecs msg = (r"^'rot_13' is not a text encoding; " r"use codecs.encode\(\) to handle arbitrary codecs") with self.assertRaisesRegex(LookupError, msg): "just an example message".encode("rot_13") def test_binary_to_text_blacklists_binary_transforms(self): # Check bytes.decode and bytearray.decode give a good error # message for binary -> binary codecs data = b"encode first to ensure we meet any format restrictions" for encoding in bytes_transform_encodings: with self.subTest(encoding=encoding): encoded_data = codecs.encode(data, encoding) fmt = (r"{!r} is not a text encoding; " r"use codecs.decode\(\) to handle arbitrary codecs") msg = fmt.format(encoding) with self.assertRaisesRegex(LookupError, msg): encoded_data.decode(encoding) with self.assertRaisesRegex(LookupError, msg): bytearray(encoded_data).decode(encoding) def test_binary_to_text_blacklists_text_transforms(self): # Check str -> str codec gives a good error for binary input for bad_input in (b"immutable", bytearray(b"mutable")): with self.subTest(bad_input=bad_input): msg = (r"^'rot_13' is not a text encoding; " r"use codecs.decode\(\) to handle arbitrary codecs") with self.assertRaisesRegex(LookupError, msg) as failure: bad_input.decode("rot_13") self.assertIsNone(failure.exception.__cause__) @unittest.skipUnless(zlib, "Requires zlib support") def test_custom_zlib_error_is_wrapped(self): # Check zlib codec gives a good error for malformed input msg = "^decoding with 'zlib_codec' codec failed" with self.assertRaisesRegex(Exception, msg) as failure: codecs.decode(b"hello", "zlib_codec") self.assertIsInstance(failure.exception.__cause__, type(failure.exception)) def test_custom_hex_error_is_wrapped(self): # Check hex codec gives a good error for malformed input msg = "^decoding with 'hex_codec' codec failed" with self.assertRaisesRegex(Exception, msg) as failure: codecs.decode(b"hello", "hex_codec") self.assertIsInstance(failure.exception.__cause__, type(failure.exception)) # Unfortunately, the bz2 module throws OSError, which the codec # machinery currently can't wrap :( # Ensure codec aliases from http://bugs.python.org/issue7475 work def test_aliases(self): for codec_name, aliases in transform_aliases.items(): expected_name = codecs.lookup(codec_name).name for alias in aliases: with self.subTest(alias=alias): info = codecs.lookup(alias) self.assertEqual(info.name, expected_name) def test_quopri_stateless(self): # Should encode with quotetabs=True encoded = codecs.encode(b"space tab\teol \n", "quopri-codec") self.assertEqual(encoded, b"space=20tab=09eol=20\n") # But should still support unescaped tabs and spaces unescaped = b"space tab eol\n" self.assertEqual(codecs.decode(unescaped, "quopri-codec"), unescaped) def test_uu_invalid(self): # Missing "begin" line self.assertRaises(ValueError, codecs.decode, b"", "uu-codec") # The codec system tries to wrap exceptions in order to ensure the error # mentions the operation being performed and the codec involved. We # currently *only* want this to happen for relatively stateless # exceptions, where the only significant information they contain is their # type and a single str argument. # Use a local codec registry to avoid appearing to leak objects when # registering multiple search functions _TEST_CODECS = {} def _get_test_codec(codec_name): return _TEST_CODECS.get(codec_name) codecs.register(_get_test_codec) # Returns None, not usable as a decorator try: # Issue #22166: Also need to clear the internal cache in CPython from _codecs import _forget_codec except ImportError: def _forget_codec(codec_name): pass class ExceptionChainingTest(unittest.TestCase): def setUp(self): # There's no way to unregister a codec search function, so we just # ensure we render this one fairly harmless after the test # case finishes by using the test case repr as the codec name # The codecs module normalizes codec names, although this doesn't # appear to be formally documented... # We also make sure we use a truly unique id for the custom codec # to avoid issues with the codec cache when running these tests # multiple times (e.g. when hunting for refleaks) unique_id = repr(self) + str(id(self)) self.codec_name = encodings.normalize_encoding(unique_id).lower() # We store the object to raise on the instance because of a bad # interaction between the codec caching (which means we can't # recreate the codec entry) and regrtest refleak hunting (which # runs the same test instance multiple times). This means we # need to ensure the codecs call back in to the instance to find # out which exception to raise rather than binding them in a # closure to an object that may change on the next run self.obj_to_raise = RuntimeError def tearDown(self): _TEST_CODECS.pop(self.codec_name, None) # Issue #22166: Also pop from caches to avoid appearance of ref leaks encodings._cache.pop(self.codec_name, None) try: _forget_codec(self.codec_name) except KeyError: pass def set_codec(self, encode, decode): codec_info = codecs.CodecInfo(encode, decode, name=self.codec_name) _TEST_CODECS[self.codec_name] = codec_info @contextlib.contextmanager def assertWrapped(self, operation, exc_type, msg): full_msg = r"{} with {!r} codec failed \({}: {}\)".format( operation, self.codec_name, exc_type.__name__, msg) with self.assertRaisesRegex(exc_type, full_msg) as caught: yield caught self.assertIsInstance(caught.exception.__cause__, exc_type) self.assertIsNotNone(caught.exception.__cause__.__traceback__) def raise_obj(self, *args, **kwds): # Helper to dynamically change the object raised by a test codec raise self.obj_to_raise def check_wrapped(self, obj_to_raise, msg, exc_type=RuntimeError): self.obj_to_raise = obj_to_raise self.set_codec(self.raise_obj, self.raise_obj) with self.assertWrapped("encoding", exc_type, msg): "str_input".encode(self.codec_name) with self.assertWrapped("encoding", exc_type, msg): codecs.encode("str_input", self.codec_name) with self.assertWrapped("decoding", exc_type, msg): b"bytes input".decode(self.codec_name) with self.assertWrapped("decoding", exc_type, msg): codecs.decode(b"bytes input", self.codec_name) def test_raise_by_type(self): self.check_wrapped(RuntimeError, "") def test_raise_by_value(self): msg = "This should be wrapped" self.check_wrapped(RuntimeError(msg), msg) def test_raise_grandchild_subclass_exact_size(self): msg = "This should be wrapped" class MyRuntimeError(RuntimeError): __slots__ = () self.check_wrapped(MyRuntimeError(msg), msg, MyRuntimeError) def test_raise_subclass_with_weakref_support(self): msg = "This should be wrapped" class MyRuntimeError(RuntimeError): pass self.check_wrapped(MyRuntimeError(msg), msg, MyRuntimeError) def check_not_wrapped(self, obj_to_raise, msg): def raise_obj(*args, **kwds): raise obj_to_raise self.set_codec(raise_obj, raise_obj) with self.assertRaisesRegex(RuntimeError, msg): "str input".encode(self.codec_name) with self.assertRaisesRegex(RuntimeError, msg): codecs.encode("str input", self.codec_name) with self.assertRaisesRegex(RuntimeError, msg): b"bytes input".decode(self.codec_name) with self.assertRaisesRegex(RuntimeError, msg): codecs.decode(b"bytes input", self.codec_name) def test_init_override_is_not_wrapped(self): class CustomInit(RuntimeError): def __init__(self): pass self.check_not_wrapped(CustomInit, "") def test_new_override_is_not_wrapped(self): class CustomNew(RuntimeError): def __new__(cls): return super().__new__(cls) self.check_not_wrapped(CustomNew, "") def test_instance_attribute_is_not_wrapped(self): msg = "This should NOT be wrapped" exc = RuntimeError(msg) exc.attr = 1 self.check_not_wrapped(exc, "^{}$".format(msg)) def test_non_str_arg_is_not_wrapped(self): self.check_not_wrapped(RuntimeError(1), "1") def test_multiple_args_is_not_wrapped(self): msg_re = r"^\('a', 'b', 'c'\)$" self.check_not_wrapped(RuntimeError('a', 'b', 'c'), msg_re) # http://bugs.python.org/issue19609 def test_codec_lookup_failure_not_wrapped(self): msg = "^unknown encoding: {}$".format(self.codec_name) # The initial codec lookup should not be wrapped with self.assertRaisesRegex(LookupError, msg): "str input".encode(self.codec_name) with self.assertRaisesRegex(LookupError, msg): codecs.encode("str input", self.codec_name) with self.assertRaisesRegex(LookupError, msg): b"bytes input".decode(self.codec_name) with self.assertRaisesRegex(LookupError, msg): codecs.decode(b"bytes input", self.codec_name) def test_unflagged_non_text_codec_handling(self): # The stdlib non-text codecs are now marked so they're # pre-emptively skipped by the text model related methods # However, third party codecs won't be flagged, so we still make # sure the case where an inappropriate output type is produced is # handled appropriately def encode_to_str(*args, **kwds): return "not bytes!", 0 def decode_to_bytes(*args, **kwds): return b"not str!", 0 self.set_codec(encode_to_str, decode_to_bytes) # No input or output type checks on the codecs module functions encoded = codecs.encode(None, self.codec_name) self.assertEqual(encoded, "not bytes!") decoded = codecs.decode(None, self.codec_name) self.assertEqual(decoded, b"not str!") # Text model methods should complain fmt = (r"^{!r} encoder returned 'str' instead of 'bytes'; " r"use codecs.encode\(\) to encode to arbitrary types$") msg = fmt.format(self.codec_name) with self.assertRaisesRegex(TypeError, msg): "str_input".encode(self.codec_name) fmt = (r"^{!r} decoder returned 'bytes' instead of 'str'; " r"use codecs.decode\(\) to decode to arbitrary types$") msg = fmt.format(self.codec_name) with self.assertRaisesRegex(TypeError, msg): b"bytes input".decode(self.codec_name) @unittest.skipUnless(sys.platform == 'win32', 'code pages are specific to Windows') class CodePageTest(unittest.TestCase): # CP_UTF8 is already tested by CP65001Test CP_UTF8 = 65001 def test_invalid_code_page(self): self.assertRaises(ValueError, codecs.code_page_encode, -1, 'a') self.assertRaises(ValueError, codecs.code_page_decode, -1, b'a') self.assertRaises(OSError, codecs.code_page_encode, 123, 'a') self.assertRaises(OSError, codecs.code_page_decode, 123, b'a') def test_code_page_name(self): self.assertRaisesRegex(UnicodeEncodeError, 'cp932', codecs.code_page_encode, 932, '\xff') self.assertRaisesRegex(UnicodeDecodeError, 'cp932', codecs.code_page_decode, 932, b'\x81\x00', 'strict', True) self.assertRaisesRegex(UnicodeDecodeError, 'CP_UTF8', codecs.code_page_decode, self.CP_UTF8, b'\xff', 'strict', True) def check_decode(self, cp, tests): for raw, errors, expected in tests: if expected is not None: try: decoded = codecs.code_page_decode(cp, raw, errors, True) except UnicodeDecodeError as err: self.fail('Unable to decode %a from "cp%s" with ' 'errors=%r: %s' % (raw, cp, errors, err)) self.assertEqual(decoded[0], expected, '%a.decode("cp%s", %r)=%a != %a' % (raw, cp, errors, decoded[0], expected)) # assert 0 <= decoded[1] <= len(raw) self.assertGreaterEqual(decoded[1], 0) self.assertLessEqual(decoded[1], len(raw)) else: self.assertRaises(UnicodeDecodeError, codecs.code_page_decode, cp, raw, errors, True) def check_encode(self, cp, tests): for text, errors, expected in tests: if expected is not None: try: encoded = codecs.code_page_encode(cp, text, errors) except UnicodeEncodeError as err: self.fail('Unable to encode %a to "cp%s" with ' 'errors=%r: %s' % (text, cp, errors, err)) self.assertEqual(encoded[0], expected, '%a.encode("cp%s", %r)=%a != %a' % (text, cp, errors, encoded[0], expected)) self.assertEqual(encoded[1], len(text)) else: self.assertRaises(UnicodeEncodeError, codecs.code_page_encode, cp, text, errors) def test_cp932(self): self.check_encode(932, ( ('abc', 'strict', b'abc'), ('\uff44\u9a3e', 'strict', b'\x82\x84\xe9\x80'), # test error handlers ('\xff', 'strict', None), ('[\xff]', 'ignore', b'[]'), ('[\xff]', 'replace', b'[y]'), ('[\u20ac]', 'replace', b'[?]'), ('[\xff]', 'backslashreplace', b'[\\xff]'), ('[\xff]', 'namereplace', b'[\\N{LATIN SMALL LETTER Y WITH DIAERESIS}]'), ('[\xff]', 'xmlcharrefreplace', b'[&#255;]'), ('\udcff', 'strict', None), ('[\udcff]', 'surrogateescape', b'[\xff]'), ('[\udcff]', 'surrogatepass', None), )) self.check_decode(932, ( (b'abc', 'strict', 'abc'), (b'\x82\x84\xe9\x80', 'strict', '\uff44\u9a3e'), # invalid bytes (b'[\xff]', 'strict', None), (b'[\xff]', 'ignore', '[]'), (b'[\xff]', 'replace', '[\ufffd]'), (b'[\xff]', 'backslashreplace', '[\\xff]'), (b'[\xff]', 'surrogateescape', '[\udcff]'), (b'[\xff]', 'surrogatepass', None), (b'\x81\x00abc', 'strict', None), (b'\x81\x00abc', 'ignore', '\x00abc'), (b'\x81\x00abc', 'replace', '\ufffd\x00abc'), (b'\x81\x00abc', 'backslashreplace', '\\x81\x00abc'), )) def test_cp1252(self): self.check_encode(1252, ( ('abc', 'strict', b'abc'), ('\xe9\u20ac', 'strict', b'\xe9\x80'), ('\xff', 'strict', b'\xff'), # test error handlers ('\u0141', 'strict', None), ('\u0141', 'ignore', b''), ('\u0141', 'replace', b'L'), ('\udc98', 'surrogateescape', b'\x98'), ('\udc98', 'surrogatepass', None), )) self.check_decode(1252, ( (b'abc', 'strict', 'abc'), (b'\xe9\x80', 'strict', '\xe9\u20ac'), (b'\xff', 'strict', '\xff'), )) def test_cp_utf7(self): cp = 65000 self.check_encode(cp, ( ('abc', 'strict', b'abc'), ('\xe9\u20ac', 'strict', b'+AOkgrA-'), ('\U0010ffff', 'strict', b'+2//f/w-'), ('\udc80', 'strict', b'+3IA-'), ('\ufffd', 'strict', b'+//0-'), )) self.check_decode(cp, ( (b'abc', 'strict', 'abc'), (b'+AOkgrA-', 'strict', '\xe9\u20ac'), (b'+2//f/w-', 'strict', '\U0010ffff'), (b'+3IA-', 'strict', '\udc80'), (b'+//0-', 'strict', '\ufffd'), # invalid bytes (b'[+/]', 'strict', '[]'), (b'[\xff]', 'strict', '[\xff]'), )) def test_multibyte_encoding(self): self.check_decode(932, ( (b'\x84\xe9\x80', 'ignore', '\u9a3e'), (b'\x84\xe9\x80', 'replace', '\ufffd\u9a3e'), )) self.check_decode(self.CP_UTF8, ( (b'\xff\xf4\x8f\xbf\xbf', 'ignore', '\U0010ffff'), (b'\xff\xf4\x8f\xbf\xbf', 'replace', '\ufffd\U0010ffff'), )) self.check_encode(self.CP_UTF8, ( ('[\U0010ffff\uDC80]', 'ignore', b'[\xf4\x8f\xbf\xbf]'), ('[\U0010ffff\uDC80]', 'replace', b'[\xf4\x8f\xbf\xbf?]'), )) def test_incremental(self): decoded = codecs.code_page_decode(932, b'\x82', 'strict', False) self.assertEqual(decoded, ('', 0)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9', 'strict', False) self.assertEqual(decoded, ('\u9a3e', 2)) decoded = codecs.code_page_decode(932, b'\xe9\x80\xe9\x80', 'strict', False) self.assertEqual(decoded, ('\u9a3e\u9a3e', 4)) decoded = codecs.code_page_decode(932, b'abc', 'strict', False) self.assertEqual(decoded, ('abc', 3)) def test_mbcs_alias(self): # Check that looking up our 'default' codepage will return # mbcs when we don't have a more specific one available import _bootlocale def _get_fake_codepage(*a): return 'cp123' old_getpreferredencoding = _bootlocale.getpreferredencoding _bootlocale.getpreferredencoding = _get_fake_codepage try: codec = codecs.lookup('cp123') self.assertEqual(codec.name, 'mbcs') finally: _bootlocale.getpreferredencoding = old_getpreferredencoding @support.bigmemtest(size=2**31, memuse=7, dry_run=False) def test_large_input(self): # Test input longer than INT_MAX. # Input should contain undecodable bytes before and after # the INT_MAX limit. encoded = (b'01234567' * (2**28-1) + b'\x85\x86\xea\xeb\xec\xef\xfc\xfd\xfe\xff') self.assertEqual(len(encoded), 2**31+2) decoded = codecs.code_page_decode(932, encoded, 'surrogateescape', True) self.assertEqual(decoded[1], len(encoded)) del encoded self.assertEqual(len(decoded[0]), decoded[1]) self.assertEqual(decoded[0][:10], '0123456701') self.assertEqual(decoded[0][-20:], '6701234567' '\udc85\udc86\udcea\udceb\udcec' '\udcef\udcfc\udcfd\udcfe\udcff') class ASCIITest(unittest.TestCase): def test_encode(self): self.assertEqual('abc123'.encode('ascii'), b'abc123') def test_encode_error(self): for data, error_handler, expected in ( ('[\x80\xff\u20ac]', 'ignore', b'[]'), ('[\x80\xff\u20ac]', 'replace', b'[???]'), ('[\x80\xff\u20ac]', 'xmlcharrefreplace', b'[&#128;&#255;&#8364;]'), ('[\x80\xff\u20ac\U000abcde]', 'backslashreplace', b'[\\x80\\xff\\u20ac\\U000abcde]'), ('[\udc80\udcff]', 'surrogateescape', b'[\x80\xff]'), ): with self.subTest(data=data, error_handler=error_handler, expected=expected): self.assertEqual(data.encode('ascii', error_handler), expected) def test_encode_surrogateescape_error(self): with self.assertRaises(UnicodeEncodeError): # the first character can be decoded, but not the second '\udc80\xff'.encode('ascii', 'surrogateescape') def test_decode(self): self.assertEqual(b'abc'.decode('ascii'), 'abc') def test_decode_error(self): for data, error_handler, expected in ( (b'[\x80\xff]', 'ignore', '[]'), (b'[\x80\xff]', 'replace', '[\ufffd\ufffd]'), (b'[\x80\xff]', 'surrogateescape', '[\udc80\udcff]'), (b'[\x80\xff]', 'backslashreplace', '[\\x80\\xff]'), ): with self.subTest(data=data, error_handler=error_handler, expected=expected): self.assertEqual(data.decode('ascii', error_handler), expected) class Latin1Test(unittest.TestCase): def test_encode(self): for data, expected in ( ('abc', b'abc'), ('\x80\xe9\xff', b'\x80\xe9\xff'), ): with self.subTest(data=data, expected=expected): self.assertEqual(data.encode('latin1'), expected) def test_encode_errors(self): for data, error_handler, expected in ( ('[\u20ac\udc80]', 'ignore', b'[]'), ('[\u20ac\udc80]', 'replace', b'[??]'), ('[\u20ac\U000abcde]', 'backslashreplace', b'[\\u20ac\\U000abcde]'), ('[\u20ac\udc80]', 'xmlcharrefreplace', b'[&#8364;&#56448;]'), ('[\udc80\udcff]', 'surrogateescape', b'[\x80\xff]'), ): with self.subTest(data=data, error_handler=error_handler, expected=expected): self.assertEqual(data.encode('latin1', error_handler), expected) def test_encode_surrogateescape_error(self): with self.assertRaises(UnicodeEncodeError): # the first character can be decoded, but not the second '\udc80\u20ac'.encode('latin1', 'surrogateescape') def test_decode(self): for data, expected in ( (b'abc', 'abc'), (b'[\x80\xff]', '[\x80\xff]'), ): with self.subTest(data=data, expected=expected): self.assertEqual(data.decode('latin1'), expected) if __name__ == "__main__": unittest.main()
130,113
3,414
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_symtable.py
""" Test the API of the symtable module. """ import symtable import unittest TEST_CODE = """ import sys glob = 42 class Mine: instance_var = 24 def a_method(p1, p2): pass def spam(a, b, *var, **kw): global bar bar = 47 x = 23 glob def internal(): return x return internal def foo(): pass def namespace_test(): pass def namespace_test(): pass """ def find_block(block, name): for ch in block.get_children(): if ch.get_name() == name: return ch class SymtableTest(unittest.TestCase): top = symtable.symtable(TEST_CODE, "?", "exec") # These correspond to scopes in TEST_CODE Mine = find_block(top, "Mine") a_method = find_block(Mine, "a_method") spam = find_block(top, "spam") internal = find_block(spam, "internal") foo = find_block(top, "foo") def test_type(self): self.assertEqual(self.top.get_type(), "module") self.assertEqual(self.Mine.get_type(), "class") self.assertEqual(self.a_method.get_type(), "function") self.assertEqual(self.spam.get_type(), "function") self.assertEqual(self.internal.get_type(), "function") def test_optimized(self): self.assertFalse(self.top.is_optimized()) self.assertFalse(self.top.has_exec()) self.assertTrue(self.spam.is_optimized()) def test_nested(self): self.assertFalse(self.top.is_nested()) self.assertFalse(self.Mine.is_nested()) self.assertFalse(self.spam.is_nested()) self.assertTrue(self.internal.is_nested()) def test_children(self): self.assertTrue(self.top.has_children()) self.assertTrue(self.Mine.has_children()) self.assertFalse(self.foo.has_children()) def test_lineno(self): self.assertEqual(self.top.get_lineno(), 0) self.assertEqual(self.spam.get_lineno(), 11) def test_function_info(self): func = self.spam self.assertEqual(sorted(func.get_parameters()), ["a", "b", "kw", "var"]) expected = ["a", "b", "internal", "kw", "var", "x"] self.assertEqual(sorted(func.get_locals()), expected) self.assertEqual(sorted(func.get_globals()), ["bar", "glob"]) self.assertEqual(self.internal.get_frees(), ("x",)) def test_globals(self): self.assertTrue(self.spam.lookup("glob").is_global()) self.assertFalse(self.spam.lookup("glob").is_declared_global()) self.assertTrue(self.spam.lookup("bar").is_global()) self.assertTrue(self.spam.lookup("bar").is_declared_global()) self.assertFalse(self.internal.lookup("x").is_global()) self.assertFalse(self.Mine.lookup("instance_var").is_global()) def test_local(self): self.assertTrue(self.spam.lookup("x").is_local()) self.assertFalse(self.internal.lookup("x").is_local()) def test_referenced(self): self.assertTrue(self.internal.lookup("x").is_referenced()) self.assertTrue(self.spam.lookup("internal").is_referenced()) self.assertFalse(self.spam.lookup("x").is_referenced()) def test_parameters(self): for sym in ("a", "var", "kw"): self.assertTrue(self.spam.lookup(sym).is_parameter()) self.assertFalse(self.spam.lookup("x").is_parameter()) def test_symbol_lookup(self): self.assertEqual(len(self.top.get_identifiers()), len(self.top.get_symbols())) self.assertRaises(KeyError, self.top.lookup, "not_here") def test_namespaces(self): self.assertTrue(self.top.lookup("Mine").is_namespace()) self.assertTrue(self.Mine.lookup("a_method").is_namespace()) self.assertTrue(self.top.lookup("spam").is_namespace()) self.assertTrue(self.spam.lookup("internal").is_namespace()) self.assertTrue(self.top.lookup("namespace_test").is_namespace()) self.assertFalse(self.spam.lookup("x").is_namespace()) self.assertTrue(self.top.lookup("spam").get_namespace() is self.spam) ns_test = self.top.lookup("namespace_test") self.assertEqual(len(ns_test.get_namespaces()), 2) self.assertRaises(ValueError, ns_test.get_namespace) def test_assigned(self): self.assertTrue(self.spam.lookup("x").is_assigned()) self.assertTrue(self.spam.lookup("bar").is_assigned()) self.assertTrue(self.top.lookup("spam").is_assigned()) self.assertTrue(self.Mine.lookup("a_method").is_assigned()) self.assertFalse(self.internal.lookup("x").is_assigned()) def test_annotated(self): st1 = symtable.symtable('def f():\n x: int\n', 'test', 'exec') st2 = st1.get_children()[0] self.assertTrue(st2.lookup('x').is_local()) self.assertTrue(st2.lookup('x').is_annotated()) self.assertFalse(st2.lookup('x').is_global()) st3 = symtable.symtable('def f():\n x = 1\n', 'test', 'exec') st4 = st3.get_children()[0] self.assertTrue(st4.lookup('x').is_local()) self.assertFalse(st4.lookup('x').is_annotated()) def test_imported(self): self.assertTrue(self.top.lookup("sys").is_imported()) def test_name(self): self.assertEqual(self.top.get_name(), "top") self.assertEqual(self.spam.get_name(), "spam") self.assertEqual(self.spam.lookup("x").get_name(), "x") self.assertEqual(self.Mine.get_name(), "Mine") def test_class_info(self): self.assertEqual(self.Mine.get_methods(), ('a_method',)) def test_filename_correct(self): ### Bug tickler: SyntaxError file name correct whether error raised ### while parsing or building symbol table. def checkfilename(brokencode, offset): try: symtable.symtable(brokencode, "spam", "exec") except SyntaxError as e: self.assertEqual(e.filename, "spam") self.assertEqual(e.lineno, 1) self.assertEqual(e.offset, offset) else: self.fail("no SyntaxError for %r" % (brokencode,)) checkfilename("def f(x): foo)(", 14) # parse-time checkfilename("def f(x): global x", 10) # symtable-build-time symtable.symtable("pass", b"spam", "exec") with self.assertWarns(DeprecationWarning), \ self.assertRaises(TypeError): symtable.symtable("pass", bytearray(b"spam"), "exec") with self.assertWarns(DeprecationWarning): symtable.symtable("pass", memoryview(b"spam"), "exec") with self.assertRaises(TypeError): symtable.symtable("pass", list(b"spam"), "exec") def test_eval(self): symbols = symtable.symtable("42", "?", "eval") def test_single(self): symbols = symtable.symtable("42", "?", "single") def test_exec(self): symbols = symtable.symtable("def f(x): return x", "?", "exec") if __name__ == '__main__': unittest.main()
6,951
194
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_pickle.py
from _compat_pickle import (IMPORT_MAPPING, REVERSE_IMPORT_MAPPING, NAME_MAPPING, REVERSE_NAME_MAPPING) import cosmo import builtins import pickle import io import collections import struct import sys import weakref import unittest from test import support from test.pickletester import AbstractUnpickleTests from test.pickletester import AbstractPickleTests from test.pickletester import AbstractPickleModuleTests from test.pickletester import AbstractPersistentPicklerTests from test.pickletester import AbstractIdentityPersistentPicklerTests from test.pickletester import AbstractPicklerUnpicklerObjectTests from test.pickletester import AbstractDispatchTableTests from test.pickletester import BigmemPickleTests try: import _pickle has_c_implementation = True except ImportError: has_c_implementation = False class PyPickleTests(AbstractPickleModuleTests): dump = staticmethod(pickle._dump) dumps = staticmethod(pickle._dumps) load = staticmethod(pickle._load) loads = staticmethod(pickle._loads) Pickler = pickle._Pickler Unpickler = pickle._Unpickler class PyUnpicklerTests(AbstractUnpickleTests): unpickler = pickle._Unpickler bad_stack_errors = (IndexError,) truncated_errors = (pickle.UnpicklingError, EOFError, AttributeError, ValueError, struct.error, IndexError, ImportError) def loads(self, buf, **kwds): f = io.BytesIO(buf) u = self.unpickler(f, **kwds) return u.load() class PyPicklerTests(AbstractPickleTests): pickler = pickle._Pickler unpickler = pickle._Unpickler def dumps(self, arg, proto=None): f = io.BytesIO() p = self.pickler(f, proto) p.dump(arg) f.seek(0) return bytes(f.read()) def loads(self, buf, **kwds): f = io.BytesIO(buf) u = self.unpickler(f, **kwds) return u.load() class InMemoryPickleTests(AbstractPickleTests, AbstractUnpickleTests, BigmemPickleTests): pickler = pickle._Pickler unpickler = pickle._Unpickler bad_stack_errors = (pickle.UnpicklingError, IndexError) truncated_errors = (pickle.UnpicklingError, EOFError, AttributeError, ValueError, struct.error, IndexError, ImportError) def dumps(self, arg, protocol=None): return pickle.dumps(arg, protocol) def loads(self, buf, **kwds): return pickle.loads(buf, **kwds) class PersistentPicklerUnpicklerMixin(object): def dumps(self, arg, proto=None): class PersPickler(self.pickler): def persistent_id(subself, obj): return self.persistent_id(obj) f = io.BytesIO() p = PersPickler(f, proto) p.dump(arg) return f.getvalue() def loads(self, buf, **kwds): class PersUnpickler(self.unpickler): def persistent_load(subself, obj): return self.persistent_load(obj) f = io.BytesIO(buf) u = PersUnpickler(f, **kwds) return u.load() class PyPersPicklerTests(AbstractPersistentPicklerTests, PersistentPicklerUnpicklerMixin): pickler = pickle._Pickler unpickler = pickle._Unpickler class PyIdPersPicklerTests(AbstractIdentityPersistentPicklerTests, PersistentPicklerUnpicklerMixin): pickler = pickle._Pickler unpickler = pickle._Unpickler @support.cpython_only def test_pickler_reference_cycle(self): def check(Pickler): for proto in range(pickle.HIGHEST_PROTOCOL + 1): f = io.BytesIO() pickler = Pickler(f, proto) pickler.dump('abc') self.assertEqual(self.loads(f.getvalue()), 'abc') pickler = Pickler(io.BytesIO()) self.assertEqual(pickler.persistent_id('def'), 'def') r = weakref.ref(pickler) del pickler self.assertIsNone(r()) class PersPickler(self.pickler): def persistent_id(subself, obj): return obj check(PersPickler) class PersPickler(self.pickler): @classmethod def persistent_id(cls, obj): return obj check(PersPickler) class PersPickler(self.pickler): @staticmethod def persistent_id(obj): return obj check(PersPickler) @support.cpython_only def test_unpickler_reference_cycle(self): def check(Unpickler): for proto in range(pickle.HIGHEST_PROTOCOL + 1): unpickler = Unpickler(io.BytesIO(self.dumps('abc', proto))) self.assertEqual(unpickler.load(), 'abc') unpickler = Unpickler(io.BytesIO()) self.assertEqual(unpickler.persistent_load('def'), 'def') r = weakref.ref(unpickler) del unpickler self.assertIsNone(r()) class PersUnpickler(self.unpickler): def persistent_load(subself, pid): return pid check(PersUnpickler) class PersUnpickler(self.unpickler): @classmethod def persistent_load(cls, pid): return pid check(PersUnpickler) class PersUnpickler(self.unpickler): @staticmethod def persistent_load(pid): return pid check(PersUnpickler) class PyPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests): pickler_class = pickle._Pickler unpickler_class = pickle._Unpickler class PyDispatchTableTests(AbstractDispatchTableTests): pickler_class = pickle._Pickler def get_dispatch_table(self): return pickle.dispatch_table.copy() class PyChainDispatchTableTests(AbstractDispatchTableTests): pickler_class = pickle._Pickler def get_dispatch_table(self): return collections.ChainMap({}, pickle.dispatch_table) if has_c_implementation: class CPickleTests(AbstractPickleModuleTests): from _pickle import dump, dumps, load, loads, Pickler, Unpickler class CUnpicklerTests(PyUnpicklerTests): unpickler = _pickle.Unpickler bad_stack_errors = (pickle.UnpicklingError,) truncated_errors = (pickle.UnpicklingError,) class CPicklerTests(PyPicklerTests): pickler = _pickle.Pickler unpickler = _pickle.Unpickler class CPersPicklerTests(PyPersPicklerTests): pickler = _pickle.Pickler unpickler = _pickle.Unpickler class CIdPersPicklerTests(PyIdPersPicklerTests): pickler = _pickle.Pickler unpickler = _pickle.Unpickler class CDumpPickle_LoadPickle(PyPicklerTests): pickler = _pickle.Pickler unpickler = pickle._Unpickler class DumpPickle_CLoadPickle(PyPicklerTests): pickler = pickle._Pickler unpickler = _pickle.Unpickler class CPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests): pickler_class = _pickle.Pickler unpickler_class = _pickle.Unpickler def test_issue18339(self): unpickler = self.unpickler_class(io.BytesIO()) with self.assertRaises(TypeError): unpickler.memo = object # used to cause a segfault with self.assertRaises(ValueError): unpickler.memo = {-1: None} unpickler.memo = {1: None} class CDispatchTableTests(AbstractDispatchTableTests): pickler_class = pickle.Pickler def get_dispatch_table(self): return pickle.dispatch_table.copy() class CChainDispatchTableTests(AbstractDispatchTableTests): pickler_class = pickle.Pickler def get_dispatch_table(self): return collections.ChainMap({}, pickle.dispatch_table) @support.cpython_only class SizeofTests(unittest.TestCase): check_sizeof = support.check_sizeof def test_pickler(self): basesize = support.calcobjsize('6P2n3i2n3iP') p = _pickle.Pickler(io.BytesIO()) self.assertEqual(object.__sizeof__(p), basesize) MT_size = struct.calcsize('3nP0n') ME_size = struct.calcsize('Pn0P') check = self.check_sizeof check(p, basesize + MT_size + 8 * ME_size + # Minimal memo table size. sys.getsizeof(b'x'*4096)) # Minimal write buffer size. for i in range(6): p.dump(chr(i)) check(p, basesize + MT_size + 32 * ME_size + # Size of memo table required to # save references to 6 objects. 0) # Write buffer is cleared after every dump(). def test_unpickler(self): basesize = support.calcobjsize('2P2n2P 2P2n2i5P 2P3n6P2n2i') unpickler = _pickle.Unpickler P = struct.calcsize('P') # Size of memo table entry. n = struct.calcsize('n') # Size of mark table entry. check = self.check_sizeof for encoding in 'ASCII', 'UTF-16', 'latin-1': for errors in 'strict', 'replace': u = unpickler(io.BytesIO(), encoding=encoding, errors=errors) self.assertEqual(object.__sizeof__(u), basesize) check(u, basesize + 32 * P + # Minimal memo table size. len(encoding) + 1 + len(errors) + 1) stdsize = basesize + len('ASCII') + 1 + len('strict') + 1 def check_unpickler(data, memo_size, marks_size): dump = pickle.dumps(data) u = unpickler(io.BytesIO(dump), encoding='ASCII', errors='strict') u.load() check(u, stdsize + memo_size * P + marks_size * n) check_unpickler(0, 32, 0) # 20 is minimal non-empty mark stack size. check_unpickler([0] * 100, 32, 20) # 128 is memo table size required to save references to 100 objects. check_unpickler([chr(i) for i in range(100)], 128, 20) def recurse(deep): data = 0 for i in range(deep): data = [data, data] return data check_unpickler(recurse(0), 32, 0) check_unpickler(recurse(1), 32, 20) check_unpickler(recurse(20), 32, 58) check_unpickler(recurse(50), 64, 58) check_unpickler(recurse(100), 128, 134) u = unpickler(io.BytesIO(pickle.dumps('a', 0)), encoding='ASCII', errors='strict') u.load() check(u, stdsize + 32 * P + 2 + 1) ALT_IMPORT_MAPPING = { ('_elementtree', 'xml.etree.ElementTree'), ('cPickle', 'pickle'), ('StringIO', 'io'), ('cStringIO', 'io'), } ALT_NAME_MAPPING = { ('__builtin__', 'basestring', 'builtins', 'str'), ('exceptions', 'StandardError', 'builtins', 'Exception'), ('UserDict', 'UserDict', 'collections', 'UserDict'), ('socket', '_socketobject', 'socket', 'SocketType'), } def mapping(module, name): if (module, name) in NAME_MAPPING: module, name = NAME_MAPPING[(module, name)] elif module in IMPORT_MAPPING: module = IMPORT_MAPPING[module] return module, name def reverse_mapping(module, name): if (module, name) in REVERSE_NAME_MAPPING: module, name = REVERSE_NAME_MAPPING[(module, name)] elif module in REVERSE_IMPORT_MAPPING: module = REVERSE_IMPORT_MAPPING[module] return module, name def getmodule(module): try: return sys.modules[module] except KeyError: try: __import__(module) except AttributeError as exc: if support.verbose: print("Can't import module %r: %s" % (module, exc)) raise ImportError except ImportError as exc: if support.verbose: print(exc) raise return sys.modules[module] def getattribute(module, name): obj = getmodule(module) for n in name.split('.'): obj = getattr(obj, n) return obj def get_exceptions(mod): for name in dir(mod): attr = getattr(mod, name) if isinstance(attr, type) and issubclass(attr, BaseException): yield name, attr class CompatPickleTests(unittest.TestCase): def test_import(self): modules = set(IMPORT_MAPPING.values()) modules |= set(REVERSE_IMPORT_MAPPING) modules |= {module for module, name in REVERSE_NAME_MAPPING} modules |= {module for module, name in NAME_MAPPING.values()} for module in modules: try: getmodule(module) except ImportError: pass def test_import_mapping(self): for module3, module2 in REVERSE_IMPORT_MAPPING.items(): with self.subTest((module3, module2)): try: getmodule(module3) except ImportError: pass if module3[:1] != '_': self.assertIn(module2, IMPORT_MAPPING) self.assertEqual(IMPORT_MAPPING[module2], module3) def test_name_mapping(self): for (module3, name3), (module2, name2) in REVERSE_NAME_MAPPING.items(): with self.subTest(((module3, name3), (module2, name2))): if (module2, name2) == ('exceptions', 'OSError'): attr = getattribute(module3, name3) self.assertTrue(issubclass(attr, OSError)) elif (module2, name2) == ('exceptions', 'ImportError'): attr = getattribute(module3, name3) self.assertTrue(issubclass(attr, ImportError)) else: module, name = mapping(module2, name2) if module3[:1] != '_': self.assertEqual((module, name), (module3, name3)) try: attr = getattribute(module3, name3) except ImportError: pass else: self.assertEqual(getattribute(module, name), attr) def test_reverse_import_mapping(self): for module2, module3 in IMPORT_MAPPING.items(): with self.subTest((module2, module3)): try: getmodule(module3) except ImportError as exc: if support.verbose: print(exc) if ((module2, module3) not in ALT_IMPORT_MAPPING and REVERSE_IMPORT_MAPPING.get(module3, None) != module2): for (m3, n3), (m2, n2) in REVERSE_NAME_MAPPING.items(): if (module3, module2) == (m3, m2): break else: self.fail('No reverse mapping from %r to %r' % (module3, module2)) module = REVERSE_IMPORT_MAPPING.get(module3, module3) module = IMPORT_MAPPING.get(module, module) self.assertEqual(module, module3) def test_reverse_name_mapping(self): for (module2, name2), (module3, name3) in NAME_MAPPING.items(): with self.subTest(((module2, name2), (module3, name3))): try: attr = getattribute(module3, name3) except ImportError: pass module, name = reverse_mapping(module3, name3) if (module2, name2, module3, name3) not in ALT_NAME_MAPPING: self.assertEqual((module, name), (module2, name2)) module, name = mapping(module, name) self.assertEqual((module, name), (module3, name3)) def test_exceptions(self): self.assertEqual(mapping('exceptions', 'StandardError'), ('builtins', 'Exception')) self.assertEqual(mapping('exceptions', 'Exception'), ('builtins', 'Exception')) self.assertEqual(reverse_mapping('builtins', 'Exception'), ('exceptions', 'Exception')) self.assertEqual(mapping('exceptions', 'OSError'), ('builtins', 'OSError')) self.assertEqual(reverse_mapping('builtins', 'OSError'), ('exceptions', 'OSError')) for name, exc in get_exceptions(builtins): with self.subTest(name): if exc in (BlockingIOError, ResourceWarning, StopAsyncIteration, RecursionError): continue if exc is not OSError and issubclass(exc, OSError): self.assertEqual(reverse_mapping('builtins', name), ('exceptions', 'OSError')) elif exc is not ImportError and issubclass(exc, ImportError): self.assertEqual(reverse_mapping('builtins', name), ('exceptions', 'ImportError')) self.assertEqual(mapping('exceptions', name), ('exceptions', name)) else: self.assertEqual(reverse_mapping('builtins', name), ('exceptions', name)) self.assertEqual(mapping('exceptions', name), ('builtins', name)) def test_multiprocessing_exceptions(self): module = support.import_module('multiprocessing.context') for name, exc in get_exceptions(module): with self.subTest(name): self.assertEqual(reverse_mapping('multiprocessing.context', name), ('multiprocessing', name)) self.assertEqual(mapping('multiprocessing', name), ('multiprocessing.context', name)) def test_main(): # [jart] so many slow superfluous tests if cosmo.MODE in ('dbg', 'asan'): tests = [] if has_c_implementation: tests.extend([CPickleTests, CUnpicklerTests]) support.run_unittest(*tests) else: tests = [] if has_c_implementation: tests.extend([CPickleTests, CUnpicklerTests, CPicklerTests, CPersPicklerTests, CIdPersPicklerTests, CDumpPickle_LoadPickle, DumpPickle_CLoadPickle, CPicklerUnpicklerObjectTests, CDispatchTableTests, CChainDispatchTableTests, InMemoryPickleTests, SizeofTests]) support.run_unittest(*tests) support.run_doctest(pickle) if __name__ == "__main__": test_main()
19,068
518
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/EUC-KR.TXT
00 0000 01 0001 02 0002 03 0003 04 0004 05 0005 06 0006 07 0007 08 0008 09 0009 0A 000A 0B 000B 0C 000C 0D 000D 0E 000E 0F 000F 10 0010 11 0011 12 0012 13 0013 14 0014 15 0015 16 0016 17 0017 18 0018 19 0019 1A 001A 1B 001B 1C 001C 1D 001D 1E 001E 1F 001F 20 0020 21 0021 22 0022 23 0023 24 0024 25 0025 26 0026 27 0027 28 0028 29 0029 2A 002A 2B 002B 2C 002C 2D 002D 2E 002E 2F 002F 30 0030 31 0031 32 0032 33 0033 34 0034 35 0035 36 0036 37 0037 38 0038 39 0039 3A 003A 3B 003B 3C 003C 3D 003D 3E 003E 3F 003F 40 0040 41 0041 42 0042 43 0043 44 0044 45 0045 46 0046 47 0047 48 0048 49 0049 4A 004A 4B 004B 4C 004C 4D 004D 4E 004E 4F 004F 50 0050 51 0051 52 0052 53 0053 54 0054 55 0055 56 0056 57 0057 58 0058 59 0059 5A 005A 5B 005B 5C 005C 5D 005D 5E 005E 5F 005F 60 0060 61 0061 62 0062 63 0063 64 0064 65 0065 66 0066 67 0067 68 0068 69 0069 6A 006A 6B 006B 6C 006C 6D 006D 6E 006E 6F 006F 70 0070 71 0071 72 0072 73 0073 74 0074 75 0075 76 0076 77 0077 78 0078 79 0079 7A 007A 7B 007B 7C 007C 7D 007D 7E 007E 7F 007F A1A1 3000 A1A2 3001 A1A3 3002 A1A4 00B7 A1A5 2025 A1A6 2026 A1A7 00A8 A1A8 3003 A1A9 00AD A1AA 2015 A1AB 2225 A1AC FF3C A1AD 223C A1AE 2018 A1AF 2019 A1B0 201C A1B1 201D A1B2 3014 A1B3 3015 A1B4 3008 A1B5 3009 A1B6 300A A1B7 300B A1B8 300C A1B9 300D A1BA 300E A1BB 300F A1BC 3010 A1BD 3011 A1BE 00B1 A1BF 00D7 A1C0 00F7 A1C1 2260 A1C2 2264 A1C3 2265 A1C4 221E A1C5 2234 A1C6 00B0 A1C7 2032 A1C8 2033 A1C9 2103 A1CA 212B A1CB FFE0 A1CC FFE1 A1CD FFE5 A1CE 2642 A1CF 2640 A1D0 2220 A1D1 22A5 A1D2 2312 A1D3 2202 A1D4 2207 A1D5 2261 A1D6 2252 A1D7 00A7 A1D8 203B A1D9 2606 A1DA 2605 A1DB 25CB A1DC 25CF A1DD 25CE A1DE 25C7 A1DF 25C6 A1E0 25A1 A1E1 25A0 A1E2 25B3 A1E3 25B2 A1E4 25BD A1E5 25BC A1E6 2192 A1E7 2190 A1E8 2191 A1E9 2193 A1EA 2194 A1EB 3013 A1EC 226A A1ED 226B A1EE 221A A1EF 223D A1F0 221D A1F1 2235 A1F2 222B A1F3 222C A1F4 2208 A1F5 220B A1F6 2286 A1F7 2287 A1F8 2282 A1F9 2283 A1FA 222A A1FB 2229 A1FC 2227 A1FD 2228 A1FE FFE2 A2A1 21D2 A2A2 21D4 A2A3 2200 A2A4 2203 A2A5 00B4 A2A6 FF5E A2A7 02C7 A2A8 02D8 A2A9 02DD A2AA 02DA A2AB 02D9 A2AC 00B8 A2AD 02DB A2AE 00A1 A2AF 00BF A2B0 02D0 A2B1 222E A2B2 2211 A2B3 220F A2B4 00A4 A2B5 2109 A2B6 2030 A2B7 25C1 A2B8 25C0 A2B9 25B7 A2BA 25B6 A2BB 2664 A2BC 2660 A2BD 2661 A2BE 2665 A2BF 2667 A2C0 2663 A2C1 2299 A2C2 25C8 A2C3 25A3 A2C4 25D0 A2C5 25D1 A2C6 2592 A2C7 25A4 A2C8 25A5 A2C9 25A8 A2CA 25A7 A2CB 25A6 A2CC 25A9 A2CD 2668 A2CE 260F A2CF 260E A2D0 261C A2D1 261E A2D2 00B6 A2D3 2020 A2D4 2021 A2D5 2195 A2D6 2197 A2D7 2199 A2D8 2196 A2D9 2198 A2DA 266D A2DB 2669 A2DC 266A A2DD 266C A2DE 327F A2DF 321C A2E0 2116 A2E1 33C7 A2E2 2122 A2E3 33C2 A2E4 33D8 A2E5 2121 A2E6 20AC A2E7 00AE A3A1 FF01 A3A2 FF02 A3A3 FF03 A3A4 FF04 A3A5 FF05 A3A6 FF06 A3A7 FF07 A3A8 FF08 A3A9 FF09 A3AA FF0A A3AB FF0B A3AC FF0C A3AD FF0D A3AE FF0E A3AF FF0F A3B0 FF10 A3B1 FF11 A3B2 FF12 A3B3 FF13 A3B4 FF14 A3B5 FF15 A3B6 FF16 A3B7 FF17 A3B8 FF18 A3B9 FF19 A3BA FF1A A3BB FF1B A3BC FF1C A3BD FF1D A3BE FF1E A3BF FF1F A3C0 FF20 A3C1 FF21 A3C2 FF22 A3C3 FF23 A3C4 FF24 A3C5 FF25 A3C6 FF26 A3C7 FF27 A3C8 FF28 A3C9 FF29 A3CA FF2A A3CB FF2B A3CC FF2C A3CD FF2D A3CE FF2E A3CF FF2F A3D0 FF30 A3D1 FF31 A3D2 FF32 A3D3 FF33 A3D4 FF34 A3D5 FF35 A3D6 FF36 A3D7 FF37 A3D8 FF38 A3D9 FF39 A3DA FF3A A3DB FF3B A3DC FFE6 A3DD FF3D A3DE FF3E A3DF FF3F A3E0 FF40 A3E1 FF41 A3E2 FF42 A3E3 FF43 A3E4 FF44 A3E5 FF45 A3E6 FF46 A3E7 FF47 A3E8 FF48 A3E9 FF49 A3EA FF4A A3EB FF4B A3EC FF4C A3ED FF4D A3EE FF4E A3EF FF4F A3F0 FF50 A3F1 FF51 A3F2 FF52 A3F3 FF53 A3F4 FF54 A3F5 FF55 A3F6 FF56 A3F7 FF57 A3F8 FF58 A3F9 FF59 A3FA FF5A A3FB FF5B A3FC FF5C A3FD FF5D A3FE FFE3 A4A1 3131 A4A2 3132 A4A3 3133 A4A4 3134 A4A5 3135 A4A6 3136 A4A7 3137 A4A8 3138 A4A9 3139 A4AA 313A A4AB 313B A4AC 313C A4AD 313D A4AE 313E A4AF 313F A4B0 3140 A4B1 3141 A4B2 3142 A4B3 3143 A4B4 3144 A4B5 3145 A4B6 3146 A4B7 3147 A4B8 3148 A4B9 3149 A4BA 314A A4BB 314B A4BC 314C A4BD 314D A4BE 314E A4BF 314F A4C0 3150 A4C1 3151 A4C2 3152 A4C3 3153 A4C4 3154 A4C5 3155 A4C6 3156 A4C7 3157 A4C8 3158 A4C9 3159 A4CA 315A A4CB 315B A4CC 315C A4CD 315D A4CE 315E A4CF 315F A4D0 3160 A4D1 3161 A4D2 3162 A4D3 3163 A4D4 3164 A4D5 3165 A4D6 3166 A4D7 3167 A4D8 3168 A4D9 3169 A4DA 316A A4DB 316B A4DC 316C A4DD 316D A4DE 316E A4DF 316F A4E0 3170 A4E1 3171 A4E2 3172 A4E3 3173 A4E4 3174 A4E5 3175 A4E6 3176 A4E7 3177 A4E8 3178 A4E9 3179 A4EA 317A A4EB 317B A4EC 317C A4ED 317D A4EE 317E A4EF 317F A4F0 3180 A4F1 3181 A4F2 3182 A4F3 3183 A4F4 3184 A4F5 3185 A4F6 3186 A4F7 3187 A4F8 3188 A4F9 3189 A4FA 318A A4FB 318B A4FC 318C A4FD 318D A4FE 318E A5A1 2170 A5A2 2171 A5A3 2172 A5A4 2173 A5A5 2174 A5A6 2175 A5A7 2176 A5A8 2177 A5A9 2178 A5AA 2179 A5B0 2160 A5B1 2161 A5B2 2162 A5B3 2163 A5B4 2164 A5B5 2165 A5B6 2166 A5B7 2167 A5B8 2168 A5B9 2169 A5C1 0391 A5C2 0392 A5C3 0393 A5C4 0394 A5C5 0395 A5C6 0396 A5C7 0397 A5C8 0398 A5C9 0399 A5CA 039A A5CB 039B A5CC 039C A5CD 039D A5CE 039E A5CF 039F A5D0 03A0 A5D1 03A1 A5D2 03A3 A5D3 03A4 A5D4 03A5 A5D5 03A6 A5D6 03A7 A5D7 03A8 A5D8 03A9 A5E1 03B1 A5E2 03B2 A5E3 03B3 A5E4 03B4 A5E5 03B5 A5E6 03B6 A5E7 03B7 A5E8 03B8 A5E9 03B9 A5EA 03BA A5EB 03BB A5EC 03BC A5ED 03BD A5EE 03BE A5EF 03BF A5F0 03C0 A5F1 03C1 A5F2 03C3 A5F3 03C4 A5F4 03C5 A5F5 03C6 A5F6 03C7 A5F7 03C8 A5F8 03C9 A6A1 2500 A6A2 2502 A6A3 250C A6A4 2510 A6A5 2518 A6A6 2514 A6A7 251C A6A8 252C A6A9 2524 A6AA 2534 A6AB 253C A6AC 2501 A6AD 2503 A6AE 250F A6AF 2513 A6B0 251B A6B1 2517 A6B2 2523 A6B3 2533 A6B4 252B A6B5 253B A6B6 254B A6B7 2520 A6B8 252F A6B9 2528 A6BA 2537 A6BB 253F A6BC 251D A6BD 2530 A6BE 2525 A6BF 2538 A6C0 2542 A6C1 2512 A6C2 2511 A6C3 251A A6C4 2519 A6C5 2516 A6C6 2515 A6C7 250E A6C8 250D A6C9 251E A6CA 251F A6CB 2521 A6CC 2522 A6CD 2526 A6CE 2527 A6CF 2529 A6D0 252A A6D1 252D A6D2 252E A6D3 2531 A6D4 2532 A6D5 2535 A6D6 2536 A6D7 2539 A6D8 253A A6D9 253D A6DA 253E A6DB 2540 A6DC 2541 A6DD 2543 A6DE 2544 A6DF 2545 A6E0 2546 A6E1 2547 A6E2 2548 A6E3 2549 A6E4 254A A7A1 3395 A7A2 3396 A7A3 3397 A7A4 2113 A7A5 3398 A7A6 33C4 A7A7 33A3 A7A8 33A4 A7A9 33A5 A7AA 33A6 A7AB 3399 A7AC 339A A7AD 339B A7AE 339C A7AF 339D A7B0 339E A7B1 339F A7B2 33A0 A7B3 33A1 A7B4 33A2 A7B5 33CA A7B6 338D A7B7 338E A7B8 338F A7B9 33CF A7BA 3388 A7BB 3389 A7BC 33C8 A7BD 33A7 A7BE 33A8 A7BF 33B0 A7C0 33B1 A7C1 33B2 A7C2 33B3 A7C3 33B4 A7C4 33B5 A7C5 33B6 A7C6 33B7 A7C7 33B8 A7C8 33B9 A7C9 3380 A7CA 3381 A7CB 3382 A7CC 3383 A7CD 3384 A7CE 33BA A7CF 33BB A7D0 33BC A7D1 33BD A7D2 33BE A7D3 33BF A7D4 3390 A7D5 3391 A7D6 3392 A7D7 3393 A7D8 3394 A7D9 2126 A7DA 33C0 A7DB 33C1 A7DC 338A A7DD 338B A7DE 338C A7DF 33D6 A7E0 33C5 A7E1 33AD A7E2 33AE A7E3 33AF A7E4 33DB A7E5 33A9 A7E6 33AA A7E7 33AB A7E8 33AC A7E9 33DD A7EA 33D0 A7EB 33D3 A7EC 33C3 A7ED 33C9 A7EE 33DC A7EF 33C6 A8A1 00C6 A8A2 00D0 A8A3 00AA A8A4 0126 A8A6 0132 A8A8 013F A8A9 0141 A8AA 00D8 A8AB 0152 A8AC 00BA A8AD 00DE A8AE 0166 A8AF 014A A8B1 3260 A8B2 3261 A8B3 3262 A8B4 3263 A8B5 3264 A8B6 3265 A8B7 3266 A8B8 3267 A8B9 3268 A8BA 3269 A8BB 326A A8BC 326B A8BD 326C A8BE 326D A8BF 326E A8C0 326F A8C1 3270 A8C2 3271 A8C3 3272 A8C4 3273 A8C5 3274 A8C6 3275 A8C7 3276 A8C8 3277 A8C9 3278 A8CA 3279 A8CB 327A A8CC 327B A8CD 24D0 A8CE 24D1 A8CF 24D2 A8D0 24D3 A8D1 24D4 A8D2 24D5 A8D3 24D6 A8D4 24D7 A8D5 24D8 A8D6 24D9 A8D7 24DA A8D8 24DB A8D9 24DC A8DA 24DD A8DB 24DE A8DC 24DF A8DD 24E0 A8DE 24E1 A8DF 24E2 A8E0 24E3 A8E1 24E4 A8E2 24E5 A8E3 24E6 A8E4 24E7 A8E5 24E8 A8E6 24E9 A8E7 2460 A8E8 2461 A8E9 2462 A8EA 2463 A8EB 2464 A8EC 2465 A8ED 2466 A8EE 2467 A8EF 2468 A8F0 2469 A8F1 246A A8F2 246B A8F3 246C A8F4 246D A8F5 246E A8F6 00BD A8F7 2153 A8F8 2154 A8F9 00BC A8FA 00BE A8FB 215B A8FC 215C A8FD 215D A8FE 215E A9A1 00E6 A9A2 0111 A9A3 00F0 A9A4 0127 A9A5 0131 A9A6 0133 A9A7 0138 A9A8 0140 A9A9 0142 A9AA 00F8 A9AB 0153 A9AC 00DF A9AD 00FE A9AE 0167 A9AF 014B A9B0 0149 A9B1 3200 A9B2 3201 A9B3 3202 A9B4 3203 A9B5 3204 A9B6 3205 A9B7 3206 A9B8 3207 A9B9 3208 A9BA 3209 A9BB 320A A9BC 320B A9BD 320C A9BE 320D A9BF 320E A9C0 320F A9C1 3210 A9C2 3211 A9C3 3212 A9C4 3213 A9C5 3214 A9C6 3215 A9C7 3216 A9C8 3217 A9C9 3218 A9CA 3219 A9CB 321A A9CC 321B A9CD 249C A9CE 249D A9CF 249E A9D0 249F A9D1 24A0 A9D2 24A1 A9D3 24A2 A9D4 24A3 A9D5 24A4 A9D6 24A5 A9D7 24A6 A9D8 24A7 A9D9 24A8 A9DA 24A9 A9DB 24AA A9DC 24AB A9DD 24AC A9DE 24AD A9DF 24AE A9E0 24AF A9E1 24B0 A9E2 24B1 A9E3 24B2 A9E4 24B3 A9E5 24B4 A9E6 24B5 A9E7 2474 A9E8 2475 A9E9 2476 A9EA 2477 A9EB 2478 A9EC 2479 A9ED 247A A9EE 247B A9EF 247C A9F0 247D A9F1 247E A9F2 247F A9F3 2480 A9F4 2481 A9F5 2482 A9F6 00B9 A9F7 00B2 A9F8 00B3 A9F9 2074 A9FA 207F A9FB 2081 A9FC 2082 A9FD 2083 A9FE 2084 AAA1 3041 AAA2 3042 AAA3 3043 AAA4 3044 AAA5 3045 AAA6 3046 AAA7 3047 AAA8 3048 AAA9 3049 AAAA 304A AAAB 304B AAAC 304C AAAD 304D AAAE 304E AAAF 304F AAB0 3050 AAB1 3051 AAB2 3052 AAB3 3053 AAB4 3054 AAB5 3055 AAB6 3056 AAB7 3057 AAB8 3058 AAB9 3059 AABA 305A AABB 305B AABC 305C AABD 305D AABE 305E AABF 305F AAC0 3060 AAC1 3061 AAC2 3062 AAC3 3063 AAC4 3064 AAC5 3065 AAC6 3066 AAC7 3067 AAC8 3068 AAC9 3069 AACA 306A AACB 306B AACC 306C AACD 306D AACE 306E AACF 306F AAD0 3070 AAD1 3071 AAD2 3072 AAD3 3073 AAD4 3074 AAD5 3075 AAD6 3076 AAD7 3077 AAD8 3078 AAD9 3079 AADA 307A AADB 307B AADC 307C AADD 307D AADE 307E AADF 307F AAE0 3080 AAE1 3081 AAE2 3082 AAE3 3083 AAE4 3084 AAE5 3085 AAE6 3086 AAE7 3087 AAE8 3088 AAE9 3089 AAEA 308A AAEB 308B AAEC 308C AAED 308D AAEE 308E AAEF 308F AAF0 3090 AAF1 3091 AAF2 3092 AAF3 3093 ABA1 30A1 ABA2 30A2 ABA3 30A3 ABA4 30A4 ABA5 30A5 ABA6 30A6 ABA7 30A7 ABA8 30A8 ABA9 30A9 ABAA 30AA ABAB 30AB ABAC 30AC ABAD 30AD ABAE 30AE ABAF 30AF ABB0 30B0 ABB1 30B1 ABB2 30B2 ABB3 30B3 ABB4 30B4 ABB5 30B5 ABB6 30B6 ABB7 30B7 ABB8 30B8 ABB9 30B9 ABBA 30BA ABBB 30BB ABBC 30BC ABBD 30BD ABBE 30BE ABBF 30BF ABC0 30C0 ABC1 30C1 ABC2 30C2 ABC3 30C3 ABC4 30C4 ABC5 30C5 ABC6 30C6 ABC7 30C7 ABC8 30C8 ABC9 30C9 ABCA 30CA ABCB 30CB ABCC 30CC ABCD 30CD ABCE 30CE ABCF 30CF ABD0 30D0 ABD1 30D1 ABD2 30D2 ABD3 30D3 ABD4 30D4 ABD5 30D5 ABD6 30D6 ABD7 30D7 ABD8 30D8 ABD9 30D9 ABDA 30DA ABDB 30DB ABDC 30DC ABDD 30DD ABDE 30DE ABDF 30DF ABE0 30E0 ABE1 30E1 ABE2 30E2 ABE3 30E3 ABE4 30E4 ABE5 30E5 ABE6 30E6 ABE7 30E7 ABE8 30E8 ABE9 30E9 ABEA 30EA ABEB 30EB ABEC 30EC ABED 30ED ABEE 30EE ABEF 30EF ABF0 30F0 ABF1 30F1 ABF2 30F2 ABF3 30F3 ABF4 30F4 ABF5 30F5 ABF6 30F6 ACA1 0410 ACA2 0411 ACA3 0412 ACA4 0413 ACA5 0414 ACA6 0415 ACA7 0401 ACA8 0416 ACA9 0417 ACAA 0418 ACAB 0419 ACAC 041A ACAD 041B ACAE 041C ACAF 041D ACB0 041E ACB1 041F ACB2 0420 ACB3 0421 ACB4 0422 ACB5 0423 ACB6 0424 ACB7 0425 ACB8 0426 ACB9 0427 ACBA 0428 ACBB 0429 ACBC 042A ACBD 042B ACBE 042C ACBF 042D ACC0 042E ACC1 042F ACD1 0430 ACD2 0431 ACD3 0432 ACD4 0433 ACD5 0434 ACD6 0435 ACD7 0451 ACD8 0436 ACD9 0437 ACDA 0438 ACDB 0439 ACDC 043A ACDD 043B ACDE 043C ACDF 043D ACE0 043E ACE1 043F ACE2 0440 ACE3 0441 ACE4 0442 ACE5 0443 ACE6 0444 ACE7 0445 ACE8 0446 ACE9 0447 ACEA 0448 ACEB 0449 ACEC 044A ACED 044B ACEE 044C ACEF 044D ACF0 044E ACF1 044F B0A1 AC00 B0A2 AC01 B0A3 AC04 B0A4 AC07 B0A5 AC08 B0A6 AC09 B0A7 AC0A B0A8 AC10 B0A9 AC11 B0AA AC12 B0AB AC13 B0AC AC14 B0AD AC15 B0AE AC16 B0AF AC17 B0B0 AC19 B0B1 AC1A B0B2 AC1B B0B3 AC1C B0B4 AC1D B0B5 AC20 B0B6 AC24 B0B7 AC2C B0B8 AC2D B0B9 AC2F B0BA AC30 B0BB AC31 B0BC AC38 B0BD AC39 B0BE AC3C B0BF AC40 B0C0 AC4B B0C1 AC4D B0C2 AC54 B0C3 AC58 B0C4 AC5C B0C5 AC70 B0C6 AC71 B0C7 AC74 B0C8 AC77 B0C9 AC78 B0CA AC7A B0CB AC80 B0CC AC81 B0CD AC83 B0CE AC84 B0CF AC85 B0D0 AC86 B0D1 AC89 B0D2 AC8A B0D3 AC8B B0D4 AC8C B0D5 AC90 B0D6 AC94 B0D7 AC9C B0D8 AC9D B0D9 AC9F B0DA ACA0 B0DB ACA1 B0DC ACA8 B0DD ACA9 B0DE ACAA B0DF ACAC B0E0 ACAF B0E1 ACB0 B0E2 ACB8 B0E3 ACB9 B0E4 ACBB B0E5 ACBC B0E6 ACBD B0E7 ACC1 B0E8 ACC4 B0E9 ACC8 B0EA ACCC B0EB ACD5 B0EC ACD7 B0ED ACE0 B0EE ACE1 B0EF ACE4 B0F0 ACE7 B0F1 ACE8 B0F2 ACEA B0F3 ACEC B0F4 ACEF B0F5 ACF0 B0F6 ACF1 B0F7 ACF3 B0F8 ACF5 B0F9 ACF6 B0FA ACFC B0FB ACFD B0FC AD00 B0FD AD04 B0FE AD06 B1A1 AD0C B1A2 AD0D B1A3 AD0F B1A4 AD11 B1A5 AD18 B1A6 AD1C B1A7 AD20 B1A8 AD29 B1A9 AD2C B1AA AD2D B1AB AD34 B1AC AD35 B1AD AD38 B1AE AD3C B1AF AD44 B1B0 AD45 B1B1 AD47 B1B2 AD49 B1B3 AD50 B1B4 AD54 B1B5 AD58 B1B6 AD61 B1B7 AD63 B1B8 AD6C B1B9 AD6D B1BA AD70 B1BB AD73 B1BC AD74 B1BD AD75 B1BE AD76 B1BF AD7B B1C0 AD7C B1C1 AD7D B1C2 AD7F B1C3 AD81 B1C4 AD82 B1C5 AD88 B1C6 AD89 B1C7 AD8C B1C8 AD90 B1C9 AD9C B1CA AD9D B1CB ADA4 B1CC ADB7 B1CD ADC0 B1CE ADC1 B1CF ADC4 B1D0 ADC8 B1D1 ADD0 B1D2 ADD1 B1D3 ADD3 B1D4 ADDC B1D5 ADE0 B1D6 ADE4 B1D7 ADF8 B1D8 ADF9 B1D9 ADFC B1DA ADFF B1DB AE00 B1DC AE01 B1DD AE08 B1DE AE09 B1DF AE0B B1E0 AE0D B1E1 AE14 B1E2 AE30 B1E3 AE31 B1E4 AE34 B1E5 AE37 B1E6 AE38 B1E7 AE3A B1E8 AE40 B1E9 AE41 B1EA AE43 B1EB AE45 B1EC AE46 B1ED AE4A B1EE AE4C B1EF AE4D B1F0 AE4E B1F1 AE50 B1F2 AE54 B1F3 AE56 B1F4 AE5C B1F5 AE5D B1F6 AE5F B1F7 AE60 B1F8 AE61 B1F9 AE65 B1FA AE68 B1FB AE69 B1FC AE6C B1FD AE70 B1FE AE78 B2A1 AE79 B2A2 AE7B B2A3 AE7C B2A4 AE7D B2A5 AE84 B2A6 AE85 B2A7 AE8C B2A8 AEBC B2A9 AEBD B2AA AEBE B2AB AEC0 B2AC AEC4 B2AD AECC B2AE AECD B2AF AECF B2B0 AED0 B2B1 AED1 B2B2 AED8 B2B3 AED9 B2B4 AEDC B2B5 AEE8 B2B6 AEEB B2B7 AEED B2B8 AEF4 B2B9 AEF8 B2BA AEFC B2BB AF07 B2BC AF08 B2BD AF0D B2BE AF10 B2BF AF2C B2C0 AF2D B2C1 AF30 B2C2 AF32 B2C3 AF34 B2C4 AF3C B2C5 AF3D B2C6 AF3F B2C7 AF41 B2C8 AF42 B2C9 AF43 B2CA AF48 B2CB AF49 B2CC AF50 B2CD AF5C B2CE AF5D B2CF AF64 B2D0 AF65 B2D1 AF79 B2D2 AF80 B2D3 AF84 B2D4 AF88 B2D5 AF90 B2D6 AF91 B2D7 AF95 B2D8 AF9C B2D9 AFB8 B2DA AFB9 B2DB AFBC B2DC AFC0 B2DD AFC7 B2DE AFC8 B2DF AFC9 B2E0 AFCB B2E1 AFCD B2E2 AFCE B2E3 AFD4 B2E4 AFDC B2E5 AFE8 B2E6 AFE9 B2E7 AFF0 B2E8 AFF1 B2E9 AFF4 B2EA AFF8 B2EB B000 B2EC B001 B2ED B004 B2EE B00C B2EF B010 B2F0 B014 B2F1 B01C B2F2 B01D B2F3 B028 B2F4 B044 B2F5 B045 B2F6 B048 B2F7 B04A B2F8 B04C B2F9 B04E B2FA B053 B2FB B054 B2FC B055 B2FD B057 B2FE B059 B3A1 B05D B3A2 B07C B3A3 B07D B3A4 B080 B3A5 B084 B3A6 B08C B3A7 B08D B3A8 B08F B3A9 B091 B3AA B098 B3AB B099 B3AC B09A B3AD B09C B3AE B09F B3AF B0A0 B3B0 B0A1 B3B1 B0A2 B3B2 B0A8 B3B3 B0A9 B3B4 B0AB B3B5 B0AC B3B6 B0AD B3B7 B0AE B3B8 B0AF B3B9 B0B1 B3BA B0B3 B3BB B0B4 B3BC B0B5 B3BD B0B8 B3BE B0BC B3BF B0C4 B3C0 B0C5 B3C1 B0C7 B3C2 B0C8 B3C3 B0C9 B3C4 B0D0 B3C5 B0D1 B3C6 B0D4 B3C7 B0D8 B3C8 B0E0 B3C9 B0E5 B3CA B108 B3CB B109 B3CC B10B B3CD B10C B3CE B110 B3CF B112 B3D0 B113 B3D1 B118 B3D2 B119 B3D3 B11B B3D4 B11C B3D5 B11D B3D6 B123 B3D7 B124 B3D8 B125 B3D9 B128 B3DA B12C B3DB B134 B3DC B135 B3DD B137 B3DE B138 B3DF B139 B3E0 B140 B3E1 B141 B3E2 B144 B3E3 B148 B3E4 B150 B3E5 B151 B3E6 B154 B3E7 B155 B3E8 B158 B3E9 B15C B3EA B160 B3EB B178 B3EC B179 B3ED B17C B3EE B180 B3EF B182 B3F0 B188 B3F1 B189 B3F2 B18B B3F3 B18D B3F4 B192 B3F5 B193 B3F6 B194 B3F7 B198 B3F8 B19C B3F9 B1A8 B3FA B1CC B3FB B1D0 B3FC B1D4 B3FD B1DC B3FE B1DD B4A1 B1DF B4A2 B1E8 B4A3 B1E9 B4A4 B1EC B4A5 B1F0 B4A6 B1F9 B4A7 B1FB B4A8 B1FD B4A9 B204 B4AA B205 B4AB B208 B4AC B20B B4AD B20C B4AE B214 B4AF B215 B4B0 B217 B4B1 B219 B4B2 B220 B4B3 B234 B4B4 B23C B4B5 B258 B4B6 B25C B4B7 B260 B4B8 B268 B4B9 B269 B4BA B274 B4BB B275 B4BC B27C B4BD B284 B4BE B285 B4BF B289 B4C0 B290 B4C1 B291 B4C2 B294 B4C3 B298 B4C4 B299 B4C5 B29A B4C6 B2A0 B4C7 B2A1 B4C8 B2A3 B4C9 B2A5 B4CA B2A6 B4CB B2AA B4CC B2AC B4CD B2B0 B4CE B2B4 B4CF B2C8 B4D0 B2C9 B4D1 B2CC B4D2 B2D0 B4D3 B2D2 B4D4 B2D8 B4D5 B2D9 B4D6 B2DB B4D7 B2DD B4D8 B2E2 B4D9 B2E4 B4DA B2E5 B4DB B2E6 B4DC B2E8 B4DD B2EB B4DE B2EC B4DF B2ED B4E0 B2EE B4E1 B2EF B4E2 B2F3 B4E3 B2F4 B4E4 B2F5 B4E5 B2F7 B4E6 B2F8 B4E7 B2F9 B4E8 B2FA B4E9 B2FB B4EA B2FF B4EB B300 B4EC B301 B4ED B304 B4EE B308 B4EF B310 B4F0 B311 B4F1 B313 B4F2 B314 B4F3 B315 B4F4 B31C B4F5 B354 B4F6 B355 B4F7 B356 B4F8 B358 B4F9 B35B B4FA B35C B4FB B35E B4FC B35F B4FD B364 B4FE B365 B5A1 B367 B5A2 B369 B5A3 B36B B5A4 B36E B5A5 B370 B5A6 B371 B5A7 B374 B5A8 B378 B5A9 B380 B5AA B381 B5AB B383 B5AC B384 B5AD B385 B5AE B38C B5AF B390 B5B0 B394 B5B1 B3A0 B5B2 B3A1 B5B3 B3A8 B5B4 B3AC B5B5 B3C4 B5B6 B3C5 B5B7 B3C8 B5B8 B3CB B5B9 B3CC B5BA B3CE B5BB B3D0 B5BC B3D4 B5BD B3D5 B5BE B3D7 B5BF B3D9 B5C0 B3DB B5C1 B3DD B5C2 B3E0 B5C3 B3E4 B5C4 B3E8 B5C5 B3FC B5C6 B410 B5C7 B418 B5C8 B41C B5C9 B420 B5CA B428 B5CB B429 B5CC B42B B5CD B434 B5CE B450 B5CF B451 B5D0 B454 B5D1 B458 B5D2 B460 B5D3 B461 B5D4 B463 B5D5 B465 B5D6 B46C B5D7 B480 B5D8 B488 B5D9 B49D B5DA B4A4 B5DB B4A8 B5DC B4AC B5DD B4B5 B5DE B4B7 B5DF B4B9 B5E0 B4C0 B5E1 B4C4 B5E2 B4C8 B5E3 B4D0 B5E4 B4D5 B5E5 B4DC B5E6 B4DD B5E7 B4E0 B5E8 B4E3 B5E9 B4E4 B5EA B4E6 B5EB B4EC B5EC B4ED B5ED B4EF B5EE B4F1 B5EF B4F8 B5F0 B514 B5F1 B515 B5F2 B518 B5F3 B51B B5F4 B51C B5F5 B524 B5F6 B525 B5F7 B527 B5F8 B528 B5F9 B529 B5FA B52A B5FB B530 B5FC B531 B5FD B534 B5FE B538 B6A1 B540 B6A2 B541 B6A3 B543 B6A4 B544 B6A5 B545 B6A6 B54B B6A7 B54C B6A8 B54D B6A9 B550 B6AA B554 B6AB B55C B6AC B55D B6AD B55F B6AE B560 B6AF B561 B6B0 B5A0 B6B1 B5A1 B6B2 B5A4 B6B3 B5A8 B6B4 B5AA B6B5 B5AB B6B6 B5B0 B6B7 B5B1 B6B8 B5B3 B6B9 B5B4 B6BA B5B5 B6BB B5BB B6BC B5BC B6BD B5BD B6BE B5C0 B6BF B5C4 B6C0 B5CC B6C1 B5CD B6C2 B5CF B6C3 B5D0 B6C4 B5D1 B6C5 B5D8 B6C6 B5EC B6C7 B610 B6C8 B611 B6C9 B614 B6CA B618 B6CB B625 B6CC B62C B6CD B634 B6CE B648 B6CF B664 B6D0 B668 B6D1 B69C B6D2 B69D B6D3 B6A0 B6D4 B6A4 B6D5 B6AB B6D6 B6AC B6D7 B6B1 B6D8 B6D4 B6D9 B6F0 B6DA B6F4 B6DB B6F8 B6DC B700 B6DD B701 B6DE B705 B6DF B728 B6E0 B729 B6E1 B72C B6E2 B72F B6E3 B730 B6E4 B738 B6E5 B739 B6E6 B73B B6E7 B744 B6E8 B748 B6E9 B74C B6EA B754 B6EB B755 B6EC B760 B6ED B764 B6EE B768 B6EF B770 B6F0 B771 B6F1 B773 B6F2 B775 B6F3 B77C B6F4 B77D B6F5 B780 B6F6 B784 B6F7 B78C B6F8 B78D B6F9 B78F B6FA B790 B6FB B791 B6FC B792 B6FD B796 B6FE B797 B7A1 B798 B7A2 B799 B7A3 B79C B7A4 B7A0 B7A5 B7A8 B7A6 B7A9 B7A7 B7AB B7A8 B7AC B7A9 B7AD B7AA B7B4 B7AB B7B5 B7AC B7B8 B7AD B7C7 B7AE B7C9 B7AF B7EC B7B0 B7ED B7B1 B7F0 B7B2 B7F4 B7B3 B7FC B7B4 B7FD B7B5 B7FF B7B6 B800 B7B7 B801 B7B8 B807 B7B9 B808 B7BA B809 B7BB B80C B7BC B810 B7BD B818 B7BE B819 B7BF B81B B7C0 B81D B7C1 B824 B7C2 B825 B7C3 B828 B7C4 B82C B7C5 B834 B7C6 B835 B7C7 B837 B7C8 B838 B7C9 B839 B7CA B840 B7CB B844 B7CC B851 B7CD B853 B7CE B85C B7CF B85D B7D0 B860 B7D1 B864 B7D2 B86C B7D3 B86D B7D4 B86F B7D5 B871 B7D6 B878 B7D7 B87C B7D8 B88D B7D9 B8A8 B7DA B8B0 B7DB B8B4 B7DC B8B8 B7DD B8C0 B7DE B8C1 B7DF B8C3 B7E0 B8C5 B7E1 B8CC B7E2 B8D0 B7E3 B8D4 B7E4 B8DD B7E5 B8DF B7E6 B8E1 B7E7 B8E8 B7E8 B8E9 B7E9 B8EC B7EA B8F0 B7EB B8F8 B7EC B8F9 B7ED B8FB B7EE B8FD B7EF B904 B7F0 B918 B7F1 B920 B7F2 B93C B7F3 B93D B7F4 B940 B7F5 B944 B7F6 B94C B7F7 B94F B7F8 B951 B7F9 B958 B7FA B959 B7FB B95C B7FC B960 B7FD B968 B7FE B969 B8A1 B96B B8A2 B96D B8A3 B974 B8A4 B975 B8A5 B978 B8A6 B97C B8A7 B984 B8A8 B985 B8A9 B987 B8AA B989 B8AB B98A B8AC B98D B8AD B98E B8AE B9AC B8AF B9AD B8B0 B9B0 B8B1 B9B4 B8B2 B9BC B8B3 B9BD B8B4 B9BF B8B5 B9C1 B8B6 B9C8 B8B7 B9C9 B8B8 B9CC B8B9 B9CE B8BA B9CF B8BB B9D0 B8BC B9D1 B8BD B9D2 B8BE B9D8 B8BF B9D9 B8C0 B9DB B8C1 B9DD B8C2 B9DE B8C3 B9E1 B8C4 B9E3 B8C5 B9E4 B8C6 B9E5 B8C7 B9E8 B8C8 B9EC B8C9 B9F4 B8CA B9F5 B8CB B9F7 B8CC B9F8 B8CD B9F9 B8CE B9FA B8CF BA00 B8D0 BA01 B8D1 BA08 B8D2 BA15 B8D3 BA38 B8D4 BA39 B8D5 BA3C B8D6 BA40 B8D7 BA42 B8D8 BA48 B8D9 BA49 B8DA BA4B B8DB BA4D B8DC BA4E B8DD BA53 B8DE BA54 B8DF BA55 B8E0 BA58 B8E1 BA5C B8E2 BA64 B8E3 BA65 B8E4 BA67 B8E5 BA68 B8E6 BA69 B8E7 BA70 B8E8 BA71 B8E9 BA74 B8EA BA78 B8EB BA83 B8EC BA84 B8ED BA85 B8EE BA87 B8EF BA8C B8F0 BAA8 B8F1 BAA9 B8F2 BAAB B8F3 BAAC B8F4 BAB0 B8F5 BAB2 B8F6 BAB8 B8F7 BAB9 B8F8 BABB B8F9 BABD B8FA BAC4 B8FB BAC8 B8FC BAD8 B8FD BAD9 B8FE BAFC B9A1 BB00 B9A2 BB04 B9A3 BB0D B9A4 BB0F B9A5 BB11 B9A6 BB18 B9A7 BB1C B9A8 BB20 B9A9 BB29 B9AA BB2B B9AB BB34 B9AC BB35 B9AD BB36 B9AE BB38 B9AF BB3B B9B0 BB3C B9B1 BB3D B9B2 BB3E B9B3 BB44 B9B4 BB45 B9B5 BB47 B9B6 BB49 B9B7 BB4D B9B8 BB4F B9B9 BB50 B9BA BB54 B9BB BB58 B9BC BB61 B9BD BB63 B9BE BB6C B9BF BB88 B9C0 BB8C B9C1 BB90 B9C2 BBA4 B9C3 BBA8 B9C4 BBAC B9C5 BBB4 B9C6 BBB7 B9C7 BBC0 B9C8 BBC4 B9C9 BBC8 B9CA BBD0 B9CB BBD3 B9CC BBF8 B9CD BBF9 B9CE BBFC B9CF BBFF B9D0 BC00 B9D1 BC02 B9D2 BC08 B9D3 BC09 B9D4 BC0B B9D5 BC0C B9D6 BC0D B9D7 BC0F B9D8 BC11 B9D9 BC14 B9DA BC15 B9DB BC16 B9DC BC17 B9DD BC18 B9DE BC1B B9DF BC1C B9E0 BC1D B9E1 BC1E B9E2 BC1F B9E3 BC24 B9E4 BC25 B9E5 BC27 B9E6 BC29 B9E7 BC2D B9E8 BC30 B9E9 BC31 B9EA BC34 B9EB BC38 B9EC BC40 B9ED BC41 B9EE BC43 B9EF BC44 B9F0 BC45 B9F1 BC49 B9F2 BC4C B9F3 BC4D B9F4 BC50 B9F5 BC5D B9F6 BC84 B9F7 BC85 B9F8 BC88 B9F9 BC8B B9FA BC8C B9FB BC8E B9FC BC94 B9FD BC95 B9FE BC97 BAA1 BC99 BAA2 BC9A BAA3 BCA0 BAA4 BCA1 BAA5 BCA4 BAA6 BCA7 BAA7 BCA8 BAA8 BCB0 BAA9 BCB1 BAAA BCB3 BAAB BCB4 BAAC BCB5 BAAD BCBC BAAE BCBD BAAF BCC0 BAB0 BCC4 BAB1 BCCD BAB2 BCCF BAB3 BCD0 BAB4 BCD1 BAB5 BCD5 BAB6 BCD8 BAB7 BCDC BAB8 BCF4 BAB9 BCF5 BABA BCF6 BABB BCF8 BABC BCFC BABD BD04 BABE BD05 BABF BD07 BAC0 BD09 BAC1 BD10 BAC2 BD14 BAC3 BD24 BAC4 BD2C BAC5 BD40 BAC6 BD48 BAC7 BD49 BAC8 BD4C BAC9 BD50 BACA BD58 BACB BD59 BACC BD64 BACD BD68 BACE BD80 BACF BD81 BAD0 BD84 BAD1 BD87 BAD2 BD88 BAD3 BD89 BAD4 BD8A BAD5 BD90 BAD6 BD91 BAD7 BD93 BAD8 BD95 BAD9 BD99 BADA BD9A BADB BD9C BADC BDA4 BADD BDB0 BADE BDB8 BADF BDD4 BAE0 BDD5 BAE1 BDD8 BAE2 BDDC BAE3 BDE9 BAE4 BDF0 BAE5 BDF4 BAE6 BDF8 BAE7 BE00 BAE8 BE03 BAE9 BE05 BAEA BE0C BAEB BE0D BAEC BE10 BAED BE14 BAEE BE1C BAEF BE1D BAF0 BE1F BAF1 BE44 BAF2 BE45 BAF3 BE48 BAF4 BE4C BAF5 BE4E BAF6 BE54 BAF7 BE55 BAF8 BE57 BAF9 BE59 BAFA BE5A BAFB BE5B BAFC BE60 BAFD BE61 BAFE BE64 BBA1 BE68 BBA2 BE6A BBA3 BE70 BBA4 BE71 BBA5 BE73 BBA6 BE74 BBA7 BE75 BBA8 BE7B BBA9 BE7C BBAA BE7D BBAB BE80 BBAC BE84 BBAD BE8C BBAE BE8D BBAF BE8F BBB0 BE90 BBB1 BE91 BBB2 BE98 BBB3 BE99 BBB4 BEA8 BBB5 BED0 BBB6 BED1 BBB7 BED4 BBB8 BED7 BBB9 BED8 BBBA BEE0 BBBB BEE3 BBBC BEE4 BBBD BEE5 BBBE BEEC BBBF BF01 BBC0 BF08 BBC1 BF09 BBC2 BF18 BBC3 BF19 BBC4 BF1B BBC5 BF1C BBC6 BF1D BBC7 BF40 BBC8 BF41 BBC9 BF44 BBCA BF48 BBCB BF50 BBCC BF51 BBCD BF55 BBCE BF94 BBCF BFB0 BBD0 BFC5 BBD1 BFCC BBD2 BFCD BBD3 BFD0 BBD4 BFD4 BBD5 BFDC BBD6 BFDF BBD7 BFE1 BBD8 C03C BBD9 C051 BBDA C058 BBDB C05C BBDC C060 BBDD C068 BBDE C069 BBDF C090 BBE0 C091 BBE1 C094 BBE2 C098 BBE3 C0A0 BBE4 C0A1 BBE5 C0A3 BBE6 C0A5 BBE7 C0AC BBE8 C0AD BBE9 C0AF BBEA C0B0 BBEB C0B3 BBEC C0B4 BBED C0B5 BBEE C0B6 BBEF C0BC BBF0 C0BD BBF1 C0BF BBF2 C0C0 BBF3 C0C1 BBF4 C0C5 BBF5 C0C8 BBF6 C0C9 BBF7 C0CC BBF8 C0D0 BBF9 C0D8 BBFA C0D9 BBFB C0DB BBFC C0DC BBFD C0DD BBFE C0E4 BCA1 C0E5 BCA2 C0E8 BCA3 C0EC BCA4 C0F4 BCA5 C0F5 BCA6 C0F7 BCA7 C0F9 BCA8 C100 BCA9 C104 BCAA C108 BCAB C110 BCAC C115 BCAD C11C BCAE C11D BCAF C11E BCB0 C11F BCB1 C120 BCB2 C123 BCB3 C124 BCB4 C126 BCB5 C127 BCB6 C12C BCB7 C12D BCB8 C12F BCB9 C130 BCBA C131 BCBB C136 BCBC C138 BCBD C139 BCBE C13C BCBF C140 BCC0 C148 BCC1 C149 BCC2 C14B BCC3 C14C BCC4 C14D BCC5 C154 BCC6 C155 BCC7 C158 BCC8 C15C BCC9 C164 BCCA C165 BCCB C167 BCCC C168 BCCD C169 BCCE C170 BCCF C174 BCD0 C178 BCD1 C185 BCD2 C18C BCD3 C18D BCD4 C18E BCD5 C190 BCD6 C194 BCD7 C196 BCD8 C19C BCD9 C19D BCDA C19F BCDB C1A1 BCDC C1A5 BCDD C1A8 BCDE C1A9 BCDF C1AC BCE0 C1B0 BCE1 C1BD BCE2 C1C4 BCE3 C1C8 BCE4 C1CC BCE5 C1D4 BCE6 C1D7 BCE7 C1D8 BCE8 C1E0 BCE9 C1E4 BCEA C1E8 BCEB C1F0 BCEC C1F1 BCED C1F3 BCEE C1FC BCEF C1FD BCF0 C200 BCF1 C204 BCF2 C20C BCF3 C20D BCF4 C20F BCF5 C211 BCF6 C218 BCF7 C219 BCF8 C21C BCF9 C21F BCFA C220 BCFB C228 BCFC C229 BCFD C22B BCFE C22D BDA1 C22F BDA2 C231 BDA3 C232 BDA4 C234 BDA5 C248 BDA6 C250 BDA7 C251 BDA8 C254 BDA9 C258 BDAA C260 BDAB C265 BDAC C26C BDAD C26D BDAE C270 BDAF C274 BDB0 C27C BDB1 C27D BDB2 C27F BDB3 C281 BDB4 C288 BDB5 C289 BDB6 C290 BDB7 C298 BDB8 C29B BDB9 C29D BDBA C2A4 BDBB C2A5 BDBC C2A8 BDBD C2AC BDBE C2AD BDBF C2B4 BDC0 C2B5 BDC1 C2B7 BDC2 C2B9 BDC3 C2DC BDC4 C2DD BDC5 C2E0 BDC6 C2E3 BDC7 C2E4 BDC8 C2EB BDC9 C2EC BDCA C2ED BDCB C2EF BDCC C2F1 BDCD C2F6 BDCE C2F8 BDCF C2F9 BDD0 C2FB BDD1 C2FC BDD2 C300 BDD3 C308 BDD4 C309 BDD5 C30C BDD6 C30D BDD7 C313 BDD8 C314 BDD9 C315 BDDA C318 BDDB C31C BDDC C324 BDDD C325 BDDE C328 BDDF C329 BDE0 C345 BDE1 C368 BDE2 C369 BDE3 C36C BDE4 C370 BDE5 C372 BDE6 C378 BDE7 C379 BDE8 C37C BDE9 C37D BDEA C384 BDEB C388 BDEC C38C BDED C3C0 BDEE C3D8 BDEF C3D9 BDF0 C3DC BDF1 C3DF BDF2 C3E0 BDF3 C3E2 BDF4 C3E8 BDF5 C3E9 BDF6 C3ED BDF7 C3F4 BDF8 C3F5 BDF9 C3F8 BDFA C408 BDFB C410 BDFC C424 BDFD C42C BDFE C430 BEA1 C434 BEA2 C43C BEA3 C43D BEA4 C448 BEA5 C464 BEA6 C465 BEA7 C468 BEA8 C46C BEA9 C474 BEAA C475 BEAB C479 BEAC C480 BEAD C494 BEAE C49C BEAF C4B8 BEB0 C4BC BEB1 C4E9 BEB2 C4F0 BEB3 C4F1 BEB4 C4F4 BEB5 C4F8 BEB6 C4FA BEB7 C4FF BEB8 C500 BEB9 C501 BEBA C50C BEBB C510 BEBC C514 BEBD C51C BEBE C528 BEBF C529 BEC0 C52C BEC1 C530 BEC2 C538 BEC3 C539 BEC4 C53B BEC5 C53D BEC6 C544 BEC7 C545 BEC8 C548 BEC9 C549 BECA C54A BECB C54C BECC C54D BECD C54E BECE C553 BECF C554 BED0 C555 BED1 C557 BED2 C558 BED3 C559 BED4 C55D BED5 C55E BED6 C560 BED7 C561 BED8 C564 BED9 C568 BEDA C570 BEDB C571 BEDC C573 BEDD C574 BEDE C575 BEDF C57C BEE0 C57D BEE1 C580 BEE2 C584 BEE3 C587 BEE4 C58C BEE5 C58D BEE6 C58F BEE7 C591 BEE8 C595 BEE9 C597 BEEA C598 BEEB C59C BEEC C5A0 BEED C5A9 BEEE C5B4 BEEF C5B5 BEF0 C5B8 BEF1 C5B9 BEF2 C5BB BEF3 C5BC BEF4 C5BD BEF5 C5BE BEF6 C5C4 BEF7 C5C5 BEF8 C5C6 BEF9 C5C7 BEFA C5C8 BEFB C5C9 BEFC C5CA BEFD C5CC BEFE C5CE BFA1 C5D0 BFA2 C5D1 BFA3 C5D4 BFA4 C5D8 BFA5 C5E0 BFA6 C5E1 BFA7 C5E3 BFA8 C5E5 BFA9 C5EC BFAA C5ED BFAB C5EE BFAC C5F0 BFAD C5F4 BFAE C5F6 BFAF C5F7 BFB0 C5FC BFB1 C5FD BFB2 C5FE BFB3 C5FF BFB4 C600 BFB5 C601 BFB6 C605 BFB7 C606 BFB8 C607 BFB9 C608 BFBA C60C BFBB C610 BFBC C618 BFBD C619 BFBE C61B BFBF C61C BFC0 C624 BFC1 C625 BFC2 C628 BFC3 C62C BFC4 C62D BFC5 C62E BFC6 C630 BFC7 C633 BFC8 C634 BFC9 C635 BFCA C637 BFCB C639 BFCC C63B BFCD C640 BFCE C641 BFCF C644 BFD0 C648 BFD1 C650 BFD2 C651 BFD3 C653 BFD4 C654 BFD5 C655 BFD6 C65C BFD7 C65D BFD8 C660 BFD9 C66C BFDA C66F BFDB C671 BFDC C678 BFDD C679 BFDE C67C BFDF C680 BFE0 C688 BFE1 C689 BFE2 C68B BFE3 C68D BFE4 C694 BFE5 C695 BFE6 C698 BFE7 C69C BFE8 C6A4 BFE9 C6A5 BFEA C6A7 BFEB C6A9 BFEC C6B0 BFED C6B1 BFEE C6B4 BFEF C6B8 BFF0 C6B9 BFF1 C6BA BFF2 C6C0 BFF3 C6C1 BFF4 C6C3 BFF5 C6C5 BFF6 C6CC BFF7 C6CD BFF8 C6D0 BFF9 C6D4 BFFA C6DC BFFB C6DD BFFC C6E0 BFFD C6E1 BFFE C6E8 C0A1 C6E9 C0A2 C6EC C0A3 C6F0 C0A4 C6F8 C0A5 C6F9 C0A6 C6FD C0A7 C704 C0A8 C705 C0A9 C708 C0AA C70C C0AB C714 C0AC C715 C0AD C717 C0AE C719 C0AF C720 C0B0 C721 C0B1 C724 C0B2 C728 C0B3 C730 C0B4 C731 C0B5 C733 C0B6 C735 C0B7 C737 C0B8 C73C C0B9 C73D C0BA C740 C0BB C744 C0BC C74A C0BD C74C C0BE C74D C0BF C74F C0C0 C751 C0C1 C752 C0C2 C753 C0C3 C754 C0C4 C755 C0C5 C756 C0C6 C757 C0C7 C758 C0C8 C75C C0C9 C760 C0CA C768 C0CB C76B C0CC C774 C0CD C775 C0CE C778 C0CF C77C C0D0 C77D C0D1 C77E C0D2 C783 C0D3 C784 C0D4 C785 C0D5 C787 C0D6 C788 C0D7 C789 C0D8 C78A C0D9 C78E C0DA C790 C0DB C791 C0DC C794 C0DD C796 C0DE C797 C0DF C798 C0E0 C79A C0E1 C7A0 C0E2 C7A1 C0E3 C7A3 C0E4 C7A4 C0E5 C7A5 C0E6 C7A6 C0E7 C7AC C0E8 C7AD C0E9 C7B0 C0EA C7B4 C0EB C7BC C0EC C7BD C0ED C7BF C0EE C7C0 C0EF C7C1 C0F0 C7C8 C0F1 C7C9 C0F2 C7CC C0F3 C7CE C0F4 C7D0 C0F5 C7D8 C0F6 C7DD C0F7 C7E4 C0F8 C7E8 C0F9 C7EC C0FA C800 C0FB C801 C0FC C804 C0FD C808 C0FE C80A C1A1 C810 C1A2 C811 C1A3 C813 C1A4 C815 C1A5 C816 C1A6 C81C C1A7 C81D C1A8 C820 C1A9 C824 C1AA C82C C1AB C82D C1AC C82F C1AD C831 C1AE C838 C1AF C83C C1B0 C840 C1B1 C848 C1B2 C849 C1B3 C84C C1B4 C84D C1B5 C854 C1B6 C870 C1B7 C871 C1B8 C874 C1B9 C878 C1BA C87A C1BB C880 C1BC C881 C1BD C883 C1BE C885 C1BF C886 C1C0 C887 C1C1 C88B C1C2 C88C C1C3 C88D C1C4 C894 C1C5 C89D C1C6 C89F C1C7 C8A1 C1C8 C8A8 C1C9 C8BC C1CA C8BD C1CB C8C4 C1CC C8C8 C1CD C8CC C1CE C8D4 C1CF C8D5 C1D0 C8D7 C1D1 C8D9 C1D2 C8E0 C1D3 C8E1 C1D4 C8E4 C1D5 C8F5 C1D6 C8FC C1D7 C8FD C1D8 C900 C1D9 C904 C1DA C905 C1DB C906 C1DC C90C C1DD C90D C1DE C90F C1DF C911 C1E0 C918 C1E1 C92C C1E2 C934 C1E3 C950 C1E4 C951 C1E5 C954 C1E6 C958 C1E7 C960 C1E8 C961 C1E9 C963 C1EA C96C C1EB C970 C1EC C974 C1ED C97C C1EE C988 C1EF C989 C1F0 C98C C1F1 C990 C1F2 C998 C1F3 C999 C1F4 C99B C1F5 C99D C1F6 C9C0 C1F7 C9C1 C1F8 C9C4 C1F9 C9C7 C1FA C9C8 C1FB C9CA C1FC C9D0 C1FD C9D1 C1FE C9D3 C2A1 C9D5 C2A2 C9D6 C2A3 C9D9 C2A4 C9DA C2A5 C9DC C2A6 C9DD C2A7 C9E0 C2A8 C9E2 C2A9 C9E4 C2AA C9E7 C2AB C9EC C2AC C9ED C2AD C9EF C2AE C9F0 C2AF C9F1 C2B0 C9F8 C2B1 C9F9 C2B2 C9FC C2B3 CA00 C2B4 CA08 C2B5 CA09 C2B6 CA0B C2B7 CA0C C2B8 CA0D C2B9 CA14 C2BA CA18 C2BB CA29 C2BC CA4C C2BD CA4D C2BE CA50 C2BF CA54 C2C0 CA5C C2C1 CA5D C2C2 CA5F C2C3 CA60 C2C4 CA61 C2C5 CA68 C2C6 CA7D C2C7 CA84 C2C8 CA98 C2C9 CABC C2CA CABD C2CB CAC0 C2CC CAC4 C2CD CACC C2CE CACD C2CF CACF C2D0 CAD1 C2D1 CAD3 C2D2 CAD8 C2D3 CAD9 C2D4 CAE0 C2D5 CAEC C2D6 CAF4 C2D7 CB08 C2D8 CB10 C2D9 CB14 C2DA CB18 C2DB CB20 C2DC CB21 C2DD CB41 C2DE CB48 C2DF CB49 C2E0 CB4C C2E1 CB50 C2E2 CB58 C2E3 CB59 C2E4 CB5D C2E5 CB64 C2E6 CB78 C2E7 CB79 C2E8 CB9C C2E9 CBB8 C2EA CBD4 C2EB CBE4 C2EC CBE7 C2ED CBE9 C2EE CC0C C2EF CC0D C2F0 CC10 C2F1 CC14 C2F2 CC1C C2F3 CC1D C2F4 CC21 C2F5 CC22 C2F6 CC27 C2F7 CC28 C2F8 CC29 C2F9 CC2C C2FA CC2E C2FB CC30 C2FC CC38 C2FD CC39 C2FE CC3B C3A1 CC3C C3A2 CC3D C3A3 CC3E C3A4 CC44 C3A5 CC45 C3A6 CC48 C3A7 CC4C C3A8 CC54 C3A9 CC55 C3AA CC57 C3AB CC58 C3AC CC59 C3AD CC60 C3AE CC64 C3AF CC66 C3B0 CC68 C3B1 CC70 C3B2 CC75 C3B3 CC98 C3B4 CC99 C3B5 CC9C C3B6 CCA0 C3B7 CCA8 C3B8 CCA9 C3B9 CCAB C3BA CCAC C3BB CCAD C3BC CCB4 C3BD CCB5 C3BE CCB8 C3BF CCBC C3C0 CCC4 C3C1 CCC5 C3C2 CCC7 C3C3 CCC9 C3C4 CCD0 C3C5 CCD4 C3C6 CCE4 C3C7 CCEC C3C8 CCF0 C3C9 CD01 C3CA CD08 C3CB CD09 C3CC CD0C C3CD CD10 C3CE CD18 C3CF CD19 C3D0 CD1B C3D1 CD1D C3D2 CD24 C3D3 CD28 C3D4 CD2C C3D5 CD39 C3D6 CD5C C3D7 CD60 C3D8 CD64 C3D9 CD6C C3DA CD6D C3DB CD6F C3DC CD71 C3DD CD78 C3DE CD88 C3DF CD94 C3E0 CD95 C3E1 CD98 C3E2 CD9C C3E3 CDA4 C3E4 CDA5 C3E5 CDA7 C3E6 CDA9 C3E7 CDB0 C3E8 CDC4 C3E9 CDCC C3EA CDD0 C3EB CDE8 C3EC CDEC C3ED CDF0 C3EE CDF8 C3EF CDF9 C3F0 CDFB C3F1 CDFD C3F2 CE04 C3F3 CE08 C3F4 CE0C C3F5 CE14 C3F6 CE19 C3F7 CE20 C3F8 CE21 C3F9 CE24 C3FA CE28 C3FB CE30 C3FC CE31 C3FD CE33 C3FE CE35 C4A1 CE58 C4A2 CE59 C4A3 CE5C C4A4 CE5F C4A5 CE60 C4A6 CE61 C4A7 CE68 C4A8 CE69 C4A9 CE6B C4AA CE6D C4AB CE74 C4AC CE75 C4AD CE78 C4AE CE7C C4AF CE84 C4B0 CE85 C4B1 CE87 C4B2 CE89 C4B3 CE90 C4B4 CE91 C4B5 CE94 C4B6 CE98 C4B7 CEA0 C4B8 CEA1 C4B9 CEA3 C4BA CEA4 C4BB CEA5 C4BC CEAC C4BD CEAD C4BE CEC1 C4BF CEE4 C4C0 CEE5 C4C1 CEE8 C4C2 CEEB C4C3 CEEC C4C4 CEF4 C4C5 CEF5 C4C6 CEF7 C4C7 CEF8 C4C8 CEF9 C4C9 CF00 C4CA CF01 C4CB CF04 C4CC CF08 C4CD CF10 C4CE CF11 C4CF CF13 C4D0 CF15 C4D1 CF1C C4D2 CF20 C4D3 CF24 C4D4 CF2C C4D5 CF2D C4D6 CF2F C4D7 CF30 C4D8 CF31 C4D9 CF38 C4DA CF54 C4DB CF55 C4DC CF58 C4DD CF5C C4DE CF64 C4DF CF65 C4E0 CF67 C4E1 CF69 C4E2 CF70 C4E3 CF71 C4E4 CF74 C4E5 CF78 C4E6 CF80 C4E7 CF85 C4E8 CF8C C4E9 CFA1 C4EA CFA8 C4EB CFB0 C4EC CFC4 C4ED CFE0 C4EE CFE1 C4EF CFE4 C4F0 CFE8 C4F1 CFF0 C4F2 CFF1 C4F3 CFF3 C4F4 CFF5 C4F5 CFFC C4F6 D000 C4F7 D004 C4F8 D011 C4F9 D018 C4FA D02D C4FB D034 C4FC D035 C4FD D038 C4FE D03C C5A1 D044 C5A2 D045 C5A3 D047 C5A4 D049 C5A5 D050 C5A6 D054 C5A7 D058 C5A8 D060 C5A9 D06C C5AA D06D C5AB D070 C5AC D074 C5AD D07C C5AE D07D C5AF D081 C5B0 D0A4 C5B1 D0A5 C5B2 D0A8 C5B3 D0AC C5B4 D0B4 C5B5 D0B5 C5B6 D0B7 C5B7 D0B9 C5B8 D0C0 C5B9 D0C1 C5BA D0C4 C5BB D0C8 C5BC D0C9 C5BD D0D0 C5BE D0D1 C5BF D0D3 C5C0 D0D4 C5C1 D0D5 C5C2 D0DC C5C3 D0DD C5C4 D0E0 C5C5 D0E4 C5C6 D0EC C5C7 D0ED C5C8 D0EF C5C9 D0F0 C5CA D0F1 C5CB D0F8 C5CC D10D C5CD D130 C5CE D131 C5CF D134 C5D0 D138 C5D1 D13A C5D2 D140 C5D3 D141 C5D4 D143 C5D5 D144 C5D6 D145 C5D7 D14C C5D8 D14D C5D9 D150 C5DA D154 C5DB D15C C5DC D15D C5DD D15F C5DE D161 C5DF D168 C5E0 D16C C5E1 D17C C5E2 D184 C5E3 D188 C5E4 D1A0 C5E5 D1A1 C5E6 D1A4 C5E7 D1A8 C5E8 D1B0 C5E9 D1B1 C5EA D1B3 C5EB D1B5 C5EC D1BA C5ED D1BC C5EE D1C0 C5EF D1D8 C5F0 D1F4 C5F1 D1F8 C5F2 D207 C5F3 D209 C5F4 D210 C5F5 D22C C5F6 D22D C5F7 D230 C5F8 D234 C5F9 D23C C5FA D23D C5FB D23F C5FC D241 C5FD D248 C5FE D25C C6A1 D264 C6A2 D280 C6A3 D281 C6A4 D284 C6A5 D288 C6A6 D290 C6A7 D291 C6A8 D295 C6A9 D29C C6AA D2A0 C6AB D2A4 C6AC D2AC C6AD D2B1 C6AE D2B8 C6AF D2B9 C6B0 D2BC C6B1 D2BF C6B2 D2C0 C6B3 D2C2 C6B4 D2C8 C6B5 D2C9 C6B6 D2CB C6B7 D2D4 C6B8 D2D8 C6B9 D2DC C6BA D2E4 C6BB D2E5 C6BC D2F0 C6BD D2F1 C6BE D2F4 C6BF D2F8 C6C0 D300 C6C1 D301 C6C2 D303 C6C3 D305 C6C4 D30C C6C5 D30D C6C6 D30E C6C7 D310 C6C8 D314 C6C9 D316 C6CA D31C C6CB D31D C6CC D31F C6CD D320 C6CE D321 C6CF D325 C6D0 D328 C6D1 D329 C6D2 D32C C6D3 D330 C6D4 D338 C6D5 D339 C6D6 D33B C6D7 D33C C6D8 D33D C6D9 D344 C6DA D345 C6DB D37C C6DC D37D C6DD D380 C6DE D384 C6DF D38C C6E0 D38D C6E1 D38F C6E2 D390 C6E3 D391 C6E4 D398 C6E5 D399 C6E6 D39C C6E7 D3A0 C6E8 D3A8 C6E9 D3A9 C6EA D3AB C6EB D3AD C6EC D3B4 C6ED D3B8 C6EE D3BC C6EF D3C4 C6F0 D3C5 C6F1 D3C8 C6F2 D3C9 C6F3 D3D0 C6F4 D3D8 C6F5 D3E1 C6F6 D3E3 C6F7 D3EC C6F8 D3ED C6F9 D3F0 C6FA D3F4 C6FB D3FC C6FC D3FD C6FD D3FF C6FE D401 C7A1 D408 C7A2 D41D C7A3 D440 C7A4 D444 C7A5 D45C C7A6 D460 C7A7 D464 C7A8 D46D C7A9 D46F C7AA D478 C7AB D479 C7AC D47C C7AD D47F C7AE D480 C7AF D482 C7B0 D488 C7B1 D489 C7B2 D48B C7B3 D48D C7B4 D494 C7B5 D4A9 C7B6 D4CC C7B7 D4D0 C7B8 D4D4 C7B9 D4DC C7BA D4DF C7BB D4E8 C7BC D4EC C7BD D4F0 C7BE D4F8 C7BF D4FB C7C0 D4FD C7C1 D504 C7C2 D508 C7C3 D50C C7C4 D514 C7C5 D515 C7C6 D517 C7C7 D53C C7C8 D53D C7C9 D540 C7CA D544 C7CB D54C C7CC D54D C7CD D54F C7CE D551 C7CF D558 C7D0 D559 C7D1 D55C C7D2 D560 C7D3 D565 C7D4 D568 C7D5 D569 C7D6 D56B C7D7 D56D C7D8 D574 C7D9 D575 C7DA D578 C7DB D57C C7DC D584 C7DD D585 C7DE D587 C7DF D588 C7E0 D589 C7E1 D590 C7E2 D5A5 C7E3 D5C8 C7E4 D5C9 C7E5 D5CC C7E6 D5D0 C7E7 D5D2 C7E8 D5D8 C7E9 D5D9 C7EA D5DB C7EB D5DD C7EC D5E4 C7ED D5E5 C7EE D5E8 C7EF D5EC C7F0 D5F4 C7F1 D5F5 C7F2 D5F7 C7F3 D5F9 C7F4 D600 C7F5 D601 C7F6 D604 C7F7 D608 C7F8 D610 C7F9 D611 C7FA D613 C7FB D614 C7FC D615 C7FD D61C C7FE D620 C8A1 D624 C8A2 D62D C8A3 D638 C8A4 D639 C8A5 D63C C8A6 D640 C8A7 D645 C8A8 D648 C8A9 D649 C8AA D64B C8AB D64D C8AC D651 C8AD D654 C8AE D655 C8AF D658 C8B0 D65C C8B1 D667 C8B2 D669 C8B3 D670 C8B4 D671 C8B5 D674 C8B6 D683 C8B7 D685 C8B8 D68C C8B9 D68D C8BA D690 C8BB D694 C8BC D69D C8BD D69F C8BE D6A1 C8BF D6A8 C8C0 D6AC C8C1 D6B0 C8C2 D6B9 C8C3 D6BB C8C4 D6C4 C8C5 D6C5 C8C6 D6C8 C8C7 D6CC C8C8 D6D1 C8C9 D6D4 C8CA D6D7 C8CB D6D9 C8CC D6E0 C8CD D6E4 C8CE D6E8 C8CF D6F0 C8D0 D6F5 C8D1 D6FC C8D2 D6FD C8D3 D700 C8D4 D704 C8D5 D711 C8D6 D718 C8D7 D719 C8D8 D71C C8D9 D720 C8DA D728 C8DB D729 C8DC D72B C8DD D72D C8DE D734 C8DF D735 C8E0 D738 C8E1 D73C C8E2 D744 C8E3 D747 C8E4 D749 C8E5 D750 C8E6 D751 C8E7 D754 C8E8 D756 C8E9 D757 C8EA D758 C8EB D759 C8EC D760 C8ED D761 C8EE D763 C8EF D765 C8F0 D769 C8F1 D76C C8F2 D770 C8F3 D774 C8F4 D77C C8F5 D77D C8F6 D781 C8F7 D788 C8F8 D789 C8F9 D78C C8FA D790 C8FB D798 C8FC D799 C8FD D79B C8FE D79D CAA1 4F3D CAA2 4F73 CAA3 5047 CAA4 50F9 CAA5 52A0 CAA6 53EF CAA7 5475 CAA8 54E5 CAA9 5609 CAAA 5AC1 CAAB 5BB6 CAAC 6687 CAAD 67B6 CAAE 67B7 CAAF 67EF CAB0 6B4C CAB1 73C2 CAB2 75C2 CAB3 7A3C CAB4 82DB CAB5 8304 CAB6 8857 CAB7 8888 CAB8 8A36 CAB9 8CC8 CABA 8DCF CABB 8EFB CABC 8FE6 CABD 99D5 CABE 523B CABF 5374 CAC0 5404 CAC1 606A CAC2 6164 CAC3 6BBC CAC4 73CF CAC5 811A CAC6 89BA CAC7 89D2 CAC8 95A3 CAC9 4F83 CACA 520A CACB 58BE CACC 5978 CACD 59E6 CACE 5E72 CACF 5E79 CAD0 61C7 CAD1 63C0 CAD2 6746 CAD3 67EC CAD4 687F CAD5 6F97 CAD6 764E CAD7 770B CAD8 78F5 CAD9 7A08 CADA 7AFF CADB 7C21 CADC 809D CADD 826E CADE 8271 CADF 8AEB CAE0 9593 CAE1 4E6B CAE2 559D CAE3 66F7 CAE4 6E34 CAE5 78A3 CAE6 7AED CAE7 845B CAE8 8910 CAE9 874E CAEA 97A8 CAEB 52D8 CAEC 574E CAED 582A CAEE 5D4C CAEF 611F CAF0 61BE CAF1 6221 CAF2 6562 CAF3 67D1 CAF4 6A44 CAF5 6E1B CAF6 7518 CAF7 75B3 CAF8 76E3 CAF9 77B0 CAFA 7D3A CAFB 90AF CAFC 9451 CAFD 9452 CAFE 9F95 CBA1 5323 CBA2 5CAC CBA3 7532 CBA4 80DB CBA5 9240 CBA6 9598 CBA7 525B CBA8 5808 CBA9 59DC CBAA 5CA1 CBAB 5D17 CBAC 5EB7 CBAD 5F3A CBAE 5F4A CBAF 6177 CBB0 6C5F CBB1 757A CBB2 7586 CBB3 7CE0 CBB4 7D73 CBB5 7DB1 CBB6 7F8C CBB7 8154 CBB8 8221 CBB9 8591 CBBA 8941 CBBB 8B1B CBBC 92FC CBBD 964D CBBE 9C47 CBBF 4ECB CBC0 4EF7 CBC1 500B CBC2 51F1 CBC3 584F CBC4 6137 CBC5 613E CBC6 6168 CBC7 6539 CBC8 69EA CBC9 6F11 CBCA 75A5 CBCB 7686 CBCC 76D6 CBCD 7B87 CBCE 82A5 CBCF 84CB CBD0 F900 CBD1 93A7 CBD2 958B CBD3 5580 CBD4 5BA2 CBD5 5751 CBD6 F901 CBD7 7CB3 CBD8 7FB9 CBD9 91B5 CBDA 5028 CBDB 53BB CBDC 5C45 CBDD 5DE8 CBDE 62D2 CBDF 636E CBE0 64DA CBE1 64E7 CBE2 6E20 CBE3 70AC CBE4 795B CBE5 8DDD CBE6 8E1E CBE7 F902 CBE8 907D CBE9 9245 CBEA 92F8 CBEB 4E7E CBEC 4EF6 CBED 5065 CBEE 5DFE CBEF 5EFA CBF0 6106 CBF1 6957 CBF2 8171 CBF3 8654 CBF4 8E47 CBF5 9375 CBF6 9A2B CBF7 4E5E CBF8 5091 CBF9 6770 CBFA 6840 CBFB 5109 CBFC 528D CBFD 5292 CBFE 6AA2 CCA1 77BC CCA2 9210 CCA3 9ED4 CCA4 52AB CCA5 602F CCA6 8FF2 CCA7 5048 CCA8 61A9 CCA9 63ED CCAA 64CA CCAB 683C CCAC 6A84 CCAD 6FC0 CCAE 8188 CCAF 89A1 CCB0 9694 CCB1 5805 CCB2 727D CCB3 72AC CCB4 7504 CCB5 7D79 CCB6 7E6D CCB7 80A9 CCB8 898B CCB9 8B74 CCBA 9063 CCBB 9D51 CCBC 6289 CCBD 6C7A CCBE 6F54 CCBF 7D50 CCC0 7F3A CCC1 8A23 CCC2 517C CCC3 614A CCC4 7B9D CCC5 8B19 CCC6 9257 CCC7 938C CCC8 4EAC CCC9 4FD3 CCCA 501E CCCB 50BE CCCC 5106 CCCD 52C1 CCCE 52CD CCCF 537F CCD0 5770 CCD1 5883 CCD2 5E9A CCD3 5F91 CCD4 6176 CCD5 61AC CCD6 64CE CCD7 656C CCD8 666F CCD9 66BB CCDA 66F4 CCDB 6897 CCDC 6D87 CCDD 7085 CCDE 70F1 CCDF 749F CCE0 74A5 CCE1 74CA CCE2 75D9 CCE3 786C CCE4 78EC CCE5 7ADF CCE6 7AF6 CCE7 7D45 CCE8 7D93 CCE9 8015 CCEA 803F CCEB 811B CCEC 8396 CCED 8B66 CCEE 8F15 CCEF 9015 CCF0 93E1 CCF1 9803 CCF2 9838 CCF3 9A5A CCF4 9BE8 CCF5 4FC2 CCF6 5553 CCF7 583A CCF8 5951 CCF9 5B63 CCFA 5C46 CCFB 60B8 CCFC 6212 CCFD 6842 CCFE 68B0 CDA1 68E8 CDA2 6EAA CDA3 754C CDA4 7678 CDA5 78CE CDA6 7A3D CDA7 7CFB CDA8 7E6B CDA9 7E7C CDAA 8A08 CDAB 8AA1 CDAC 8C3F CDAD 968E CDAE 9DC4 CDAF 53E4 CDB0 53E9 CDB1 544A CDB2 5471 CDB3 56FA CDB4 59D1 CDB5 5B64 CDB6 5C3B CDB7 5EAB CDB8 62F7 CDB9 6537 CDBA 6545 CDBB 6572 CDBC 66A0 CDBD 67AF CDBE 69C1 CDBF 6CBD CDC0 75FC CDC1 7690 CDC2 777E CDC3 7A3F CDC4 7F94 CDC5 8003 CDC6 80A1 CDC7 818F CDC8 82E6 CDC9 82FD CDCA 83F0 CDCB 85C1 CDCC 8831 CDCD 88B4 CDCE 8AA5 CDCF F903 CDD0 8F9C CDD1 932E CDD2 96C7 CDD3 9867 CDD4 9AD8 CDD5 9F13 CDD6 54ED CDD7 659B CDD8 66F2 CDD9 688F CDDA 7A40 CDDB 8C37 CDDC 9D60 CDDD 56F0 CDDE 5764 CDDF 5D11 CDE0 6606 CDE1 68B1 CDE2 68CD CDE3 6EFE CDE4 7428 CDE5 889E CDE6 9BE4 CDE7 6C68 CDE8 F904 CDE9 9AA8 CDEA 4F9B CDEB 516C CDEC 5171 CDED 529F CDEE 5B54 CDEF 5DE5 CDF0 6050 CDF1 606D CDF2 62F1 CDF3 63A7 CDF4 653B CDF5 73D9 CDF6 7A7A CDF7 86A3 CDF8 8CA2 CDF9 978F CDFA 4E32 CDFB 5BE1 CDFC 6208 CDFD 679C CDFE 74DC CEA1 79D1 CEA2 83D3 CEA3 8A87 CEA4 8AB2 CEA5 8DE8 CEA6 904E CEA7 934B CEA8 9846 CEA9 5ED3 CEAA 69E8 CEAB 85FF CEAC 90ED CEAD F905 CEAE 51A0 CEAF 5B98 CEB0 5BEC CEB1 6163 CEB2 68FA CEB3 6B3E CEB4 704C CEB5 742F CEB6 74D8 CEB7 7BA1 CEB8 7F50 CEB9 83C5 CEBA 89C0 CEBB 8CAB CEBC 95DC CEBD 9928 CEBE 522E CEBF 605D CEC0 62EC CEC1 9002 CEC2 4F8A CEC3 5149 CEC4 5321 CEC5 58D9 CEC6 5EE3 CEC7 66E0 CEC8 6D38 CEC9 709A CECA 72C2 CECB 73D6 CECC 7B50 CECD 80F1 CECE 945B CECF 5366 CED0 639B CED1 7F6B CED2 4E56 CED3 5080 CED4 584A CED5 58DE CED6 602A CED7 6127 CED8 62D0 CED9 69D0 CEDA 9B41 CEDB 5B8F CEDC 7D18 CEDD 80B1 CEDE 8F5F CEDF 4EA4 CEE0 50D1 CEE1 54AC CEE2 55AC CEE3 5B0C CEE4 5DA0 CEE5 5DE7 CEE6 652A CEE7 654E CEE8 6821 CEE9 6A4B CEEA 72E1 CEEB 768E CEEC 77EF CEED 7D5E CEEE 7FF9 CEEF 81A0 CEF0 854E CEF1 86DF CEF2 8F03 CEF3 8F4E CEF4 90CA CEF5 9903 CEF6 9A55 CEF7 9BAB CEF8 4E18 CEF9 4E45 CEFA 4E5D CEFB 4EC7 CEFC 4FF1 CEFD 5177 CEFE 52FE CFA1 5340 CFA2 53E3 CFA3 53E5 CFA4 548E CFA5 5614 CFA6 5775 CFA7 57A2 CFA8 5BC7 CFA9 5D87 CFAA 5ED0 CFAB 61FC CFAC 62D8 CFAD 6551 CFAE 67B8 CFAF 67E9 CFB0 69CB CFB1 6B50 CFB2 6BC6 CFB3 6BEC CFB4 6C42 CFB5 6E9D CFB6 7078 CFB7 72D7 CFB8 7396 CFB9 7403 CFBA 77BF CFBB 77E9 CFBC 7A76 CFBD 7D7F CFBE 8009 CFBF 81FC CFC0 8205 CFC1 820A CFC2 82DF CFC3 8862 CFC4 8B33 CFC5 8CFC CFC6 8EC0 CFC7 9011 CFC8 90B1 CFC9 9264 CFCA 92B6 CFCB 99D2 CFCC 9A45 CFCD 9CE9 CFCE 9DD7 CFCF 9F9C CFD0 570B CFD1 5C40 CFD2 83CA CFD3 97A0 CFD4 97AB CFD5 9EB4 CFD6 541B CFD7 7A98 CFD8 7FA4 CFD9 88D9 CFDA 8ECD CFDB 90E1 CFDC 5800 CFDD 5C48 CFDE 6398 CFDF 7A9F CFE0 5BAE CFE1 5F13 CFE2 7A79 CFE3 7AAE CFE4 828E CFE5 8EAC CFE6 5026 CFE7 5238 CFE8 52F8 CFE9 5377 CFEA 5708 CFEB 62F3 CFEC 6372 CFED 6B0A CFEE 6DC3 CFEF 7737 CFF0 53A5 CFF1 7357 CFF2 8568 CFF3 8E76 CFF4 95D5 CFF5 673A CFF6 6AC3 CFF7 6F70 CFF8 8A6D CFF9 8ECC CFFA 994B CFFB F906 CFFC 6677 CFFD 6B78 CFFE 8CB4 D0A1 9B3C D0A2 F907 D0A3 53EB D0A4 572D D0A5 594E D0A6 63C6 D0A7 69FB D0A8 73EA D0A9 7845 D0AA 7ABA D0AB 7AC5 D0AC 7CFE D0AD 8475 D0AE 898F D0AF 8D73 D0B0 9035 D0B1 95A8 D0B2 52FB D0B3 5747 D0B4 7547 D0B5 7B60 D0B6 83CC D0B7 921E D0B8 F908 D0B9 6A58 D0BA 514B D0BB 524B D0BC 5287 D0BD 621F D0BE 68D8 D0BF 6975 D0C0 9699 D0C1 50C5 D0C2 52A4 D0C3 52E4 D0C4 61C3 D0C5 65A4 D0C6 6839 D0C7 69FF D0C8 747E D0C9 7B4B D0CA 82B9 D0CB 83EB D0CC 89B2 D0CD 8B39 D0CE 8FD1 D0CF 9949 D0D0 F909 D0D1 4ECA D0D2 5997 D0D3 64D2 D0D4 6611 D0D5 6A8E D0D6 7434 D0D7 7981 D0D8 79BD D0D9 82A9 D0DA 887E D0DB 887F D0DC 895F D0DD F90A D0DE 9326 D0DF 4F0B D0E0 53CA D0E1 6025 D0E2 6271 D0E3 6C72 D0E4 7D1A D0E5 7D66 D0E6 4E98 D0E7 5162 D0E8 77DC D0E9 80AF D0EA 4F01 D0EB 4F0E D0EC 5176 D0ED 5180 D0EE 55DC D0EF 5668 D0F0 573B D0F1 57FA D0F2 57FC D0F3 5914 D0F4 5947 D0F5 5993 D0F6 5BC4 D0F7 5C90 D0F8 5D0E D0F9 5DF1 D0FA 5E7E D0FB 5FCC D0FC 6280 D0FD 65D7 D0FE 65E3 D1A1 671E D1A2 671F D1A3 675E D1A4 68CB D1A5 68C4 D1A6 6A5F D1A7 6B3A D1A8 6C23 D1A9 6C7D D1AA 6C82 D1AB 6DC7 D1AC 7398 D1AD 7426 D1AE 742A D1AF 7482 D1B0 74A3 D1B1 7578 D1B2 757F D1B3 7881 D1B4 78EF D1B5 7941 D1B6 7947 D1B7 7948 D1B8 797A D1B9 7B95 D1BA 7D00 D1BB 7DBA D1BC 7F88 D1BD 8006 D1BE 802D D1BF 808C D1C0 8A18 D1C1 8B4F D1C2 8C48 D1C3 8D77 D1C4 9321 D1C5 9324 D1C6 98E2 D1C7 9951 D1C8 9A0E D1C9 9A0F D1CA 9A65 D1CB 9E92 D1CC 7DCA D1CD 4F76 D1CE 5409 D1CF 62EE D1D0 6854 D1D1 91D1 D1D2 55AB D1D3 513A D1D4 F90B D1D5 F90C D1D6 5A1C D1D7 61E6 D1D8 F90D D1D9 62CF D1DA 62FF D1DB F90E D1DC F90F D1DD F910 D1DE F911 D1DF F912 D1E0 F913 D1E1 90A3 D1E2 F914 D1E3 F915 D1E4 F916 D1E5 F917 D1E6 F918 D1E7 8AFE D1E8 F919 D1E9 F91A D1EA F91B D1EB F91C D1EC 6696 D1ED F91D D1EE 7156 D1EF F91E D1F0 F91F D1F1 96E3 D1F2 F920 D1F3 634F D1F4 637A D1F5 5357 D1F6 F921 D1F7 678F D1F8 6960 D1F9 6E73 D1FA F922 D1FB 7537 D1FC F923 D1FD F924 D1FE F925 D2A1 7D0D D2A2 F926 D2A3 F927 D2A4 8872 D2A5 56CA D2A6 5A18 D2A7 F928 D2A8 F929 D2A9 F92A D2AA F92B D2AB F92C D2AC 4E43 D2AD F92D D2AE 5167 D2AF 5948 D2B0 67F0 D2B1 8010 D2B2 F92E D2B3 5973 D2B4 5E74 D2B5 649A D2B6 79CA D2B7 5FF5 D2B8 606C D2B9 62C8 D2BA 637B D2BB 5BE7 D2BC 5BD7 D2BD 52AA D2BE F92F D2BF 5974 D2C0 5F29 D2C1 6012 D2C2 F930 D2C3 F931 D2C4 F932 D2C5 7459 D2C6 F933 D2C7 F934 D2C8 F935 D2C9 F936 D2CA F937 D2CB F938 D2CC 99D1 D2CD F939 D2CE F93A D2CF F93B D2D0 F93C D2D1 F93D D2D2 F93E D2D3 F93F D2D4 F940 D2D5 F941 D2D6 F942 D2D7 F943 D2D8 6FC3 D2D9 F944 D2DA F945 D2DB 81BF D2DC 8FB2 D2DD 60F1 D2DE F946 D2DF F947 D2E0 8166 D2E1 F948 D2E2 F949 D2E3 5C3F D2E4 F94A D2E5 F94B D2E6 F94C D2E7 F94D D2E8 F94E D2E9 F94F D2EA F950 D2EB F951 D2EC 5AE9 D2ED 8A25 D2EE 677B D2EF 7D10 D2F0 F952 D2F1 F953 D2F2 F954 D2F3 F955 D2F4 F956 D2F5 F957 D2F6 80FD D2F7 F958 D2F8 F959 D2F9 5C3C D2FA 6CE5 D2FB 533F D2FC 6EBA D2FD 591A D2FE 8336 D3A1 4E39 D3A2 4EB6 D3A3 4F46 D3A4 55AE D3A5 5718 D3A6 58C7 D3A7 5F56 D3A8 65B7 D3A9 65E6 D3AA 6A80 D3AB 6BB5 D3AC 6E4D D3AD 77ED D3AE 7AEF D3AF 7C1E D3B0 7DDE D3B1 86CB D3B2 8892 D3B3 9132 D3B4 935B D3B5 64BB D3B6 6FBE D3B7 737A D3B8 75B8 D3B9 9054 D3BA 5556 D3BB 574D D3BC 61BA D3BD 64D4 D3BE 66C7 D3BF 6DE1 D3C0 6E5B D3C1 6F6D D3C2 6FB9 D3C3 75F0 D3C4 8043 D3C5 81BD D3C6 8541 D3C7 8983 D3C8 8AC7 D3C9 8B5A D3CA 931F D3CB 6C93 D3CC 7553 D3CD 7B54 D3CE 8E0F D3CF 905D D3D0 5510 D3D1 5802 D3D2 5858 D3D3 5E62 D3D4 6207 D3D5 649E D3D6 68E0 D3D7 7576 D3D8 7CD6 D3D9 87B3 D3DA 9EE8 D3DB 4EE3 D3DC 5788 D3DD 576E D3DE 5927 D3DF 5C0D D3E0 5CB1 D3E1 5E36 D3E2 5F85 D3E3 6234 D3E4 64E1 D3E5 73B3 D3E6 81FA D3E7 888B D3E8 8CB8 D3E9 968A D3EA 9EDB D3EB 5B85 D3EC 5FB7 D3ED 60B3 D3EE 5012 D3EF 5200 D3F0 5230 D3F1 5716 D3F2 5835 D3F3 5857 D3F4 5C0E D3F5 5C60 D3F6 5CF6 D3F7 5D8B D3F8 5EA6 D3F9 5F92 D3FA 60BC D3FB 6311 D3FC 6389 D3FD 6417 D3FE 6843 D4A1 68F9 D4A2 6AC2 D4A3 6DD8 D4A4 6E21 D4A5 6ED4 D4A6 6FE4 D4A7 71FE D4A8 76DC D4A9 7779 D4AA 79B1 D4AB 7A3B D4AC 8404 D4AD 89A9 D4AE 8CED D4AF 8DF3 D4B0 8E48 D4B1 9003 D4B2 9014 D4B3 9053 D4B4 90FD D4B5 934D D4B6 9676 D4B7 97DC D4B8 6BD2 D4B9 7006 D4BA 7258 D4BB 72A2 D4BC 7368 D4BD 7763 D4BE 79BF D4BF 7BE4 D4C0 7E9B D4C1 8B80 D4C2 58A9 D4C3 60C7 D4C4 6566 D4C5 65FD D4C6 66BE D4C7 6C8C D4C8 711E D4C9 71C9 D4CA 8C5A D4CB 9813 D4CC 4E6D D4CD 7A81 D4CE 4EDD D4CF 51AC D4D0 51CD D4D1 52D5 D4D2 540C D4D3 61A7 D4D4 6771 D4D5 6850 D4D6 68DF D4D7 6D1E D4D8 6F7C D4D9 75BC D4DA 77B3 D4DB 7AE5 D4DC 80F4 D4DD 8463 D4DE 9285 D4DF 515C D4E0 6597 D4E1 675C D4E2 6793 D4E3 75D8 D4E4 7AC7 D4E5 8373 D4E6 F95A D4E7 8C46 D4E8 9017 D4E9 982D D4EA 5C6F D4EB 81C0 D4EC 829A D4ED 9041 D4EE 906F D4EF 920D D4F0 5F97 D4F1 5D9D D4F2 6A59 D4F3 71C8 D4F4 767B D4F5 7B49 D4F6 85E4 D4F7 8B04 D4F8 9127 D4F9 9A30 D4FA 5587 D4FB 61F6 D4FC F95B D4FD 7669 D4FE 7F85 D5A1 863F D5A2 87BA D5A3 88F8 D5A4 908F D5A5 F95C D5A6 6D1B D5A7 70D9 D5A8 73DE D5A9 7D61 D5AA 843D D5AB F95D D5AC 916A D5AD 99F1 D5AE F95E D5AF 4E82 D5B0 5375 D5B1 6B04 D5B2 6B12 D5B3 703E D5B4 721B D5B5 862D D5B6 9E1E D5B7 524C D5B8 8FA3 D5B9 5D50 D5BA 64E5 D5BB 652C D5BC 6B16 D5BD 6FEB D5BE 7C43 D5BF 7E9C D5C0 85CD D5C1 8964 D5C2 89BD D5C3 62C9 D5C4 81D8 D5C5 881F D5C6 5ECA D5C7 6717 D5C8 6D6A D5C9 72FC D5CA 7405 D5CB 746F D5CC 8782 D5CD 90DE D5CE 4F86 D5CF 5D0D D5D0 5FA0 D5D1 840A D5D2 51B7 D5D3 63A0 D5D4 7565 D5D5 4EAE D5D6 5006 D5D7 5169 D5D8 51C9 D5D9 6881 D5DA 6A11 D5DB 7CAE D5DC 7CB1 D5DD 7CE7 D5DE 826F D5DF 8AD2 D5E0 8F1B D5E1 91CF D5E2 4FB6 D5E3 5137 D5E4 52F5 D5E5 5442 D5E6 5EEC D5E7 616E D5E8 623E D5E9 65C5 D5EA 6ADA D5EB 6FFE D5EC 792A D5ED 85DC D5EE 8823 D5EF 95AD D5F0 9A62 D5F1 9A6A D5F2 9E97 D5F3 9ECE D5F4 529B D5F5 66C6 D5F6 6B77 D5F7 701D D5F8 792B D5F9 8F62 D5FA 9742 D5FB 6190 D5FC 6200 D5FD 6523 D5FE 6F23 D6A1 7149 D6A2 7489 D6A3 7DF4 D6A4 806F D6A5 84EE D6A6 8F26 D6A7 9023 D6A8 934A D6A9 51BD D6AA 5217 D6AB 52A3 D6AC 6D0C D6AD 70C8 D6AE 88C2 D6AF 5EC9 D6B0 6582 D6B1 6BAE D6B2 6FC2 D6B3 7C3E D6B4 7375 D6B5 4EE4 D6B6 4F36 D6B7 56F9 D6B8 F95F D6B9 5CBA D6BA 5DBA D6BB 601C D6BC 73B2 D6BD 7B2D D6BE 7F9A D6BF 7FCE D6C0 8046 D6C1 901E D6C2 9234 D6C3 96F6 D6C4 9748 D6C5 9818 D6C6 9F61 D6C7 4F8B D6C8 6FA7 D6C9 79AE D6CA 91B4 D6CB 96B7 D6CC 52DE D6CD F960 D6CE 6488 D6CF 64C4 D6D0 6AD3 D6D1 6F5E D6D2 7018 D6D3 7210 D6D4 76E7 D6D5 8001 D6D6 8606 D6D7 865C D6D8 8DEF D6D9 8F05 D6DA 9732 D6DB 9B6F D6DC 9DFA D6DD 9E75 D6DE 788C D6DF 797F D6E0 7DA0 D6E1 83C9 D6E2 9304 D6E3 9E7F D6E4 9E93 D6E5 8AD6 D6E6 58DF D6E7 5F04 D6E8 6727 D6E9 7027 D6EA 74CF D6EB 7C60 D6EC 807E D6ED 5121 D6EE 7028 D6EF 7262 D6F0 78CA D6F1 8CC2 D6F2 8CDA D6F3 8CF4 D6F4 96F7 D6F5 4E86 D6F6 50DA D6F7 5BEE D6F8 5ED6 D6F9 6599 D6FA 71CE D6FB 7642 D6FC 77AD D6FD 804A D6FE 84FC D7A1 907C D7A2 9B27 D7A3 9F8D D7A4 58D8 D7A5 5A41 D7A6 5C62 D7A7 6A13 D7A8 6DDA D7A9 6F0F D7AA 763B D7AB 7D2F D7AC 7E37 D7AD 851E D7AE 8938 D7AF 93E4 D7B0 964B D7B1 5289 D7B2 65D2 D7B3 67F3 D7B4 69B4 D7B5 6D41 D7B6 6E9C D7B7 700F D7B8 7409 D7B9 7460 D7BA 7559 D7BB 7624 D7BC 786B D7BD 8B2C D7BE 985E D7BF 516D D7C0 622E D7C1 9678 D7C2 4F96 D7C3 502B D7C4 5D19 D7C5 6DEA D7C6 7DB8 D7C7 8F2A D7C8 5F8B D7C9 6144 D7CA 6817 D7CB F961 D7CC 9686 D7CD 52D2 D7CE 808B D7CF 51DC D7D0 51CC D7D1 695E D7D2 7A1C D7D3 7DBE D7D4 83F1 D7D5 9675 D7D6 4FDA D7D7 5229 D7D8 5398 D7D9 540F D7DA 550E D7DB 5C65 D7DC 60A7 D7DD 674E D7DE 68A8 D7DF 6D6C D7E0 7281 D7E1 72F8 D7E2 7406 D7E3 7483 D7E4 F962 D7E5 75E2 D7E6 7C6C D7E7 7F79 D7E8 7FB8 D7E9 8389 D7EA 88CF D7EB 88E1 D7EC 91CC D7ED 91D0 D7EE 96E2 D7EF 9BC9 D7F0 541D D7F1 6F7E D7F2 71D0 D7F3 7498 D7F4 85FA D7F5 8EAA D7F6 96A3 D7F7 9C57 D7F8 9E9F D7F9 6797 D7FA 6DCB D7FB 7433 D7FC 81E8 D7FD 9716 D7FE 782C D8A1 7ACB D8A2 7B20 D8A3 7C92 D8A4 6469 D8A5 746A D8A6 75F2 D8A7 78BC D8A8 78E8 D8A9 99AC D8AA 9B54 D8AB 9EBB D8AC 5BDE D8AD 5E55 D8AE 6F20 D8AF 819C D8B0 83AB D8B1 9088 D8B2 4E07 D8B3 534D D8B4 5A29 D8B5 5DD2 D8B6 5F4E D8B7 6162 D8B8 633D D8B9 6669 D8BA 66FC D8BB 6EFF D8BC 6F2B D8BD 7063 D8BE 779E D8BF 842C D8C0 8513 D8C1 883B D8C2 8F13 D8C3 9945 D8C4 9C3B D8C5 551C D8C6 62B9 D8C7 672B D8C8 6CAB D8C9 8309 D8CA 896A D8CB 977A D8CC 4EA1 D8CD 5984 D8CE 5FD8 D8CF 5FD9 D8D0 671B D8D1 7DB2 D8D2 7F54 D8D3 8292 D8D4 832B D8D5 83BD D8D6 8F1E D8D7 9099 D8D8 57CB D8D9 59B9 D8DA 5A92 D8DB 5BD0 D8DC 6627 D8DD 679A D8DE 6885 D8DF 6BCF D8E0 7164 D8E1 7F75 D8E2 8CB7 D8E3 8CE3 D8E4 9081 D8E5 9B45 D8E6 8108 D8E7 8C8A D8E8 964C D8E9 9A40 D8EA 9EA5 D8EB 5B5F D8EC 6C13 D8ED 731B D8EE 76F2 D8EF 76DF D8F0 840C D8F1 51AA D8F2 8993 D8F3 514D D8F4 5195 D8F5 52C9 D8F6 68C9 D8F7 6C94 D8F8 7704 D8F9 7720 D8FA 7DBF D8FB 7DEC D8FC 9762 D8FD 9EB5 D8FE 6EC5 D9A1 8511 D9A2 51A5 D9A3 540D D9A4 547D D9A5 660E D9A6 669D D9A7 6927 D9A8 6E9F D9A9 76BF D9AA 7791 D9AB 8317 D9AC 84C2 D9AD 879F D9AE 9169 D9AF 9298 D9B0 9CF4 D9B1 8882 D9B2 4FAE D9B3 5192 D9B4 52DF D9B5 59C6 D9B6 5E3D D9B7 6155 D9B8 6478 D9B9 6479 D9BA 66AE D9BB 67D0 D9BC 6A21 D9BD 6BCD D9BE 6BDB D9BF 725F D9C0 7261 D9C1 7441 D9C2 7738 D9C3 77DB D9C4 8017 D9C5 82BC D9C6 8305 D9C7 8B00 D9C8 8B28 D9C9 8C8C D9CA 6728 D9CB 6C90 D9CC 7267 D9CD 76EE D9CE 7766 D9CF 7A46 D9D0 9DA9 D9D1 6B7F D9D2 6C92 D9D3 5922 D9D4 6726 D9D5 8499 D9D6 536F D9D7 5893 D9D8 5999 D9D9 5EDF D9DA 63CF D9DB 6634 D9DC 6773 D9DD 6E3A D9DE 732B D9DF 7AD7 D9E0 82D7 D9E1 9328 D9E2 52D9 D9E3 5DEB D9E4 61AE D9E5 61CB D9E6 620A D9E7 62C7 D9E8 64AB D9E9 65E0 D9EA 6959 D9EB 6B66 D9EC 6BCB D9ED 7121 D9EE 73F7 D9EF 755D D9F0 7E46 D9F1 821E D9F2 8302 D9F3 856A D9F4 8AA3 D9F5 8CBF D9F6 9727 D9F7 9D61 D9F8 58A8 D9F9 9ED8 D9FA 5011 D9FB 520E D9FC 543B D9FD 554F D9FE 6587 DAA1 6C76 DAA2 7D0A DAA3 7D0B DAA4 805E DAA5 868A DAA6 9580 DAA7 96EF DAA8 52FF DAA9 6C95 DAAA 7269 DAAB 5473 DAAC 5A9A DAAD 5C3E DAAE 5D4B DAAF 5F4C DAB0 5FAE DAB1 672A DAB2 68B6 DAB3 6963 DAB4 6E3C DAB5 6E44 DAB6 7709 DAB7 7C73 DAB8 7F8E DAB9 8587 DABA 8B0E DABB 8FF7 DABC 9761 DABD 9EF4 DABE 5CB7 DABF 60B6 DAC0 610D DAC1 61AB DAC2 654F DAC3 65FB DAC4 65FC DAC5 6C11 DAC6 6CEF DAC7 739F DAC8 73C9 DAC9 7DE1 DACA 9594 DACB 5BC6 DACC 871C DACD 8B10 DACE 525D DACF 535A DAD0 62CD DAD1 640F DAD2 64B2 DAD3 6734 DAD4 6A38 DAD5 6CCA DAD6 73C0 DAD7 749E DAD8 7B94 DAD9 7C95 DADA 7E1B DADB 818A DADC 8236 DADD 8584 DADE 8FEB DADF 96F9 DAE0 99C1 DAE1 4F34 DAE2 534A DAE3 53CD DAE4 53DB DAE5 62CC DAE6 642C DAE7 6500 DAE8 6591 DAE9 69C3 DAEA 6CEE DAEB 6F58 DAEC 73ED DAED 7554 DAEE 7622 DAEF 76E4 DAF0 76FC DAF1 78D0 DAF2 78FB DAF3 792C DAF4 7D46 DAF5 822C DAF6 87E0 DAF7 8FD4 DAF8 9812 DAF9 98EF DAFA 52C3 DAFB 62D4 DAFC 64A5 DAFD 6E24 DAFE 6F51 DBA1 767C DBA2 8DCB DBA3 91B1 DBA4 9262 DBA5 9AEE DBA6 9B43 DBA7 5023 DBA8 508D DBA9 574A DBAA 59A8 DBAB 5C28 DBAC 5E47 DBAD 5F77 DBAE 623F DBAF 653E DBB0 65B9 DBB1 65C1 DBB2 6609 DBB3 678B DBB4 699C DBB5 6EC2 DBB6 78C5 DBB7 7D21 DBB8 80AA DBB9 8180 DBBA 822B DBBB 82B3 DBBC 84A1 DBBD 868C DBBE 8A2A DBBF 8B17 DBC0 90A6 DBC1 9632 DBC2 9F90 DBC3 500D DBC4 4FF3 DBC5 F963 DBC6 57F9 DBC7 5F98 DBC8 62DC DBC9 6392 DBCA 676F DBCB 6E43 DBCC 7119 DBCD 76C3 DBCE 80CC DBCF 80DA DBD0 88F4 DBD1 88F5 DBD2 8919 DBD3 8CE0 DBD4 8F29 DBD5 914D DBD6 966A DBD7 4F2F DBD8 4F70 DBD9 5E1B DBDA 67CF DBDB 6822 DBDC 767D DBDD 767E DBDE 9B44 DBDF 5E61 DBE0 6A0A DBE1 7169 DBE2 71D4 DBE3 756A DBE4 F964 DBE5 7E41 DBE6 8543 DBE7 85E9 DBE8 98DC DBE9 4F10 DBEA 7B4F DBEB 7F70 DBEC 95A5 DBED 51E1 DBEE 5E06 DBEF 68B5 DBF0 6C3E DBF1 6C4E DBF2 6CDB DBF3 72AF DBF4 7BC4 DBF5 8303 DBF6 6CD5 DBF7 743A DBF8 50FB DBF9 5288 DBFA 58C1 DBFB 64D8 DBFC 6A97 DBFD 74A7 DBFE 7656 DCA1 78A7 DCA2 8617 DCA3 95E2 DCA4 9739 DCA5 F965 DCA6 535E DCA7 5F01 DCA8 8B8A DCA9 8FA8 DCAA 8FAF DCAB 908A DCAC 5225 DCAD 77A5 DCAE 9C49 DCAF 9F08 DCB0 4E19 DCB1 5002 DCB2 5175 DCB3 5C5B DCB4 5E77 DCB5 661E DCB6 663A DCB7 67C4 DCB8 68C5 DCB9 70B3 DCBA 7501 DCBB 75C5 DCBC 79C9 DCBD 7ADD DCBE 8F27 DCBF 9920 DCC0 9A08 DCC1 4FDD DCC2 5821 DCC3 5831 DCC4 5BF6 DCC5 666E DCC6 6B65 DCC7 6D11 DCC8 6E7A DCC9 6F7D DCCA 73E4 DCCB 752B DCCC 83E9 DCCD 88DC DCCE 8913 DCCF 8B5C DCD0 8F14 DCD1 4F0F DCD2 50D5 DCD3 5310 DCD4 535C DCD5 5B93 DCD6 5FA9 DCD7 670D DCD8 798F DCD9 8179 DCDA 832F DCDB 8514 DCDC 8907 DCDD 8986 DCDE 8F39 DCDF 8F3B DCE0 99A5 DCE1 9C12 DCE2 672C DCE3 4E76 DCE4 4FF8 DCE5 5949 DCE6 5C01 DCE7 5CEF DCE8 5CF0 DCE9 6367 DCEA 68D2 DCEB 70FD DCEC 71A2 DCED 742B DCEE 7E2B DCEF 84EC DCF0 8702 DCF1 9022 DCF2 92D2 DCF3 9CF3 DCF4 4E0D DCF5 4ED8 DCF6 4FEF DCF7 5085 DCF8 5256 DCF9 526F DCFA 5426 DCFB 5490 DCFC 57E0 DCFD 592B DCFE 5A66 DDA1 5B5A DDA2 5B75 DDA3 5BCC DDA4 5E9C DDA5 F966 DDA6 6276 DDA7 6577 DDA8 65A7 DDA9 6D6E DDAA 6EA5 DDAB 7236 DDAC 7B26 DDAD 7C3F DDAE 7F36 DDAF 8150 DDB0 8151 DDB1 819A DDB2 8240 DDB3 8299 DDB4 83A9 DDB5 8A03 DDB6 8CA0 DDB7 8CE6 DDB8 8CFB DDB9 8D74 DDBA 8DBA DDBB 90E8 DDBC 91DC DDBD 961C DDBE 9644 DDBF 99D9 DDC0 9CE7 DDC1 5317 DDC2 5206 DDC3 5429 DDC4 5674 DDC5 58B3 DDC6 5954 DDC7 596E DDC8 5FFF DDC9 61A4 DDCA 626E DDCB 6610 DDCC 6C7E DDCD 711A DDCE 76C6 DDCF 7C89 DDD0 7CDE DDD1 7D1B DDD2 82AC DDD3 8CC1 DDD4 96F0 DDD5 F967 DDD6 4F5B DDD7 5F17 DDD8 5F7F DDD9 62C2 DDDA 5D29 DDDB 670B DDDC 68DA DDDD 787C DDDE 7E43 DDDF 9D6C DDE0 4E15 DDE1 5099 DDE2 5315 DDE3 532A DDE4 5351 DDE5 5983 DDE6 5A62 DDE7 5E87 DDE8 60B2 DDE9 618A DDEA 6249 DDEB 6279 DDEC 6590 DDED 6787 DDEE 69A7 DDEF 6BD4 DDF0 6BD6 DDF1 6BD7 DDF2 6BD8 DDF3 6CB8 DDF4 F968 DDF5 7435 DDF6 75FA DDF7 7812 DDF8 7891 DDF9 79D5 DDFA 79D8 DDFB 7C83 DDFC 7DCB DDFD 7FE1 DDFE 80A5 DEA1 813E DEA2 81C2 DEA3 83F2 DEA4 871A DEA5 88E8 DEA6 8AB9 DEA7 8B6C DEA8 8CBB DEA9 9119 DEAA 975E DEAB 98DB DEAC 9F3B DEAD 56AC DEAE 5B2A DEAF 5F6C DEB0 658C DEB1 6AB3 DEB2 6BAF DEB3 6D5C DEB4 6FF1 DEB5 7015 DEB6 725D DEB7 73AD DEB8 8CA7 DEB9 8CD3 DEBA 983B DEBB 6191 DEBC 6C37 DEBD 8058 DEBE 9A01 DEBF 4E4D DEC0 4E8B DEC1 4E9B DEC2 4ED5 DEC3 4F3A DEC4 4F3C DEC5 4F7F DEC6 4FDF DEC7 50FF DEC8 53F2 DEC9 53F8 DECA 5506 DECB 55E3 DECC 56DB DECD 58EB DECE 5962 DECF 5A11 DED0 5BEB DED1 5BFA DED2 5C04 DED3 5DF3 DED4 5E2B DED5 5F99 DED6 601D DED7 6368 DED8 659C DED9 65AF DEDA 67F6 DEDB 67FB DEDC 68AD DEDD 6B7B DEDE 6C99 DEDF 6CD7 DEE0 6E23 DEE1 7009 DEE2 7345 DEE3 7802 DEE4 793E DEE5 7940 DEE6 7960 DEE7 79C1 DEE8 7BE9 DEE9 7D17 DEEA 7D72 DEEB 8086 DEEC 820D DEED 838E DEEE 84D1 DEEF 86C7 DEF0 88DF DEF1 8A50 DEF2 8A5E DEF3 8B1D DEF4 8CDC DEF5 8D66 DEF6 8FAD DEF7 90AA DEF8 98FC DEF9 99DF DEFA 9E9D DEFB 524A DEFC F969 DEFD 6714 DEFE F96A DFA1 5098 DFA2 522A DFA3 5C71 DFA4 6563 DFA5 6C55 DFA6 73CA DFA7 7523 DFA8 759D DFA9 7B97 DFAA 849C DFAB 9178 DFAC 9730 DFAD 4E77 DFAE 6492 DFAF 6BBA DFB0 715E DFB1 85A9 DFB2 4E09 DFB3 F96B DFB4 6749 DFB5 68EE DFB6 6E17 DFB7 829F DFB8 8518 DFB9 886B DFBA 63F7 DFBB 6F81 DFBC 9212 DFBD 98AF DFBE 4E0A DFBF 50B7 DFC0 50CF DFC1 511F DFC2 5546 DFC3 55AA DFC4 5617 DFC5 5B40 DFC6 5C19 DFC7 5CE0 DFC8 5E38 DFC9 5E8A DFCA 5EA0 DFCB 5EC2 DFCC 60F3 DFCD 6851 DFCE 6A61 DFCF 6E58 DFD0 723D DFD1 7240 DFD2 72C0 DFD3 76F8 DFD4 7965 DFD5 7BB1 DFD6 7FD4 DFD7 88F3 DFD8 89F4 DFD9 8A73 DFDA 8C61 DFDB 8CDE DFDC 971C DFDD 585E DFDE 74BD DFDF 8CFD DFE0 55C7 DFE1 F96C DFE2 7A61 DFE3 7D22 DFE4 8272 DFE5 7272 DFE6 751F DFE7 7525 DFE8 F96D DFE9 7B19 DFEA 5885 DFEB 58FB DFEC 5DBC DFED 5E8F DFEE 5EB6 DFEF 5F90 DFF0 6055 DFF1 6292 DFF2 637F DFF3 654D DFF4 6691 DFF5 66D9 DFF6 66F8 DFF7 6816 DFF8 68F2 DFF9 7280 DFFA 745E DFFB 7B6E DFFC 7D6E DFFD 7DD6 DFFE 7F72 E0A1 80E5 E0A2 8212 E0A3 85AF E0A4 897F E0A5 8A93 E0A6 901D E0A7 92E4 E0A8 9ECD E0A9 9F20 E0AA 5915 E0AB 596D E0AC 5E2D E0AD 60DC E0AE 6614 E0AF 6673 E0B0 6790 E0B1 6C50 E0B2 6DC5 E0B3 6F5F E0B4 77F3 E0B5 78A9 E0B6 84C6 E0B7 91CB E0B8 932B E0B9 4ED9 E0BA 50CA E0BB 5148 E0BC 5584 E0BD 5B0B E0BE 5BA3 E0BF 6247 E0C0 657E E0C1 65CB E0C2 6E32 E0C3 717D E0C4 7401 E0C5 7444 E0C6 7487 E0C7 74BF E0C8 766C E0C9 79AA E0CA 7DDA E0CB 7E55 E0CC 7FA8 E0CD 817A E0CE 81B3 E0CF 8239 E0D0 861A E0D1 87EC E0D2 8A75 E0D3 8DE3 E0D4 9078 E0D5 9291 E0D6 9425 E0D7 994D E0D8 9BAE E0D9 5368 E0DA 5C51 E0DB 6954 E0DC 6CC4 E0DD 6D29 E0DE 6E2B E0DF 820C E0E0 859B E0E1 893B E0E2 8A2D E0E3 8AAA E0E4 96EA E0E5 9F67 E0E6 5261 E0E7 66B9 E0E8 6BB2 E0E9 7E96 E0EA 87FE E0EB 8D0D E0EC 9583 E0ED 965D E0EE 651D E0EF 6D89 E0F0 71EE E0F1 F96E E0F2 57CE E0F3 59D3 E0F4 5BAC E0F5 6027 E0F6 60FA E0F7 6210 E0F8 661F E0F9 665F E0FA 7329 E0FB 73F9 E0FC 76DB E0FD 7701 E0FE 7B6C E1A1 8056 E1A2 8072 E1A3 8165 E1A4 8AA0 E1A5 9192 E1A6 4E16 E1A7 52E2 E1A8 6B72 E1A9 6D17 E1AA 7A05 E1AB 7B39 E1AC 7D30 E1AD F96F E1AE 8CB0 E1AF 53EC E1B0 562F E1B1 5851 E1B2 5BB5 E1B3 5C0F E1B4 5C11 E1B5 5DE2 E1B6 6240 E1B7 6383 E1B8 6414 E1B9 662D E1BA 68B3 E1BB 6CBC E1BC 6D88 E1BD 6EAF E1BE 701F E1BF 70A4 E1C0 71D2 E1C1 7526 E1C2 758F E1C3 758E E1C4 7619 E1C5 7B11 E1C6 7BE0 E1C7 7C2B E1C8 7D20 E1C9 7D39 E1CA 852C E1CB 856D E1CC 8607 E1CD 8A34 E1CE 900D E1CF 9061 E1D0 90B5 E1D1 92B7 E1D2 97F6 E1D3 9A37 E1D4 4FD7 E1D5 5C6C E1D6 675F E1D7 6D91 E1D8 7C9F E1D9 7E8C E1DA 8B16 E1DB 8D16 E1DC 901F E1DD 5B6B E1DE 5DFD E1DF 640D E1E0 84C0 E1E1 905C E1E2 98E1 E1E3 7387 E1E4 5B8B E1E5 609A E1E6 677E E1E7 6DDE E1E8 8A1F E1E9 8AA6 E1EA 9001 E1EB 980C E1EC 5237 E1ED F970 E1EE 7051 E1EF 788E E1F0 9396 E1F1 8870 E1F2 91D7 E1F3 4FEE E1F4 53D7 E1F5 55FD E1F6 56DA E1F7 5782 E1F8 58FD E1F9 5AC2 E1FA 5B88 E1FB 5CAB E1FC 5CC0 E1FD 5E25 E1FE 6101 E2A1 620D E2A2 624B E2A3 6388 E2A4 641C E2A5 6536 E2A6 6578 E2A7 6A39 E2A8 6B8A E2A9 6C34 E2AA 6D19 E2AB 6F31 E2AC 71E7 E2AD 72E9 E2AE 7378 E2AF 7407 E2B0 74B2 E2B1 7626 E2B2 7761 E2B3 79C0 E2B4 7A57 E2B5 7AEA E2B6 7CB9 E2B7 7D8F E2B8 7DAC E2B9 7E61 E2BA 7F9E E2BB 8129 E2BC 8331 E2BD 8490 E2BE 84DA E2BF 85EA E2C0 8896 E2C1 8AB0 E2C2 8B90 E2C3 8F38 E2C4 9042 E2C5 9083 E2C6 916C E2C7 9296 E2C8 92B9 E2C9 968B E2CA 96A7 E2CB 96A8 E2CC 96D6 E2CD 9700 E2CE 9808 E2CF 9996 E2D0 9AD3 E2D1 9B1A E2D2 53D4 E2D3 587E E2D4 5919 E2D5 5B70 E2D6 5BBF E2D7 6DD1 E2D8 6F5A E2D9 719F E2DA 7421 E2DB 74B9 E2DC 8085 E2DD 83FD E2DE 5DE1 E2DF 5F87 E2E0 5FAA E2E1 6042 E2E2 65EC E2E3 6812 E2E4 696F E2E5 6A53 E2E6 6B89 E2E7 6D35 E2E8 6DF3 E2E9 73E3 E2EA 76FE E2EB 77AC E2EC 7B4D E2ED 7D14 E2EE 8123 E2EF 821C E2F0 8340 E2F1 84F4 E2F2 8563 E2F3 8A62 E2F4 8AC4 E2F5 9187 E2F6 931E E2F7 9806 E2F8 99B4 E2F9 620C E2FA 8853 E2FB 8FF0 E2FC 9265 E2FD 5D07 E2FE 5D27 E3A1 5D69 E3A2 745F E3A3 819D E3A4 8768 E3A5 6FD5 E3A6 62FE E3A7 7FD2 E3A8 8936 E3A9 8972 E3AA 4E1E E3AB 4E58 E3AC 50E7 E3AD 52DD E3AE 5347 E3AF 627F E3B0 6607 E3B1 7E69 E3B2 8805 E3B3 965E E3B4 4F8D E3B5 5319 E3B6 5636 E3B7 59CB E3B8 5AA4 E3B9 5C38 E3BA 5C4E E3BB 5C4D E3BC 5E02 E3BD 5F11 E3BE 6043 E3BF 65BD E3C0 662F E3C1 6642 E3C2 67BE E3C3 67F4 E3C4 731C E3C5 77E2 E3C6 793A E3C7 7FC5 E3C8 8494 E3C9 84CD E3CA 8996 E3CB 8A66 E3CC 8A69 E3CD 8AE1 E3CE 8C55 E3CF 8C7A E3D0 57F4 E3D1 5BD4 E3D2 5F0F E3D3 606F E3D4 62ED E3D5 690D E3D6 6B96 E3D7 6E5C E3D8 7184 E3D9 7BD2 E3DA 8755 E3DB 8B58 E3DC 8EFE E3DD 98DF E3DE 98FE E3DF 4F38 E3E0 4F81 E3E1 4FE1 E3E2 547B E3E3 5A20 E3E4 5BB8 E3E5 613C E3E6 65B0 E3E7 6668 E3E8 71FC E3E9 7533 E3EA 795E E3EB 7D33 E3EC 814E E3ED 81E3 E3EE 8398 E3EF 85AA E3F0 85CE E3F1 8703 E3F2 8A0A E3F3 8EAB E3F4 8F9B E3F5 F971 E3F6 8FC5 E3F7 5931 E3F8 5BA4 E3F9 5BE6 E3FA 6089 E3FB 5BE9 E3FC 5C0B E3FD 5FC3 E3FE 6C81 E4A1 F972 E4A2 6DF1 E4A3 700B E4A4 751A E4A5 82AF E4A6 8AF6 E4A7 4EC0 E4A8 5341 E4A9 F973 E4AA 96D9 E4AB 6C0F E4AC 4E9E E4AD 4FC4 E4AE 5152 E4AF 555E E4B0 5A25 E4B1 5CE8 E4B2 6211 E4B3 7259 E4B4 82BD E4B5 83AA E4B6 86FE E4B7 8859 E4B8 8A1D E4B9 963F E4BA 96C5 E4BB 9913 E4BC 9D09 E4BD 9D5D E4BE 580A E4BF 5CB3 E4C0 5DBD E4C1 5E44 E4C2 60E1 E4C3 6115 E4C4 63E1 E4C5 6A02 E4C6 6E25 E4C7 9102 E4C8 9354 E4C9 984E E4CA 9C10 E4CB 9F77 E4CC 5B89 E4CD 5CB8 E4CE 6309 E4CF 664F E4D0 6848 E4D1 773C E4D2 96C1 E4D3 978D E4D4 9854 E4D5 9B9F E4D6 65A1 E4D7 8B01 E4D8 8ECB E4D9 95BC E4DA 5535 E4DB 5CA9 E4DC 5DD6 E4DD 5EB5 E4DE 6697 E4DF 764C E4E0 83F4 E4E1 95C7 E4E2 58D3 E4E3 62BC E4E4 72CE E4E5 9D28 E4E6 4EF0 E4E7 592E E4E8 600F E4E9 663B E4EA 6B83 E4EB 79E7 E4EC 9D26 E4ED 5393 E4EE 54C0 E4EF 57C3 E4F0 5D16 E4F1 611B E4F2 66D6 E4F3 6DAF E4F4 788D E4F5 827E E4F6 9698 E4F7 9744 E4F8 5384 E4F9 627C E4FA 6396 E4FB 6DB2 E4FC 7E0A E4FD 814B E4FE 984D E5A1 6AFB E5A2 7F4C E5A3 9DAF E5A4 9E1A E5A5 4E5F E5A6 503B E5A7 51B6 E5A8 591C E5A9 60F9 E5AA 63F6 E5AB 6930 E5AC 723A E5AD 8036 E5AE F974 E5AF 91CE E5B0 5F31 E5B1 F975 E5B2 F976 E5B3 7D04 E5B4 82E5 E5B5 846F E5B6 84BB E5B7 85E5 E5B8 8E8D E5B9 F977 E5BA 4F6F E5BB F978 E5BC F979 E5BD 58E4 E5BE 5B43 E5BF 6059 E5C0 63DA E5C1 6518 E5C2 656D E5C3 6698 E5C4 F97A E5C5 694A E5C6 6A23 E5C7 6D0B E5C8 7001 E5C9 716C E5CA 75D2 E5CB 760D E5CC 79B3 E5CD 7A70 E5CE F97B E5CF 7F8A E5D0 F97C E5D1 8944 E5D2 F97D E5D3 8B93 E5D4 91C0 E5D5 967D E5D6 F97E E5D7 990A E5D8 5704 E5D9 5FA1 E5DA 65BC E5DB 6F01 E5DC 7600 E5DD 79A6 E5DE 8A9E E5DF 99AD E5E0 9B5A E5E1 9F6C E5E2 5104 E5E3 61B6 E5E4 6291 E5E5 6A8D E5E6 81C6 E5E7 5043 E5E8 5830 E5E9 5F66 E5EA 7109 E5EB 8A00 E5EC 8AFA E5ED 5B7C E5EE 8616 E5EF 4FFA E5F0 513C E5F1 56B4 E5F2 5944 E5F3 63A9 E5F4 6DF9 E5F5 5DAA E5F6 696D E5F7 5186 E5F8 4E88 E5F9 4F59 E5FA F97F E5FB F980 E5FC F981 E5FD 5982 E5FE F982 E6A1 F983 E6A2 6B5F E6A3 6C5D E6A4 F984 E6A5 74B5 E6A6 7916 E6A7 F985 E6A8 8207 E6A9 8245 E6AA 8339 E6AB 8F3F E6AC 8F5D E6AD F986 E6AE 9918 E6AF F987 E6B0 F988 E6B1 F989 E6B2 4EA6 E6B3 F98A E6B4 57DF E6B5 5F79 E6B6 6613 E6B7 F98B E6B8 F98C E6B9 75AB E6BA 7E79 E6BB 8B6F E6BC F98D E6BD 9006 E6BE 9A5B E6BF 56A5 E6C0 5827 E6C1 59F8 E6C2 5A1F E6C3 5BB4 E6C4 F98E E6C5 5EF6 E6C6 F98F E6C7 F990 E6C8 6350 E6C9 633B E6CA F991 E6CB 693D E6CC 6C87 E6CD 6CBF E6CE 6D8E E6CF 6D93 E6D0 6DF5 E6D1 6F14 E6D2 F992 E6D3 70DF E6D4 7136 E6D5 7159 E6D6 F993 E6D7 71C3 E6D8 71D5 E6D9 F994 E6DA 784F E6DB 786F E6DC F995 E6DD 7B75 E6DE 7DE3 E6DF F996 E6E0 7E2F E6E1 F997 E6E2 884D E6E3 8EDF E6E4 F998 E6E5 F999 E6E6 F99A E6E7 925B E6E8 F99B E6E9 9CF6 E6EA F99C E6EB F99D E6EC F99E E6ED 6085 E6EE 6D85 E6EF F99F E6F0 71B1 E6F1 F9A0 E6F2 F9A1 E6F3 95B1 E6F4 53AD E6F5 F9A2 E6F6 F9A3 E6F7 F9A4 E6F8 67D3 E6F9 F9A5 E6FA 708E E6FB 7130 E6FC 7430 E6FD 8276 E6FE 82D2 E7A1 F9A6 E7A2 95BB E7A3 9AE5 E7A4 9E7D E7A5 66C4 E7A6 F9A7 E7A7 71C1 E7A8 8449 E7A9 F9A8 E7AA F9A9 E7AB 584B E7AC F9AA E7AD F9AB E7AE 5DB8 E7AF 5F71 E7B0 F9AC E7B1 6620 E7B2 668E E7B3 6979 E7B4 69AE E7B5 6C38 E7B6 6CF3 E7B7 6E36 E7B8 6F41 E7B9 6FDA E7BA 701B E7BB 702F E7BC 7150 E7BD 71DF E7BE 7370 E7BF F9AD E7C0 745B E7C1 F9AE E7C2 74D4 E7C3 76C8 E7C4 7A4E E7C5 7E93 E7C6 F9AF E7C7 F9B0 E7C8 82F1 E7C9 8A60 E7CA 8FCE E7CB F9B1 E7CC 9348 E7CD F9B2 E7CE 9719 E7CF F9B3 E7D0 F9B4 E7D1 4E42 E7D2 502A E7D3 F9B5 E7D4 5208 E7D5 53E1 E7D6 66F3 E7D7 6C6D E7D8 6FCA E7D9 730A E7DA 777F E7DB 7A62 E7DC 82AE E7DD 85DD E7DE 8602 E7DF F9B6 E7E0 88D4 E7E1 8A63 E7E2 8B7D E7E3 8C6B E7E4 F9B7 E7E5 92B3 E7E6 F9B8 E7E7 9713 E7E8 9810 E7E9 4E94 E7EA 4F0D E7EB 4FC9 E7EC 50B2 E7ED 5348 E7EE 543E E7EF 5433 E7F0 55DA E7F1 5862 E7F2 58BA E7F3 5967 E7F4 5A1B E7F5 5BE4 E7F6 609F E7F7 F9B9 E7F8 61CA E7F9 6556 E7FA 65FF E7FB 6664 E7FC 68A7 E7FD 6C5A E7FE 6FB3 E8A1 70CF E8A2 71AC E8A3 7352 E8A4 7B7D E8A5 8708 E8A6 8AA4 E8A7 9C32 E8A8 9F07 E8A9 5C4B E8AA 6C83 E8AB 7344 E8AC 7389 E8AD 923A E8AE 6EAB E8AF 7465 E8B0 761F E8B1 7A69 E8B2 7E15 E8B3 860A E8B4 5140 E8B5 58C5 E8B6 64C1 E8B7 74EE E8B8 7515 E8B9 7670 E8BA 7FC1 E8BB 9095 E8BC 96CD E8BD 9954 E8BE 6E26 E8BF 74E6 E8C0 7AA9 E8C1 7AAA E8C2 81E5 E8C3 86D9 E8C4 8778 E8C5 8A1B E8C6 5A49 E8C7 5B8C E8C8 5B9B E8C9 68A1 E8CA 6900 E8CB 6D63 E8CC 73A9 E8CD 7413 E8CE 742C E8CF 7897 E8D0 7DE9 E8D1 7FEB E8D2 8118 E8D3 8155 E8D4 839E E8D5 8C4C E8D6 962E E8D7 9811 E8D8 66F0 E8D9 5F80 E8DA 65FA E8DB 6789 E8DC 6C6A E8DD 738B E8DE 502D E8DF 5A03 E8E0 6B6A E8E1 77EE E8E2 5916 E8E3 5D6C E8E4 5DCD E8E5 7325 E8E6 754F E8E7 F9BA E8E8 F9BB E8E9 50E5 E8EA 51F9 E8EB 582F E8EC 592D E8ED 5996 E8EE 59DA E8EF 5BE5 E8F0 F9BC E8F1 F9BD E8F2 5DA2 E8F3 62D7 E8F4 6416 E8F5 6493 E8F6 64FE E8F7 F9BE E8F8 66DC E8F9 F9BF E8FA 6A48 E8FB F9C0 E8FC 71FF E8FD 7464 E8FE F9C1 E9A1 7A88 E9A2 7AAF E9A3 7E47 E9A4 7E5E E9A5 8000 E9A6 8170 E9A7 F9C2 E9A8 87EF E9A9 8981 E9AA 8B20 E9AB 9059 E9AC F9C3 E9AD 9080 E9AE 9952 E9AF 617E E9B0 6B32 E9B1 6D74 E9B2 7E1F E9B3 8925 E9B4 8FB1 E9B5 4FD1 E9B6 50AD E9B7 5197 E9B8 52C7 E9B9 57C7 E9BA 5889 E9BB 5BB9 E9BC 5EB8 E9BD 6142 E9BE 6995 E9BF 6D8C E9C0 6E67 E9C1 6EB6 E9C2 7194 E9C3 7462 E9C4 7528 E9C5 752C E9C6 8073 E9C7 8338 E9C8 84C9 E9C9 8E0A E9CA 9394 E9CB 93DE E9CC F9C4 E9CD 4E8E E9CE 4F51 E9CF 5076 E9D0 512A E9D1 53C8 E9D2 53CB E9D3 53F3 E9D4 5B87 E9D5 5BD3 E9D6 5C24 E9D7 611A E9D8 6182 E9D9 65F4 E9DA 725B E9DB 7397 E9DC 7440 E9DD 76C2 E9DE 7950 E9DF 7991 E9E0 79B9 E9E1 7D06 E9E2 7FBD E9E3 828B E9E4 85D5 E9E5 865E E9E6 8FC2 E9E7 9047 E9E8 90F5 E9E9 91EA E9EA 9685 E9EB 96E8 E9EC 96E9 E9ED 52D6 E9EE 5F67 E9EF 65ED E9F0 6631 E9F1 682F E9F2 715C E9F3 7A36 E9F4 90C1 E9F5 980A E9F6 4E91 E9F7 F9C5 E9F8 6A52 E9F9 6B9E E9FA 6F90 E9FB 7189 E9FC 8018 E9FD 82B8 E9FE 8553 EAA1 904B EAA2 9695 EAA3 96F2 EAA4 97FB EAA5 851A EAA6 9B31 EAA7 4E90 EAA8 718A EAA9 96C4 EAAA 5143 EAAB 539F EAAC 54E1 EAAD 5713 EAAE 5712 EAAF 57A3 EAB0 5A9B EAB1 5AC4 EAB2 5BC3 EAB3 6028 EAB4 613F EAB5 63F4 EAB6 6C85 EAB7 6D39 EAB8 6E72 EAB9 6E90 EABA 7230 EABB 733F EABC 7457 EABD 82D1 EABE 8881 EABF 8F45 EAC0 9060 EAC1 F9C6 EAC2 9662 EAC3 9858 EAC4 9D1B EAC5 6708 EAC6 8D8A EAC7 925E EAC8 4F4D EAC9 5049 EACA 50DE EACB 5371 EACC 570D EACD 59D4 EACE 5A01 EACF 5C09 EAD0 6170 EAD1 6690 EAD2 6E2D EAD3 7232 EAD4 744B EAD5 7DEF EAD6 80C3 EAD7 840E EAD8 8466 EAD9 853F EADA 875F EADB 885B EADC 8918 EADD 8B02 EADE 9055 EADF 97CB EAE0 9B4F EAE1 4E73 EAE2 4F91 EAE3 5112 EAE4 516A EAE5 F9C7 EAE6 552F EAE7 55A9 EAE8 5B7A EAE9 5BA5 EAEA 5E7C EAEB 5E7D EAEC 5EBE EAED 60A0 EAEE 60DF EAEF 6108 EAF0 6109 EAF1 63C4 EAF2 6538 EAF3 6709 EAF4 F9C8 EAF5 67D4 EAF6 67DA EAF7 F9C9 EAF8 6961 EAF9 6962 EAFA 6CB9 EAFB 6D27 EAFC F9CA EAFD 6E38 EAFE F9CB EBA1 6FE1 EBA2 7336 EBA3 7337 EBA4 F9CC EBA5 745C EBA6 7531 EBA7 F9CD EBA8 7652 EBA9 F9CE EBAA F9CF EBAB 7DAD EBAC 81FE EBAD 8438 EBAE 88D5 EBAF 8A98 EBB0 8ADB EBB1 8AED EBB2 8E30 EBB3 8E42 EBB4 904A EBB5 903E EBB6 907A EBB7 9149 EBB8 91C9 EBB9 936E EBBA F9D0 EBBB F9D1 EBBC 5809 EBBD F9D2 EBBE 6BD3 EBBF 8089 EBC0 80B2 EBC1 F9D3 EBC2 F9D4 EBC3 5141 EBC4 596B EBC5 5C39 EBC6 F9D5 EBC7 F9D6 EBC8 6F64 EBC9 73A7 EBCA 80E4 EBCB 8D07 EBCC F9D7 EBCD 9217 EBCE 958F EBCF F9D8 EBD0 F9D9 EBD1 F9DA EBD2 F9DB EBD3 807F EBD4 620E EBD5 701C EBD6 7D68 EBD7 878D EBD8 F9DC EBD9 57A0 EBDA 6069 EBDB 6147 EBDC 6BB7 EBDD 8ABE EBDE 9280 EBDF 96B1 EBE0 4E59 EBE1 541F EBE2 6DEB EBE3 852D EBE4 9670 EBE5 97F3 EBE6 98EE EBE7 63D6 EBE8 6CE3 EBE9 9091 EBEA 51DD EBEB 61C9 EBEC 81BA EBED 9DF9 EBEE 4F9D EBEF 501A EBF0 5100 EBF1 5B9C EBF2 610F EBF3 61FF EBF4 64EC EBF5 6905 EBF6 6BC5 EBF7 7591 EBF8 77E3 EBF9 7FA9 EBFA 8264 EBFB 858F EBFC 87FB EBFD 8863 EBFE 8ABC ECA1 8B70 ECA2 91AB ECA3 4E8C ECA4 4EE5 ECA5 4F0A ECA6 F9DD ECA7 F9DE ECA8 5937 ECA9 59E8 ECAA F9DF ECAB 5DF2 ECAC 5F1B ECAD 5F5B ECAE 6021 ECAF F9E0 ECB0 F9E1 ECB1 F9E2 ECB2 F9E3 ECB3 723E ECB4 73E5 ECB5 F9E4 ECB6 7570 ECB7 75CD ECB8 F9E5 ECB9 79FB ECBA F9E6 ECBB 800C ECBC 8033 ECBD 8084 ECBE 82E1 ECBF 8351 ECC0 F9E7 ECC1 F9E8 ECC2 8CBD ECC3 8CB3 ECC4 9087 ECC5 F9E9 ECC6 F9EA ECC7 98F4 ECC8 990C ECC9 F9EB ECCA F9EC ECCB 7037 ECCC 76CA ECCD 7FCA ECCE 7FCC ECCF 7FFC ECD0 8B1A ECD1 4EBA ECD2 4EC1 ECD3 5203 ECD4 5370 ECD5 F9ED ECD6 54BD ECD7 56E0 ECD8 59FB ECD9 5BC5 ECDA 5F15 ECDB 5FCD ECDC 6E6E ECDD F9EE ECDE F9EF ECDF 7D6A ECE0 8335 ECE1 F9F0 ECE2 8693 ECE3 8A8D ECE4 F9F1 ECE5 976D ECE6 9777 ECE7 F9F2 ECE8 F9F3 ECE9 4E00 ECEA 4F5A ECEB 4F7E ECEC 58F9 ECED 65E5 ECEE 6EA2 ECEF 9038 ECF0 93B0 ECF1 99B9 ECF2 4EFB ECF3 58EC ECF4 598A ECF5 59D9 ECF6 6041 ECF7 F9F4 ECF8 F9F5 ECF9 7A14 ECFA F9F6 ECFB 834F ECFC 8CC3 ECFD 5165 ECFE 5344 EDA1 F9F7 EDA2 F9F8 EDA3 F9F9 EDA4 4ECD EDA5 5269 EDA6 5B55 EDA7 82BF EDA8 4ED4 EDA9 523A EDAA 54A8 EDAB 59C9 EDAC 59FF EDAD 5B50 EDAE 5B57 EDAF 5B5C EDB0 6063 EDB1 6148 EDB2 6ECB EDB3 7099 EDB4 716E EDB5 7386 EDB6 74F7 EDB7 75B5 EDB8 78C1 EDB9 7D2B EDBA 8005 EDBB 81EA EDBC 8328 EDBD 8517 EDBE 85C9 EDBF 8AEE EDC0 8CC7 EDC1 96CC EDC2 4F5C EDC3 52FA EDC4 56BC EDC5 65AB EDC6 6628 EDC7 707C EDC8 70B8 EDC9 7235 EDCA 7DBD EDCB 828D EDCC 914C EDCD 96C0 EDCE 9D72 EDCF 5B71 EDD0 68E7 EDD1 6B98 EDD2 6F7A EDD3 76DE EDD4 5C91 EDD5 66AB EDD6 6F5B EDD7 7BB4 EDD8 7C2A EDD9 8836 EDDA 96DC EDDB 4E08 EDDC 4ED7 EDDD 5320 EDDE 5834 EDDF 58BB EDE0 58EF EDE1 596C EDE2 5C07 EDE3 5E33 EDE4 5E84 EDE5 5F35 EDE6 638C EDE7 66B2 EDE8 6756 EDE9 6A1F EDEA 6AA3 EDEB 6B0C EDEC 6F3F EDED 7246 EDEE F9FA EDEF 7350 EDF0 748B EDF1 7AE0 EDF2 7CA7 EDF3 8178 EDF4 81DF EDF5 81E7 EDF6 838A EDF7 846C EDF8 8523 EDF9 8594 EDFA 85CF EDFB 88DD EDFC 8D13 EDFD 91AC EDFE 9577 EEA1 969C EEA2 518D EEA3 54C9 EEA4 5728 EEA5 5BB0 EEA6 624D EEA7 6750 EEA8 683D EEA9 6893 EEAA 6E3D EEAB 6ED3 EEAC 707D EEAD 7E21 EEAE 88C1 EEAF 8CA1 EEB0 8F09 EEB1 9F4B EEB2 9F4E EEB3 722D EEB4 7B8F EEB5 8ACD EEB6 931A EEB7 4F47 EEB8 4F4E EEB9 5132 EEBA 5480 EEBB 59D0 EEBC 5E95 EEBD 62B5 EEBE 6775 EEBF 696E EEC0 6A17 EEC1 6CAE EEC2 6E1A EEC3 72D9 EEC4 732A EEC5 75BD EEC6 7BB8 EEC7 7D35 EEC8 82E7 EEC9 83F9 EECA 8457 EECB 85F7 EECC 8A5B EECD 8CAF EECE 8E87 EECF 9019 EED0 90B8 EED1 96CE EED2 9F5F EED3 52E3 EED4 540A EED5 5AE1 EED6 5BC2 EED7 6458 EED8 6575 EED9 6EF4 EEDA 72C4 EEDB F9FB EEDC 7684 EEDD 7A4D EEDE 7B1B EEDF 7C4D EEE0 7E3E EEE1 7FDF EEE2 837B EEE3 8B2B EEE4 8CCA EEE5 8D64 EEE6 8DE1 EEE7 8E5F EEE8 8FEA EEE9 8FF9 EEEA 9069 EEEB 93D1 EEEC 4F43 EEED 4F7A EEEE 50B3 EEEF 5168 EEF0 5178 EEF1 524D EEF2 526A EEF3 5861 EEF4 587C EEF5 5960 EEF6 5C08 EEF7 5C55 EEF8 5EDB EEF9 609B EEFA 6230 EEFB 6813 EEFC 6BBF EEFD 6C08 EEFE 6FB1 EFA1 714E EFA2 7420 EFA3 7530 EFA4 7538 EFA5 7551 EFA6 7672 EFA7 7B4C EFA8 7B8B EFA9 7BAD EFAA 7BC6 EFAB 7E8F EFAC 8A6E EFAD 8F3E EFAE 8F49 EFAF 923F EFB0 9293 EFB1 9322 EFB2 942B EFB3 96FB EFB4 985A EFB5 986B EFB6 991E EFB7 5207 EFB8 622A EFB9 6298 EFBA 6D59 EFBB 7664 EFBC 7ACA EFBD 7BC0 EFBE 7D76 EFBF 5360 EFC0 5CBE EFC1 5E97 EFC2 6F38 EFC3 70B9 EFC4 7C98 EFC5 9711 EFC6 9B8E EFC7 9EDE EFC8 63A5 EFC9 647A EFCA 8776 EFCB 4E01 EFCC 4E95 EFCD 4EAD EFCE 505C EFCF 5075 EFD0 5448 EFD1 59C3 EFD2 5B9A EFD3 5E40 EFD4 5EAD EFD5 5EF7 EFD6 5F81 EFD7 60C5 EFD8 633A EFD9 653F EFDA 6574 EFDB 65CC EFDC 6676 EFDD 6678 EFDE 67FE EFDF 6968 EFE0 6A89 EFE1 6B63 EFE2 6C40 EFE3 6DC0 EFE4 6DE8 EFE5 6E1F EFE6 6E5E EFE7 701E EFE8 70A1 EFE9 738E EFEA 73FD EFEB 753A EFEC 775B EFED 7887 EFEE 798E EFEF 7A0B EFF0 7A7D EFF1 7CBE EFF2 7D8E EFF3 8247 EFF4 8A02 EFF5 8AEA EFF6 8C9E EFF7 912D EFF8 914A EFF9 91D8 EFFA 9266 EFFB 92CC EFFC 9320 EFFD 9706 EFFE 9756 F0A1 975C F0A2 9802 F0A3 9F0E F0A4 5236 F0A5 5291 F0A6 557C F0A7 5824 F0A8 5E1D F0A9 5F1F F0AA 608C F0AB 63D0 F0AC 68AF F0AD 6FDF F0AE 796D F0AF 7B2C F0B0 81CD F0B1 85BA F0B2 88FD F0B3 8AF8 F0B4 8E44 F0B5 918D F0B6 9664 F0B7 969B F0B8 973D F0B9 984C F0BA 9F4A F0BB 4FCE F0BC 5146 F0BD 51CB F0BE 52A9 F0BF 5632 F0C0 5F14 F0C1 5F6B F0C2 63AA F0C3 64CD F0C4 65E9 F0C5 6641 F0C6 66FA F0C7 66F9 F0C8 671D F0C9 689D F0CA 68D7 F0CB 69FD F0CC 6F15 F0CD 6F6E F0CE 7167 F0CF 71E5 F0D0 722A F0D1 74AA F0D2 773A F0D3 7956 F0D4 795A F0D5 79DF F0D6 7A20 F0D7 7A95 F0D8 7C97 F0D9 7CDF F0DA 7D44 F0DB 7E70 F0DC 8087 F0DD 85FB F0DE 86A4 F0DF 8A54 F0E0 8ABF F0E1 8D99 F0E2 8E81 F0E3 9020 F0E4 906D F0E5 91E3 F0E6 963B F0E7 96D5 F0E8 9CE5 F0E9 65CF F0EA 7C07 F0EB 8DB3 F0EC 93C3 F0ED 5B58 F0EE 5C0A F0EF 5352 F0F0 62D9 F0F1 731D F0F2 5027 F0F3 5B97 F0F4 5F9E F0F5 60B0 F0F6 616B F0F7 68D5 F0F8 6DD9 F0F9 742E F0FA 7A2E F0FB 7D42 F0FC 7D9C F0FD 7E31 F0FE 816B F1A1 8E2A F1A2 8E35 F1A3 937E F1A4 9418 F1A5 4F50 F1A6 5750 F1A7 5DE6 F1A8 5EA7 F1A9 632B F1AA 7F6A F1AB 4E3B F1AC 4F4F F1AD 4F8F F1AE 505A F1AF 59DD F1B0 80C4 F1B1 546A F1B2 5468 F1B3 55FE F1B4 594F F1B5 5B99 F1B6 5DDE F1B7 5EDA F1B8 665D F1B9 6731 F1BA 67F1 F1BB 682A F1BC 6CE8 F1BD 6D32 F1BE 6E4A F1BF 6F8D F1C0 70B7 F1C1 73E0 F1C2 7587 F1C3 7C4C F1C4 7D02 F1C5 7D2C F1C6 7DA2 F1C7 821F F1C8 86DB F1C9 8A3B F1CA 8A85 F1CB 8D70 F1CC 8E8A F1CD 8F33 F1CE 9031 F1CF 914E F1D0 9152 F1D1 9444 F1D2 99D0 F1D3 7AF9 F1D4 7CA5 F1D5 4FCA F1D6 5101 F1D7 51C6 F1D8 57C8 F1D9 5BEF F1DA 5CFB F1DB 6659 F1DC 6A3D F1DD 6D5A F1DE 6E96 F1DF 6FEC F1E0 710C F1E1 756F F1E2 7AE3 F1E3 8822 F1E4 9021 F1E5 9075 F1E6 96CB F1E7 99FF F1E8 8301 F1E9 4E2D F1EA 4EF2 F1EB 8846 F1EC 91CD F1ED 537D F1EE 6ADB F1EF 696B F1F0 6C41 F1F1 847A F1F2 589E F1F3 618E F1F4 66FE F1F5 62EF F1F6 70DD F1F7 7511 F1F8 75C7 F1F9 7E52 F1FA 84B8 F1FB 8B49 F1FC 8D08 F1FD 4E4B F1FE 53EA F2A1 54AB F2A2 5730 F2A3 5740 F2A4 5FD7 F2A5 6301 F2A6 6307 F2A7 646F F2A8 652F F2A9 65E8 F2AA 667A F2AB 679D F2AC 67B3 F2AD 6B62 F2AE 6C60 F2AF 6C9A F2B0 6F2C F2B1 77E5 F2B2 7825 F2B3 7949 F2B4 7957 F2B5 7D19 F2B6 80A2 F2B7 8102 F2B8 81F3 F2B9 829D F2BA 82B7 F2BB 8718 F2BC 8A8C F2BD F9FC F2BE 8D04 F2BF 8DBE F2C0 9072 F2C1 76F4 F2C2 7A19 F2C3 7A37 F2C4 7E54 F2C5 8077 F2C6 5507 F2C7 55D4 F2C8 5875 F2C9 632F F2CA 6422 F2CB 6649 F2CC 664B F2CD 686D F2CE 699B F2CF 6B84 F2D0 6D25 F2D1 6EB1 F2D2 73CD F2D3 7468 F2D4 74A1 F2D5 755B F2D6 75B9 F2D7 76E1 F2D8 771E F2D9 778B F2DA 79E6 F2DB 7E09 F2DC 7E1D F2DD 81FB F2DE 852F F2DF 8897 F2E0 8A3A F2E1 8CD1 F2E2 8EEB F2E3 8FB0 F2E4 9032 F2E5 93AD F2E6 9663 F2E7 9673 F2E8 9707 F2E9 4F84 F2EA 53F1 F2EB 59EA F2EC 5AC9 F2ED 5E19 F2EE 684E F2EF 74C6 F2F0 75BE F2F1 79E9 F2F2 7A92 F2F3 81A3 F2F4 86ED F2F5 8CEA F2F6 8DCC F2F7 8FED F2F8 659F F2F9 6715 F2FA F9FD F2FB 57F7 F2FC 6F57 F2FD 7DDD F2FE 8F2F F3A1 93F6 F3A2 96C6 F3A3 5FB5 F3A4 61F2 F3A5 6F84 F3A6 4E14 F3A7 4F98 F3A8 501F F3A9 53C9 F3AA 55DF F3AB 5D6F F3AC 5DEE F3AD 6B21 F3AE 6B64 F3AF 78CB F3B0 7B9A F3B1 F9FE F3B2 8E49 F3B3 8ECA F3B4 906E F3B5 6349 F3B6 643E F3B7 7740 F3B8 7A84 F3B9 932F F3BA 947F F3BB 9F6A F3BC 64B0 F3BD 6FAF F3BE 71E6 F3BF 74A8 F3C0 74DA F3C1 7AC4 F3C2 7C12 F3C3 7E82 F3C4 7CB2 F3C5 7E98 F3C6 8B9A F3C7 8D0A F3C8 947D F3C9 9910 F3CA 994C F3CB 5239 F3CC 5BDF F3CD 64E6 F3CE 672D F3CF 7D2E F3D0 50ED F3D1 53C3 F3D2 5879 F3D3 6158 F3D4 6159 F3D5 61FA F3D6 65AC F3D7 7AD9 F3D8 8B92 F3D9 8B96 F3DA 5009 F3DB 5021 F3DC 5275 F3DD 5531 F3DE 5A3C F3DF 5EE0 F3E0 5F70 F3E1 6134 F3E2 655E F3E3 660C F3E4 6636 F3E5 66A2 F3E6 69CD F3E7 6EC4 F3E8 6F32 F3E9 7316 F3EA 7621 F3EB 7A93 F3EC 8139 F3ED 8259 F3EE 83D6 F3EF 84BC F3F0 50B5 F3F1 57F0 F3F2 5BC0 F3F3 5BE8 F3F4 5F69 F3F5 63A1 F3F6 7826 F3F7 7DB5 F3F8 83DC F3F9 8521 F3FA 91C7 F3FB 91F5 F3FC 518A F3FD 67F5 F3FE 7B56 F4A1 8CAC F4A2 51C4 F4A3 59BB F4A4 60BD F4A5 8655 F4A6 501C F4A7 F9FF F4A8 5254 F4A9 5C3A F4AA 617D F4AB 621A F4AC 62D3 F4AD 64F2 F4AE 65A5 F4AF 6ECC F4B0 7620 F4B1 810A F4B2 8E60 F4B3 965F F4B4 96BB F4B5 4EDF F4B6 5343 F4B7 5598 F4B8 5929 F4B9 5DDD F4BA 64C5 F4BB 6CC9 F4BC 6DFA F4BD 7394 F4BE 7A7F F4BF 821B F4C0 85A6 F4C1 8CE4 F4C2 8E10 F4C3 9077 F4C4 91E7 F4C5 95E1 F4C6 9621 F4C7 97C6 F4C8 51F8 F4C9 54F2 F4CA 5586 F4CB 5FB9 F4CC 64A4 F4CD 6F88 F4CE 7DB4 F4CF 8F1F F4D0 8F4D F4D1 9435 F4D2 50C9 F4D3 5C16 F4D4 6CBE F4D5 6DFB F4D6 751B F4D7 77BB F4D8 7C3D F4D9 7C64 F4DA 8A79 F4DB 8AC2 F4DC 581E F4DD 59BE F4DE 5E16 F4DF 6377 F4E0 7252 F4E1 758A F4E2 776B F4E3 8ADC F4E4 8CBC F4E5 8F12 F4E6 5EF3 F4E7 6674 F4E8 6DF8 F4E9 807D F4EA 83C1 F4EB 8ACB F4EC 9751 F4ED 9BD6 F4EE FA00 F4EF 5243 F4F0 66FF F4F1 6D95 F4F2 6EEF F4F3 7DE0 F4F4 8AE6 F4F5 902E F4F6 905E F4F7 9AD4 F4F8 521D F4F9 527F F4FA 54E8 F4FB 6194 F4FC 6284 F4FD 62DB F4FE 68A2 F5A1 6912 F5A2 695A F5A3 6A35 F5A4 7092 F5A5 7126 F5A6 785D F5A7 7901 F5A8 790E F5A9 79D2 F5AA 7A0D F5AB 8096 F5AC 8278 F5AD 82D5 F5AE 8349 F5AF 8549 F5B0 8C82 F5B1 8D85 F5B2 9162 F5B3 918B F5B4 91AE F5B5 4FC3 F5B6 56D1 F5B7 71ED F5B8 77D7 F5B9 8700 F5BA 89F8 F5BB 5BF8 F5BC 5FD6 F5BD 6751 F5BE 90A8 F5BF 53E2 F5C0 585A F5C1 5BF5 F5C2 60A4 F5C3 6181 F5C4 6460 F5C5 7E3D F5C6 8070 F5C7 8525 F5C8 9283 F5C9 64AE F5CA 50AC F5CB 5D14 F5CC 6700 F5CD 589C F5CE 62BD F5CF 63A8 F5D0 690E F5D1 6978 F5D2 6A1E F5D3 6E6B F5D4 76BA F5D5 79CB F5D6 82BB F5D7 8429 F5D8 8ACF F5D9 8DA8 F5DA 8FFD F5DB 9112 F5DC 914B F5DD 919C F5DE 9310 F5DF 9318 F5E0 939A F5E1 96DB F5E2 9A36 F5E3 9C0D F5E4 4E11 F5E5 755C F5E6 795D F5E7 7AFA F5E8 7B51 F5E9 7BC9 F5EA 7E2E F5EB 84C4 F5EC 8E59 F5ED 8E74 F5EE 8EF8 F5EF 9010 F5F0 6625 F5F1 693F F5F2 7443 F5F3 51FA F5F4 672E F5F5 9EDC F5F6 5145 F5F7 5FE0 F5F8 6C96 F5F9 87F2 F5FA 885D F5FB 8877 F5FC 60B4 F5FD 81B5 F5FE 8403 F6A1 8D05 F6A2 53D6 F6A3 5439 F6A4 5634 F6A5 5A36 F6A6 5C31 F6A7 708A F6A8 7FE0 F6A9 805A F6AA 8106 F6AB 81ED F6AC 8DA3 F6AD 9189 F6AE 9A5F F6AF 9DF2 F6B0 5074 F6B1 4EC4 F6B2 53A0 F6B3 60FB F6B4 6E2C F6B5 5C64 F6B6 4F88 F6B7 5024 F6B8 55E4 F6B9 5CD9 F6BA 5E5F F6BB 6065 F6BC 6894 F6BD 6CBB F6BE 6DC4 F6BF 71BE F6C0 75D4 F6C1 75F4 F6C2 7661 F6C3 7A1A F6C4 7A49 F6C5 7DC7 F6C6 7DFB F6C7 7F6E F6C8 81F4 F6C9 86A9 F6CA 8F1C F6CB 96C9 F6CC 99B3 F6CD 9F52 F6CE 5247 F6CF 52C5 F6D0 98ED F6D1 89AA F6D2 4E03 F6D3 67D2 F6D4 6F06 F6D5 4FB5 F6D6 5BE2 F6D7 6795 F6D8 6C88 F6D9 6D78 F6DA 741B F6DB 7827 F6DC 91DD F6DD 937C F6DE 87C4 F6DF 79E4 F6E0 7A31 F6E1 5FEB F6E2 4ED6 F6E3 54A4 F6E4 553E F6E5 58AE F6E6 59A5 F6E7 60F0 F6E8 6253 F6E9 62D6 F6EA 6736 F6EB 6955 F6EC 8235 F6ED 9640 F6EE 99B1 F6EF 99DD F6F0 502C F6F1 5353 F6F2 5544 F6F3 577C F6F4 FA01 F6F5 6258 F6F6 FA02 F6F7 64E2 F6F8 666B F6F9 67DD F6FA 6FC1 F6FB 6FEF F6FC 7422 F6FD 7438 F6FE 8A17 F7A1 9438 F7A2 5451 F7A3 5606 F7A4 5766 F7A5 5F48 F7A6 619A F7A7 6B4E F7A8 7058 F7A9 70AD F7AA 7DBB F7AB 8A95 F7AC 596A F7AD 812B F7AE 63A2 F7AF 7708 F7B0 803D F7B1 8CAA F7B2 5854 F7B3 642D F7B4 69BB F7B5 5B95 F7B6 5E11 F7B7 6E6F F7B8 FA03 F7B9 8569 F7BA 514C F7BB 53F0 F7BC 592A F7BD 6020 F7BE 614B F7BF 6B86 F7C0 6C70 F7C1 6CF0 F7C2 7B1E F7C3 80CE F7C4 82D4 F7C5 8DC6 F7C6 90B0 F7C7 98B1 F7C8 FA04 F7C9 64C7 F7CA 6FA4 F7CB 6491 F7CC 6504 F7CD 514E F7CE 5410 F7CF 571F F7D0 8A0E F7D1 615F F7D2 6876 F7D3 FA05 F7D4 75DB F7D5 7B52 F7D6 7D71 F7D7 901A F7D8 5806 F7D9 69CC F7DA 817F F7DB 892A F7DC 9000 F7DD 9839 F7DE 5078 F7DF 5957 F7E0 59AC F7E1 6295 F7E2 900F F7E3 9B2A F7E4 615D F7E5 7279 F7E6 95D6 F7E7 5761 F7E8 5A46 F7E9 5DF4 F7EA 628A F7EB 64AD F7EC 64FA F7ED 6777 F7EE 6CE2 F7EF 6D3E F7F0 722C F7F1 7436 F7F2 7834 F7F3 7F77 F7F4 82AD F7F5 8DDB F7F6 9817 F7F7 5224 F7F8 5742 F7F9 677F F7FA 7248 F7FB 74E3 F7FC 8CA9 F7FD 8FA6 F7FE 9211 F8A1 962A F8A2 516B F8A3 53ED F8A4 634C F8A5 4F69 F8A6 5504 F8A7 6096 F8A8 6557 F8A9 6C9B F8AA 6D7F F8AB 724C F8AC 72FD F8AD 7A17 F8AE 8987 F8AF 8C9D F8B0 5F6D F8B1 6F8E F8B2 70F9 F8B3 81A8 F8B4 610E F8B5 4FBF F8B6 504F F8B7 6241 F8B8 7247 F8B9 7BC7 F8BA 7DE8 F8BB 7FE9 F8BC 904D F8BD 97AD F8BE 9A19 F8BF 8CB6 F8C0 576A F8C1 5E73 F8C2 67B0 F8C3 840D F8C4 8A55 F8C5 5420 F8C6 5B16 F8C7 5E63 F8C8 5EE2 F8C9 5F0A F8CA 6583 F8CB 80BA F8CC 853D F8CD 9589 F8CE 965B F8CF 4F48 F8D0 5305 F8D1 530D F8D2 530F F8D3 5486 F8D4 54FA F8D5 5703 F8D6 5E03 F8D7 6016 F8D8 629B F8D9 62B1 F8DA 6355 F8DB FA06 F8DC 6CE1 F8DD 6D66 F8DE 75B1 F8DF 7832 F8E0 80DE F8E1 812F F8E2 82DE F8E3 8461 F8E4 84B2 F8E5 888D F8E6 8912 F8E7 900B F8E8 92EA F8E9 98FD F8EA 9B91 F8EB 5E45 F8EC 66B4 F8ED 66DD F8EE 7011 F8EF 7206 F8F0 FA07 F8F1 4FF5 F8F2 527D F8F3 5F6A F8F4 6153 F8F5 6753 F8F6 6A19 F8F7 6F02 F8F8 74E2 F8F9 7968 F8FA 8868 F8FB 8C79 F8FC 98C7 F8FD 98C4 F8FE 9A43 F9A1 54C1 F9A2 7A1F F9A3 6953 F9A4 8AF7 F9A5 8C4A F9A6 98A8 F9A7 99AE F9A8 5F7C F9A9 62AB F9AA 75B2 F9AB 76AE F9AC 88AB F9AD 907F F9AE 9642 F9AF 5339 F9B0 5F3C F9B1 5FC5 F9B2 6CCC F9B3 73CC F9B4 7562 F9B5 758B F9B6 7B46 F9B7 82FE F9B8 999D F9B9 4E4F F9BA 903C F9BB 4E0B F9BC 4F55 F9BD 53A6 F9BE 590F F9BF 5EC8 F9C0 6630 F9C1 6CB3 F9C2 7455 F9C3 8377 F9C4 8766 F9C5 8CC0 F9C6 9050 F9C7 971E F9C8 9C15 F9C9 58D1 F9CA 5B78 F9CB 8650 F9CC 8B14 F9CD 9DB4 F9CE 5BD2 F9CF 6068 F9D0 608D F9D1 65F1 F9D2 6C57 F9D3 6F22 F9D4 6FA3 F9D5 701A F9D6 7F55 F9D7 7FF0 F9D8 9591 F9D9 9592 F9DA 9650 F9DB 97D3 F9DC 5272 F9DD 8F44 F9DE 51FD F9DF 542B F9E0 54B8 F9E1 5563 F9E2 558A F9E3 6ABB F9E4 6DB5 F9E5 7DD8 F9E6 8266 F9E7 929C F9E8 9677 F9E9 9E79 F9EA 5408 F9EB 54C8 F9EC 76D2 F9ED 86E4 F9EE 95A4 F9EF 95D4 F9F0 965C F9F1 4EA2 F9F2 4F09 F9F3 59EE F9F4 5AE6 F9F5 5DF7 F9F6 6052 F9F7 6297 F9F8 676D F9F9 6841 F9FA 6C86 F9FB 6E2F F9FC 7F38 F9FD 809B F9FE 822A FAA1 FA08 FAA2 FA09 FAA3 9805 FAA4 4EA5 FAA5 5055 FAA6 54B3 FAA7 5793 FAA8 595A FAA9 5B69 FAAA 5BB3 FAAB 61C8 FAAC 6977 FAAD 6D77 FAAE 7023 FAAF 87F9 FAB0 89E3 FAB1 8A72 FAB2 8AE7 FAB3 9082 FAB4 99ED FAB5 9AB8 FAB6 52BE FAB7 6838 FAB8 5016 FAB9 5E78 FABA 674F FABB 8347 FABC 884C FABD 4EAB FABE 5411 FABF 56AE FAC0 73E6 FAC1 9115 FAC2 97FF FAC3 9909 FAC4 9957 FAC5 9999 FAC6 5653 FAC7 589F FAC8 865B FAC9 8A31 FACA 61B2 FACB 6AF6 FACC 737B FACD 8ED2 FACE 6B47 FACF 96AA FAD0 9A57 FAD1 5955 FAD2 7200 FAD3 8D6B FAD4 9769 FAD5 4FD4 FAD6 5CF4 FAD7 5F26 FAD8 61F8 FAD9 665B FADA 6CEB FADB 70AB FADC 7384 FADD 73B9 FADE 73FE FADF 7729 FAE0 774D FAE1 7D43 FAE2 7D62 FAE3 7E23 FAE4 8237 FAE5 8852 FAE6 FA0A FAE7 8CE2 FAE8 9249 FAE9 986F FAEA 5B51 FAEB 7A74 FAEC 8840 FAED 9801 FAEE 5ACC FAEF 4FE0 FAF0 5354 FAF1 593E FAF2 5CFD FAF3 633E FAF4 6D79 FAF5 72F9 FAF6 8105 FAF7 8107 FAF8 83A2 FAF9 92CF FAFA 9830 FAFB 4EA8 FAFC 5144 FAFD 5211 FAFE 578B FBA1 5F62 FBA2 6CC2 FBA3 6ECE FBA4 7005 FBA5 7050 FBA6 70AF FBA7 7192 FBA8 73E9 FBA9 7469 FBAA 834A FBAB 87A2 FBAC 8861 FBAD 9008 FBAE 90A2 FBAF 93A3 FBB0 99A8 FBB1 516E FBB2 5F57 FBB3 60E0 FBB4 6167 FBB5 66B3 FBB6 8559 FBB7 8E4A FBB8 91AF FBB9 978B FBBA 4E4E FBBB 4E92 FBBC 547C FBBD 58D5 FBBE 58FA FBBF 597D FBC0 5CB5 FBC1 5F27 FBC2 6236 FBC3 6248 FBC4 660A FBC5 6667 FBC6 6BEB FBC7 6D69 FBC8 6DCF FBC9 6E56 FBCA 6EF8 FBCB 6F94 FBCC 6FE0 FBCD 6FE9 FBCE 705D FBCF 72D0 FBD0 7425 FBD1 745A FBD2 74E0 FBD3 7693 FBD4 795C FBD5 7CCA FBD6 7E1E FBD7 80E1 FBD8 82A6 FBD9 846B FBDA 84BF FBDB 864E FBDC 865F FBDD 8774 FBDE 8B77 FBDF 8C6A FBE0 93AC FBE1 9800 FBE2 9865 FBE3 60D1 FBE4 6216 FBE5 9177 FBE6 5A5A FBE7 660F FBE8 6DF7 FBE9 6E3E FBEA 743F FBEB 9B42 FBEC 5FFD FBED 60DA FBEE 7B0F FBEF 54C4 FBF0 5F18 FBF1 6C5E FBF2 6CD3 FBF3 6D2A FBF4 70D8 FBF5 7D05 FBF6 8679 FBF7 8A0C FBF8 9D3B FBF9 5316 FBFA 548C FBFB 5B05 FBFC 6A3A FBFD 706B FBFE 7575 FCA1 798D FCA2 79BE FCA3 82B1 FCA4 83EF FCA5 8A71 FCA6 8B41 FCA7 8CA8 FCA8 9774 FCA9 FA0B FCAA 64F4 FCAB 652B FCAC 78BA FCAD 78BB FCAE 7A6B FCAF 4E38 FCB0 559A FCB1 5950 FCB2 5BA6 FCB3 5E7B FCB4 60A3 FCB5 63DB FCB6 6B61 FCB7 6665 FCB8 6853 FCB9 6E19 FCBA 7165 FCBB 74B0 FCBC 7D08 FCBD 9084 FCBE 9A69 FCBF 9C25 FCC0 6D3B FCC1 6ED1 FCC2 733E FCC3 8C41 FCC4 95CA FCC5 51F0 FCC6 5E4C FCC7 5FA8 FCC8 604D FCC9 60F6 FCCA 6130 FCCB 614C FCCC 6643 FCCD 6644 FCCE 69A5 FCCF 6CC1 FCD0 6E5F FCD1 6EC9 FCD2 6F62 FCD3 714C FCD4 749C FCD5 7687 FCD6 7BC1 FCD7 7C27 FCD8 8352 FCD9 8757 FCDA 9051 FCDB 968D FCDC 9EC3 FCDD 532F FCDE 56DE FCDF 5EFB FCE0 5F8A FCE1 6062 FCE2 6094 FCE3 61F7 FCE4 6666 FCE5 6703 FCE6 6A9C FCE7 6DEE FCE8 6FAE FCE9 7070 FCEA 736A FCEB 7E6A FCEC 81BE FCED 8334 FCEE 86D4 FCEF 8AA8 FCF0 8CC4 FCF1 5283 FCF2 7372 FCF3 5B96 FCF4 6A6B FCF5 9404 FCF6 54EE FCF7 5686 FCF8 5B5D FCF9 6548 FCFA 6585 FCFB 66C9 FCFC 689F FCFD 6D8D FCFE 6DC6 FDA1 723B FDA2 80B4 FDA3 9175 FDA4 9A4D FDA5 4FAF FDA6 5019 FDA7 539A FDA8 540E FDA9 543C FDAA 5589 FDAB 55C5 FDAC 5E3F FDAD 5F8C FDAE 673D FDAF 7166 FDB0 73DD FDB1 9005 FDB2 52DB FDB3 52F3 FDB4 5864 FDB5 58CE FDB6 7104 FDB7 718F FDB8 71FB FDB9 85B0 FDBA 8A13 FDBB 6688 FDBC 85A8 FDBD 55A7 FDBE 6684 FDBF 714A FDC0 8431 FDC1 5349 FDC2 5599 FDC3 6BC1 FDC4 5F59 FDC5 5FBD FDC6 63EE FDC7 6689 FDC8 7147 FDC9 8AF1 FDCA 8F1D FDCB 9EBE FDCC 4F11 FDCD 643A FDCE 70CB FDCF 7566 FDD0 8667 FDD1 6064 FDD2 8B4E FDD3 9DF8 FDD4 5147 FDD5 51F6 FDD6 5308 FDD7 6D36 FDD8 80F8 FDD9 9ED1 FDDA 6615 FDDB 6B23 FDDC 7098 FDDD 75D5 FDDE 5403 FDDF 5C79 FDE0 7D07 FDE1 8A16 FDE2 6B20 FDE3 6B3D FDE4 6B46 FDE5 5438 FDE6 6070 FDE7 6D3D FDE8 7FD5 FDE9 8208 FDEA 50D6 FDEB 51DE FDEC 559C FDED 566B FDEE 56CD FDEF 59EC FDF0 5B09 FDF1 5E0C FDF2 6199 FDF3 6198 FDF4 6231 FDF5 665E FDF6 66E6 FDF7 7199 FDF8 71B9 FDF9 71BA FDFA 72A7 FDFB 79A7 FDFC 7A00 FDFD 7FB2 FDFE 8A70
83,284
8,355
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_fcntl.py
"""Test program for the fcntl C module. """ import platform import os import struct import sys import unittest from test.support import (verbose, TESTFN, unlink, run_unittest, import_module, cpython_only) # Skip test if no fcntl module. fcntl = import_module('fcntl') if __name__ == 'PYOBJ.COM': import fcntl import termios # TODO - Write tests for flock() and lockf(). def get_lockdata(): try: os.O_LARGEFILE except AttributeError: start_len = "ll" else: start_len = "qq" if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos')) or sys.platform == 'darwin'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' else: off_t = 'lxxxx' pid_t = 'l' lockdata = struct.pack(off_t + off_t + pid_t + 'hh', 0, 0, 0, fcntl.F_WRLCK, 0) elif sys.platform.startswith('gnukfreebsd'): lockdata = struct.pack('qqihhi', 0, 0, 0, fcntl.F_WRLCK, 0, 0) elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']: lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0) else: lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0) if lockdata: if verbose: print('struct.pack: ', repr(lockdata)) return lockdata lockdata = get_lockdata() class BadFile: def __init__(self, fn): self.fn = fn def fileno(self): return self.fn class TestFcntl(unittest.TestCase): def setUp(self): self.f = None def tearDown(self): if self.f and not self.f.closed: self.f.close() unlink(TESTFN) def test_fcntl_fileno(self): # the example from the library docs self.f = open(TESTFN, 'wb') rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) if verbose: print('Status from fcntl with O_NONBLOCK: ', rv) rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, lockdata) if verbose: print('String from fcntl with F_SETLKW: ', repr(rv)) self.f.close() def test_fcntl_file_descriptor(self): # again, but pass the file rather than numeric descriptor self.f = open(TESTFN, 'wb') rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK) if verbose: print('Status from fcntl with O_NONBLOCK: ', rv) rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) if verbose: print('String from fcntl with F_SETLKW: ', repr(rv)) self.f.close() def test_fcntl_bad_file(self): with self.assertRaises(ValueError): fcntl.fcntl(-1, fcntl.F_SETFL, os.O_NONBLOCK) with self.assertRaises(ValueError): fcntl.fcntl(BadFile(-1), fcntl.F_SETFL, os.O_NONBLOCK) with self.assertRaises(TypeError): fcntl.fcntl('spam', fcntl.F_SETFL, os.O_NONBLOCK) with self.assertRaises(TypeError): fcntl.fcntl(BadFile('spam'), fcntl.F_SETFL, os.O_NONBLOCK) @cpython_only def test_fcntl_bad_file_overflow(self): from _testcapi import INT_MAX, INT_MIN # Issue 15989 with self.assertRaises(OverflowError): fcntl.fcntl(INT_MAX + 1, fcntl.F_SETFL, os.O_NONBLOCK) with self.assertRaises(OverflowError): fcntl.fcntl(BadFile(INT_MAX + 1), fcntl.F_SETFL, os.O_NONBLOCK) with self.assertRaises(OverflowError): fcntl.fcntl(INT_MIN - 1, fcntl.F_SETFL, os.O_NONBLOCK) with self.assertRaises(OverflowError): fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK) @unittest.skipIf( platform.machine().startswith('arm') and platform.system() == 'Linux', "ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT") def test_fcntl_64_bit(self): # Issue #1309352: fcntl shouldn't fail when the third arg fits in a # C 'long' but not in a C 'int'. try: cmd = fcntl.F_NOTIFY # This flag is larger than 2**31 in 64-bit builds flags = fcntl.DN_MULTISHOT except AttributeError: self.skipTest("F_NOTIFY or DN_MULTISHOT unavailable") fd = os.open(os.path.dirname(os.path.abspath(TESTFN)), os.O_RDONLY) try: fcntl.fcntl(fd, cmd, flags) finally: os.close(fd) def test_flock(self): # Solaris needs readable file for shared lock self.f = open(TESTFN, 'wb+') fileno = self.f.fileno() fcntl.flock(fileno, fcntl.LOCK_SH) fcntl.flock(fileno, fcntl.LOCK_UN) fcntl.flock(self.f, fcntl.LOCK_SH | fcntl.LOCK_NB) fcntl.flock(self.f, fcntl.LOCK_UN) fcntl.flock(fileno, fcntl.LOCK_EX) fcntl.flock(fileno, fcntl.LOCK_UN) self.assertRaises(ValueError, fcntl.flock, -1, fcntl.LOCK_SH) self.assertRaises(TypeError, fcntl.flock, 'spam', fcntl.LOCK_SH) @cpython_only def test_flock_overflow(self): import _testcapi self.assertRaises(OverflowError, fcntl.flock, _testcapi.INT_MAX+1, fcntl.LOCK_SH) def test_main(): run_unittest(TestFcntl) if __name__ == '__main__': test_main()
5,285
157
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_keyword.py
import cosmo import keyword import unittest from test import support import filecmp import os import sys import subprocess import shutil import textwrap KEYWORD_FILE = support.findfile('keyword.py') GRAMMAR_FILE = os.path.join(os.path.split(__file__)[0], '..', '..', 'Python', 'graminit.c') TEST_PY_FILE = 'keyword_test.py' GRAMMAR_TEST_FILE = 'graminit_test.c' PY_FILE_WITHOUT_KEYWORDS = 'minimal_keyword.py' NONEXISTENT_FILE = 'not_here.txt' class Test_iskeyword(unittest.TestCase): def test_true_is_a_keyword(self): self.assertTrue(keyword.iskeyword('True')) def test_uppercase_true_is_not_a_keyword(self): self.assertFalse(keyword.iskeyword('TRUE')) def test_none_value_is_not_a_keyword(self): self.assertFalse(keyword.iskeyword(None)) # This is probably an accident of the current implementation, but should be # preserved for backward compatibility. def test_changing_the_kwlist_does_not_affect_iskeyword(self): oldlist = keyword.kwlist self.addCleanup(setattr, keyword, 'kwlist', oldlist) keyword.kwlist = ['its', 'all', 'eggs', 'beans', 'and', 'a', 'slice'] self.assertFalse(keyword.iskeyword('eggs')) class TestKeywordGeneration(unittest.TestCase): def _copy_file_without_generated_keywords(self, source_file, dest_file): with open(source_file, 'rb') as fp: lines = fp.readlines() nl = lines[0][len(lines[0].strip()):] with open(dest_file, 'wb') as fp: fp.writelines(lines[:lines.index(b"#--start keywords--" + nl) + 1]) fp.writelines(lines[lines.index(b"#--end keywords--" + nl):]) def _generate_keywords(self, grammar_file, target_keyword_py_file): proc = subprocess.Popen([sys.executable, KEYWORD_FILE, grammar_file, target_keyword_py_file], stderr=subprocess.PIPE) stderr = proc.communicate()[1] return proc.returncode, stderr @unittest.skipIf(not os.path.exists(GRAMMAR_FILE), 'test only works from source build directory') def test_real_grammar_and_keyword_file(self): self._copy_file_without_generated_keywords(KEYWORD_FILE, TEST_PY_FILE) self.addCleanup(support.unlink, TEST_PY_FILE) self.assertFalse(filecmp.cmp(KEYWORD_FILE, TEST_PY_FILE)) self.assertEqual((0, b''), self._generate_keywords(GRAMMAR_FILE, TEST_PY_FILE)) self.assertTrue(filecmp.cmp(KEYWORD_FILE, TEST_PY_FILE)) @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "no py file in rel mode") def test_grammar(self): self._copy_file_without_generated_keywords(KEYWORD_FILE, TEST_PY_FILE) self.addCleanup(support.unlink, TEST_PY_FILE) with open(GRAMMAR_TEST_FILE, 'w') as fp: # Some of these are probably implementation accidents. fp.writelines(textwrap.dedent("""\ {2, 1}, {11, "encoding_decl", 0, 2, states_79, "\000\000\040\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000"}, {1, "jello"}, {326, 0}, {1, "turnip"}, \t{1, "This one is tab indented" {278, 0}, {1, "crazy but legal" "also legal" {1, " {1, "continue"}, {1, "lemon"}, {1, "tomato"}, {1, "wigii"}, {1, 'no good'} {283, 0}, {1, "too many spaces"}""")) self.addCleanup(support.unlink, GRAMMAR_TEST_FILE) self._generate_keywords(GRAMMAR_TEST_FILE, TEST_PY_FILE) expected = [ " 'This one is tab indented',", " 'also legal',", " 'continue',", " 'crazy but legal',", " 'jello',", " 'lemon',", " 'tomato',", " 'turnip',", " 'wigii',", ] with open(TEST_PY_FILE) as fp: lines = fp.read().splitlines() start = lines.index("#--start keywords--") + 1 end = lines.index("#--end keywords--") actual = lines[start:end] self.assertEqual(actual, expected) @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "no py file in rel mode") def test_empty_grammar_results_in_no_keywords(self): self._copy_file_without_generated_keywords(KEYWORD_FILE, PY_FILE_WITHOUT_KEYWORDS) self.addCleanup(support.unlink, PY_FILE_WITHOUT_KEYWORDS) shutil.copyfile(KEYWORD_FILE, TEST_PY_FILE) self.addCleanup(support.unlink, TEST_PY_FILE) self.assertEqual((0, b''), self._generate_keywords(os.devnull, TEST_PY_FILE)) self.assertTrue(filecmp.cmp(TEST_PY_FILE, PY_FILE_WITHOUT_KEYWORDS)) @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "no py file in rel mode") def test_keywords_py_without_markers_produces_error(self): rc, stderr = self._generate_keywords(os.devnull, os.devnull) self.assertNotEqual(rc, 0) self.assertRegex(stderr, b'does not contain format markers') @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "no py file in rel mode") def test_missing_grammar_file_produces_error(self): rc, stderr = self._generate_keywords(NONEXISTENT_FILE, KEYWORD_FILE) self.assertNotEqual(rc, 0) self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode()) @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "no py file in rel mode") def test_missing_keywords_py_file_produces_error(self): rc, stderr = self._generate_keywords(os.devnull, NONEXISTENT_FILE) self.assertNotEqual(rc, 0) self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode()) if __name__ == "__main__": unittest.main()
6,348
150
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_codecmaps_cn.py
# # test_codecmaps_cn.py # Codec mapping tests for PRC encodings # from test import multibytecodec_support import unittest class TestGB2312Map(multibytecodec_support.TestBase_Mapping, unittest.TestCase): encoding = 'gb2312' mapfileurl = '/zip/.python/test/EUC-CN.TXT' class TestGBKMap(multibytecodec_support.TestBase_Mapping, unittest.TestCase): encoding = 'gbk' mapfileurl = '/zip/.python/test/CP936.TXT' class TestGB18030Map(multibytecodec_support.TestBase_Mapping, unittest.TestCase): encoding = 'gb18030' mapfileurl = '/zip/.python/test/gb-18030-2000.ucm' if __name__ == "__main__": unittest.main()
697
26
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_cmd_line.py
# Tests invocation of the interpreter with various command line arguments # Most tests are executed with environment variables ignored # See test_cmd_line_script.py for testing of script execution import test.support, unittest import os import shutil import sys import subprocess import tempfile from test.support import script_helper, is_android from test.support.script_helper import (spawn_python, kill_python, assert_python_ok, assert_python_failure, interpreter_requires_environment) # XXX (ncoghlan): Move to script_helper and make consistent with run_python def _kill_python_and_exit_code(p): data = kill_python(p) returncode = p.wait() return data, returncode class CmdLineTest(unittest.TestCase): def test_directories(self): assert_python_failure('.') assert_python_failure('< .') def verify_valid_flag(self, cmd_line): rc, out, err = assert_python_ok(*cmd_line) self.assertTrue(out == b'' or out.endswith(b'\n')) self.assertNotIn(b'Traceback', out) self.assertNotIn(b'Traceback', err) def test_optimize(self): self.verify_valid_flag('-O') self.verify_valid_flag('-OO') def test_site_flag(self): self.verify_valid_flag('-S') def test_usage(self): rc, out, err = assert_python_ok('-h') self.assertIn(b'usage', out) def test_version(self): version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii") for switch in '-V', '--version', '-VV': rc, out, err = assert_python_ok(switch) self.assertFalse(err.startswith(version)) self.assertTrue(out.startswith(version)) def test_verbose(self): # -v causes imports to write to stderr. If the write to # stderr itself causes an import to happen (for the output # codec), a recursion loop can occur. rc, out, err = assert_python_ok('-v') self.assertNotIn(b'stack overflow', err) rc, out, err = assert_python_ok('-vv') self.assertNotIn(b'stack overflow', err) @unittest.skipIf(True, # TODO: figure out this error #interpreter_requires_environment(), 'Cannot run -E tests when PYTHON env vars are required.') def test_xoptions(self): def get_xoptions(*args): # use subprocess module directly because test.support.script_helper adds # "-X faulthandler" to the command line args = (sys.executable, '-E') + args args += ('-c', 'import sys; print(sys._xoptions)') out = subprocess.check_output(args) opts = eval(out.splitlines()[0]) return opts opts = get_xoptions() self.assertEqual(opts, {}) opts = get_xoptions('-Xa', '-Xb=c,d=e') self.assertEqual(opts, {'a': True, 'b': 'c,d=e'}) def test_showrefcount(self): def run_python(*args): # this is similar to assert_python_ok but doesn't strip # the refcount from stderr. It can be replaced once # assert_python_ok stops doing that. cmd = [sys.executable] cmd.extend(args) PIPE = subprocess.PIPE p = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE) out, err = p.communicate() p.stdout.close() p.stderr.close() rc = p.returncode self.assertEqual(rc, 0) return rc, out, err code = 'import sys; print(sys._xoptions)' # normally the refcount is hidden rc, out, err = run_python('-c', code) self.assertEqual(out.rstrip(), b'{}') self.assertEqual(err, b'') # "-X showrefcount" shows the refcount, but only in debug builds rc, out, err = run_python('-X', 'showrefcount', '-c', code) self.assertEqual(out.rstrip(), b"{'showrefcount': True}") if hasattr(sys, 'gettotalrefcount'): # debug build self.assertRegex(err, br'^\[\d+ refs, \d+ blocks\]') else: self.assertEqual(err, b'') def test_run_module(self): # Test expected operation of the '-m' switch # Switch needs an argument assert_python_failure('-m') # Check we get an error for a nonexistent module assert_python_failure('-m', 'fnord43520xyz') # Check the runpy module also gives an error for # a nonexistent module assert_python_failure('-m', 'runpy', 'fnord43520xyz') # All good if module is located and run successfully assert_python_ok('-m', 'timeit', '-n', '1') def test_run_module_bug1764407(self): # -m and -i need to play well together # Runs the timeit module and checks the __main__ # namespace has been populated appropriately p = spawn_python('-i', '-m', 'timeit', '-n', '1') p.stdin.write(b'Timer\n') p.stdin.write(b'exit()\n') data = kill_python(p) self.assertTrue(data.find(b'1 loop') != -1) self.assertTrue(data.find(b'__main__.Timer') != -1) def test_run_code(self): # Test expected operation of the '-c' switch # Switch needs an argument assert_python_failure('-c') # Check we get an error for an uncaught exception assert_python_failure('-c', 'raise Exception') # All good if execution is successful assert_python_ok('-c', 'pass') @unittest.skipUnless(test.support.FS_NONASCII, 'need support.FS_NONASCII') def test_non_ascii(self): # Test handling of non-ascii data command = ("assert(ord(%r) == %s)" % (test.support.FS_NONASCII, ord(test.support.FS_NONASCII))) assert_python_ok('-c', command) # On Windows, pass bytes to subprocess doesn't test how Python decodes the # command line, but how subprocess does decode bytes to unicode. Python # doesn't decode the command line because Windows provides directly the # arguments as unicode (using wmain() instead of main()). @unittest.skipIf(sys.platform == 'win32', 'Windows has a native unicode API') def test_undecodable_code(self): undecodable = b"\xff" env = os.environ.copy() # Use C locale to get ascii for the locale encoding env['LC_ALL'] = 'C' code = ( b'import locale; ' b'print(ascii("' + undecodable + b'"), ' b'locale.getpreferredencoding())') p = subprocess.Popen( [sys.executable, "-c", code], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) stdout, stderr = p.communicate() if p.returncode == 1: # _Py_char2wchar() decoded b'\xff' as '\udcff' (b'\xff' is not # decodable from ASCII) and run_command() failed on # PyUnicode_AsUTF8String(). This is the expected behaviour on # Linux. pattern = b"Unable to decode the command from the command line:" elif p.returncode == 0: # _Py_char2wchar() decoded b'\xff' as '\xff' even if the locale is # C and the locale encoding is ASCII. It occurs on FreeBSD, Solaris # and Mac OS X. pattern = b"'\\xff' " # The output is followed by the encoding name, an alias to ASCII. # Examples: "US-ASCII" or "646" (ISO 646, on Solaris). else: raise AssertionError("Unknown exit code: %s, output=%a" % (p.returncode, stdout)) if not stdout.startswith(pattern): raise AssertionError("%a doesn't start with %a" % (stdout, pattern)) @unittest.skipUnless((sys.platform == 'darwin' or is_android), 'test specific to Mac OS X and Android') def test_osx_android_utf8(self): def check_output(text): decoded = text.decode('utf-8', 'surrogateescape') expected = ascii(decoded).encode('ascii') + b'\n' env = os.environ.copy() # C locale gives ASCII locale encoding, but Python uses UTF-8 # to parse the command line arguments on Mac OS X and Android. env['LC_ALL'] = 'C' p = subprocess.Popen( (sys.executable, "-c", "import sys; print(ascii(sys.argv[1]))", text), stdout=subprocess.PIPE, env=env) stdout, stderr = p.communicate() self.assertEqual(stdout, expected) self.assertEqual(p.returncode, 0) # test valid utf-8 text = 'e:\xe9, euro:\u20ac, non-bmp:\U0010ffff'.encode('utf-8') check_output(text) # test invalid utf-8 text = ( b'\xff' # invalid byte b'\xc3\xa9' # valid utf-8 character b'\xc3\xff' # invalid byte sequence b'\xed\xa0\x80' # lone surrogate character (invalid) ) check_output(text) def test_unbuffered_output(self): # Test expected operation of the '-u' switch for stream in ('stdout', 'stderr'): # Binary is unbuffered code = ("import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)" % stream) rc, out, err = assert_python_ok('-u', '-c', code) data = err if stream == 'stderr' else out self.assertEqual(data, b'x', "binary %s not unbuffered" % stream) # Text is line-buffered code = ("import os, sys; sys.%s.write('x\\n'); os._exit(0)" % stream) rc, out, err = assert_python_ok('-u', '-c', code) data = err if stream == 'stderr' else out self.assertEqual(data.strip(), b'x', "text %s not line-buffered" % stream) def test_unbuffered_input(self): # sys.stdin still works with '-u' code = ("import sys; sys.stdout.write(sys.stdin.read(1))") p = spawn_python('-u', '-c', code) p.stdin.write(b'x') p.stdin.flush() data, rc = _kill_python_and_exit_code(p) self.assertEqual(rc, 0) self.assertTrue(data.startswith(b'x'), data) @unittest.skipIf(True, "APE doesn't check PYTHONPATH") def test_large_PYTHONPATH(self): path1 = "ABCDE" * 100 path2 = "FGHIJ" * 100 path = path1 + os.pathsep + path2 code = """if 1: import sys path = ":".join(sys.path) path = path.encode("ascii", "backslashreplace") sys.stdout.buffer.write(path)""" rc, out, err = assert_python_ok('-S', '-c', code, PYTHONPATH=path) self.assertIn(path1.encode('ascii'), out) self.assertIn(path2.encode('ascii'), out) def test_empty_PYTHONPATH_issue16309(self): # On Posix, it is documented that setting PATH to the # empty string is equivalent to not setting PATH at all, # which is an exception to the rule that in a string like # "/bin::/usr/bin" the empty string in the middle gets # interpreted as '.' code = """if 1: import sys path = ":".join(sys.path) path = path.encode("ascii", "backslashreplace") sys.stdout.buffer.write(path)""" rc1, out1, err1 = assert_python_ok('-c', code, PYTHONPATH="") rc2, out2, err2 = assert_python_ok('-c', code, __isolated=False) # regarding to Posix specification, outputs should be equal # for empty and unset PYTHONPATH self.assertEqual(out1, out2) def test_displayhook_unencodable(self): for encoding in ('ascii', 'latin-1', 'utf-8'): env = os.environ.copy() env['PYTHONIOENCODING'] = encoding p = subprocess.Popen( [sys.executable, '-i'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) # non-ascii, surrogate, non-BMP printable, non-BMP unprintable text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF" p.stdin.write(ascii(text).encode('ascii') + b"\n") p.stdin.write(b'exit()\n') data = kill_python(p) escaped = repr(text).encode(encoding, 'backslashreplace') self.assertIn(escaped, data) def check_input(self, code, expected): with tempfile.NamedTemporaryFile("wb+") as stdin: sep = os.linesep.encode('ASCII') stdin.write(sep.join((b'abc', b'def'))) stdin.flush() stdin.seek(0) with subprocess.Popen( (sys.executable, "-c", code), stdin=stdin, stdout=subprocess.PIPE) as proc: stdout, stderr = proc.communicate() self.assertEqual(stdout.rstrip(), expected) def test_stdin_readline(self): # Issue #11272: check that sys.stdin.readline() replaces '\r\n' by '\n' # on Windows (sys.stdin is opened in binary mode) self.check_input( "import sys; print(repr(sys.stdin.readline()))", b"'abc\\n'") def test_builtin_input(self): # Issue #11272: check that input() strips newlines ('\n' or '\r\n') self.check_input( "print(repr(input()))", b"'abc'") def test_output_newline(self): # Issue 13119 Newline for print() should be \r\n on Windows. code = """if 1: import sys print(1) print(2) print(3, file=sys.stderr) print(4, file=sys.stderr)""" rc, out, err = assert_python_ok('-c', code) if sys.platform == 'win32': self.assertEqual(b'1\r\n2\r\n', out) self.assertEqual(b'3\r\n4', err) else: self.assertEqual(b'1\n2\n', out) self.assertEqual(b'3\n4', err) def test_unmached_quote(self): # Issue #10206: python program starting with unmatched quote # spewed spaces to stdout rc, out, err = assert_python_failure('-c', "'") self.assertRegex(err.decode('ascii', 'ignore'), 'SyntaxError') self.assertEqual(b'', out) def test_stdout_flush_at_shutdown(self): # Issue #5319: if stdout.flush() fails at shutdown, an error should # be printed out. code = """if 1: import os, sys, test.support test.support.SuppressCrashReport().__enter__() sys.stdout.write('x') os.close(sys.stdout.fileno())""" rc, out, err = assert_python_failure('-c', code) self.assertEqual(b'', out) self.assertEqual(120, rc) self.assertRegex(err.decode('ascii', 'ignore'), 'Exception ignored in.*\nOSError: .*') def test_closed_stdout(self): # Issue #13444: if stdout has been explicitly closed, we should # not attempt to flush it at shutdown. code = "import sys; sys.stdout.close()" rc, out, err = assert_python_ok('-c', code) self.assertEqual(b'', err) # Issue #7111: Python should work without standard streams @unittest.skipIf(True, # TODO: sys, os need to be tested first # os.name != 'posix', "test needs POSIX semantics") def _test_no_stdio(self, streams): code = """if 1: import os, sys for i, s in enumerate({streams}): if getattr(sys, s) is not None: os._exit(i + 1) os._exit(42)""".format(streams=streams) def preexec(): if 'stdin' in streams: os.close(0) if 'stdout' in streams: os.close(1) if 'stderr' in streams: os.close(2) p = subprocess.Popen( [sys.executable, "-E", "-c", code], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=preexec) out, err = p.communicate() self.assertEqual(test.support.strip_python_stderr(err), b'') self.assertEqual(p.returncode, 42) def test_no_stdin(self): self._test_no_stdio(['stdin']) def test_no_stdout(self): self._test_no_stdio(['stdout']) def test_no_stderr(self): self._test_no_stdio(['stderr']) def test_no_std_streams(self): self._test_no_stdio(['stdin', 'stdout', 'stderr']) def test_hash_randomization(self): # Verify that -R enables hash randomization: self.verify_valid_flag('-R') hashes = [] if os.environ.get('PYTHONHASHSEED', 'random') != 'random': env = dict(os.environ) # copy # We need to test that it is enabled by default without # the environment variable enabling it for us. del env['PYTHONHASHSEED'] env['__cleanenv'] = '1' # consumed by assert_python_ok() else: env = {} for i in range(3): code = 'print(hash("spam"))' rc, out, err = assert_python_ok('-c', code, **env) self.assertEqual(rc, 0) hashes.append(out) hashes = sorted(set(hashes)) # uniq # Rare chance of failure due to 3 random seeds honestly being equal. self.assertGreater(len(hashes), 1, msg='3 runs produced an identical random hash ' ' for "spam": {}'.format(hashes)) # Verify that sys.flags contains hash_randomization code = 'import sys; print("random is", sys.flags.hash_randomization)' rc, out, err = assert_python_ok('-c', code, PYTHONHASHSEED='') self.assertIn(b'random is 1', out) rc, out, err = assert_python_ok('-c', code, PYTHONHASHSEED='random') self.assertIn(b'random is 1', out) rc, out, err = assert_python_ok('-c', code, PYTHONHASHSEED='0') self.assertIn(b'random is 0', out) def test_del___main__(self): # Issue #15001: PyRun_SimpleFileExFlags() did crash because it kept a # borrowed reference to the dict of __main__ module and later modify # the dict whereas the module was destroyed filename = test.support.TESTFN self.addCleanup(test.support.unlink, filename) with open(filename, "w") as script: print("import sys", file=script) print("del sys.modules['__main__']", file=script) assert_python_ok(filename) def test_unknown_options(self): rc, out, err = assert_python_failure('-E', '-z') self.assertIn(b'Unknown option: -z', err) self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1) self.assertEqual(b'', out) # Add "without='-E'" to prevent _assert_python to append -E # to env_vars and change the output of stderr rc, out, err = assert_python_failure('-z', without='-E') self.assertIn(b'Unknown option: -z', err) self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1) self.assertEqual(b'', out) rc, out, err = assert_python_failure('-a', '-z', without='-E') self.assertIn(b'Unknown option: -a', err) # only the first unknown option is reported self.assertNotIn(b'Unknown option: -z', err) self.assertEqual(err.splitlines().count(b'Unknown option: -a'), 1) self.assertEqual(b'', out) @unittest.skipIf(script_helper.interpreter_requires_environment(), 'Cannot run -I tests when PYTHON env vars are required.') def test_isolatedmode(self): self.verify_valid_flag('-I') self.verify_valid_flag('-IEs') rc, out, err = assert_python_ok('-I', '-c', 'from sys import flags as f; ' 'print(f.no_user_site, f.ignore_environment, f.isolated)', # dummyvar to prevent extraneous -E dummyvar="") self.assertEqual(out.strip(), b'1 1 1') with test.support.temp_cwd() as tmpdir: fake = os.path.join(tmpdir, "uuid.py") main = os.path.join(tmpdir, "main.py") with open(fake, "w") as f: f.write("raise RuntimeError('isolated mode test')\n") with open(main, "w") as f: f.write("import sys\n") f.write("import _imp\n") f.write("if sys.meta_path[0] == _imp.CosmoImporter:\n") f.write("\tsys.meta_path.pop(0)\n") f.write("import uuid\n") f.write("print('ok')\n") self.assertRaises(subprocess.CalledProcessError, subprocess.check_output, [sys.executable, main], cwd=tmpdir, stderr=subprocess.DEVNULL) out = subprocess.check_output([sys.executable, "-I", main], cwd=tmpdir) self.assertEqual(out.strip(), b"ok") @unittest.skipUnless(sys.platform == 'win32', 'bpo-32457 only applies on Windows') def test_argv0_normalization(self): args = sys.executable, '-c', 'print(0)' prefix, exe = os.path.split(sys.executable) executable = prefix + '\\.\\.\\.\\' + exe proc = subprocess.run(args, stdout=subprocess.PIPE, executable=executable) self.assertEqual(proc.returncode, 0, proc) self.assertEqual(proc.stdout.strip(), b'0') def test_main(): test.support.run_unittest(CmdLineTest) test.support.reap_children() if __name__ == "__main__": test_main()
21,617
519
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_descr.py
import builtins import copyreg import gc import itertools import math import pickle import sys import cosmo import types import unittest import warnings import weakref from copy import deepcopy from test import support class OperatorsTest(unittest.TestCase): def __init__(self, *args, **kwargs): unittest.TestCase.__init__(self, *args, **kwargs) self.binops = { 'add': '+', 'sub': '-', 'mul': '*', 'matmul': '@', 'truediv': '/', 'floordiv': '//', 'divmod': 'divmod', 'pow': '**', 'lshift': '<<', 'rshift': '>>', 'and': '&', 'xor': '^', 'or': '|', 'cmp': 'cmp', 'lt': '<', 'le': '<=', 'eq': '==', 'ne': '!=', 'gt': '>', 'ge': '>=', } for name, expr in list(self.binops.items()): if expr.islower(): expr = expr + "(a, b)" else: expr = 'a %s b' % expr self.binops[name] = expr self.unops = { 'pos': '+', 'neg': '-', 'abs': 'abs', 'invert': '~', 'int': 'int', 'float': 'float', } for name, expr in list(self.unops.items()): if expr.islower(): expr = expr + "(a)" else: expr = '%s a' % expr self.unops[name] = expr def unop_test(self, a, res, expr="len(a)", meth="__len__"): d = {'a': a} self.assertEqual(eval(expr, d), res) t = type(a) m = getattr(t, meth) # Find method in parent class while meth not in t.__dict__: t = t.__bases__[0] # in some implementations (e.g. PyPy), 'm' can be a regular unbound # method object; the getattr() below obtains its underlying function. self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) self.assertEqual(m(a), res) bm = getattr(a, meth) self.assertEqual(bm(), res) def binop_test(self, a, b, res, expr="a+b", meth="__add__"): d = {'a': a, 'b': b} self.assertEqual(eval(expr, d), res) t = type(a) m = getattr(t, meth) while meth not in t.__dict__: t = t.__bases__[0] # in some implementations (e.g. PyPy), 'm' can be a regular unbound # method object; the getattr() below obtains its underlying function. self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) self.assertEqual(m(a, b), res) bm = getattr(a, meth) self.assertEqual(bm(b), res) def sliceop_test(self, a, b, c, res, expr="a[b:c]", meth="__getitem__"): d = {'a': a, 'b': b, 'c': c} self.assertEqual(eval(expr, d), res) t = type(a) m = getattr(t, meth) while meth not in t.__dict__: t = t.__bases__[0] # in some implementations (e.g. PyPy), 'm' can be a regular unbound # method object; the getattr() below obtains its underlying function. self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) self.assertEqual(m(a, slice(b, c)), res) bm = getattr(a, meth) self.assertEqual(bm(slice(b, c)), res) def setop_test(self, a, b, res, stmt="a+=b", meth="__iadd__"): d = {'a': deepcopy(a), 'b': b} exec(stmt, d) self.assertEqual(d['a'], res) t = type(a) m = getattr(t, meth) while meth not in t.__dict__: t = t.__bases__[0] # in some implementations (e.g. PyPy), 'm' can be a regular unbound # method object; the getattr() below obtains its underlying function. self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) d['a'] = deepcopy(a) m(d['a'], b) self.assertEqual(d['a'], res) d['a'] = deepcopy(a) bm = getattr(d['a'], meth) bm(b) self.assertEqual(d['a'], res) def set2op_test(self, a, b, c, res, stmt="a[b]=c", meth="__setitem__"): d = {'a': deepcopy(a), 'b': b, 'c': c} exec(stmt, d) self.assertEqual(d['a'], res) t = type(a) m = getattr(t, meth) while meth not in t.__dict__: t = t.__bases__[0] # in some implementations (e.g. PyPy), 'm' can be a regular unbound # method object; the getattr() below obtains its underlying function. self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) d['a'] = deepcopy(a) m(d['a'], b, c) self.assertEqual(d['a'], res) d['a'] = deepcopy(a) bm = getattr(d['a'], meth) bm(b, c) self.assertEqual(d['a'], res) def setsliceop_test(self, a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__"): dictionary = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d} exec(stmt, dictionary) self.assertEqual(dictionary['a'], res) t = type(a) while meth not in t.__dict__: t = t.__bases__[0] m = getattr(t, meth) # in some implementations (e.g. PyPy), 'm' can be a regular unbound # method object; the getattr() below obtains its underlying function. self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) dictionary['a'] = deepcopy(a) m(dictionary['a'], slice(b, c), d) self.assertEqual(dictionary['a'], res) dictionary['a'] = deepcopy(a) bm = getattr(dictionary['a'], meth) bm(slice(b, c), d) self.assertEqual(dictionary['a'], res) def test_lists(self): # Testing list operations... # Asserts are within individual test methods self.binop_test([1], [2], [1,2], "a+b", "__add__") self.binop_test([1,2,3], 2, 1, "b in a", "__contains__") self.binop_test([1,2,3], 4, 0, "b in a", "__contains__") self.binop_test([1,2,3], 1, 2, "a[b]", "__getitem__") self.sliceop_test([1,2,3], 0, 2, [1,2], "a[b:c]", "__getitem__") self.setop_test([1], [2], [1,2], "a+=b", "__iadd__") self.setop_test([1,2], 3, [1,2,1,2,1,2], "a*=b", "__imul__") self.unop_test([1,2,3], 3, "len(a)", "__len__") self.binop_test([1,2], 3, [1,2,1,2,1,2], "a*b", "__mul__") self.binop_test([1,2], 3, [1,2,1,2,1,2], "b*a", "__rmul__") self.set2op_test([1,2], 1, 3, [1,3], "a[b]=c", "__setitem__") self.setsliceop_test([1,2,3,4], 1, 3, [5,6], [1,5,6,4], "a[b:c]=d", "__setitem__") def test_dicts(self): # Testing dict operations... self.binop_test({1:2,3:4}, 1, 1, "b in a", "__contains__") self.binop_test({1:2,3:4}, 2, 0, "b in a", "__contains__") self.binop_test({1:2,3:4}, 1, 2, "a[b]", "__getitem__") d = {1:2, 3:4} l1 = [] for i in list(d.keys()): l1.append(i) l = [] for i in iter(d): l.append(i) self.assertEqual(l, l1) l = [] for i in d.__iter__(): l.append(i) self.assertEqual(l, l1) l = [] for i in dict.__iter__(d): l.append(i) self.assertEqual(l, l1) d = {1:2, 3:4} self.unop_test(d, 2, "len(a)", "__len__") self.assertEqual(eval(repr(d), {}), d) self.assertEqual(eval(d.__repr__(), {}), d) self.set2op_test({1:2,3:4}, 2, 3, {1:2,2:3,3:4}, "a[b]=c", "__setitem__") # Tests for unary and binary operators def number_operators(self, a, b, skip=[]): dict = {'a': a, 'b': b} for name, expr in self.binops.items(): if name not in skip: name = "__%s__" % name if hasattr(a, name): res = eval(expr, dict) self.binop_test(a, b, res, expr, name) for name, expr in list(self.unops.items()): if name not in skip: name = "__%s__" % name if hasattr(a, name): res = eval(expr, dict) self.unop_test(a, res, expr, name) def test_ints(self): # Testing int operations... self.number_operators(100, 3) # The following crashes in Python 2.2 self.assertEqual((1).__bool__(), 1) self.assertEqual((0).__bool__(), 0) # This returns 'NotImplemented' in Python 2.2 class C(int): def __add__(self, other): return NotImplemented self.assertEqual(C(5), 5) try: C() + "" except TypeError: pass else: self.fail("NotImplemented should have caused TypeError") def test_floats(self): # Testing float operations... self.number_operators(100.0, 3.0) def test_complexes(self): # Testing complex operations... self.number_operators(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge', 'int', 'float', 'floordiv', 'divmod', 'mod']) class Number(complex): __slots__ = ['prec'] def __new__(cls, *args, **kwds): result = complex.__new__(cls, *args) result.prec = kwds.get('prec', 12) return result def __repr__(self): prec = self.prec if self.imag == 0.0: return "%.*g" % (prec, self.real) if self.real == 0.0: return "%.*gj" % (prec, self.imag) return "(%.*g+%.*gj)" % (prec, self.real, prec, self.imag) __str__ = __repr__ a = Number(3.14, prec=6) self.assertEqual(repr(a), "3.14") self.assertEqual(a.prec, 6) a = Number(a, prec=2) self.assertEqual(repr(a), "3.1") self.assertEqual(a.prec, 2) a = Number(234.5) self.assertEqual(repr(a), "234.5") self.assertEqual(a.prec, 12) def test_explicit_reverse_methods(self): # see issue 9930 self.assertEqual(complex.__radd__(3j, 4.0), complex(4.0, 3.0)) self.assertEqual(float.__rsub__(3.0, 1), -2.0) @support.impl_detail("the module 'xxsubtype' is internal") def test_spam_lists(self): # Testing spamlist operations... import copy, xxsubtype as spam def spamlist(l, memo=None): import xxsubtype as spam return spam.spamlist(l) # This is an ugly hack: copy._deepcopy_dispatch[spam.spamlist] = spamlist self.binop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+b", "__add__") self.binop_test(spamlist([1,2,3]), 2, 1, "b in a", "__contains__") self.binop_test(spamlist([1,2,3]), 4, 0, "b in a", "__contains__") self.binop_test(spamlist([1,2,3]), 1, 2, "a[b]", "__getitem__") self.sliceop_test(spamlist([1,2,3]), 0, 2, spamlist([1,2]), "a[b:c]", "__getitem__") self.setop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+=b", "__iadd__") self.setop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*=b", "__imul__") self.unop_test(spamlist([1,2,3]), 3, "len(a)", "__len__") self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*b", "__mul__") self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "b*a", "__rmul__") self.set2op_test(spamlist([1,2]), 1, 3, spamlist([1,3]), "a[b]=c", "__setitem__") self.setsliceop_test(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]), spamlist([1,5,6,4]), "a[b:c]=d", "__setitem__") # Test subclassing class C(spam.spamlist): def foo(self): return 1 a = C() self.assertEqual(a, []) self.assertEqual(a.foo(), 1) a.append(100) self.assertEqual(a, [100]) self.assertEqual(a.getstate(), 0) a.setstate(42) self.assertEqual(a.getstate(), 42) @support.impl_detail("the module 'xxsubtype' is internal") def test_spam_dicts(self): # Testing spamdict operations... import copy, xxsubtype as spam def spamdict(d, memo=None): import xxsubtype as spam sd = spam.spamdict() for k, v in list(d.items()): sd[k] = v return sd # This is an ugly hack: copy._deepcopy_dispatch[spam.spamdict] = spamdict self.binop_test(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__") self.binop_test(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__") self.binop_test(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__") d = spamdict({1:2,3:4}) l1 = [] for i in list(d.keys()): l1.append(i) l = [] for i in iter(d): l.append(i) self.assertEqual(l, l1) l = [] for i in d.__iter__(): l.append(i) self.assertEqual(l, l1) l = [] for i in type(spamdict({})).__iter__(d): l.append(i) self.assertEqual(l, l1) straightd = {1:2, 3:4} spamd = spamdict(straightd) self.unop_test(spamd, 2, "len(a)", "__len__") self.unop_test(spamd, repr(straightd), "repr(a)", "__repr__") self.set2op_test(spamdict({1:2,3:4}), 2, 3, spamdict({1:2,2:3,3:4}), "a[b]=c", "__setitem__") # Test subclassing class C(spam.spamdict): def foo(self): return 1 a = C() self.assertEqual(list(a.items()), []) self.assertEqual(a.foo(), 1) a['foo'] = 'bar' self.assertEqual(list(a.items()), [('foo', 'bar')]) self.assertEqual(a.getstate(), 0) a.setstate(100) self.assertEqual(a.getstate(), 100) class ClassPropertiesAndMethods(unittest.TestCase): def assertHasAttr(self, obj, name): self.assertTrue(hasattr(obj, name), '%r has no attribute %r' % (obj, name)) def assertNotHasAttr(self, obj, name): self.assertFalse(hasattr(obj, name), '%r has unexpected attribute %r' % (obj, name)) def test_python_dicts(self): # Testing Python subclass of dict... self.assertTrue(issubclass(dict, dict)) self.assertIsInstance({}, dict) d = dict() self.assertEqual(d, {}) self.assertIs(d.__class__, dict) self.assertIsInstance(d, dict) class C(dict): state = -1 def __init__(self_local, *a, **kw): if a: self.assertEqual(len(a), 1) self_local.state = a[0] if kw: for k, v in list(kw.items()): self_local[v] = k def __getitem__(self, key): return self.get(key, 0) def __setitem__(self_local, key, value): self.assertIsInstance(key, type(0)) dict.__setitem__(self_local, key, value) def setstate(self, state): self.state = state def getstate(self): return self.state self.assertTrue(issubclass(C, dict)) a1 = C(12) self.assertEqual(a1.state, 12) a2 = C(foo=1, bar=2) self.assertEqual(a2[1] == 'foo' and a2[2], 'bar') a = C() self.assertEqual(a.state, -1) self.assertEqual(a.getstate(), -1) a.setstate(0) self.assertEqual(a.state, 0) self.assertEqual(a.getstate(), 0) a.setstate(10) self.assertEqual(a.state, 10) self.assertEqual(a.getstate(), 10) self.assertEqual(a[42], 0) a[42] = 24 self.assertEqual(a[42], 24) N = 50 for i in range(N): a[i] = C() for j in range(N): a[i][j] = i*j for i in range(N): for j in range(N): self.assertEqual(a[i][j], i*j) def test_python_lists(self): # Testing Python subclass of list... class C(list): def __getitem__(self, i): if isinstance(i, slice): return i.start, i.stop return list.__getitem__(self, i) + 100 a = C() a.extend([0,1,2]) self.assertEqual(a[0], 100) self.assertEqual(a[1], 101) self.assertEqual(a[2], 102) self.assertEqual(a[100:200], (100,200)) def test_metaclass(self): # Testing metaclasses... class C(metaclass=type): def __init__(self): self.__state = 0 def getstate(self): return self.__state def setstate(self, state): self.__state = state a = C() self.assertEqual(a.getstate(), 0) a.setstate(10) self.assertEqual(a.getstate(), 10) class _metaclass(type): def myself(cls): return cls class D(metaclass=_metaclass): pass self.assertEqual(D.myself(), D) d = D() self.assertEqual(d.__class__, D) class M1(type): def __new__(cls, name, bases, dict): dict['__spam__'] = 1 return type.__new__(cls, name, bases, dict) class C(metaclass=M1): pass self.assertEqual(C.__spam__, 1) c = C() self.assertEqual(c.__spam__, 1) class _instance(object): pass class M2(object): @staticmethod def __new__(cls, name, bases, dict): self = object.__new__(cls) self.name = name self.bases = bases self.dict = dict return self def __call__(self): it = _instance() # Early binding of methods for key in self.dict: if key.startswith("__"): continue setattr(it, key, self.dict[key].__get__(it, self)) return it class C(metaclass=M2): def spam(self): return 42 self.assertEqual(C.name, 'C') self.assertEqual(C.bases, ()) self.assertIn('spam', C.dict) c = C() self.assertEqual(c.spam(), 42) # More metaclass examples class autosuper(type): # Automatically add __super to the class # This trick only works for dynamic classes def __new__(metaclass, name, bases, dict): cls = super(autosuper, metaclass).__new__(metaclass, name, bases, dict) # Name mangling for __super removes leading underscores while name[:1] == "_": name = name[1:] if name: name = "_%s__super" % name else: name = "__super" setattr(cls, name, super(cls)) return cls class A(metaclass=autosuper): def meth(self): return "A" class B(A): def meth(self): return "B" + self.__super.meth() class C(A): def meth(self): return "C" + self.__super.meth() class D(C, B): def meth(self): return "D" + self.__super.meth() self.assertEqual(D().meth(), "DCBA") class E(B, C): def meth(self): return "E" + self.__super.meth() self.assertEqual(E().meth(), "EBCA") class autoproperty(type): # Automatically create property attributes when methods # named _get_x and/or _set_x are found def __new__(metaclass, name, bases, dict): hits = {} for key, val in dict.items(): if key.startswith("_get_"): key = key[5:] get, set = hits.get(key, (None, None)) get = val hits[key] = get, set elif key.startswith("_set_"): key = key[5:] get, set = hits.get(key, (None, None)) set = val hits[key] = get, set for key, (get, set) in hits.items(): dict[key] = property(get, set) return super(autoproperty, metaclass).__new__(metaclass, name, bases, dict) class A(metaclass=autoproperty): def _get_x(self): return -self.__x def _set_x(self, x): self.__x = -x a = A() self.assertNotHasAttr(a, "x") a.x = 12 self.assertEqual(a.x, 12) self.assertEqual(a._A__x, -12) class multimetaclass(autoproperty, autosuper): # Merge of multiple cooperating metaclasses pass class A(metaclass=multimetaclass): def _get_x(self): return "A" class B(A): def _get_x(self): return "B" + self.__super._get_x() class C(A): def _get_x(self): return "C" + self.__super._get_x() class D(C, B): def _get_x(self): return "D" + self.__super._get_x() self.assertEqual(D().x, "DCBA") # Make sure type(x) doesn't call x.__class__.__init__ class T(type): counter = 0 def __init__(self, *args): T.counter += 1 class C(metaclass=T): pass self.assertEqual(T.counter, 1) a = C() self.assertEqual(type(a), C) self.assertEqual(T.counter, 1) class C(object): pass c = C() try: c() except TypeError: pass else: self.fail("calling object w/o call method should raise " "TypeError") # Testing code to find most derived baseclass class A(type): def __new__(*args, **kwargs): return type.__new__(*args, **kwargs) class B(object): pass class C(object, metaclass=A): pass # The most derived metaclass of D is A rather than type. class D(B, C): pass self.assertIs(A, type(D)) # issue1294232: correct metaclass calculation new_calls = [] # to check the order of __new__ calls class AMeta(type): @staticmethod def __new__(mcls, name, bases, ns): new_calls.append('AMeta') return super().__new__(mcls, name, bases, ns) @classmethod def __prepare__(mcls, name, bases): return {} class BMeta(AMeta): @staticmethod def __new__(mcls, name, bases, ns): new_calls.append('BMeta') return super().__new__(mcls, name, bases, ns) @classmethod def __prepare__(mcls, name, bases): ns = super().__prepare__(name, bases) ns['BMeta_was_here'] = True return ns class A(metaclass=AMeta): pass self.assertEqual(['AMeta'], new_calls) new_calls.clear() class B(metaclass=BMeta): pass # BMeta.__new__ calls AMeta.__new__ with super: self.assertEqual(['BMeta', 'AMeta'], new_calls) new_calls.clear() class C(A, B): pass # The most derived metaclass is BMeta: self.assertEqual(['BMeta', 'AMeta'], new_calls) new_calls.clear() # BMeta.__prepare__ should've been called: self.assertIn('BMeta_was_here', C.__dict__) # The order of the bases shouldn't matter: class C2(B, A): pass self.assertEqual(['BMeta', 'AMeta'], new_calls) new_calls.clear() self.assertIn('BMeta_was_here', C2.__dict__) # Check correct metaclass calculation when a metaclass is declared: class D(C, metaclass=type): pass self.assertEqual(['BMeta', 'AMeta'], new_calls) new_calls.clear() self.assertIn('BMeta_was_here', D.__dict__) class E(C, metaclass=AMeta): pass self.assertEqual(['BMeta', 'AMeta'], new_calls) new_calls.clear() self.assertIn('BMeta_was_here', E.__dict__) # Special case: the given metaclass isn't a class, # so there is no metaclass calculation. marker = object() def func(*args, **kwargs): return marker class X(metaclass=func): pass class Y(object, metaclass=func): pass class Z(D, metaclass=func): pass self.assertIs(marker, X) self.assertIs(marker, Y) self.assertIs(marker, Z) # The given metaclass is a class, # but not a descendant of type. prepare_calls = [] # to track __prepare__ calls class ANotMeta: def __new__(mcls, *args, **kwargs): new_calls.append('ANotMeta') return super().__new__(mcls) @classmethod def __prepare__(mcls, name, bases): prepare_calls.append('ANotMeta') return {} class BNotMeta(ANotMeta): def __new__(mcls, *args, **kwargs): new_calls.append('BNotMeta') return super().__new__(mcls) @classmethod def __prepare__(mcls, name, bases): prepare_calls.append('BNotMeta') return super().__prepare__(name, bases) class A(metaclass=ANotMeta): pass self.assertIs(ANotMeta, type(A)) self.assertEqual(['ANotMeta'], prepare_calls) prepare_calls.clear() self.assertEqual(['ANotMeta'], new_calls) new_calls.clear() class B(metaclass=BNotMeta): pass self.assertIs(BNotMeta, type(B)) self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls) prepare_calls.clear() self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls) new_calls.clear() class C(A, B): pass self.assertIs(BNotMeta, type(C)) self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls) new_calls.clear() self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls) prepare_calls.clear() class C2(B, A): pass self.assertIs(BNotMeta, type(C2)) self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls) new_calls.clear() self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls) prepare_calls.clear() # This is a TypeError, because of a metaclass conflict: # BNotMeta is neither a subclass, nor a superclass of type with self.assertRaises(TypeError): class D(C, metaclass=type): pass class E(C, metaclass=ANotMeta): pass self.assertIs(BNotMeta, type(E)) self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls) new_calls.clear() self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls) prepare_calls.clear() class F(object(), C): pass self.assertIs(BNotMeta, type(F)) self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls) new_calls.clear() self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls) prepare_calls.clear() class F2(C, object()): pass self.assertIs(BNotMeta, type(F2)) self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls) new_calls.clear() self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls) prepare_calls.clear() # TypeError: BNotMeta is neither a # subclass, nor a superclass of int with self.assertRaises(TypeError): class X(C, int()): pass with self.assertRaises(TypeError): class X(int(), C): pass def test_module_subclasses(self): # Testing Python subclass of module... log = [] MT = type(sys) class MM(MT): def __init__(self, name): MT.__init__(self, name) def __getattribute__(self, name): log.append(("getattr", name)) return MT.__getattribute__(self, name) def __setattr__(self, name, value): log.append(("setattr", name, value)) MT.__setattr__(self, name, value) def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name) a = MM("a") a.foo = 12 x = a.foo del a.foo self.assertEqual(log, [("setattr", "foo", 12), ("getattr", "foo"), ("delattr", "foo")]) # http://python.org/sf/1174712 try: class Module(types.ModuleType, str): pass except TypeError: pass else: self.fail("inheriting from ModuleType and str at the same time " "should fail") def test_multiple_inheritance(self): # Testing multiple inheritance... class C(object): def __init__(self): self.__state = 0 def getstate(self): return self.__state def setstate(self, state): self.__state = state a = C() self.assertEqual(a.getstate(), 0) a.setstate(10) self.assertEqual(a.getstate(), 10) class D(dict, C): def __init__(self): type({}).__init__(self) C.__init__(self) d = D() self.assertEqual(list(d.keys()), []) d["hello"] = "world" self.assertEqual(list(d.items()), [("hello", "world")]) self.assertEqual(d["hello"], "world") self.assertEqual(d.getstate(), 0) d.setstate(10) self.assertEqual(d.getstate(), 10) self.assertEqual(D.__mro__, (D, dict, C, object)) # SF bug #442833 class Node(object): def __int__(self): return int(self.foo()) def foo(self): return "23" class Frag(Node, list): def foo(self): return "42" self.assertEqual(Node().__int__(), 23) self.assertEqual(int(Node()), 23) self.assertEqual(Frag().__int__(), 42) self.assertEqual(int(Frag()), 42) def test_diamond_inheritance(self): # Testing multiple inheritance special cases... class A(object): def spam(self): return "A" self.assertEqual(A().spam(), "A") class B(A): def boo(self): return "B" def spam(self): return "B" self.assertEqual(B().spam(), "B") self.assertEqual(B().boo(), "B") class C(A): def boo(self): return "C" self.assertEqual(C().spam(), "A") self.assertEqual(C().boo(), "C") class D(B, C): pass self.assertEqual(D().spam(), "B") self.assertEqual(D().boo(), "B") self.assertEqual(D.__mro__, (D, B, C, A, object)) class E(C, B): pass self.assertEqual(E().spam(), "B") self.assertEqual(E().boo(), "C") self.assertEqual(E.__mro__, (E, C, B, A, object)) # MRO order disagreement try: class F(D, E): pass except TypeError: pass else: self.fail("expected MRO order disagreement (F)") try: class G(E, D): pass except TypeError: pass else: self.fail("expected MRO order disagreement (G)") # see thread python-dev/2002-October/029035.html def test_ex5_from_c3_switch(self): # Testing ex5 from C3 switch discussion... class A(object): pass class B(object): pass class C(object): pass class X(A): pass class Y(A): pass class Z(X,B,Y,C): pass self.assertEqual(Z.__mro__, (Z, X, B, Y, A, C, object)) # see "A Monotonic Superclass Linearization for Dylan", # by Kim Barrett et al. (OOPSLA 1996) def test_monotonicity(self): # Testing MRO monotonicity... class Boat(object): pass class DayBoat(Boat): pass class WheelBoat(Boat): pass class EngineLess(DayBoat): pass class SmallMultihull(DayBoat): pass class PedalWheelBoat(EngineLess,WheelBoat): pass class SmallCatamaran(SmallMultihull): pass class Pedalo(PedalWheelBoat,SmallCatamaran): pass self.assertEqual(PedalWheelBoat.__mro__, (PedalWheelBoat, EngineLess, DayBoat, WheelBoat, Boat, object)) self.assertEqual(SmallCatamaran.__mro__, (SmallCatamaran, SmallMultihull, DayBoat, Boat, object)) self.assertEqual(Pedalo.__mro__, (Pedalo, PedalWheelBoat, EngineLess, SmallCatamaran, SmallMultihull, DayBoat, WheelBoat, Boat, object)) # see "A Monotonic Superclass Linearization for Dylan", # by Kim Barrett et al. (OOPSLA 1996) def test_consistency_with_epg(self): # Testing consistency with EPG... class Pane(object): pass class ScrollingMixin(object): pass class EditingMixin(object): pass class ScrollablePane(Pane,ScrollingMixin): pass class EditablePane(Pane,EditingMixin): pass class EditableScrollablePane(ScrollablePane,EditablePane): pass self.assertEqual(EditableScrollablePane.__mro__, (EditableScrollablePane, ScrollablePane, EditablePane, Pane, ScrollingMixin, EditingMixin, object)) def test_mro_disagreement(self): # Testing error messages for MRO disagreement... mro_err_msg = """Cannot create a consistent method resolution order (MRO) for bases """ def raises(exc, expected, callable, *args): try: callable(*args) except exc as msg: # the exact msg is generally considered an impl detail if support.check_impl_detail(): if not str(msg).startswith(expected): self.fail("Message %r, expected %r" % (str(msg), expected)) else: self.fail("Expected %s" % exc) class A(object): pass class B(A): pass class C(object): pass # Test some very simple errors raises(TypeError, "duplicate base class A", type, "X", (A, A), {}) raises(TypeError, mro_err_msg, type, "X", (A, B), {}) raises(TypeError, mro_err_msg, type, "X", (A, C, B), {}) # Test a slightly more complex error class GridLayout(object): pass class HorizontalGrid(GridLayout): pass class VerticalGrid(GridLayout): pass class HVGrid(HorizontalGrid, VerticalGrid): pass class VHGrid(VerticalGrid, HorizontalGrid): pass raises(TypeError, mro_err_msg, type, "ConfusedGrid", (HVGrid, VHGrid), {}) def test_object_class(self): # Testing object class... a = object() self.assertEqual(a.__class__, object) self.assertEqual(type(a), object) b = object() self.assertNotEqual(a, b) self.assertNotHasAttr(a, "foo") try: a.foo = 12 except (AttributeError, TypeError): pass else: self.fail("object() should not allow setting a foo attribute") self.assertNotHasAttr(object(), "__dict__") class Cdict(object): pass x = Cdict() self.assertEqual(x.__dict__, {}) x.foo = 1 self.assertEqual(x.foo, 1) self.assertEqual(x.__dict__, {'foo': 1}) def test_object_class_assignment_between_heaptypes_and_nonheaptypes(self): class SubType(types.ModuleType): a = 1 m = types.ModuleType("m") self.assertTrue(m.__class__ is types.ModuleType) self.assertFalse(hasattr(m, "a")) m.__class__ = SubType self.assertTrue(m.__class__ is SubType) self.assertTrue(hasattr(m, "a")) m.__class__ = types.ModuleType self.assertTrue(m.__class__ is types.ModuleType) self.assertFalse(hasattr(m, "a")) # Make sure that builtin immutable objects don't support __class__ # assignment, because the object instances may be interned. # We set __slots__ = () to ensure that the subclasses are # memory-layout compatible, and thus otherwise reasonable candidates # for __class__ assignment. # The following types have immutable instances, but are not # subclassable and thus don't need to be checked: # NoneType, bool class MyInt(int): __slots__ = () with self.assertRaises(TypeError): (1).__class__ = MyInt class MyFloat(float): __slots__ = () with self.assertRaises(TypeError): (1.0).__class__ = MyFloat class MyComplex(complex): __slots__ = () with self.assertRaises(TypeError): (1 + 2j).__class__ = MyComplex class MyStr(str): __slots__ = () with self.assertRaises(TypeError): "a".__class__ = MyStr class MyBytes(bytes): __slots__ = () with self.assertRaises(TypeError): b"a".__class__ = MyBytes class MyTuple(tuple): __slots__ = () with self.assertRaises(TypeError): ().__class__ = MyTuple class MyFrozenSet(frozenset): __slots__ = () with self.assertRaises(TypeError): frozenset().__class__ = MyFrozenSet def test_slots(self): # Testing __slots__... class C0(object): __slots__ = [] x = C0() self.assertNotHasAttr(x, "__dict__") self.assertNotHasAttr(x, "foo") class C1(object): __slots__ = ['a'] x = C1() self.assertNotHasAttr(x, "__dict__") self.assertNotHasAttr(x, "a") x.a = 1 self.assertEqual(x.a, 1) x.a = None self.assertEqual(x.a, None) del x.a self.assertNotHasAttr(x, "a") class C3(object): __slots__ = ['a', 'b', 'c'] x = C3() self.assertNotHasAttr(x, "__dict__") self.assertNotHasAttr(x, 'a') self.assertNotHasAttr(x, 'b') self.assertNotHasAttr(x, 'c') x.a = 1 x.b = 2 x.c = 3 self.assertEqual(x.a, 1) self.assertEqual(x.b, 2) self.assertEqual(x.c, 3) class C4(object): """Validate name mangling""" __slots__ = ['__a'] def __init__(self, value): self.__a = value def get(self): return self.__a x = C4(5) self.assertNotHasAttr(x, '__dict__') self.assertNotHasAttr(x, '__a') self.assertEqual(x.get(), 5) try: x.__a = 6 except AttributeError: pass else: self.fail("Double underscored names not mangled") # Make sure slot names are proper identifiers try: class C(object): __slots__ = [None] except TypeError: pass else: self.fail("[None] slots not caught") try: class C(object): __slots__ = ["foo bar"] except TypeError: pass else: self.fail("['foo bar'] slots not caught") try: class C(object): __slots__ = ["foo\0bar"] except TypeError: pass else: self.fail("['foo\\0bar'] slots not caught") try: class C(object): __slots__ = ["1"] except TypeError: pass else: self.fail("['1'] slots not caught") try: class C(object): __slots__ = [""] except TypeError: pass else: self.fail("[''] slots not caught") class C(object): __slots__ = ["a", "a_b", "_a", "A0123456789Z"] # XXX(nnorwitz): was there supposed to be something tested # from the class above? # Test a single string is not expanded as a sequence. class C(object): __slots__ = "abc" c = C() c.abc = 5 self.assertEqual(c.abc, 5) # Test unicode slot names # Test a single unicode string is not expanded as a sequence. class C(object): __slots__ = "abc" c = C() c.abc = 5 self.assertEqual(c.abc, 5) # _unicode_to_string used to modify slots in certain circumstances slots = ("foo", "bar") class C(object): __slots__ = slots x = C() x.foo = 5 self.assertEqual(x.foo, 5) self.assertIs(type(slots[0]), str) # this used to leak references try: class C(object): __slots__ = [chr(128)] except (TypeError, UnicodeEncodeError): pass else: self.fail("[chr(128)] slots not caught") # Test leaks class Counted(object): counter = 0 # counts the number of instances alive def __init__(self): Counted.counter += 1 def __del__(self): Counted.counter -= 1 class C(object): __slots__ = ['a', 'b', 'c'] x = C() x.a = Counted() x.b = Counted() x.c = Counted() self.assertEqual(Counted.counter, 3) del x support.gc_collect() self.assertEqual(Counted.counter, 0) class D(C): pass x = D() x.a = Counted() x.z = Counted() self.assertEqual(Counted.counter, 2) del x support.gc_collect() self.assertEqual(Counted.counter, 0) class E(D): __slots__ = ['e'] x = E() x.a = Counted() x.z = Counted() x.e = Counted() self.assertEqual(Counted.counter, 3) del x support.gc_collect() self.assertEqual(Counted.counter, 0) # Test cyclical leaks [SF bug 519621] class F(object): __slots__ = ['a', 'b'] s = F() s.a = [Counted(), s] self.assertEqual(Counted.counter, 1) s = None support.gc_collect() self.assertEqual(Counted.counter, 0) # Test lookup leaks [SF bug 572567] if hasattr(gc, 'get_objects'): class G(object): def __eq__(self, other): return False g = G() orig_objects = len(gc.get_objects()) for i in range(10): g==g new_objects = len(gc.get_objects()) self.assertEqual(orig_objects, new_objects) class H(object): __slots__ = ['a', 'b'] def __init__(self): self.a = 1 self.b = 2 def __del__(self_): self.assertEqual(self_.a, 1) self.assertEqual(self_.b, 2) with support.captured_output('stderr') as s: h = H() del h self.assertEqual(s.getvalue(), '') class X(object): __slots__ = "a" with self.assertRaises(AttributeError): del X().a def test_slots_special(self): # Testing __dict__ and __weakref__ in __slots__... class D(object): __slots__ = ["__dict__"] a = D() self.assertHasAttr(a, "__dict__") self.assertNotHasAttr(a, "__weakref__") a.foo = 42 self.assertEqual(a.__dict__, {"foo": 42}) class W(object): __slots__ = ["__weakref__"] a = W() self.assertHasAttr(a, "__weakref__") self.assertNotHasAttr(a, "__dict__") try: a.foo = 42 except AttributeError: pass else: self.fail("shouldn't be allowed to set a.foo") class C1(W, D): __slots__ = [] a = C1() self.assertHasAttr(a, "__dict__") self.assertHasAttr(a, "__weakref__") a.foo = 42 self.assertEqual(a.__dict__, {"foo": 42}) class C2(D, W): __slots__ = [] a = C2() self.assertHasAttr(a, "__dict__") self.assertHasAttr(a, "__weakref__") a.foo = 42 self.assertEqual(a.__dict__, {"foo": 42}) def test_slots_descriptor(self): # Issue2115: slot descriptors did not correctly check # the type of the given object import abc class MyABC(metaclass=abc.ABCMeta): __slots__ = "a" class Unrelated(object): pass MyABC.register(Unrelated) u = Unrelated() self.assertIsInstance(u, MyABC) # This used to crash self.assertRaises(TypeError, MyABC.a.__set__, u, 3) def test_dynamics(self): # Testing class attribute propagation... class D(object): pass class E(D): pass class F(D): pass D.foo = 1 self.assertEqual(D.foo, 1) # Test that dynamic attributes are inherited self.assertEqual(E.foo, 1) self.assertEqual(F.foo, 1) # Test dynamic instances class C(object): pass a = C() self.assertNotHasAttr(a, "foobar") C.foobar = 2 self.assertEqual(a.foobar, 2) C.method = lambda self: 42 self.assertEqual(a.method(), 42) C.__repr__ = lambda self: "C()" self.assertEqual(repr(a), "C()") C.__int__ = lambda self: 100 self.assertEqual(int(a), 100) self.assertEqual(a.foobar, 2) self.assertNotHasAttr(a, "spam") def mygetattr(self, name): if name == "spam": return "spam" raise AttributeError C.__getattr__ = mygetattr self.assertEqual(a.spam, "spam") a.new = 12 self.assertEqual(a.new, 12) def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value) C.__setattr__ = mysetattr try: a.spam = "not spam" except AttributeError: pass else: self.fail("expected AttributeError") self.assertEqual(a.spam, "spam") class D(C): pass d = D() d.foo = 1 self.assertEqual(d.foo, 1) # Test handling of int*seq and seq*int class I(int): pass self.assertEqual("a"*I(2), "aa") self.assertEqual(I(2)*"a", "aa") self.assertEqual(2*I(3), 6) self.assertEqual(I(3)*2, 6) self.assertEqual(I(3)*I(2), 6) # Test comparison of classes with dynamic metaclasses class dynamicmetaclass(type): pass class someclass(metaclass=dynamicmetaclass): pass self.assertNotEqual(someclass, object) def test_errors(self): # Testing errors... try: class C(list, dict): pass except TypeError: pass else: self.fail("inheritance from both list and dict should be illegal") try: class C(object, None): pass except TypeError: pass else: self.fail("inheritance from non-type should be illegal") class Classic: pass try: class C(type(len)): pass except TypeError: pass else: self.fail("inheritance from CFunction should be illegal") try: class C(object): __slots__ = 1 except TypeError: pass else: self.fail("__slots__ = 1 should be illegal") try: class C(object): __slots__ = [1] except TypeError: pass else: self.fail("__slots__ = [1] should be illegal") class M1(type): pass class M2(type): pass class A1(object, metaclass=M1): pass class A2(object, metaclass=M2): pass try: class B(A1, A2): pass except TypeError: pass else: self.fail("finding the most derived metaclass should have failed") def test_classmethods(self): # Testing class methods... class C(object): def foo(*a): return a goo = classmethod(foo) c = C() self.assertEqual(C.goo(1), (C, 1)) self.assertEqual(c.goo(1), (C, 1)) self.assertEqual(c.foo(1), (c, 1)) class D(C): pass d = D() self.assertEqual(D.goo(1), (D, 1)) self.assertEqual(d.goo(1), (D, 1)) self.assertEqual(d.foo(1), (d, 1)) self.assertEqual(D.foo(d, 1), (d, 1)) # Test for a specific crash (SF bug 528132) def f(cls, arg): return (cls, arg) ff = classmethod(f) self.assertEqual(ff.__get__(0, int)(42), (int, 42)) self.assertEqual(ff.__get__(0)(42), (int, 42)) # Test super() with classmethods (SF bug 535444) self.assertEqual(C.goo.__self__, C) self.assertEqual(D.goo.__self__, D) self.assertEqual(super(D,D).goo.__self__, D) self.assertEqual(super(D,d).goo.__self__, D) self.assertEqual(super(D,D).goo(), (D,)) self.assertEqual(super(D,d).goo(), (D,)) # Verify that a non-callable will raise meth = classmethod(1).__get__(1) self.assertRaises(TypeError, meth) # Verify that classmethod() doesn't allow keyword args try: classmethod(f, kw=1) except TypeError: pass else: self.fail("classmethod shouldn't accept keyword args") cm = classmethod(f) self.assertEqual(cm.__dict__, {}) cm.x = 42 self.assertEqual(cm.x, 42) self.assertEqual(cm.__dict__, {"x" : 42}) del cm.x self.assertNotHasAttr(cm, "x") @support.refcount_test def test_refleaks_in_classmethod___init__(self): gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') cm = classmethod(None) refs_before = gettotalrefcount() for i in range(100): cm.__init__(None) self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) @support.impl_detail("the module 'xxsubtype' is internal") def test_classmethods_in_c(self): # Testing C-based class methods... import xxsubtype as spam a = (1, 2, 3) d = {'abc': 123} x, a1, d1 = spam.spamlist.classmeth(*a, **d) self.assertEqual(x, spam.spamlist) self.assertEqual(a, a1) self.assertEqual(d, d1) x, a1, d1 = spam.spamlist().classmeth(*a, **d) self.assertEqual(x, spam.spamlist) self.assertEqual(a, a1) self.assertEqual(d, d1) spam_cm = spam.spamlist.__dict__['classmeth'] x2, a2, d2 = spam_cm(spam.spamlist, *a, **d) self.assertEqual(x2, spam.spamlist) self.assertEqual(a2, a1) self.assertEqual(d2, d1) class SubSpam(spam.spamlist): pass x2, a2, d2 = spam_cm(SubSpam, *a, **d) self.assertEqual(x2, SubSpam) self.assertEqual(a2, a1) self.assertEqual(d2, d1) with self.assertRaises(TypeError): spam_cm() with self.assertRaises(TypeError): spam_cm(spam.spamlist()) with self.assertRaises(TypeError): spam_cm(list) def test_staticmethods(self): # Testing static methods... class C(object): def foo(*a): return a goo = staticmethod(foo) c = C() self.assertEqual(C.goo(1), (1,)) self.assertEqual(c.goo(1), (1,)) self.assertEqual(c.foo(1), (c, 1,)) class D(C): pass d = D() self.assertEqual(D.goo(1), (1,)) self.assertEqual(d.goo(1), (1,)) self.assertEqual(d.foo(1), (d, 1)) self.assertEqual(D.foo(d, 1), (d, 1)) sm = staticmethod(None) self.assertEqual(sm.__dict__, {}) sm.x = 42 self.assertEqual(sm.x, 42) self.assertEqual(sm.__dict__, {"x" : 42}) del sm.x self.assertNotHasAttr(sm, "x") @support.refcount_test def test_refleaks_in_staticmethod___init__(self): gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') sm = staticmethod(None) refs_before = gettotalrefcount() for i in range(100): sm.__init__(None) self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) @support.impl_detail("the module 'xxsubtype' is internal") def test_staticmethods_in_c(self): # Testing C-based static methods... import xxsubtype as spam a = (1, 2, 3) d = {"abc": 123} x, a1, d1 = spam.spamlist.staticmeth(*a, **d) self.assertEqual(x, None) self.assertEqual(a, a1) self.assertEqual(d, d1) x, a1, d2 = spam.spamlist().staticmeth(*a, **d) self.assertEqual(x, None) self.assertEqual(a, a1) self.assertEqual(d, d1) def test_classic(self): # Testing classic classes... class C: def foo(*a): return a goo = classmethod(foo) c = C() self.assertEqual(C.goo(1), (C, 1)) self.assertEqual(c.goo(1), (C, 1)) self.assertEqual(c.foo(1), (c, 1)) class D(C): pass d = D() self.assertEqual(D.goo(1), (D, 1)) self.assertEqual(d.goo(1), (D, 1)) self.assertEqual(d.foo(1), (d, 1)) self.assertEqual(D.foo(d, 1), (d, 1)) class E: # *not* subclassing from C foo = C.foo self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound self.assertTrue(repr(C.foo.__get__(C())).startswith("<bound method ")) def test_compattr(self): # Testing computed attributes... class C(object): class computed_attribute(object): def __init__(self, get, set=None, delete=None): self.__get = get self.__set = set self.__delete = delete def __get__(self, obj, type=None): return self.__get(obj) def __set__(self, obj, value): return self.__set(obj, value) def __delete__(self, obj): return self.__delete(obj) def __init__(self): self.__x = 0 def __get_x(self): x = self.__x self.__x = x+1 return x def __set_x(self, x): self.__x = x def __delete_x(self): del self.__x x = computed_attribute(__get_x, __set_x, __delete_x) a = C() self.assertEqual(a.x, 0) self.assertEqual(a.x, 1) a.x = 10 self.assertEqual(a.x, 10) self.assertEqual(a.x, 11) del a.x self.assertNotHasAttr(a, 'x') def test_newslots(self): # Testing __new__ slot override... class C(list): def __new__(cls): self = list.__new__(cls) self.foo = 1 return self def __init__(self): self.foo = self.foo + 2 a = C() self.assertEqual(a.foo, 3) self.assertEqual(a.__class__, C) class D(C): pass b = D() self.assertEqual(b.foo, 3) self.assertEqual(b.__class__, D) @unittest.expectedFailure def test_bad_new(self): self.assertRaises(TypeError, object.__new__) self.assertRaises(TypeError, object.__new__, '') self.assertRaises(TypeError, list.__new__, object) self.assertRaises(TypeError, object.__new__, list) class C(object): __new__ = list.__new__ self.assertRaises(TypeError, C) class C(list): __new__ = object.__new__ self.assertRaises(TypeError, C) def test_object_new(self): class A(object): pass object.__new__(A) self.assertRaises(TypeError, object.__new__, A, 5) object.__init__(A()) self.assertRaises(TypeError, object.__init__, A(), 5) class A(object): def __init__(self, foo): self.foo = foo object.__new__(A) object.__new__(A, 5) object.__init__(A(3)) self.assertRaises(TypeError, object.__init__, A(3), 5) class A(object): def __new__(cls, foo): return object.__new__(cls) object.__new__(A) self.assertRaises(TypeError, object.__new__, A, 5) object.__init__(A(3)) object.__init__(A(3), 5) class A(object): def __new__(cls, foo): return object.__new__(cls) def __init__(self, foo): self.foo = foo object.__new__(A) self.assertRaises(TypeError, object.__new__, A, 5) object.__init__(A(3)) self.assertRaises(TypeError, object.__init__, A(3), 5) @unittest.expectedFailure def test_restored_object_new(self): class A(object): def __new__(cls, *args, **kwargs): raise AssertionError self.assertRaises(AssertionError, A) class B(A): __new__ = object.__new__ def __init__(self, foo): self.foo = foo with warnings.catch_warnings(): warnings.simplefilter('error', DeprecationWarning) b = B(3) self.assertEqual(b.foo, 3) self.assertEqual(b.__class__, B) del B.__new__ self.assertRaises(AssertionError, B) del A.__new__ with warnings.catch_warnings(): warnings.simplefilter('error', DeprecationWarning) b = B(3) self.assertEqual(b.foo, 3) self.assertEqual(b.__class__, B) def test_altmro(self): # Testing mro() and overriding it... class A(object): def f(self): return "A" class B(A): pass class C(A): def f(self): return "C" class D(B, C): pass self.assertEqual(D.mro(), [D, B, C, A, object]) self.assertEqual(D.__mro__, (D, B, C, A, object)) self.assertEqual(D().f(), "C") class PerverseMetaType(type): def mro(cls): L = type.mro(cls) L.reverse() return L class X(D,B,C,A, metaclass=PerverseMetaType): pass self.assertEqual(X.__mro__, (object, A, C, B, D, X)) self.assertEqual(X().f(), "A") try: class _metaclass(type): def mro(self): return [self, dict, object] class X(object, metaclass=_metaclass): pass # In CPython, the class creation above already raises # TypeError, as a protection against the fact that # instances of X would segfault it. In other Python # implementations it would be ok to let the class X # be created, but instead get a clean TypeError on the # __setitem__ below. x = object.__new__(X) x[5] = 6 except TypeError: pass else: self.fail("devious mro() return not caught") try: class _metaclass(type): def mro(self): return [1] class X(object, metaclass=_metaclass): pass except TypeError: pass else: self.fail("non-class mro() return not caught") try: class _metaclass(type): def mro(self): return 1 class X(object, metaclass=_metaclass): pass except TypeError: pass else: self.fail("non-sequence mro() return not caught") def test_overloading(self): # Testing operator overloading... class B(object): "Intermediate class because object doesn't have a __setattr__" class C(B): def __getattr__(self, name): if name == "foo": return ("getattr", name) else: raise AttributeError def __setattr__(self, name, value): if name == "foo": self.setattr = (name, value) else: return B.__setattr__(self, name, value) def __delattr__(self, name): if name == "foo": self.delattr = name else: return B.__delattr__(self, name) def __getitem__(self, key): return ("getitem", key) def __setitem__(self, key, value): self.setitem = (key, value) def __delitem__(self, key): self.delitem = key a = C() self.assertEqual(a.foo, ("getattr", "foo")) a.foo = 12 self.assertEqual(a.setattr, ("foo", 12)) del a.foo self.assertEqual(a.delattr, "foo") self.assertEqual(a[12], ("getitem", 12)) a[12] = 21 self.assertEqual(a.setitem, (12, 21)) del a[12] self.assertEqual(a.delitem, 12) self.assertEqual(a[0:10], ("getitem", slice(0, 10))) a[0:10] = "foo" self.assertEqual(a.setitem, (slice(0, 10), "foo")) del a[0:10] self.assertEqual(a.delitem, (slice(0, 10))) def test_methods(self): # Testing methods... class C(object): def __init__(self, x): self.x = x def foo(self): return self.x c1 = C(1) self.assertEqual(c1.foo(), 1) class D(C): boo = C.foo goo = c1.foo d2 = D(2) self.assertEqual(d2.foo(), 2) self.assertEqual(d2.boo(), 2) self.assertEqual(d2.goo(), 1) class E(object): foo = C.foo self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound self.assertTrue(repr(C.foo.__get__(C(1))).startswith("<bound method ")) def test_special_method_lookup(self): # The lookup of special methods bypasses __getattr__ and # __getattribute__, but they still can be descriptors. def run_context(manager): with manager: pass def iden(self): return self def hello(self): return b"hello" def empty_seq(self): return [] def zero(self): return 0 def complex_num(self): return 1j def stop(self): raise StopIteration def return_true(self, thing=None): return True def do_isinstance(obj): return isinstance(int, obj) def do_issubclass(obj): return issubclass(int, obj) def do_dict_missing(checker): class DictSub(checker.__class__, dict): pass self.assertEqual(DictSub()["hi"], 4) def some_number(self_, key): self.assertEqual(key, "hi") return 4 def swallow(*args): pass def format_impl(self, spec): return "hello" # It would be nice to have every special method tested here, but I'm # only listing the ones I can remember outside of typeobject.c, since it # does it right. specials = [ ("__bytes__", bytes, hello, set(), {}), ("__reversed__", reversed, empty_seq, set(), {}), ("__length_hint__", list, zero, set(), {"__iter__" : iden, "__next__" : stop}), ("__sizeof__", sys.getsizeof, zero, set(), {}), ("__instancecheck__", do_isinstance, return_true, set(), {}), ("__missing__", do_dict_missing, some_number, set(("__class__",)), {}), ("__subclasscheck__", do_issubclass, return_true, set(("__bases__",)), {}), ("__enter__", run_context, iden, set(), {"__exit__" : swallow}), ("__exit__", run_context, swallow, set(), {"__enter__" : iden}), ("__complex__", complex, complex_num, set(), {}), ("__format__", format, format_impl, set(), {}), ("__floor__", math.floor, zero, set(), {}), ("__trunc__", math.trunc, zero, set(), {}), ("__trunc__", int, zero, set(), {}), ("__ceil__", math.ceil, zero, set(), {}), ("__dir__", dir, empty_seq, set(), {}), ("__round__", round, zero, set(), {}), ] class Checker(object): def __getattr__(self, attr, test=self): test.fail("__getattr__ called with {0}".format(attr)) def __getattribute__(self, attr, test=self): if attr not in ok: test.fail("__getattribute__ called with {0}".format(attr)) return object.__getattribute__(self, attr) class SpecialDescr(object): def __init__(self, impl): self.impl = impl def __get__(self, obj, owner): record.append(1) return self.impl.__get__(obj, owner) class MyException(Exception): pass class ErrDescr(object): def __get__(self, obj, owner): raise MyException for name, runner, meth_impl, ok, env in specials: class X(Checker): pass for attr, obj in env.items(): setattr(X, attr, obj) setattr(X, name, meth_impl) runner(X()) record = [] class X(Checker): pass for attr, obj in env.items(): setattr(X, attr, obj) setattr(X, name, SpecialDescr(meth_impl)) runner(X()) self.assertEqual(record, [1], name) class X(Checker): pass for attr, obj in env.items(): setattr(X, attr, obj) setattr(X, name, ErrDescr()) self.assertRaises(MyException, runner, X()) def test_specials(self): # Testing special operators... # Test operators like __hash__ for which a built-in default exists # Test the default behavior for static classes class C(object): def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError c1 = C() c2 = C() self.assertFalse(not c1) self.assertNotEqual(id(c1), id(c2)) hash(c1) hash(c2) self.assertEqual(c1, c1) self.assertTrue(c1 != c2) self.assertFalse(c1 != c1) self.assertFalse(c1 == c2) # Note that the module name appears in str/repr, and that varies # depending on whether this test is run standalone or from a framework. self.assertGreaterEqual(str(c1).find('C object at '), 0) self.assertEqual(str(c1), repr(c1)) self.assertNotIn(-1, c1) for i in range(10): self.assertIn(i, c1) self.assertNotIn(10, c1) # Test the default behavior for dynamic classes class D(object): def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError d1 = D() d2 = D() self.assertFalse(not d1) self.assertNotEqual(id(d1), id(d2)) hash(d1) hash(d2) self.assertEqual(d1, d1) self.assertNotEqual(d1, d2) self.assertFalse(d1 != d1) self.assertFalse(d1 == d2) # Note that the module name appears in str/repr, and that varies # depending on whether this test is run standalone or from a framework. self.assertGreaterEqual(str(d1).find('D object at '), 0) self.assertEqual(str(d1), repr(d1)) self.assertNotIn(-1, d1) for i in range(10): self.assertIn(i, d1) self.assertNotIn(10, d1) # Test overridden behavior class Proxy(object): def __init__(self, x): self.x = x def __bool__(self): return not not self.x def __hash__(self): return hash(self.x) def __eq__(self, other): return self.x == other def __ne__(self, other): return self.x != other def __ge__(self, other): return self.x >= other def __gt__(self, other): return self.x > other def __le__(self, other): return self.x <= other def __lt__(self, other): return self.x < other def __str__(self): return "Proxy:%s" % self.x def __repr__(self): return "Proxy(%r)" % self.x def __contains__(self, value): return value in self.x p0 = Proxy(0) p1 = Proxy(1) p_1 = Proxy(-1) self.assertFalse(p0) self.assertFalse(not p1) self.assertEqual(hash(p0), hash(0)) self.assertEqual(p0, p0) self.assertNotEqual(p0, p1) self.assertFalse(p0 != p0) self.assertEqual(not p0, p1) self.assertTrue(p0 < p1) self.assertTrue(p0 <= p1) self.assertTrue(p1 > p0) self.assertTrue(p1 >= p0) self.assertEqual(str(p0), "Proxy:0") self.assertEqual(repr(p0), "Proxy(0)") p10 = Proxy(range(10)) self.assertNotIn(-1, p10) for i in range(10): self.assertIn(i, p10) self.assertNotIn(10, p10) def test_weakrefs(self): # Testing weak references... import weakref class C(object): pass c = C() r = weakref.ref(c) self.assertEqual(r(), c) del c support.gc_collect() self.assertEqual(r(), None) del r class NoWeak(object): __slots__ = ['foo'] no = NoWeak() try: weakref.ref(no) except TypeError as msg: self.assertIn("weak reference", str(msg)) else: self.fail("weakref.ref(no) should be illegal") class Weak(object): __slots__ = ['foo', '__weakref__'] yes = Weak() r = weakref.ref(yes) self.assertEqual(r(), yes) del yes support.gc_collect() self.assertEqual(r(), None) del r def test_properties(self): # Testing property... class C(object): def getx(self): return self.__x def setx(self, value): self.__x = value def delx(self): del self.__x x = property(getx, setx, delx, doc="I'm the x property.") a = C() self.assertNotHasAttr(a, "x") a.x = 42 self.assertEqual(a._C__x, 42) self.assertEqual(a.x, 42) del a.x self.assertNotHasAttr(a, "x") self.assertNotHasAttr(a, "_C__x") C.x.__set__(a, 100) self.assertEqual(C.x.__get__(a), 100) C.x.__delete__(a) self.assertNotHasAttr(a, "x") raw = C.__dict__['x'] self.assertIsInstance(raw, property) attrs = dir(raw) self.assertIn("__doc__", attrs) self.assertIn("fget", attrs) self.assertIn("fset", attrs) self.assertIn("fdel", attrs) self.assertEqual(raw.__doc__, "I'm the x property.") self.assertIs(raw.fget, C.__dict__['getx']) self.assertIs(raw.fset, C.__dict__['setx']) self.assertIs(raw.fdel, C.__dict__['delx']) for attr in "fget", "fset", "fdel": try: setattr(raw, attr, 42) except AttributeError as msg: if str(msg).find('readonly') < 0: self.fail("when setting readonly attr %r on a property, " "got unexpected AttributeError msg %r" % (attr, str(msg))) else: self.fail("expected AttributeError from trying to set readonly %r " "attr on a property" % attr) raw.__doc__ = 42 self.assertEqual(raw.__doc__, 42) class D(object): __getitem__ = property(lambda s: 1/0) d = D() try: for i in d: str(i) except ZeroDivisionError: pass else: self.fail("expected ZeroDivisionError from bad property") @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_properties_doc_attrib(self): class E(object): def getter(self): "getter method" return 0 def setter(self_, value): "setter method" pass prop = property(getter) self.assertEqual(prop.__doc__, "getter method") prop2 = property(fset=setter) self.assertEqual(prop2.__doc__, None) @support.cpython_only def test_testcapi_no_segfault(self): # this segfaulted in 2.5b2 try: import _testcapi except ImportError: pass else: class X(object): p = property(_testcapi.test_with_docstring) def test_properties_plus(self): class C(object): foo = property(doc="hello") @foo.getter def foo(self): return self._foo @foo.setter def foo(self, value): self._foo = abs(value) @foo.deleter def foo(self): del self._foo c = C() self.assertEqual(C.foo.__doc__, "hello") self.assertNotHasAttr(c, "foo") c.foo = -42 self.assertHasAttr(c, '_foo') self.assertEqual(c._foo, 42) self.assertEqual(c.foo, 42) del c.foo self.assertNotHasAttr(c, '_foo') self.assertNotHasAttr(c, "foo") class D(C): @C.foo.deleter def foo(self): try: del self._foo except AttributeError: pass d = D() d.foo = 24 self.assertEqual(d.foo, 24) del d.foo del d.foo class E(object): @property def foo(self): return self._foo @foo.setter def foo(self, value): raise RuntimeError @foo.setter def foo(self, value): self._foo = abs(value) @foo.deleter def foo(self, value=None): del self._foo e = E() e.foo = -42 self.assertEqual(e.foo, 42) del e.foo class F(E): @E.foo.deleter def foo(self): del self._foo @foo.setter def foo(self, value): self._foo = max(0, value) f = F() f.foo = -10 self.assertEqual(f.foo, 0) del f.foo def test_dict_constructors(self): # Testing dict constructor ... d = dict() self.assertEqual(d, {}) d = dict({}) self.assertEqual(d, {}) d = dict({1: 2, 'a': 'b'}) self.assertEqual(d, {1: 2, 'a': 'b'}) self.assertEqual(d, dict(list(d.items()))) self.assertEqual(d, dict(iter(d.items()))) d = dict({'one':1, 'two':2}) self.assertEqual(d, dict(one=1, two=2)) self.assertEqual(d, dict(**d)) self.assertEqual(d, dict({"one": 1}, two=2)) self.assertEqual(d, dict([("two", 2)], one=1)) self.assertEqual(d, dict([("one", 100), ("two", 200)], **d)) self.assertEqual(d, dict(**d)) for badarg in 0, 0, 0j, "0", [0], (0,): try: dict(badarg) except TypeError: pass except ValueError: if badarg == "0": # It's a sequence, and its elements are also sequences (gotta # love strings <wink>), but they aren't of length 2, so this # one seemed better as a ValueError than a TypeError. pass else: self.fail("no TypeError from dict(%r)" % badarg) else: self.fail("no TypeError from dict(%r)" % badarg) try: dict({}, {}) except TypeError: pass else: self.fail("no TypeError from dict({}, {})") class Mapping: # Lacks a .keys() method; will be added later. dict = {1:2, 3:4, 'a':1j} try: dict(Mapping()) except TypeError: pass else: self.fail("no TypeError from dict(incomplete mapping)") Mapping.keys = lambda self: list(self.dict.keys()) Mapping.__getitem__ = lambda self, i: self.dict[i] d = dict(Mapping()) self.assertEqual(d, Mapping.dict) # Init from sequence of iterable objects, each producing a 2-sequence. class AddressBookEntry: def __init__(self, first, last): self.first = first self.last = last def __iter__(self): return iter([self.first, self.last]) d = dict([AddressBookEntry('Tim', 'Warsaw'), AddressBookEntry('Barry', 'Peters'), AddressBookEntry('Tim', 'Peters'), AddressBookEntry('Barry', 'Warsaw')]) self.assertEqual(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) d = dict(zip(range(4), range(1, 5))) self.assertEqual(d, dict([(i, i+1) for i in range(4)])) # Bad sequence lengths. for bad in [('tooshort',)], [('too', 'long', 'by 1')]: try: dict(bad) except ValueError: pass else: self.fail("no ValueError from dict(%r)" % bad) def test_dir(self): # Testing dir() ... junk = 12 self.assertEqual(dir(), ['junk', 'self']) del junk # Just make sure these don't blow up! for arg in 2, 2, 2j, 2e0, [2], "2", b"2", (2,), {2:2}, type, self.test_dir: dir(arg) # Test dir on new-style classes. Since these have object as a # base class, a lot more gets sucked in. def interesting(strings): return [s for s in strings if not s.startswith('_')] class C(object): Cdata = 1 def Cmethod(self): pass cstuff = ['Cdata', 'Cmethod'] self.assertEqual(interesting(dir(C)), cstuff) c = C() self.assertEqual(interesting(dir(c)), cstuff) ## self.assertIn('__self__', dir(C.Cmethod)) c.cdata = 2 c.cmethod = lambda self: 0 self.assertEqual(interesting(dir(c)), cstuff + ['cdata', 'cmethod']) ## self.assertIn('__self__', dir(c.Cmethod)) class A(C): Adata = 1 def Amethod(self): pass astuff = ['Adata', 'Amethod'] + cstuff self.assertEqual(interesting(dir(A)), astuff) ## self.assertIn('__self__', dir(A.Amethod)) a = A() self.assertEqual(interesting(dir(a)), astuff) a.adata = 42 a.amethod = lambda self: 3 self.assertEqual(interesting(dir(a)), astuff + ['adata', 'amethod']) ## self.assertIn('__self__', dir(a.Amethod)) # Try a module subclass. class M(type(sys)): pass minstance = M("m") minstance.b = 2 minstance.a = 1 default_attributes = ['__name__', '__doc__', '__package__', '__loader__', '__spec__'] names = [x for x in dir(minstance) if x not in default_attributes] self.assertEqual(names, ['a', 'b']) class M2(M): def getdict(self): return "Not a dict!" __dict__ = property(getdict) m2instance = M2("m2") m2instance.b = 2 m2instance.a = 1 self.assertEqual(m2instance.__dict__, "Not a dict!") try: dir(m2instance) except TypeError: pass # Two essentially featureless objects, just inheriting stuff from # object. self.assertEqual(dir(NotImplemented), dir(Ellipsis)) # Nasty test case for proxied objects class Wrapper(object): def __init__(self, obj): self.__obj = obj def __repr__(self): return "Wrapper(%s)" % repr(self.__obj) def __getitem__(self, key): return Wrapper(self.__obj[key]) def __len__(self): return len(self.__obj) def __getattr__(self, name): return Wrapper(getattr(self.__obj, name)) class C(object): def __getclass(self): return Wrapper(type(self)) __class__ = property(__getclass) dir(C()) # This used to segfault def test_supers(self): # Testing super... class A(object): def meth(self, a): return "A(%r)" % a self.assertEqual(A().meth(1), "A(1)") class B(A): def __init__(self): self.__super = super(B, self) def meth(self, a): return "B(%r)" % a + self.__super.meth(a) self.assertEqual(B().meth(2), "B(2)A(2)") class C(A): def meth(self, a): return "C(%r)" % a + self.__super.meth(a) C._C__super = super(C) self.assertEqual(C().meth(3), "C(3)A(3)") class D(C, B): def meth(self, a): return "D(%r)" % a + super(D, self).meth(a) self.assertEqual(D().meth(4), "D(4)C(4)B(4)A(4)") # Test for subclassing super class mysuper(super): def __init__(self, *args): return super(mysuper, self).__init__(*args) class E(D): def meth(self, a): return "E(%r)" % a + mysuper(E, self).meth(a) self.assertEqual(E().meth(5), "E(5)D(5)C(5)B(5)A(5)") class F(E): def meth(self, a): s = self.__super # == mysuper(F, self) return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a) F._F__super = mysuper(F) self.assertEqual(F().meth(6), "F(6)[mysuper]E(6)D(6)C(6)B(6)A(6)") # Make sure certain errors are raised try: super(D, 42) except TypeError: pass else: self.fail("shouldn't allow super(D, 42)") try: super(D, C()) except TypeError: pass else: self.fail("shouldn't allow super(D, C())") try: super(D).__get__(12) except TypeError: pass else: self.fail("shouldn't allow super(D).__get__(12)") try: super(D).__get__(C()) except TypeError: pass else: self.fail("shouldn't allow super(D).__get__(C())") # Make sure data descriptors can be overridden and accessed via super # (new feature in Python 2.3) class DDbase(object): def getx(self): return 42 x = property(getx) class DDsub(DDbase): def getx(self): return "hello" x = property(getx) dd = DDsub() self.assertEqual(dd.x, "hello") self.assertEqual(super(DDsub, dd).x, 42) # Ensure that super() lookup of descriptor from classmethod # works (SF ID# 743627) class Base(object): aProp = property(lambda self: "foo") class Sub(Base): @classmethod def test(klass): return super(Sub,klass).aProp self.assertEqual(Sub.test(), Base.aProp) # Verify that super() doesn't allow keyword args try: super(Base, kw=1) except TypeError: pass else: self.assertEqual("super shouldn't accept keyword args") def test_basic_inheritance(self): # Testing inheritance from basic types... class hexint(int): def __repr__(self): return hex(self) def __add__(self, other): return hexint(int.__add__(self, other)) # (Note that overriding __radd__ doesn't work, # because the int type gets first dibs.) self.assertEqual(repr(hexint(7) + 9), "0x10") self.assertEqual(repr(hexint(1000) + 7), "0x3ef") a = hexint(12345) self.assertEqual(a, 12345) self.assertEqual(int(a), 12345) self.assertIs(int(a).__class__, int) self.assertEqual(hash(a), hash(12345)) self.assertIs((+a).__class__, int) self.assertIs((a >> 0).__class__, int) self.assertIs((a << 0).__class__, int) self.assertIs((hexint(0) << 12).__class__, int) self.assertIs((hexint(0) >> 12).__class__, int) class octlong(int): __slots__ = [] def __str__(self): return oct(self) def __add__(self, other): return self.__class__(super(octlong, self).__add__(other)) __radd__ = __add__ self.assertEqual(str(octlong(3) + 5), "0o10") # (Note that overriding __radd__ here only seems to work # because the example uses a short int left argument.) self.assertEqual(str(5 + octlong(3000)), "0o5675") a = octlong(12345) self.assertEqual(a, 12345) self.assertEqual(int(a), 12345) self.assertEqual(hash(a), hash(12345)) self.assertIs(int(a).__class__, int) self.assertIs((+a).__class__, int) self.assertIs((-a).__class__, int) self.assertIs((-octlong(0)).__class__, int) self.assertIs((a >> 0).__class__, int) self.assertIs((a << 0).__class__, int) self.assertIs((a - 0).__class__, int) self.assertIs((a * 1).__class__, int) self.assertIs((a ** 1).__class__, int) self.assertIs((a // 1).__class__, int) self.assertIs((1 * a).__class__, int) self.assertIs((a | 0).__class__, int) self.assertIs((a ^ 0).__class__, int) self.assertIs((a & -1).__class__, int) self.assertIs((octlong(0) << 12).__class__, int) self.assertIs((octlong(0) >> 12).__class__, int) self.assertIs(abs(octlong(0)).__class__, int) # Because octlong overrides __add__, we can't check the absence of +0 # optimizations using octlong. class longclone(int): pass a = longclone(1) self.assertIs((a + 0).__class__, int) self.assertIs((0 + a).__class__, int) # Check that negative clones don't segfault a = longclone(-1) self.assertEqual(a.__dict__, {}) self.assertEqual(int(a), -1) # self.assertTrue PyNumber_Long() copies the sign bit class precfloat(float): __slots__ = ['prec'] def __init__(self, value=0.0, prec=12): self.prec = int(prec) def __repr__(self): return "%.*g" % (self.prec, self) self.assertEqual(repr(precfloat(1.1)), "1.1") a = precfloat(12345) self.assertEqual(a, 12345.0) self.assertEqual(float(a), 12345.0) self.assertIs(float(a).__class__, float) self.assertEqual(hash(a), hash(12345.0)) self.assertIs((+a).__class__, float) class madcomplex(complex): def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real) a = madcomplex(-3, 4) self.assertEqual(repr(a), "4j-3") base = complex(-3, 4) self.assertEqual(base.__class__, complex) self.assertEqual(a, base) self.assertEqual(complex(a), base) self.assertEqual(complex(a).__class__, complex) a = madcomplex(a) # just trying another form of the constructor self.assertEqual(repr(a), "4j-3") self.assertEqual(a, base) self.assertEqual(complex(a), base) self.assertEqual(complex(a).__class__, complex) self.assertEqual(hash(a), hash(base)) self.assertEqual((+a).__class__, complex) self.assertEqual((a + 0).__class__, complex) self.assertEqual(a + 0, base) self.assertEqual((a - 0).__class__, complex) self.assertEqual(a - 0, base) self.assertEqual((a * 1).__class__, complex) self.assertEqual(a * 1, base) self.assertEqual((a / 1).__class__, complex) self.assertEqual(a / 1, base) class madtuple(tuple): _rev = None def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__(L) return self._rev a = madtuple((1,2,3,4,5,6,7,8,9,0)) self.assertEqual(a, (1,2,3,4,5,6,7,8,9,0)) self.assertEqual(a.rev(), madtuple((0,9,8,7,6,5,4,3,2,1))) self.assertEqual(a.rev().rev(), madtuple((1,2,3,4,5,6,7,8,9,0))) for i in range(512): t = madtuple(range(i)) u = t.rev() v = u.rev() self.assertEqual(v, t) a = madtuple((1,2,3,4,5)) self.assertEqual(tuple(a), (1,2,3,4,5)) self.assertIs(tuple(a).__class__, tuple) self.assertEqual(hash(a), hash((1,2,3,4,5))) self.assertIs(a[:].__class__, tuple) self.assertIs((a * 1).__class__, tuple) self.assertIs((a * 0).__class__, tuple) self.assertIs((a + ()).__class__, tuple) a = madtuple(()) self.assertEqual(tuple(a), ()) self.assertIs(tuple(a).__class__, tuple) self.assertIs((a + a).__class__, tuple) self.assertIs((a * 0).__class__, tuple) self.assertIs((a * 1).__class__, tuple) self.assertIs((a * 2).__class__, tuple) self.assertIs(a[:].__class__, tuple) class madstring(str): _rev = None def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__("".join(L)) return self._rev s = madstring("abcdefghijklmnopqrstuvwxyz") self.assertEqual(s, "abcdefghijklmnopqrstuvwxyz") self.assertEqual(s.rev(), madstring("zyxwvutsrqponmlkjihgfedcba")) self.assertEqual(s.rev().rev(), madstring("abcdefghijklmnopqrstuvwxyz")) for i in range(256): s = madstring("".join(map(chr, range(i)))) t = s.rev() u = t.rev() self.assertEqual(u, s) s = madstring("12345") self.assertEqual(str(s), "12345") self.assertIs(str(s).__class__, str) base = "\x00" * 5 s = madstring(base) self.assertEqual(s, base) self.assertEqual(str(s), base) self.assertIs(str(s).__class__, str) self.assertEqual(hash(s), hash(base)) self.assertEqual({s: 1}[base], 1) self.assertEqual({base: 1}[s], 1) self.assertIs((s + "").__class__, str) self.assertEqual(s + "", base) self.assertIs(("" + s).__class__, str) self.assertEqual("" + s, base) self.assertIs((s * 0).__class__, str) self.assertEqual(s * 0, "") self.assertIs((s * 1).__class__, str) self.assertEqual(s * 1, base) self.assertIs((s * 2).__class__, str) self.assertEqual(s * 2, base + base) self.assertIs(s[:].__class__, str) self.assertEqual(s[:], base) self.assertIs(s[0:0].__class__, str) self.assertEqual(s[0:0], "") self.assertIs(s.strip().__class__, str) self.assertEqual(s.strip(), base) self.assertIs(s.lstrip().__class__, str) self.assertEqual(s.lstrip(), base) self.assertIs(s.rstrip().__class__, str) self.assertEqual(s.rstrip(), base) identitytab = {} self.assertIs(s.translate(identitytab).__class__, str) self.assertEqual(s.translate(identitytab), base) self.assertIs(s.replace("x", "x").__class__, str) self.assertEqual(s.replace("x", "x"), base) self.assertIs(s.ljust(len(s)).__class__, str) self.assertEqual(s.ljust(len(s)), base) self.assertIs(s.rjust(len(s)).__class__, str) self.assertEqual(s.rjust(len(s)), base) self.assertIs(s.center(len(s)).__class__, str) self.assertEqual(s.center(len(s)), base) self.assertIs(s.lower().__class__, str) self.assertEqual(s.lower(), base) class madunicode(str): _rev = None def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__("".join(L)) return self._rev u = madunicode("ABCDEF") self.assertEqual(u, "ABCDEF") self.assertEqual(u.rev(), madunicode("FEDCBA")) self.assertEqual(u.rev().rev(), madunicode("ABCDEF")) base = "12345" u = madunicode(base) self.assertEqual(str(u), base) self.assertIs(str(u).__class__, str) self.assertEqual(hash(u), hash(base)) self.assertEqual({u: 1}[base], 1) self.assertEqual({base: 1}[u], 1) self.assertIs(u.strip().__class__, str) self.assertEqual(u.strip(), base) self.assertIs(u.lstrip().__class__, str) self.assertEqual(u.lstrip(), base) self.assertIs(u.rstrip().__class__, str) self.assertEqual(u.rstrip(), base) self.assertIs(u.replace("x", "x").__class__, str) self.assertEqual(u.replace("x", "x"), base) self.assertIs(u.replace("xy", "xy").__class__, str) self.assertEqual(u.replace("xy", "xy"), base) self.assertIs(u.center(len(u)).__class__, str) self.assertEqual(u.center(len(u)), base) self.assertIs(u.ljust(len(u)).__class__, str) self.assertEqual(u.ljust(len(u)), base) self.assertIs(u.rjust(len(u)).__class__, str) self.assertEqual(u.rjust(len(u)), base) self.assertIs(u.lower().__class__, str) self.assertEqual(u.lower(), base) self.assertIs(u.upper().__class__, str) self.assertEqual(u.upper(), base) self.assertIs(u.capitalize().__class__, str) self.assertEqual(u.capitalize(), base) self.assertIs(u.title().__class__, str) self.assertEqual(u.title(), base) self.assertIs((u + "").__class__, str) self.assertEqual(u + "", base) self.assertIs(("" + u).__class__, str) self.assertEqual("" + u, base) self.assertIs((u * 0).__class__, str) self.assertEqual(u * 0, "") self.assertIs((u * 1).__class__, str) self.assertEqual(u * 1, base) self.assertIs((u * 2).__class__, str) self.assertEqual(u * 2, base + base) self.assertIs(u[:].__class__, str) self.assertEqual(u[:], base) self.assertIs(u[0:0].__class__, str) self.assertEqual(u[0:0], "") class sublist(list): pass a = sublist(range(5)) self.assertEqual(a, list(range(5))) a.append("hello") self.assertEqual(a, list(range(5)) + ["hello"]) a[5] = 5 self.assertEqual(a, list(range(6))) a.extend(range(6, 20)) self.assertEqual(a, list(range(20))) a[-5:] = [] self.assertEqual(a, list(range(15))) del a[10:15] self.assertEqual(len(a), 10) self.assertEqual(a, list(range(10))) self.assertEqual(list(a), list(range(10))) self.assertEqual(a[0], 0) self.assertEqual(a[9], 9) self.assertEqual(a[-10], 0) self.assertEqual(a[-1], 9) self.assertEqual(a[:5], list(range(5))) ## class CountedInput(file): ## """Counts lines read by self.readline(). ## ## self.lineno is the 0-based ordinal of the last line read, up to ## a maximum of one greater than the number of lines in the file. ## ## self.ateof is true if and only if the final "" line has been read, ## at which point self.lineno stops incrementing, and further calls ## to readline() continue to return "". ## """ ## ## lineno = 0 ## ateof = 0 ## def readline(self): ## if self.ateof: ## return "" ## s = file.readline(self) ## # Next line works too. ## # s = super(CountedInput, self).readline() ## self.lineno += 1 ## if s == "": ## self.ateof = 1 ## return s ## ## f = file(name=support.TESTFN, mode='w') ## lines = ['a\n', 'b\n', 'c\n'] ## try: ## f.writelines(lines) ## f.close() ## f = CountedInput(support.TESTFN) ## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]): ## got = f.readline() ## self.assertEqual(expected, got) ## self.assertEqual(f.lineno, i) ## self.assertEqual(f.ateof, (i > len(lines))) ## f.close() ## finally: ## try: ## f.close() ## except: ## pass ## support.unlink(support.TESTFN) def test_keywords(self): # Testing keyword args to basic type constructors ... self.assertEqual(int(x=1), 1) self.assertEqual(float(x=2), 2.0) self.assertEqual(int(x=3), 3) self.assertEqual(complex(imag=42, real=666), complex(666, 42)) self.assertEqual(str(object=500), '500') self.assertEqual(str(object=b'abc', errors='strict'), 'abc') self.assertEqual(tuple(sequence=range(3)), (0, 1, 2)) self.assertEqual(list(sequence=(0, 1, 2)), list(range(3))) # note: as of Python 2.3, dict() no longer has an "items" keyword arg for constructor in (int, float, int, complex, str, str, tuple, list): try: constructor(bogus_keyword_arg=1) except TypeError: pass else: self.fail("expected TypeError from bogus keyword argument to %r" % constructor) def test_str_subclass_as_dict_key(self): # Testing a str subclass used as dict key .. class cistr(str): """Sublcass of str that computes __eq__ case-insensitively. Also computes a hash code of the string in canonical form. """ def __init__(self, value): self.canonical = value.lower() self.hashcode = hash(self.canonical) def __eq__(self, other): if not isinstance(other, cistr): other = cistr(other) return self.canonical == other.canonical def __hash__(self): return self.hashcode self.assertEqual(cistr('ABC'), 'abc') self.assertEqual('aBc', cistr('ABC')) self.assertEqual(str(cistr('ABC')), 'ABC') d = {cistr('one'): 1, cistr('two'): 2, cistr('tHree'): 3} self.assertEqual(d[cistr('one')], 1) self.assertEqual(d[cistr('tWo')], 2) self.assertEqual(d[cistr('THrEE')], 3) self.assertIn(cistr('ONe'), d) self.assertEqual(d.get(cistr('thrEE')), 3) def test_classic_comparisons(self): # Testing classic comparisons... class classic: pass for base in (classic, int, object): class C(base): def __init__(self, value): self.value = int(value) def __eq__(self, other): if isinstance(other, C): return self.value == other.value if isinstance(other, int) or isinstance(other, int): return self.value == other return NotImplemented def __ne__(self, other): if isinstance(other, C): return self.value != other.value if isinstance(other, int) or isinstance(other, int): return self.value != other return NotImplemented def __lt__(self, other): if isinstance(other, C): return self.value < other.value if isinstance(other, int) or isinstance(other, int): return self.value < other return NotImplemented def __le__(self, other): if isinstance(other, C): return self.value <= other.value if isinstance(other, int) or isinstance(other, int): return self.value <= other return NotImplemented def __gt__(self, other): if isinstance(other, C): return self.value > other.value if isinstance(other, int) or isinstance(other, int): return self.value > other return NotImplemented def __ge__(self, other): if isinstance(other, C): return self.value >= other.value if isinstance(other, int) or isinstance(other, int): return self.value >= other return NotImplemented c1 = C(1) c2 = C(2) c3 = C(3) self.assertEqual(c1, 1) c = {1: c1, 2: c2, 3: c3} for x in 1, 2, 3: for y in 1, 2, 3: for op in "<", "<=", "==", "!=", ">", ">=": self.assertEqual(eval("c[x] %s c[y]" % op), eval("x %s y" % op), "x=%d, y=%d" % (x, y)) self.assertEqual(eval("c[x] %s y" % op), eval("x %s y" % op), "x=%d, y=%d" % (x, y)) self.assertEqual(eval("x %s c[y]" % op), eval("x %s y" % op), "x=%d, y=%d" % (x, y)) def test_rich_comparisons(self): # Testing rich comparisons... class Z(complex): pass z = Z(1) self.assertEqual(z, 1+0j) self.assertEqual(1+0j, z) class ZZ(complex): def __eq__(self, other): try: return abs(self - other) <= 1e-6 except: return NotImplemented zz = ZZ(1.0000003) self.assertEqual(zz, 1+0j) self.assertEqual(1+0j, zz) class classic: pass for base in (classic, int, object, list): class C(base): def __init__(self, value): self.value = int(value) def __cmp__(self_, other): self.fail("shouldn't call __cmp__") def __eq__(self, other): if isinstance(other, C): return self.value == other.value if isinstance(other, int) or isinstance(other, int): return self.value == other return NotImplemented def __ne__(self, other): if isinstance(other, C): return self.value != other.value if isinstance(other, int) or isinstance(other, int): return self.value != other return NotImplemented def __lt__(self, other): if isinstance(other, C): return self.value < other.value if isinstance(other, int) or isinstance(other, int): return self.value < other return NotImplemented def __le__(self, other): if isinstance(other, C): return self.value <= other.value if isinstance(other, int) or isinstance(other, int): return self.value <= other return NotImplemented def __gt__(self, other): if isinstance(other, C): return self.value > other.value if isinstance(other, int) or isinstance(other, int): return self.value > other return NotImplemented def __ge__(self, other): if isinstance(other, C): return self.value >= other.value if isinstance(other, int) or isinstance(other, int): return self.value >= other return NotImplemented c1 = C(1) c2 = C(2) c3 = C(3) self.assertEqual(c1, 1) c = {1: c1, 2: c2, 3: c3} for x in 1, 2, 3: for y in 1, 2, 3: for op in "<", "<=", "==", "!=", ">", ">=": self.assertEqual(eval("c[x] %s c[y]" % op), eval("x %s y" % op), "x=%d, y=%d" % (x, y)) self.assertEqual(eval("c[x] %s y" % op), eval("x %s y" % op), "x=%d, y=%d" % (x, y)) self.assertEqual(eval("x %s c[y]" % op), eval("x %s y" % op), "x=%d, y=%d" % (x, y)) def test_descrdoc(self): # Testing descriptor doc strings... from _io import FileIO def check(descr, what): self.assertEqual(descr.__doc__, what) check(FileIO.closed, "True if the file is closed") # getset descriptor check(complex.real, "the real part of a complex number") # member descriptor def test_doc_descriptor(self): # Testing __doc__ descriptor... # SF bug 542984 class DocDescr(object): def __get__(self, object, otype): if object: object = object.__class__.__name__ + ' instance' if otype: otype = otype.__name__ return 'object=%s; type=%s' % (object, otype) class OldClass: __doc__ = DocDescr() class NewClass(object): __doc__ = DocDescr() self.assertEqual(OldClass.__doc__, 'object=None; type=OldClass') self.assertEqual(OldClass().__doc__, 'object=OldClass instance; type=OldClass') self.assertEqual(NewClass.__doc__, 'object=None; type=NewClass') self.assertEqual(NewClass().__doc__, 'object=NewClass instance; type=NewClass') def test_set_class(self): # Testing __class__ assignment... class C(object): pass class D(object): pass class E(object): pass class F(D, E): pass for cls in C, D, E, F: for cls2 in C, D, E, F: x = cls() x.__class__ = cls2 self.assertIs(x.__class__, cls2) x.__class__ = cls self.assertIs(x.__class__, cls) def cant(x, C): try: x.__class__ = C except TypeError: pass else: self.fail("shouldn't allow %r.__class__ = %r" % (x, C)) try: delattr(x, "__class__") except (TypeError, AttributeError): pass else: self.fail("shouldn't allow del %r.__class__" % x) cant(C(), list) cant(list(), C) cant(C(), 1) cant(C(), object) cant(object(), list) cant(list(), object) class Int(int): __slots__ = [] cant(True, int) cant(2, bool) o = object() cant(o, type(1)) cant(o, type(None)) del o class G(object): __slots__ = ["a", "b"] class H(object): __slots__ = ["b", "a"] class I(object): __slots__ = ["a", "b"] class J(object): __slots__ = ["c", "b"] class K(object): __slots__ = ["a", "b", "d"] class L(H): __slots__ = ["e"] class M(I): __slots__ = ["e"] class N(J): __slots__ = ["__weakref__"] class P(J): __slots__ = ["__dict__"] class Q(J): pass class R(J): __slots__ = ["__dict__", "__weakref__"] for cls, cls2 in ((G, H), (G, I), (I, H), (Q, R), (R, Q)): x = cls() x.a = 1 x.__class__ = cls2 self.assertIs(x.__class__, cls2, "assigning %r as __class__ for %r silently failed" % (cls2, x)) self.assertEqual(x.a, 1) x.__class__ = cls self.assertIs(x.__class__, cls, "assigning %r as __class__ for %r silently failed" % (cls, x)) self.assertEqual(x.a, 1) for cls in G, J, K, L, M, N, P, R, list, Int: for cls2 in G, J, K, L, M, N, P, R, list, Int: if cls is cls2: continue cant(cls(), cls2) # Issue5283: when __class__ changes in __del__, the wrong # type gets DECREF'd. class O(object): pass class A(object): def __del__(self): self.__class__ = O l = [A() for x in range(100)] del l def test_set_dict(self): # Testing __dict__ assignment... class C(object): pass a = C() a.__dict__ = {'b': 1} self.assertEqual(a.b, 1) def cant(x, dict): try: x.__dict__ = dict except (AttributeError, TypeError): pass else: self.fail("shouldn't allow %r.__dict__ = %r" % (x, dict)) cant(a, None) cant(a, []) cant(a, 1) del a.__dict__ # Deleting __dict__ is allowed class Base(object): pass def verify_dict_readonly(x): """ x has to be an instance of a class inheriting from Base. """ cant(x, {}) try: del x.__dict__ except (AttributeError, TypeError): pass else: self.fail("shouldn't allow del %r.__dict__" % x) dict_descr = Base.__dict__["__dict__"] try: dict_descr.__set__(x, {}) except (AttributeError, TypeError): pass else: self.fail("dict_descr allowed access to %r's dict" % x) # Classes don't allow __dict__ assignment and have readonly dicts class Meta1(type, Base): pass class Meta2(Base, type): pass class D(object, metaclass=Meta1): pass class E(object, metaclass=Meta2): pass for cls in C, D, E: verify_dict_readonly(cls) class_dict = cls.__dict__ try: class_dict["spam"] = "eggs" except TypeError: pass else: self.fail("%r's __dict__ can be modified" % cls) # Modules also disallow __dict__ assignment class Module1(types.ModuleType, Base): pass class Module2(Base, types.ModuleType): pass for ModuleType in Module1, Module2: mod = ModuleType("spam") verify_dict_readonly(mod) mod.__dict__["spam"] = "eggs" # Exception's __dict__ can be replaced, but not deleted # (at least not any more than regular exception's __dict__ can # be deleted; on CPython it is not the case, whereas on PyPy they # can, just like any other new-style instance's __dict__.) def can_delete_dict(e): try: del e.__dict__ except (TypeError, AttributeError): return False else: return True class Exception1(Exception, Base): pass class Exception2(Base, Exception): pass for ExceptionType in Exception, Exception1, Exception2: e = ExceptionType() e.__dict__ = {"a": 1} self.assertEqual(e.a, 1) self.assertEqual(can_delete_dict(e), can_delete_dict(ValueError())) def test_binary_operator_override(self): # Testing overrides of binary operations... class I(int): def __repr__(self): return "I(%r)" % int(self) def __add__(self, other): return I(int(self) + int(other)) __radd__ = __add__ def __pow__(self, other, mod=None): if mod is None: return I(pow(int(self), int(other))) else: return I(pow(int(self), int(other), int(mod))) def __rpow__(self, other, mod=None): if mod is None: return I(pow(int(other), int(self), mod)) else: return I(pow(int(other), int(self), int(mod))) self.assertEqual(repr(I(1) + I(2)), "I(3)") self.assertEqual(repr(I(1) + 2), "I(3)") self.assertEqual(repr(1 + I(2)), "I(3)") self.assertEqual(repr(I(2) ** I(3)), "I(8)") self.assertEqual(repr(2 ** I(3)), "I(8)") self.assertEqual(repr(I(2) ** 3), "I(8)") self.assertEqual(repr(pow(I(2), I(3), I(5))), "I(3)") class S(str): def __eq__(self, other): return self.lower() == other.lower() def test_subclass_propagation(self): # Testing propagation of slot functions to subclasses... class A(object): pass class B(A): pass class C(A): pass class D(B, C): pass d = D() orig_hash = hash(d) # related to id(d) in platform-dependent ways A.__hash__ = lambda self: 42 self.assertEqual(hash(d), 42) C.__hash__ = lambda self: 314 self.assertEqual(hash(d), 314) B.__hash__ = lambda self: 144 self.assertEqual(hash(d), 144) D.__hash__ = lambda self: 100 self.assertEqual(hash(d), 100) D.__hash__ = None self.assertRaises(TypeError, hash, d) del D.__hash__ self.assertEqual(hash(d), 144) B.__hash__ = None self.assertRaises(TypeError, hash, d) del B.__hash__ self.assertEqual(hash(d), 314) C.__hash__ = None self.assertRaises(TypeError, hash, d) del C.__hash__ self.assertEqual(hash(d), 42) A.__hash__ = None self.assertRaises(TypeError, hash, d) del A.__hash__ self.assertEqual(hash(d), orig_hash) d.foo = 42 d.bar = 42 self.assertEqual(d.foo, 42) self.assertEqual(d.bar, 42) def __getattribute__(self, name): if name == "foo": return 24 return object.__getattribute__(self, name) A.__getattribute__ = __getattribute__ self.assertEqual(d.foo, 24) self.assertEqual(d.bar, 42) def __getattr__(self, name): if name in ("spam", "foo", "bar"): return "hello" raise AttributeError(name) B.__getattr__ = __getattr__ self.assertEqual(d.spam, "hello") self.assertEqual(d.foo, 24) self.assertEqual(d.bar, 42) del A.__getattribute__ self.assertEqual(d.foo, 42) del d.foo self.assertEqual(d.foo, "hello") self.assertEqual(d.bar, 42) del B.__getattr__ try: d.foo except AttributeError: pass else: self.fail("d.foo should be undefined now") # Test a nasty bug in recurse_down_subclasses() class A(object): pass class B(A): pass del B support.gc_collect() A.__setitem__ = lambda *a: None # crash def test_buffer_inheritance(self): # Testing that buffer interface is inherited ... import binascii # SF bug [#470040] ParseTuple t# vs subclasses. class MyBytes(bytes): pass base = b'abc' m = MyBytes(base) # b2a_hex uses the buffer interface to get its argument's value, via # PyArg_ParseTuple 't#' code. self.assertEqual(binascii.b2a_hex(m), binascii.b2a_hex(base)) class MyInt(int): pass m = MyInt(42) try: binascii.b2a_hex(m) self.fail('subclass of int should not have a buffer interface') except TypeError: pass def test_str_of_str_subclass(self): # Testing __str__ defined in subclass of str ... import binascii import io class octetstring(str): def __str__(self): return binascii.b2a_hex(self.encode('ascii')).decode("ascii") def __repr__(self): return self + " repr" o = octetstring('A') self.assertEqual(type(o), octetstring) self.assertEqual(type(str(o)), str) self.assertEqual(type(repr(o)), str) self.assertEqual(ord(o), 0x41) self.assertEqual(str(o), '41') self.assertEqual(repr(o), 'A repr') self.assertEqual(o.__str__(), '41') self.assertEqual(o.__repr__(), 'A repr') capture = io.StringIO() # Calling str() or not exercises different internal paths. print(o, file=capture) print(str(o), file=capture) self.assertEqual(capture.getvalue(), '41\n41\n') capture.close() def test_keyword_arguments(self): # Testing keyword arguments to __init__, __call__... def f(a): return a self.assertEqual(f.__call__(a=42), 42) a = [] list.__init__(a, sequence=[0, 1, 2]) self.assertEqual(a, [0, 1, 2]) def test_recursive_call(self): # Testing recursive __call__() by setting to instance of class... class A(object): pass A.__call__ = A() try: A()() except (RecursionError, MemoryError): pass else: self.fail("Recursion limit should have been reached for __call__()") def test_delete_hook(self): # Testing __del__ hook... log = [] class C(object): def __del__(self): log.append(1) c = C() self.assertEqual(log, []) del c support.gc_collect() self.assertEqual(log, [1]) class D(object): pass d = D() try: del d[0] except TypeError: pass else: self.fail("invalid del() didn't raise TypeError") def test_hash_inheritance(self): # Testing hash of mutable subclasses... class mydict(dict): pass d = mydict() try: hash(d) except TypeError: pass else: self.fail("hash() of dict subclass should fail") class mylist(list): pass d = mylist() try: hash(d) except TypeError: pass else: self.fail("hash() of list subclass should fail") def test_str_operations(self): try: 'a' + 5 except TypeError: pass else: self.fail("'' + 5 doesn't raise TypeError") try: ''.split('') except ValueError: pass else: self.fail("''.split('') doesn't raise ValueError") try: ''.join([0]) except TypeError: pass else: self.fail("''.join([0]) doesn't raise TypeError") try: ''.rindex('5') except ValueError: pass else: self.fail("''.rindex('5') doesn't raise ValueError") try: '%(n)s' % None except TypeError: pass else: self.fail("'%(n)s' % None doesn't raise TypeError") try: '%(n' % {} except ValueError: pass else: self.fail("'%(n' % {} '' doesn't raise ValueError") try: '%*s' % ('abc') except TypeError: pass else: self.fail("'%*s' % ('abc') doesn't raise TypeError") try: '%*.*s' % ('abc', 5) except TypeError: pass else: self.fail("'%*.*s' % ('abc', 5) doesn't raise TypeError") try: '%s' % (1, 2) except TypeError: pass else: self.fail("'%s' % (1, 2) doesn't raise TypeError") try: '%' % None except ValueError: pass else: self.fail("'%' % None doesn't raise ValueError") self.assertEqual('534253'.isdigit(), 1) self.assertEqual('534253x'.isdigit(), 0) self.assertEqual('%c' % 5, '\x05') self.assertEqual('%c' % '5', '5') def test_deepcopy_recursive(self): # Testing deepcopy of recursive objects... class Node: pass a = Node() b = Node() a.b = b b.a = a z = deepcopy(a) # This blew up before def test_uninitialized_modules(self): # Testing uninitialized module objects... from types import ModuleType as M m = M.__new__(M) str(m) self.assertNotHasAttr(m, "__name__") self.assertNotHasAttr(m, "__file__") self.assertNotHasAttr(m, "foo") self.assertFalse(m.__dict__) # None or {} are both reasonable answers m.foo = 1 self.assertEqual(m.__dict__, {"foo": 1}) def test_funny_new(self): # Testing __new__ returning something unexpected... class C(object): def __new__(cls, arg): if isinstance(arg, str): return [1, 2, 3] elif isinstance(arg, int): return object.__new__(D) else: return object.__new__(cls) class D(C): def __init__(self, arg): self.foo = arg self.assertEqual(C("1"), [1, 2, 3]) self.assertEqual(D("1"), [1, 2, 3]) d = D(None) self.assertEqual(d.foo, None) d = C(1) self.assertIsInstance(d, D) self.assertEqual(d.foo, 1) d = D(1) self.assertIsInstance(d, D) self.assertEqual(d.foo, 1) class C(object): @staticmethod def __new__(*args): return args self.assertEqual(C(1, 2), (C, 1, 2)) class D(C): pass self.assertEqual(D(1, 2), (D, 1, 2)) class C(object): @classmethod def __new__(*args): return args self.assertEqual(C(1, 2), (C, C, 1, 2)) class D(C): pass self.assertEqual(D(1, 2), (D, D, 1, 2)) def test_imul_bug(self): # Testing for __imul__ problems... # SF bug 544647 class C(object): def __imul__(self, other): return (self, other) x = C() y = x y *= 1.0 self.assertEqual(y, (x, 1.0)) y = x y *= 2 self.assertEqual(y, (x, 2)) y = x y *= 3 self.assertEqual(y, (x, 3)) y = x y *= 1<<100 self.assertEqual(y, (x, 1<<100)) y = x y *= None self.assertEqual(y, (x, None)) y = x y *= "foo" self.assertEqual(y, (x, "foo")) def test_copy_setstate(self): # Testing that copy.*copy() correctly uses __setstate__... import copy class C(object): def __init__(self, foo=None): self.foo = foo self.__foo = foo def setfoo(self, foo=None): self.foo = foo def getfoo(self): return self.__foo def __getstate__(self): return [self.foo] def __setstate__(self_, lst): self.assertEqual(len(lst), 1) self_.__foo = self_.foo = lst[0] a = C(42) a.setfoo(24) self.assertEqual(a.foo, 24) self.assertEqual(a.getfoo(), 42) b = copy.copy(a) self.assertEqual(b.foo, 24) self.assertEqual(b.getfoo(), 24) b = copy.deepcopy(a) self.assertEqual(b.foo, 24) self.assertEqual(b.getfoo(), 24) def test_slices(self): # Testing cases with slices and overridden __getitem__ ... # Strings self.assertEqual("hello"[:4], "hell") self.assertEqual("hello"[slice(4)], "hell") self.assertEqual(str.__getitem__("hello", slice(4)), "hell") class S(str): def __getitem__(self, x): return str.__getitem__(self, x) self.assertEqual(S("hello")[:4], "hell") self.assertEqual(S("hello")[slice(4)], "hell") self.assertEqual(S("hello").__getitem__(slice(4)), "hell") # Tuples self.assertEqual((1,2,3)[:2], (1,2)) self.assertEqual((1,2,3)[slice(2)], (1,2)) self.assertEqual(tuple.__getitem__((1,2,3), slice(2)), (1,2)) class T(tuple): def __getitem__(self, x): return tuple.__getitem__(self, x) self.assertEqual(T((1,2,3))[:2], (1,2)) self.assertEqual(T((1,2,3))[slice(2)], (1,2)) self.assertEqual(T((1,2,3)).__getitem__(slice(2)), (1,2)) # Lists self.assertEqual([1,2,3][:2], [1,2]) self.assertEqual([1,2,3][slice(2)], [1,2]) self.assertEqual(list.__getitem__([1,2,3], slice(2)), [1,2]) class L(list): def __getitem__(self, x): return list.__getitem__(self, x) self.assertEqual(L([1,2,3])[:2], [1,2]) self.assertEqual(L([1,2,3])[slice(2)], [1,2]) self.assertEqual(L([1,2,3]).__getitem__(slice(2)), [1,2]) # Now do lists and __setitem__ a = L([1,2,3]) a[slice(1, 3)] = [3,2] self.assertEqual(a, [1,3,2]) a[slice(0, 2, 1)] = [3,1] self.assertEqual(a, [3,1,2]) a.__setitem__(slice(1, 3), [2,1]) self.assertEqual(a, [3,2,1]) a.__setitem__(slice(0, 2, 1), [2,3]) self.assertEqual(a, [2,3,1]) def test_subtype_resurrection(self): # Testing resurrection of new-style instance... class C(object): container = [] def __del__(self): # resurrect the instance C.container.append(self) c = C() c.attr = 42 # The most interesting thing here is whether this blows up, due to # flawed GC tracking logic in typeobject.c's call_finalizer() (a 2.2.1 # bug). del c support.gc_collect() self.assertEqual(len(C.container), 1) # Make c mortal again, so that the test framework with -l doesn't report # it as a leak. del C.__del__ def test_slots_trash(self): # Testing slot trash... # Deallocating deeply nested slotted trash caused stack overflows class trash(object): __slots__ = ['x'] def __init__(self, x): self.x = x o = None for i in range(50000): o = trash(o) del o def test_slots_multiple_inheritance(self): # SF bug 575229, multiple inheritance w/ slots dumps core class A(object): __slots__=() class B(object): pass class C(A,B) : __slots__=() if support.check_impl_detail(): self.assertEqual(C.__basicsize__, B.__basicsize__) self.assertHasAttr(C, '__dict__') self.assertHasAttr(C, '__weakref__') C().x = 2 def test_rmul(self): # Testing correct invocation of __rmul__... # SF patch 592646 class C(object): def __mul__(self, other): return "mul" def __rmul__(self, other): return "rmul" a = C() self.assertEqual(a*2, "mul") self.assertEqual(a*2.2, "mul") self.assertEqual(2*a, "rmul") self.assertEqual(2.2*a, "rmul") def test_ipow(self): # Testing correct invocation of __ipow__... # [SF bug 620179] class C(object): def __ipow__(self, other): pass a = C() a **= 2 def test_mutable_bases(self): # Testing mutable bases... # stuff that should work: class C(object): pass class C2(object): def __getattribute__(self, attr): if attr == 'a': return 2 else: return super(C2, self).__getattribute__(attr) def meth(self): return 1 class D(C): pass class E(D): pass d = D() e = E() D.__bases__ = (C,) D.__bases__ = (C2,) self.assertEqual(d.meth(), 1) self.assertEqual(e.meth(), 1) self.assertEqual(d.a, 2) self.assertEqual(e.a, 2) self.assertEqual(C2.__subclasses__(), [D]) try: del D.__bases__ except (TypeError, AttributeError): pass else: self.fail("shouldn't be able to delete .__bases__") try: D.__bases__ = () except TypeError as msg: if str(msg) == "a new-style class can't have only classic bases": self.fail("wrong error message for .__bases__ = ()") else: self.fail("shouldn't be able to set .__bases__ to ()") try: D.__bases__ = (D,) except TypeError: pass else: # actually, we'll have crashed by here... self.fail("shouldn't be able to create inheritance cycles") try: D.__bases__ = (C, C) except TypeError: pass else: self.fail("didn't detect repeated base classes") try: D.__bases__ = (E,) except TypeError: pass else: self.fail("shouldn't be able to create inheritance cycles") def test_builtin_bases(self): # Make sure all the builtin types can have their base queried without # segfaulting. See issue #5787. builtin_types = [tp for tp in builtins.__dict__.values() if isinstance(tp, type)] for tp in builtin_types: object.__getattribute__(tp, "__bases__") if tp is not object: self.assertEqual(len(tp.__bases__), 1, tp) class L(list): pass class C(object): pass class D(C): pass try: L.__bases__ = (dict,) except TypeError: pass else: self.fail("shouldn't turn list subclass into dict subclass") try: list.__bases__ = (dict,) except TypeError: pass else: self.fail("shouldn't be able to assign to list.__bases__") try: D.__bases__ = (C, list) except TypeError: pass else: assert 0, "best_base calculation found wanting" def test_unsubclassable_types(self): with self.assertRaises(TypeError): class X(type(None)): pass with self.assertRaises(TypeError): class X(object, type(None)): pass with self.assertRaises(TypeError): class X(type(None), object): pass class O(object): pass with self.assertRaises(TypeError): class X(O, type(None)): pass with self.assertRaises(TypeError): class X(type(None), O): pass class X(object): pass with self.assertRaises(TypeError): X.__bases__ = type(None), with self.assertRaises(TypeError): X.__bases__ = object, type(None) with self.assertRaises(TypeError): X.__bases__ = type(None), object with self.assertRaises(TypeError): X.__bases__ = O, type(None) with self.assertRaises(TypeError): X.__bases__ = type(None), O def test_mutable_bases_with_failing_mro(self): # Testing mutable bases with failing mro... class WorkOnce(type): def __new__(self, name, bases, ns): self.flag = 0 return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns) def mro(self): if self.flag > 0: raise RuntimeError("bozo") else: self.flag += 1 return type.mro(self) class WorkAlways(type): def mro(self): # this is here to make sure that .mro()s aren't called # with an exception set (which was possible at one point). # An error message will be printed in a debug build. # What's a good way to test for this? return type.mro(self) class C(object): pass class C2(object): pass class D(C): pass class E(D): pass class F(D, metaclass=WorkOnce): pass class G(D, metaclass=WorkAlways): pass # Immediate subclasses have their mro's adjusted in alphabetical # order, so E's will get adjusted before adjusting F's fails. We # check here that E's gets restored. E_mro_before = E.__mro__ D_mro_before = D.__mro__ try: D.__bases__ = (C2,) except RuntimeError: self.assertEqual(E.__mro__, E_mro_before) self.assertEqual(D.__mro__, D_mro_before) else: self.fail("exception not propagated") def test_mutable_bases_catch_mro_conflict(self): # Testing mutable bases catch mro conflict... class A(object): pass class B(object): pass class C(A, B): pass class D(A, B): pass class E(C, D): pass try: C.__bases__ = (B, A) except TypeError: pass else: self.fail("didn't catch MRO conflict") def test_mutable_names(self): # Testing mutable names... class C(object): pass # C.__module__ could be 'test_descr' or '__main__' mod = C.__module__ C.__name__ = 'D' self.assertEqual((C.__module__, C.__name__), (mod, 'D')) C.__name__ = 'D.E' self.assertEqual((C.__module__, C.__name__), (mod, 'D.E')) def test_evil_type_name(self): # A badly placed Py_DECREF in type_set_name led to arbitrary code # execution while the type structure was not in a sane state, and a # possible segmentation fault as a result. See bug #16447. class Nasty(str): def __del__(self): C.__name__ = "other" class C: pass C.__name__ = Nasty("abc") C.__name__ = "normal" def test_subclass_right_op(self): # Testing correct dispatch of subclass overloading __r<op>__... # This code tests various cases where right-dispatch of a subclass # should be preferred over left-dispatch of a base class. # Case 1: subclass of int; this tests code in abstract.c::binary_op1() class B(int): def __floordiv__(self, other): return "B.__floordiv__" def __rfloordiv__(self, other): return "B.__rfloordiv__" self.assertEqual(B(1) // 1, "B.__floordiv__") self.assertEqual(1 // B(1), "B.__rfloordiv__") # Case 2: subclass of object; this is just the baseline for case 3 class C(object): def __floordiv__(self, other): return "C.__floordiv__" def __rfloordiv__(self, other): return "C.__rfloordiv__" self.assertEqual(C() // 1, "C.__floordiv__") self.assertEqual(1 // C(), "C.__rfloordiv__") # Case 3: subclass of new-style class; here it gets interesting class D(C): def __floordiv__(self, other): return "D.__floordiv__" def __rfloordiv__(self, other): return "D.__rfloordiv__" self.assertEqual(D() // C(), "D.__floordiv__") self.assertEqual(C() // D(), "D.__rfloordiv__") # Case 4: this didn't work right in 2.2.2 and 2.3a1 class E(C): pass self.assertEqual(E.__rfloordiv__, C.__rfloordiv__) self.assertEqual(E() // 1, "C.__floordiv__") self.assertEqual(1 // E(), "C.__rfloordiv__") self.assertEqual(E() // C(), "C.__floordiv__") self.assertEqual(C() // E(), "C.__floordiv__") # This one would fail @support.impl_detail("testing an internal kind of method object") def test_meth_class_get(self): # Testing __get__ method of METH_CLASS C methods... # Full coverage of descrobject.c::classmethod_get() # Baseline arg = [1, 2, 3] res = {1: None, 2: None, 3: None} self.assertEqual(dict.fromkeys(arg), res) self.assertEqual({}.fromkeys(arg), res) # Now get the descriptor descr = dict.__dict__["fromkeys"] # More baseline using the descriptor directly self.assertEqual(descr.__get__(None, dict)(arg), res) self.assertEqual(descr.__get__({})(arg), res) # Now check various error cases try: descr.__get__(None, None) except TypeError: pass else: self.fail("shouldn't have allowed descr.__get__(None, None)") try: descr.__get__(42) except TypeError: pass else: self.fail("shouldn't have allowed descr.__get__(42)") try: descr.__get__(None, 42) except TypeError: pass else: self.fail("shouldn't have allowed descr.__get__(None, 42)") try: descr.__get__(None, int) except TypeError: pass else: self.fail("shouldn't have allowed descr.__get__(None, int)") def test_isinst_isclass(self): # Testing proxy isinstance() and isclass()... class Proxy(object): def __init__(self, obj): self.__obj = obj def __getattribute__(self, name): if name.startswith("_Proxy__"): return object.__getattribute__(self, name) else: return getattr(self.__obj, name) # Test with a classic class class C: pass a = C() pa = Proxy(a) self.assertIsInstance(a, C) # Baseline self.assertIsInstance(pa, C) # Test # Test with a classic subclass class D(C): pass a = D() pa = Proxy(a) self.assertIsInstance(a, C) # Baseline self.assertIsInstance(pa, C) # Test # Test with a new-style class class C(object): pass a = C() pa = Proxy(a) self.assertIsInstance(a, C) # Baseline self.assertIsInstance(pa, C) # Test # Test with a new-style subclass class D(C): pass a = D() pa = Proxy(a) self.assertIsInstance(a, C) # Baseline self.assertIsInstance(pa, C) # Test def test_proxy_super(self): # Testing super() for a proxy object... class Proxy(object): def __init__(self, obj): self.__obj = obj def __getattribute__(self, name): if name.startswith("_Proxy__"): return object.__getattribute__(self, name) else: return getattr(self.__obj, name) class B(object): def f(self): return "B.f" class C(B): def f(self): return super(C, self).f() + "->C.f" obj = C() p = Proxy(obj) self.assertEqual(C.__dict__["f"](p), "B.f->C.f") def test_carloverre(self): # Testing prohibition of Carlo Verre's hack... try: object.__setattr__(str, "foo", 42) except TypeError: pass else: self.fail("Carlo Verre __setattr__ succeeded!") try: object.__delattr__(str, "lower") except TypeError: pass else: self.fail("Carlo Verre __delattr__ succeeded!") def test_weakref_segfault(self): # Testing weakref segfault... # SF 742911 import weakref class Provoker: def __init__(self, referrent): self.ref = weakref.ref(referrent) def __del__(self): x = self.ref() class Oops(object): pass o = Oops() o.whatever = Provoker(o) del o def test_wrapper_segfault(self): # SF 927248: deeply nested wrappers could cause stack overflow f = lambda:None for i in range(1000000): f = f.__call__ f = None def test_file_fault(self): # Testing sys.stdout is changed in getattr... test_stdout = sys.stdout class StdoutGuard: def __getattr__(self, attr): sys.stdout = sys.__stdout__ raise RuntimeError("Premature access to sys.stdout.%s" % attr) sys.stdout = StdoutGuard() try: print("Oops!") except RuntimeError: pass finally: sys.stdout = test_stdout def test_vicious_descriptor_nonsense(self): # Testing vicious_descriptor_nonsense... # A potential segfault spotted by Thomas Wouters in mail to # python-dev 2003-04-17, turned into an example & fixed by Michael # Hudson just less than four months later... class Evil(object): def __hash__(self): return hash('attr') def __eq__(self, other): del C.attr return 0 class Descr(object): def __get__(self, ob, type=None): return 1 class C(object): attr = Descr() c = C() c.__dict__[Evil()] = 0 self.assertEqual(c.attr, 1) # this makes a crash more likely: support.gc_collect() self.assertNotHasAttr(c, 'attr') def test_init(self): # SF 1155938 class Foo(object): def __init__(self): return 10 try: Foo() except TypeError: pass else: self.fail("did not test __init__() for None return") def test_method_wrapper(self): # Testing method-wrapper objects... # <type 'method-wrapper'> did not support any reflection before 2.5 # XXX should methods really support __eq__? l = [] self.assertEqual(l.__add__, l.__add__) self.assertEqual(l.__add__, [].__add__) self.assertNotEqual(l.__add__, [5].__add__) self.assertNotEqual(l.__add__, l.__mul__) self.assertEqual(l.__add__.__name__, '__add__') if hasattr(l.__add__, '__self__'): # CPython self.assertIs(l.__add__.__self__, l) self.assertIs(l.__add__.__objclass__, list) else: # Python implementations where [].__add__ is a normal bound method self.assertIs(l.__add__.im_self, l) self.assertIs(l.__add__.im_class, list) self.assertEqual(l.__add__.__doc__, list.__add__.__doc__) try: hash(l.__add__) except TypeError: pass else: self.fail("no TypeError from hash([].__add__)") t = () t += (7,) self.assertEqual(t.__add__, (7,).__add__) self.assertEqual(hash(t.__add__), hash((7,).__add__)) def test_not_implemented(self): # Testing NotImplemented... # all binary methods should be able to return a NotImplemented import operator def specialmethod(self, other): return NotImplemented def check(expr, x, y): try: exec(expr, {'x': x, 'y': y, 'operator': operator}) except TypeError: pass else: self.fail("no TypeError from %r" % (expr,)) N1 = sys.maxsize + 1 # might trigger OverflowErrors instead of # TypeErrors N2 = sys.maxsize # if sizeof(int) < sizeof(long), might trigger # ValueErrors instead of TypeErrors for name, expr, iexpr in [ ('__add__', 'x + y', 'x += y'), ('__sub__', 'x - y', 'x -= y'), ('__mul__', 'x * y', 'x *= y'), ('__matmul__', 'x @ y', 'x @= y'), ('__truediv__', 'x / y', 'x /= y'), ('__floordiv__', 'x // y', 'x //= y'), ('__mod__', 'x % y', 'x %= y'), ('__divmod__', 'divmod(x, y)', None), ('__pow__', 'x ** y', 'x **= y'), ('__lshift__', 'x << y', 'x <<= y'), ('__rshift__', 'x >> y', 'x >>= y'), ('__and__', 'x & y', 'x &= y'), ('__or__', 'x | y', 'x |= y'), ('__xor__', 'x ^ y', 'x ^= y')]: rname = '__r' + name[2:] A = type('A', (), {name: specialmethod}) a = A() check(expr, a, a) check(expr, a, N1) check(expr, a, N2) if iexpr: check(iexpr, a, a) check(iexpr, a, N1) check(iexpr, a, N2) iname = '__i' + name[2:] C = type('C', (), {iname: specialmethod}) c = C() check(iexpr, c, a) check(iexpr, c, N1) check(iexpr, c, N2) def test_assign_slice(self): # ceval.c's assign_slice used to check for # tp->tp_as_sequence->sq_slice instead of # tp->tp_as_sequence->sq_ass_slice class C(object): def __setitem__(self, idx, value): self.value = value c = C() c[1:2] = 3 self.assertEqual(c.value, 3) def test_set_and_no_get(self): # See # http://mail.python.org/pipermail/python-dev/2010-January/095637.html class Descr(object): def __init__(self, name): self.name = name def __set__(self, obj, value): obj.__dict__[self.name] = value descr = Descr("a") class X(object): a = descr x = X() self.assertIs(x.a, descr) x.a = 42 self.assertEqual(x.a, 42) # Also check type_getattro for correctness. class Meta(type): pass class X(metaclass=Meta): pass X.a = 42 Meta.a = Descr("a") self.assertEqual(X.a, 42) def test_getattr_hooks(self): # issue 4230 class Descriptor(object): counter = 0 def __get__(self, obj, objtype=None): def getter(name): self.counter += 1 raise AttributeError(name) return getter descr = Descriptor() class A(object): __getattribute__ = descr class B(object): __getattr__ = descr class C(object): __getattribute__ = descr __getattr__ = descr self.assertRaises(AttributeError, getattr, A(), "attr") self.assertEqual(descr.counter, 1) self.assertRaises(AttributeError, getattr, B(), "attr") self.assertEqual(descr.counter, 2) self.assertRaises(AttributeError, getattr, C(), "attr") self.assertEqual(descr.counter, 4) class EvilGetattribute(object): # This used to segfault def __getattr__(self, name): raise AttributeError(name) def __getattribute__(self, name): del EvilGetattribute.__getattr__ for i in range(5): gc.collect() raise AttributeError(name) self.assertRaises(AttributeError, getattr, EvilGetattribute(), "attr") def test_type___getattribute__(self): self.assertRaises(TypeError, type.__getattribute__, list, type) def test_abstractmethods(self): # type pretends not to have __abstractmethods__. self.assertRaises(AttributeError, getattr, type, "__abstractmethods__") class meta(type): pass self.assertRaises(AttributeError, getattr, meta, "__abstractmethods__") class X(object): pass with self.assertRaises(AttributeError): del X.__abstractmethods__ def test_proxy_call(self): class FakeStr: __class__ = str fake_str = FakeStr() # isinstance() reads __class__ self.assertIsInstance(fake_str, str) # call a method descriptor with self.assertRaises(TypeError): str.split(fake_str) # call a slot wrapper descriptor with self.assertRaises(TypeError): str.__add__(fake_str, "abc") def test_repr_as_str(self): # Issue #11603: crash or infinite loop when rebinding __str__ as # __repr__. class Foo: pass Foo.__repr__ = Foo.__str__ foo = Foo() if cosmo.MODE == 'dbg': self.assertRaises(RecursionError, str, foo) self.assertRaises(RecursionError, repr, foo) else: self.assertRaises(MemoryError, str, foo) self.assertRaises(MemoryError, repr, foo) def test_mixing_slot_wrappers(self): class X(dict): __setattr__ = dict.__setitem__ x = X() x.y = 42 self.assertEqual(x["y"], 42) def test_slot_shadows_class_variable(self): with self.assertRaises(ValueError) as cm: class X: __slots__ = ["foo"] foo = None m = str(cm.exception) self.assertEqual("'foo' in __slots__ conflicts with class variable", m) def test_set_doc(self): class X: "elephant" X.__doc__ = "banana" self.assertEqual(X.__doc__, "banana") with self.assertRaises(TypeError) as cm: type(list).__dict__["__doc__"].__set__(list, "blah") self.assertIn("can't set list.__doc__", str(cm.exception)) with self.assertRaises(TypeError) as cm: type(X).__dict__["__doc__"].__delete__(X) self.assertIn("can't delete X.__doc__", str(cm.exception)) self.assertEqual(X.__doc__, "banana") def test_qualname(self): descriptors = [str.lower, complex.real, float.real, int.__add__] types = ['method', 'member', 'getset', 'wrapper'] # make sure we have an example of each type of descriptor for d, n in zip(descriptors, types): self.assertEqual(type(d).__name__, n + '_descriptor') for d in descriptors: qualname = d.__objclass__.__qualname__ + '.' + d.__name__ self.assertEqual(d.__qualname__, qualname) self.assertEqual(str.lower.__qualname__, 'str.lower') self.assertEqual(complex.real.__qualname__, 'complex.real') self.assertEqual(float.real.__qualname__, 'float.real') self.assertEqual(int.__add__.__qualname__, 'int.__add__') class X: pass with self.assertRaises(TypeError): del X.__qualname__ self.assertRaises(TypeError, type.__dict__['__qualname__'].__set__, str, 'Oink') global Y class Y: class Inside: pass self.assertEqual(Y.__qualname__, 'Y') self.assertEqual(Y.Inside.__qualname__, 'Y.Inside') def test_qualname_dict(self): ns = {'__qualname__': 'some.name'} tp = type('Foo', (), ns) self.assertEqual(tp.__qualname__, 'some.name') self.assertNotIn('__qualname__', tp.__dict__) self.assertEqual(ns, {'__qualname__': 'some.name'}) ns = {'__qualname__': 1} self.assertRaises(TypeError, type, 'Foo', (), ns) def test_cycle_through_dict(self): # See bug #1469629 class X(dict): def __init__(self): dict.__init__(self) self.__dict__ = self x = X() x.attr = 42 wr = weakref.ref(x) del x support.gc_collect() self.assertIsNone(wr()) for o in gc.get_objects(): self.assertIsNot(type(o), X) def test_object_new_and_init_with_parameters(self): # See issue #1683368 class OverrideNeither: pass self.assertRaises(TypeError, OverrideNeither, 1) self.assertRaises(TypeError, OverrideNeither, kw=1) class OverrideNew: def __new__(cls, foo, kw=0, *args, **kwds): return object.__new__(cls, *args, **kwds) class OverrideInit: def __init__(self, foo, kw=0, *args, **kwargs): return object.__init__(self, *args, **kwargs) class OverrideBoth(OverrideNew, OverrideInit): pass for case in OverrideNew, OverrideInit, OverrideBoth: case(1) case(1, kw=2) self.assertRaises(TypeError, case, 1, 2, 3) self.assertRaises(TypeError, case, 1, 2, foo=3) def test_subclassing_does_not_duplicate_dict_descriptors(self): class Base: pass class Sub(Base): pass self.assertIn("__dict__", Base.__dict__) self.assertNotIn("__dict__", Sub.__dict__) def test_bound_method_repr(self): class Foo: def method(self): pass self.assertRegex(repr(Foo().method), r"<bound method .*Foo\.method of <.*Foo object at .*>>") class Base: def method(self): pass class Derived1(Base): pass class Derived2(Base): def method(self): pass base = Base() derived1 = Derived1() derived2 = Derived2() super_d2 = super(Derived2, derived2) self.assertRegex(repr(base.method), r"<bound method .*Base\.method of <.*Base object at .*>>") self.assertRegex(repr(derived1.method), r"<bound method .*Base\.method of <.*Derived1 object at .*>>") self.assertRegex(repr(derived2.method), r"<bound method .*Derived2\.method of <.*Derived2 object at .*>>") self.assertRegex(repr(super_d2.method), r"<bound method .*Base\.method of <.*Derived2 object at .*>>") class Foo: @classmethod def method(cls): pass foo = Foo() self.assertRegex(repr(foo.method), # access via instance r"<bound method .*Foo\.method of <class '.*Foo'>>") self.assertRegex(repr(Foo.method), # access via the class r"<bound method .*Foo\.method of <class '.*Foo'>>") class MyCallable: def __call__(self, arg): pass func = MyCallable() # func has no __name__ or __qualname__ attributes instance = object() method = types.MethodType(func, instance) self.assertRegex(repr(method), r"<bound method \? of <object object at .*>>") func.__name__ = "name" self.assertRegex(repr(method), r"<bound method name of <object object at .*>>") func.__qualname__ = "qualname" self.assertRegex(repr(method), r"<bound method qualname of <object object at .*>>") class DictProxyTests(unittest.TestCase): def setUp(self): class C(object): def meth(self): pass self.C = C @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __local__') def test_iter_keys(self): # Testing dict-proxy keys... it = self.C.__dict__.keys() self.assertNotIsInstance(it, list) keys = list(it) keys.sort() self.assertEqual(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth']) @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __local__') def test_iter_values(self): # Testing dict-proxy values... it = self.C.__dict__.values() self.assertNotIsInstance(it, list) values = list(it) self.assertEqual(len(values), 5) @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __local__') def test_iter_items(self): # Testing dict-proxy iteritems... it = self.C.__dict__.items() self.assertNotIsInstance(it, list) keys = [item[0] for item in it] keys.sort() self.assertEqual(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth']) def test_dict_type_with_metaclass(self): # Testing type of __dict__ when metaclass set... class B(object): pass class M(type): pass class C(metaclass=M): # In 2.3a1, C.__dict__ was a real dict rather than a dict proxy pass self.assertEqual(type(C.__dict__), type(B.__dict__)) def test_repr(self): # Testing mappingproxy.__repr__. # We can't blindly compare with the repr of another dict as ordering # of keys and values is arbitrary and may differ. r = repr(self.C.__dict__) self.assertTrue(r.startswith('mappingproxy('), r) self.assertTrue(r.endswith(')'), r) for k, v in self.C.__dict__.items(): self.assertIn('{!r}: {!r}'.format(k, v), r) class PTypesLongInitTest(unittest.TestCase): # This is in its own TestCase so that it can be run before any other tests. def test_pytype_long_ready(self): # Testing SF bug 551412 ... # This dumps core when SF bug 551412 isn't fixed -- # but only when test_descr.py is run separately. # (That can't be helped -- as soon as PyType_Ready() # is called for PyLong_Type, the bug is gone.) class UserLong(object): def __pow__(self, *args): pass try: pow(0, UserLong(), 0) except: pass # Another segfault only when run early # (before PyType_Ready(tuple) is called) type.mro(tuple) class MiscTests(unittest.TestCase): def test_type_lookup_mro_reference(self): # Issue #14199: _PyType_Lookup() has to keep a strong reference to # the type MRO because it may be modified during the lookup, if # __bases__ is set during the lookup for example. class MyKey(object): def __hash__(self): return hash('mykey') def __eq__(self, other): X.__bases__ = (Base2,) class Base(object): mykey = 'from Base' mykey2 = 'from Base' class Base2(object): mykey = 'from Base2' mykey2 = 'from Base2' X = type('X', (Base,), {MyKey(): 5}) # mykey is read from Base self.assertEqual(X.mykey, 'from Base') # mykey2 is read from Base2 because MyKey.__eq__ has set __bases__ self.assertEqual(X.mykey2, 'from Base2') class PicklingTests(unittest.TestCase): def _check_reduce(self, proto, obj, args=(), kwargs={}, state=None, listitems=None, dictitems=None): if proto >= 2: reduce_value = obj.__reduce_ex__(proto) if kwargs: self.assertEqual(reduce_value[0], copyreg.__newobj_ex__) self.assertEqual(reduce_value[1], (type(obj), args, kwargs)) else: self.assertEqual(reduce_value[0], copyreg.__newobj__) self.assertEqual(reduce_value[1], (type(obj),) + args) self.assertEqual(reduce_value[2], state) if listitems is not None: self.assertListEqual(list(reduce_value[3]), listitems) else: self.assertIsNone(reduce_value[3]) if dictitems is not None: self.assertDictEqual(dict(reduce_value[4]), dictitems) else: self.assertIsNone(reduce_value[4]) else: base_type = type(obj).__base__ reduce_value = (copyreg._reconstructor, (type(obj), base_type, None if base_type is object else base_type(obj))) if state is not None: reduce_value += (state,) self.assertEqual(obj.__reduce_ex__(proto), reduce_value) self.assertEqual(obj.__reduce__(), reduce_value) def test_reduce(self): protocols = range(pickle.HIGHEST_PROTOCOL + 1) args = (-101, "spam") kwargs = {'bacon': -201, 'fish': -301} state = {'cheese': -401} class C1: def __getnewargs__(self): return args obj = C1() for proto in protocols: self._check_reduce(proto, obj, args) for name, value in state.items(): setattr(obj, name, value) for proto in protocols: self._check_reduce(proto, obj, args, state=state) class C2: def __getnewargs__(self): return "bad args" obj = C2() for proto in protocols: if proto >= 2: with self.assertRaises(TypeError): obj.__reduce_ex__(proto) class C3: def __getnewargs_ex__(self): return (args, kwargs) obj = C3() for proto in protocols: if proto >= 2: self._check_reduce(proto, obj, args, kwargs) class C4: def __getnewargs_ex__(self): return (args, "bad dict") class C5: def __getnewargs_ex__(self): return ("bad tuple", kwargs) class C6: def __getnewargs_ex__(self): return () class C7: def __getnewargs_ex__(self): return "bad args" for proto in protocols: for cls in C4, C5, C6, C7: obj = cls() if proto >= 2: with self.assertRaises((TypeError, ValueError)): obj.__reduce_ex__(proto) class C9: def __getnewargs_ex__(self): return (args, {}) obj = C9() for proto in protocols: self._check_reduce(proto, obj, args) class C10: def __getnewargs_ex__(self): raise IndexError obj = C10() for proto in protocols: if proto >= 2: with self.assertRaises(IndexError): obj.__reduce_ex__(proto) class C11: def __getstate__(self): return state obj = C11() for proto in protocols: self._check_reduce(proto, obj, state=state) class C12: def __getstate__(self): return "not dict" obj = C12() for proto in protocols: self._check_reduce(proto, obj, state="not dict") class C13: def __getstate__(self): raise IndexError obj = C13() for proto in protocols: with self.assertRaises(IndexError): obj.__reduce_ex__(proto) if proto < 2: with self.assertRaises(IndexError): obj.__reduce__() class C14: __slots__ = tuple(state) def __init__(self): for name, value in state.items(): setattr(self, name, value) obj = C14() for proto in protocols: if proto >= 2: self._check_reduce(proto, obj, state=(None, state)) else: with self.assertRaises(TypeError): obj.__reduce_ex__(proto) with self.assertRaises(TypeError): obj.__reduce__() class C15(dict): pass obj = C15({"quebec": -601}) for proto in protocols: self._check_reduce(proto, obj, dictitems=dict(obj)) class C16(list): pass obj = C16(["yukon"]) for proto in protocols: self._check_reduce(proto, obj, listitems=list(obj)) def test_special_method_lookup(self): protocols = range(pickle.HIGHEST_PROTOCOL + 1) class Picky: def __getstate__(self): return {} def __getattr__(self, attr): if attr in ("__getnewargs__", "__getnewargs_ex__"): raise AssertionError(attr) return None for protocol in protocols: state = {} if protocol >= 2 else None self._check_reduce(protocol, Picky(), state=state) def _assert_is_copy(self, obj, objcopy, msg=None): """Utility method to verify if two objects are copies of each others. """ if msg is None: msg = "{!r} is not a copy of {!r}".format(obj, objcopy) if type(obj).__repr__ is object.__repr__: # We have this limitation for now because we use the object's repr # to help us verify that the two objects are copies. This allows # us to delegate the non-generic verification logic to the objects # themselves. raise ValueError("object passed to _assert_is_copy must " + "override the __repr__ method.") self.assertIsNot(obj, objcopy, msg=msg) self.assertIs(type(obj), type(objcopy), msg=msg) if hasattr(obj, '__dict__'): self.assertDictEqual(obj.__dict__, objcopy.__dict__, msg=msg) self.assertIsNot(obj.__dict__, objcopy.__dict__, msg=msg) if hasattr(obj, '__slots__'): self.assertListEqual(obj.__slots__, objcopy.__slots__, msg=msg) for slot in obj.__slots__: self.assertEqual( hasattr(obj, slot), hasattr(objcopy, slot), msg=msg) self.assertEqual(getattr(obj, slot, None), getattr(objcopy, slot, None), msg=msg) self.assertEqual(repr(obj), repr(objcopy), msg=msg) @staticmethod def _generate_pickle_copiers(): """Utility method to generate the many possible pickle configurations. """ class PickleCopier: "This class copies object using pickle." def __init__(self, proto, dumps, loads): self.proto = proto self.dumps = dumps self.loads = loads def copy(self, obj): return self.loads(self.dumps(obj, self.proto)) def __repr__(self): # We try to be as descriptive as possible here since this is # the string which we will allow us to tell the pickle # configuration we are using during debugging. return ("PickleCopier(proto={}, dumps={}.{}, loads={}.{})" .format(self.proto, self.dumps.__module__, self.dumps.__qualname__, self.loads.__module__, self.loads.__qualname__)) return (PickleCopier(*args) for args in itertools.product(range(pickle.HIGHEST_PROTOCOL + 1), {pickle.dumps, pickle._dumps}, {pickle.loads, pickle._loads})) def test_pickle_slots(self): # Tests pickling of classes with __slots__. # Pickling of classes with __slots__ but without __getstate__ should # fail (if using protocol 0 or 1) global C class C: __slots__ = ['a'] with self.assertRaises(TypeError): pickle.dumps(C(), 0) global D class D(C): pass with self.assertRaises(TypeError): pickle.dumps(D(), 0) class C: "A class with __getstate__ and __setstate__ implemented." __slots__ = ['a'] def __getstate__(self): state = getattr(self, '__dict__', {}).copy() for cls in type(self).__mro__: for slot in cls.__dict__.get('__slots__', ()): try: state[slot] = getattr(self, slot) except AttributeError: pass return state def __setstate__(self, state): for k, v in state.items(): setattr(self, k, v) def __repr__(self): return "%s()<%r>" % (type(self).__name__, self.__getstate__()) class D(C): "A subclass of a class with slots." pass global E class E(C): "A subclass with an extra slot." __slots__ = ['b'] # Now it should work for pickle_copier in self._generate_pickle_copiers(): with self.subTest(pickle_copier=pickle_copier): x = C() y = pickle_copier.copy(x) self._assert_is_copy(x, y) x.a = 42 y = pickle_copier.copy(x) self._assert_is_copy(x, y) x = D() x.a = 42 x.b = 100 y = pickle_copier.copy(x) self._assert_is_copy(x, y) x = E() x.a = 42 x.b = "foo" y = pickle_copier.copy(x) self._assert_is_copy(x, y) def test_reduce_copying(self): # Tests pickling and copying new-style classes and objects. global C1 class C1: "The state of this class is copyable via its instance dict." ARGS = (1, 2) NEED_DICT_COPYING = True def __init__(self, a, b): super().__init__() self.a = a self.b = b def __repr__(self): return "C1(%r, %r)" % (self.a, self.b) global C2 class C2(list): "A list subclass copyable via __getnewargs__." ARGS = (1, 2) NEED_DICT_COPYING = False def __new__(cls, a, b): self = super().__new__(cls) self.a = a self.b = b return self def __init__(self, *args): super().__init__() # This helps testing that __init__ is not called during the # unpickling process, which would cause extra appends. self.append("cheese") @classmethod def __getnewargs__(cls): return cls.ARGS def __repr__(self): return "C2(%r, %r)<%r>" % (self.a, self.b, list(self)) global C3 class C3(list): "A list subclass copyable via __getstate__." ARGS = (1, 2) NEED_DICT_COPYING = False def __init__(self, a, b): self.a = a self.b = b # This helps testing that __init__ is not called during the # unpickling process, which would cause extra appends. self.append("cheese") @classmethod def __getstate__(cls): return cls.ARGS def __setstate__(self, state): a, b = state self.a = a self.b = b def __repr__(self): return "C3(%r, %r)<%r>" % (self.a, self.b, list(self)) global C4 class C4(int): "An int subclass copyable via __getnewargs__." ARGS = ("hello", "world", 1) NEED_DICT_COPYING = False def __new__(cls, a, b, value): self = super().__new__(cls, value) self.a = a self.b = b return self @classmethod def __getnewargs__(cls): return cls.ARGS def __repr__(self): return "C4(%r, %r)<%r>" % (self.a, self.b, int(self)) global C5 class C5(int): "An int subclass copyable via __getnewargs_ex__." ARGS = (1, 2) KWARGS = {'value': 3} NEED_DICT_COPYING = False def __new__(cls, a, b, *, value=0): self = super().__new__(cls, value) self.a = a self.b = b return self @classmethod def __getnewargs_ex__(cls): return (cls.ARGS, cls.KWARGS) def __repr__(self): return "C5(%r, %r)<%r>" % (self.a, self.b, int(self)) test_classes = (C1, C2, C3, C4, C5) # Testing copying through pickle pickle_copiers = self._generate_pickle_copiers() for cls, pickle_copier in itertools.product(test_classes, pickle_copiers): with self.subTest(cls=cls, pickle_copier=pickle_copier): kwargs = getattr(cls, 'KWARGS', {}) obj = cls(*cls.ARGS, **kwargs) proto = pickle_copier.proto objcopy = pickle_copier.copy(obj) self._assert_is_copy(obj, objcopy) # For test classes that supports this, make sure we didn't go # around the reduce protocol by simply copying the attribute # dictionary. We clear attributes using the previous copy to # not mutate the original argument. if proto >= 2 and not cls.NEED_DICT_COPYING: objcopy.__dict__.clear() objcopy2 = pickle_copier.copy(objcopy) self._assert_is_copy(obj, objcopy2) # Testing copying through copy.deepcopy() for cls in test_classes: with self.subTest(cls=cls): kwargs = getattr(cls, 'KWARGS', {}) obj = cls(*cls.ARGS, **kwargs) objcopy = deepcopy(obj) self._assert_is_copy(obj, objcopy) # For test classes that supports this, make sure we didn't go # around the reduce protocol by simply copying the attribute # dictionary. We clear attributes using the previous copy to # not mutate the original argument. if not cls.NEED_DICT_COPYING: objcopy.__dict__.clear() objcopy2 = deepcopy(objcopy) self._assert_is_copy(obj, objcopy2) def test_issue24097(self): # Slot name is freed inside __getattr__ and is later used. class S(str): # Not interned pass class A: __slotnames__ = [S('spam')] def __getattr__(self, attr): if attr == 'spam': A.__slotnames__[:] = [S('spam')] return 42 else: raise AttributeError import copyreg expected = (copyreg.__newobj__, (A,), (None, {'spam': 42}), None, None) self.assertEqual(A().__reduce__(2), expected) # Shouldn't crash class SharedKeyTests(unittest.TestCase): @support.cpython_only def test_subclasses(self): # Verify that subclasses can share keys (per PEP 412) class A: pass class B(A): pass a, b = A(), B() self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b))) self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({})) # Initial hash table can contain at most 5 elements. # Set 6 attributes to cause internal resizing. a.x, a.y, a.z, a.w, a.v, a.u = range(6) self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b))) a2 = A() self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2))) self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({})) b.u, b.v, b.w, b.t, b.s, b.r = range(6) self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({})) class DebugHelperMeta(type): """ Sets default __doc__ and simplifies repr() output. """ def __new__(mcls, name, bases, attrs): if attrs.get('__doc__') is None: attrs['__doc__'] = name # helps when debugging with gdb return type.__new__(mcls, name, bases, attrs) def __repr__(cls): return repr(cls.__name__) class MroTest(unittest.TestCase): """ Regressions for some bugs revealed through mcsl.mro() customization (typeobject.c: mro_internal()) and cls.__bases__ assignment (typeobject.c: type_set_bases()). """ def setUp(self): self.step = 0 self.ready = False def step_until(self, limit): ret = (self.step < limit) if ret: self.step += 1 return ret def test_incomplete_set_bases_on_self(self): """ type_set_bases must be aware that type->tp_mro can be NULL. """ class M(DebugHelperMeta): def mro(cls): if self.step_until(1): assert cls.__mro__ is None cls.__bases__ += () return type.mro(cls) class A(metaclass=M): pass def test_reent_set_bases_on_base(self): """ Deep reentrancy must not over-decref old_mro. """ class M(DebugHelperMeta): def mro(cls): if cls.__mro__ is not None and cls.__name__ == 'B': # 4-5 steps are usually enough to make it crash somewhere if self.step_until(10): A.__bases__ += () return type.mro(cls) class A(metaclass=M): pass class B(A): pass B.__bases__ += () def test_reent_set_bases_on_direct_base(self): """ Similar to test_reent_set_bases_on_base, but may crash differently. """ class M(DebugHelperMeta): def mro(cls): base = cls.__bases__[0] if base is not object: if self.step_until(5): base.__bases__ += () return type.mro(cls) class A(metaclass=M): pass class B(A): pass class C(B): pass def test_reent_set_bases_tp_base_cycle(self): """ type_set_bases must check for an inheritance cycle not only through MRO of the type, which may be not yet updated in case of reentrance, but also through tp_base chain, which is assigned before diving into inner calls to mro(). Otherwise, the following snippet can loop forever: do { // ... type = type->tp_base; } while (type != NULL); Functions that rely on tp_base (like solid_base and PyType_IsSubtype) would not be happy in that case, causing a stack overflow. """ class M(DebugHelperMeta): def mro(cls): if self.ready: if cls.__name__ == 'B1': B2.__bases__ = (B1,) if cls.__name__ == 'B2': B1.__bases__ = (B2,) return type.mro(cls) class A(metaclass=M): pass class B1(A): pass class B2(A): pass self.ready = True with self.assertRaises(TypeError): B1.__bases__ += () def test_tp_subclasses_cycle_in_update_slots(self): """ type_set_bases must check for reentrancy upon finishing its job by updating tp_subclasses of old/new bases of the type. Otherwise, an implicit inheritance cycle through tp_subclasses can break functions that recurse on elements of that field (like recurse_down_subclasses and mro_hierarchy) eventually leading to a stack overflow. """ class M(DebugHelperMeta): def mro(cls): if self.ready and cls.__name__ == 'C': self.ready = False C.__bases__ = (B2,) return type.mro(cls) class A(metaclass=M): pass class B1(A): pass class B2(A): pass class C(A): pass self.ready = True C.__bases__ = (B1,) B1.__bases__ = (C,) self.assertEqual(C.__bases__, (B2,)) self.assertEqual(B2.__subclasses__(), [C]) self.assertEqual(B1.__subclasses__(), []) self.assertEqual(B1.__bases__, (C,)) self.assertEqual(C.__subclasses__(), [B1]) def test_tp_subclasses_cycle_error_return_path(self): """ The same as test_tp_subclasses_cycle_in_update_slots, but tests a code path executed on error (goto bail). """ class E(Exception): pass class M(DebugHelperMeta): def mro(cls): if self.ready and cls.__name__ == 'C': if C.__bases__ == (B2,): self.ready = False else: C.__bases__ = (B2,) raise E return type.mro(cls) class A(metaclass=M): pass class B1(A): pass class B2(A): pass class C(A): pass self.ready = True with self.assertRaises(E): C.__bases__ = (B1,) B1.__bases__ = (C,) self.assertEqual(C.__bases__, (B2,)) self.assertEqual(C.__mro__, tuple(type.mro(C))) def test_incomplete_extend(self): """ Extending an unitialized type with type->tp_mro == NULL must throw a reasonable TypeError exception, instead of failing with PyErr_BadInternalCall. """ class M(DebugHelperMeta): def mro(cls): if cls.__mro__ is None and cls.__name__ != 'X': with self.assertRaises(TypeError): class X(cls): pass return type.mro(cls) class A(metaclass=M): pass def test_incomplete_super(self): """ Attrubute lookup on a super object must be aware that its target type can be uninitialized (type->tp_mro == NULL). """ class M(DebugHelperMeta): def mro(cls): if cls.__mro__ is None: with self.assertRaises(AttributeError): super(cls, cls).xxx return type.mro(cls) class A(metaclass=M): pass def test_main(): # Run all local test cases, with PTypesLongInitTest first. support.run_unittest(PTypesLongInitTest, OperatorsTest, ClassPropertiesAndMethods, DictProxyTests, MiscTests, PicklingTests, SharedKeyTests, MroTest) if __name__ == "__main__": test_main()
187,168
5,475
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_unicode_file_functions.py
# Test the Unicode versions of normal file functions # open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir import os import sys import unittest import warnings from unicodedata import normalize from test import support filenames = [ '1_abc', '2_ascii', '3_Gr\xfc\xdf-Gott', '4_\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', '5_\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', '6_\u306b\u307d\u3093', '7_\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', '8_\u66e8\u66e9\u66eb', '9_\u66e8\u05e9\u3093\u0434\u0393\xdf', # Specific code points: fn, NFC(fn) and NFKC(fn) all differents '10_\u1fee\u1ffd', ] # Mac OS X decomposes Unicode names, using Normal Form D. # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html # "However, most volume formats do not follow the exact specification for # these normal forms. For example, HFS Plus uses a variant of Normal Form D # in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through # U+2FAFF are not decomposed." if sys.platform != 'darwin': filenames.extend([ # Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all differents '11_\u0385\u03d3\u03d4', '12_\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD('\u0385\u03d3\u03d4') '13_\u0020\u0308\u0301\u038e\u03ab', # == NFKC('\u0385\u03d3\u03d4') '14_\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed', # Specific code points: fn, NFC(fn) and NFKC(fn) all differents '15_\u1fee\u1ffd\ufad1', '16_\u2000\u2000\u2000A', '17_\u2001\u2001\u2001A', '18_\u2003\u2003\u2003A', # == NFC('\u2001\u2001\u2001A') '19_\u0020\u0020\u0020A', # '\u0020' == ' ' == NFKC('\u2000') == # NFKC('\u2001') == NFKC('\u2003') ]) # Is it Unicode-friendly? if not os.path.supports_unicode_filenames: fsencoding = sys.getfilesystemencoding() try: for name in filenames: name.encode(fsencoding) except UnicodeEncodeError: raise unittest.SkipTest("only NT+ and systems with " "Unicode-friendly filesystem encoding") class UnicodeFileTests(unittest.TestCase): files = set(filenames) normal_form = None def setUp(self): try: os.mkdir(support.TESTFN) except FileExistsError: pass self.addCleanup(support.rmtree, support.TESTFN) files = set() for name in self.files: name = os.path.join(support.TESTFN, self.norm(name)) with open(name, 'wb') as f: f.write((name+'\n').encode("utf-8")) os.stat(name) files.add(name) self.files = files def norm(self, s): if self.normal_form: return normalize(self.normal_form, s) return s def _apply_failure(self, fn, filename, expected_exception=FileNotFoundError, check_filename=True): with self.assertRaises(expected_exception) as c: fn(filename) exc_filename = c.exception.filename if check_filename: self.assertEqual(exc_filename, filename, "Function '%s(%a) failed " "with bad filename in the exception: %a" % (fn.__name__, filename, exc_filename)) def test_failures(self): # Pass non-existing Unicode filenames all over the place. for name in self.files: name = "not_" + name self._apply_failure(open, name) self._apply_failure(os.stat, name) self._apply_failure(os.chdir, name) self._apply_failure(os.rmdir, name) self._apply_failure(os.remove, name) self._apply_failure(os.listdir, name) if sys.platform == 'win32': # Windows is lunatic. Issue #13366. _listdir_failure = NotADirectoryError, FileNotFoundError else: _listdir_failure = NotADirectoryError def test_open(self): for name in self.files: f = open(name, 'wb') f.write((name+'\n').encode("utf-8")) f.close() os.stat(name) self._apply_failure(os.listdir, name, self._listdir_failure) # Skip the test on darwin, because darwin does normalize the filename to # NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC, # NFKD in Python is useless, because darwin will normalize it later and so # open(), os.stat(), etc. don't raise any exception. @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X') def test_normalize(self): files = set(self.files) others = set() for nf in set(['NFC', 'NFD', 'NFKC', 'NFKD']): others |= set(normalize(nf, file) for file in files) others -= files for name in others: self._apply_failure(open, name) self._apply_failure(os.stat, name) self._apply_failure(os.chdir, name) self._apply_failure(os.rmdir, name) self._apply_failure(os.remove, name) self._apply_failure(os.listdir, name) # Skip the test on darwin, because darwin uses a normalization different # than Python NFD normalization: filenames are different even if we use # Python NFD normalization. @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X') def test_listdir(self): sf0 = set(self.files) with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) f1 = os.listdir(support.TESTFN.encode(sys.getfilesystemencoding())) f2 = os.listdir(support.TESTFN) sf2 = set(os.path.join(support.TESTFN, f) for f in f2) self.assertEqual(sf0, sf2, "%a != %a" % (sf0, sf2)) self.assertEqual(len(f1), len(f2)) def test_rename(self): for name in self.files: tmp = os.environ.get('TMPDIR', '/tmp') pid = os.getpid() os.rename(name, "%s/foobar.%d" % (tmp, pid)) os.rename("%s/foobar.%d" % (tmp, pid), name) def test_directory(self): dirname = os.path.join(support.TESTFN, 'Gr\xfc\xdf-\u66e8\u66e9\u66eb') filename = '\xdf-\u66e8\u66e9\u66eb' with support.temp_cwd(dirname): with open(filename, 'wb') as f: f.write((filename + '\n').encode("utf-8")) os.access(filename,os.R_OK) os.remove(filename) class UnicodeNFCFileTests(UnicodeFileTests): normal_form = 'NFC' class UnicodeNFDFileTests(UnicodeFileTests): normal_form = 'NFD' class UnicodeNFKCFileTests(UnicodeFileTests): normal_form = 'NFKC' class UnicodeNFKDFileTests(UnicodeFileTests): normal_form = 'NFKD' def test_main(): support.run_unittest( UnicodeFileTests, UnicodeNFCFileTests, UnicodeNFDFileTests, UnicodeNFKCFileTests, UnicodeNFKDFileTests, ) if __name__ == "__main__": test_main()
7,132
198
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_optparse.py
# # Test suite for Optik. Supplied by Johannes Gijsbers # ([email protected]) -- translated from the original Optik # test suite to this PyUnit-based version. # # $Id$ # import sys import os import re import copy import unittest from io import StringIO from test import support import optparse from optparse import make_option, Option, \ TitledHelpFormatter, OptionParser, OptionGroup, \ SUPPRESS_USAGE, OptionError, OptionConflictError, \ BadOptionError, OptionValueError, Values from optparse import _match_abbrev from optparse import _parse_num retype = type(re.compile('')) class InterceptedError(Exception): def __init__(self, error_message=None, exit_status=None, exit_message=None): self.error_message = error_message self.exit_status = exit_status self.exit_message = exit_message def __str__(self): return self.error_message or self.exit_message or "intercepted error" class InterceptingOptionParser(OptionParser): def exit(self, status=0, msg=None): raise InterceptedError(exit_status=status, exit_message=msg) def error(self, msg): raise InterceptedError(error_message=msg) class BaseTest(unittest.TestCase): def assertParseOK(self, args, expected_opts, expected_positional_args): """Assert the options are what we expected when parsing arguments. Otherwise, fail with a nicely formatted message. Keyword arguments: args -- A list of arguments to parse with OptionParser. expected_opts -- The options expected. expected_positional_args -- The positional arguments expected. Returns the options and positional args for further testing. """ (options, positional_args) = self.parser.parse_args(args) optdict = vars(options) self.assertEqual(optdict, expected_opts, """ Options are %(optdict)s. Should be %(expected_opts)s. Args were %(args)s.""" % locals()) self.assertEqual(positional_args, expected_positional_args, """ Positional arguments are %(positional_args)s. Should be %(expected_positional_args)s. Args were %(args)s.""" % locals ()) return (options, positional_args) def assertRaises(self, func, args, kwargs, expected_exception, expected_message): """ Assert that the expected exception is raised when calling a function, and that the right error message is included with that exception. Arguments: func -- the function to call args -- positional arguments to `func` kwargs -- keyword arguments to `func` expected_exception -- exception that should be raised expected_message -- expected exception message (or pattern if a compiled regex object) Returns the exception raised for further testing. """ if args is None: args = () if kwargs is None: kwargs = {} try: func(*args, **kwargs) except expected_exception as err: actual_message = str(err) if isinstance(expected_message, retype): self.assertTrue(expected_message.search(actual_message), """\ expected exception message pattern: /%s/ actual exception message: '''%s''' """ % (expected_message.pattern, actual_message)) else: self.assertEqual(actual_message, expected_message, """\ expected exception message: '''%s''' actual exception message: '''%s''' """ % (expected_message, actual_message)) return err else: self.fail("""expected exception %(expected_exception)s not raised called %(func)r with args %(args)r and kwargs %(kwargs)r """ % locals ()) # -- Assertions used in more than one class -------------------- def assertParseFail(self, cmdline_args, expected_output): """ Assert the parser fails with the expected message. Caller must ensure that self.parser is an InterceptingOptionParser. """ try: self.parser.parse_args(cmdline_args) except InterceptedError as err: self.assertEqual(err.error_message, expected_output) else: self.assertFalse("expected parse failure") def assertOutput(self, cmdline_args, expected_output, expected_status=0, expected_error=None): """Assert the parser prints the expected output on stdout.""" save_stdout = sys.stdout try: try: sys.stdout = StringIO() self.parser.parse_args(cmdline_args) finally: output = sys.stdout.getvalue() sys.stdout = save_stdout except InterceptedError as err: self.assertTrue( isinstance(output, str), "expected output to be an ordinary string, not %r" % type(output)) if output != expected_output: self.fail("expected: \n'''\n" + expected_output + "'''\nbut got \n'''\n" + output + "'''") self.assertEqual(err.exit_status, expected_status) self.assertEqual(err.exit_message, expected_error) else: self.assertFalse("expected parser.exit()") def assertTypeError(self, func, expected_message, *args): """Assert that TypeError is raised when executing func.""" self.assertRaises(func, args, None, TypeError, expected_message) def assertHelp(self, parser, expected_help): actual_help = parser.format_help() if actual_help != expected_help: raise self.failureException( 'help text failure; expected:\n"' + expected_help + '"; got:\n"' + actual_help + '"\n') # -- Test make_option() aka Option ------------------------------------- # It's not necessary to test correct options here. All the tests in the # parser.parse_args() section deal with those, because they're needed # there. class TestOptionChecks(BaseTest): def setUp(self): self.parser = OptionParser(usage=SUPPRESS_USAGE) def assertOptionError(self, expected_message, args=[], kwargs={}): self.assertRaises(make_option, args, kwargs, OptionError, expected_message) def test_opt_string_empty(self): self.assertTypeError(make_option, "at least one option string must be supplied") def test_opt_string_too_short(self): self.assertOptionError( "invalid option string 'b': must be at least two characters long", ["b"]) def test_opt_string_short_invalid(self): self.assertOptionError( "invalid short option string '--': must be " "of the form -x, (x any non-dash char)", ["--"]) def test_opt_string_long_invalid(self): self.assertOptionError( "invalid long option string '---': " "must start with --, followed by non-dash", ["---"]) def test_attr_invalid(self): self.assertOptionError( "option -b: invalid keyword arguments: bar, foo", ["-b"], {'foo': None, 'bar': None}) def test_action_invalid(self): self.assertOptionError( "option -b: invalid action: 'foo'", ["-b"], {'action': 'foo'}) def test_type_invalid(self): self.assertOptionError( "option -b: invalid option type: 'foo'", ["-b"], {'type': 'foo'}) self.assertOptionError( "option -b: invalid option type: 'tuple'", ["-b"], {'type': tuple}) def test_no_type_for_action(self): self.assertOptionError( "option -b: must not supply a type for action 'count'", ["-b"], {'action': 'count', 'type': 'int'}) def test_no_choices_list(self): self.assertOptionError( "option -b/--bad: must supply a list of " "choices for type 'choice'", ["-b", "--bad"], {'type': "choice"}) def test_bad_choices_list(self): typename = type('').__name__ self.assertOptionError( "option -b/--bad: choices must be a list of " "strings ('%s' supplied)" % typename, ["-b", "--bad"], {'type': "choice", 'choices':"bad choices"}) def test_no_choices_for_type(self): self.assertOptionError( "option -b: must not supply choices for type 'int'", ["-b"], {'type': 'int', 'choices':"bad"}) def test_no_const_for_action(self): self.assertOptionError( "option -b: 'const' must not be supplied for action 'store'", ["-b"], {'action': 'store', 'const': 1}) def test_no_nargs_for_action(self): self.assertOptionError( "option -b: 'nargs' must not be supplied for action 'count'", ["-b"], {'action': 'count', 'nargs': 2}) def test_callback_not_callable(self): self.assertOptionError( "option -b: callback not callable: 'foo'", ["-b"], {'action': 'callback', 'callback': 'foo'}) def dummy(self): pass def test_callback_args_no_tuple(self): self.assertOptionError( "option -b: callback_args, if supplied, " "must be a tuple: not 'foo'", ["-b"], {'action': 'callback', 'callback': self.dummy, 'callback_args': 'foo'}) def test_callback_kwargs_no_dict(self): self.assertOptionError( "option -b: callback_kwargs, if supplied, " "must be a dict: not 'foo'", ["-b"], {'action': 'callback', 'callback': self.dummy, 'callback_kwargs': 'foo'}) def test_no_callback_for_action(self): self.assertOptionError( "option -b: callback supplied ('foo') for non-callback option", ["-b"], {'action': 'store', 'callback': 'foo'}) def test_no_callback_args_for_action(self): self.assertOptionError( "option -b: callback_args supplied for non-callback option", ["-b"], {'action': 'store', 'callback_args': 'foo'}) def test_no_callback_kwargs_for_action(self): self.assertOptionError( "option -b: callback_kwargs supplied for non-callback option", ["-b"], {'action': 'store', 'callback_kwargs': 'foo'}) def test_no_single_dash(self): self.assertOptionError( "invalid long option string '-debug': " "must start with --, followed by non-dash", ["-debug"]) self.assertOptionError( "option -d: invalid long option string '-debug': must start with" " --, followed by non-dash", ["-d", "-debug"]) self.assertOptionError( "invalid long option string '-debug': " "must start with --, followed by non-dash", ["-debug", "--debug"]) class TestOptionParser(BaseTest): def setUp(self): self.parser = OptionParser() self.parser.add_option("-v", "--verbose", "-n", "--noisy", action="store_true", dest="verbose") self.parser.add_option("-q", "--quiet", "--silent", action="store_false", dest="verbose") def test_add_option_no_Option(self): self.assertTypeError(self.parser.add_option, "not an Option instance: None", None) def test_add_option_invalid_arguments(self): self.assertTypeError(self.parser.add_option, "invalid arguments", None, None) def test_get_option(self): opt1 = self.parser.get_option("-v") self.assertIsInstance(opt1, Option) self.assertEqual(opt1._short_opts, ["-v", "-n"]) self.assertEqual(opt1._long_opts, ["--verbose", "--noisy"]) self.assertEqual(opt1.action, "store_true") self.assertEqual(opt1.dest, "verbose") def test_get_option_equals(self): opt1 = self.parser.get_option("-v") opt2 = self.parser.get_option("--verbose") opt3 = self.parser.get_option("-n") opt4 = self.parser.get_option("--noisy") self.assertTrue(opt1 is opt2 is opt3 is opt4) def test_has_option(self): self.assertTrue(self.parser.has_option("-v")) self.assertTrue(self.parser.has_option("--verbose")) def assertTrueremoved(self): self.assertTrue(self.parser.get_option("-v") is None) self.assertTrue(self.parser.get_option("--verbose") is None) self.assertTrue(self.parser.get_option("-n") is None) self.assertTrue(self.parser.get_option("--noisy") is None) self.assertFalse(self.parser.has_option("-v")) self.assertFalse(self.parser.has_option("--verbose")) self.assertFalse(self.parser.has_option("-n")) self.assertFalse(self.parser.has_option("--noisy")) self.assertTrue(self.parser.has_option("-q")) self.assertTrue(self.parser.has_option("--silent")) def test_remove_short_opt(self): self.parser.remove_option("-n") self.assertTrueremoved() def test_remove_long_opt(self): self.parser.remove_option("--verbose") self.assertTrueremoved() def test_remove_nonexistent(self): self.assertRaises(self.parser.remove_option, ('foo',), None, ValueError, "no such option 'foo'") @support.impl_detail('Relies on sys.getrefcount', cpython=True) def test_refleak(self): # If an OptionParser is carrying around a reference to a large # object, various cycles can prevent it from being GC'd in # a timely fashion. destroy() breaks the cycles to ensure stuff # can be cleaned up. big_thing = [42] refcount = sys.getrefcount(big_thing) parser = OptionParser() parser.add_option("-a", "--aaarggh") parser.big_thing = big_thing parser.destroy() #self.assertEqual(refcount, sys.getrefcount(big_thing)) del parser self.assertEqual(refcount, sys.getrefcount(big_thing)) class TestOptionValues(BaseTest): def setUp(self): pass def test_basics(self): values = Values() self.assertEqual(vars(values), {}) self.assertEqual(values, {}) self.assertNotEqual(values, {"foo": "bar"}) self.assertNotEqual(values, "") dict = {"foo": "bar", "baz": 42} values = Values(defaults=dict) self.assertEqual(vars(values), dict) self.assertEqual(values, dict) self.assertNotEqual(values, {"foo": "bar"}) self.assertNotEqual(values, {}) self.assertNotEqual(values, "") self.assertNotEqual(values, []) class TestTypeAliases(BaseTest): def setUp(self): self.parser = OptionParser() def test_str_aliases_string(self): self.parser.add_option("-s", type="str") self.assertEqual(self.parser.get_option("-s").type, "string") def test_type_object(self): self.parser.add_option("-s", type=str) self.assertEqual(self.parser.get_option("-s").type, "string") self.parser.add_option("-x", type=int) self.assertEqual(self.parser.get_option("-x").type, "int") # Custom type for testing processing of default values. _time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 } def _check_duration(option, opt, value): try: if value[-1].isdigit(): return int(value) else: return int(value[:-1]) * _time_units[value[-1]] except (ValueError, IndexError): raise OptionValueError( 'option %s: invalid duration: %r' % (opt, value)) class DurationOption(Option): TYPES = Option.TYPES + ('duration',) TYPE_CHECKER = copy.copy(Option.TYPE_CHECKER) TYPE_CHECKER['duration'] = _check_duration class TestDefaultValues(BaseTest): def setUp(self): self.parser = OptionParser() self.parser.add_option("-v", "--verbose", default=True) self.parser.add_option("-q", "--quiet", dest='verbose') self.parser.add_option("-n", type="int", default=37) self.parser.add_option("-m", type="int") self.parser.add_option("-s", default="foo") self.parser.add_option("-t") self.parser.add_option("-u", default=None) self.expected = { 'verbose': True, 'n': 37, 'm': None, 's': "foo", 't': None, 'u': None } def test_basic_defaults(self): self.assertEqual(self.parser.get_default_values(), self.expected) def test_mixed_defaults_post(self): self.parser.set_defaults(n=42, m=-100) self.expected.update({'n': 42, 'm': -100}) self.assertEqual(self.parser.get_default_values(), self.expected) def test_mixed_defaults_pre(self): self.parser.set_defaults(x="barf", y="blah") self.parser.add_option("-x", default="frob") self.parser.add_option("-y") self.expected.update({'x': "frob", 'y': "blah"}) self.assertEqual(self.parser.get_default_values(), self.expected) self.parser.remove_option("-y") self.parser.add_option("-y", default=None) self.expected.update({'y': None}) self.assertEqual(self.parser.get_default_values(), self.expected) def test_process_default(self): self.parser.option_class = DurationOption self.parser.add_option("-d", type="duration", default=300) self.parser.add_option("-e", type="duration", default="6m") self.parser.set_defaults(n="42") self.expected.update({'d': 300, 'e': 360, 'n': 42}) self.assertEqual(self.parser.get_default_values(), self.expected) self.parser.set_process_default_values(False) self.expected.update({'d': 300, 'e': "6m", 'n': "42"}) self.assertEqual(self.parser.get_default_values(), self.expected) class TestProgName(BaseTest): """ Test that %prog expands to the right thing in usage, version, and help strings. """ def assertUsage(self, parser, expected_usage): self.assertEqual(parser.get_usage(), expected_usage) def assertVersion(self, parser, expected_version): self.assertEqual(parser.get_version(), expected_version) def test_default_progname(self): # Make sure that program name taken from sys.argv[0] by default. save_argv = sys.argv[:] try: sys.argv[0] = os.path.join("foo", "bar", "baz.py") parser = OptionParser("%prog ...", version="%prog 1.2") expected_usage = "Usage: baz.py ...\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "baz.py 1.2") self.assertHelp(parser, expected_usage + "\n" + "Options:\n" " --version show program's version number and exit\n" " -h, --help show this help message and exit\n") finally: sys.argv[:] = save_argv def test_custom_progname(self): parser = OptionParser(prog="thingy", version="%prog 0.1", usage="%prog arg arg") parser.remove_option("-h") parser.remove_option("--version") expected_usage = "Usage: thingy arg arg\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "thingy 0.1") self.assertHelp(parser, expected_usage + "\n") class TestExpandDefaults(BaseTest): def setUp(self): self.parser = OptionParser(prog="test") self.help_prefix = """\ Usage: test [options] Options: -h, --help show this help message and exit """ self.file_help = "read from FILE [default: %default]" self.expected_help_file = self.help_prefix + \ " -f FILE, --file=FILE read from FILE [default: foo.txt]\n" self.expected_help_none = self.help_prefix + \ " -f FILE, --file=FILE read from FILE [default: none]\n" def test_option_default(self): self.parser.add_option("-f", "--file", default="foo.txt", help=self.file_help) self.assertHelp(self.parser, self.expected_help_file) def test_parser_default_1(self): self.parser.add_option("-f", "--file", help=self.file_help) self.parser.set_default('file', "foo.txt") self.assertHelp(self.parser, self.expected_help_file) def test_parser_default_2(self): self.parser.add_option("-f", "--file", help=self.file_help) self.parser.set_defaults(file="foo.txt") self.assertHelp(self.parser, self.expected_help_file) def test_no_default(self): self.parser.add_option("-f", "--file", help=self.file_help) self.assertHelp(self.parser, self.expected_help_none) def test_default_none_1(self): self.parser.add_option("-f", "--file", default=None, help=self.file_help) self.assertHelp(self.parser, self.expected_help_none) def test_default_none_2(self): self.parser.add_option("-f", "--file", help=self.file_help) self.parser.set_defaults(file=None) self.assertHelp(self.parser, self.expected_help_none) def test_float_default(self): self.parser.add_option( "-p", "--prob", help="blow up with probability PROB [default: %default]") self.parser.set_defaults(prob=0.43) expected_help = self.help_prefix + \ " -p PROB, --prob=PROB blow up with probability PROB [default: 0.43]\n" self.assertHelp(self.parser, expected_help) def test_alt_expand(self): self.parser.add_option("-f", "--file", default="foo.txt", help="read from FILE [default: *DEFAULT*]") self.parser.formatter.default_tag = "*DEFAULT*" self.assertHelp(self.parser, self.expected_help_file) def test_no_expand(self): self.parser.add_option("-f", "--file", default="foo.txt", help="read from %default file") self.parser.formatter.default_tag = None expected_help = self.help_prefix + \ " -f FILE, --file=FILE read from %default file\n" self.assertHelp(self.parser, expected_help) # -- Test parser.parse_args() ------------------------------------------ class TestStandard(BaseTest): def setUp(self): options = [make_option("-a", type="string"), make_option("-b", "--boo", type="int", dest='boo'), make_option("--foo", action="append")] self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE, option_list=options) def test_required_value(self): self.assertParseFail(["-a"], "-a option requires 1 argument") def test_invalid_integer(self): self.assertParseFail(["-b", "5x"], "option -b: invalid integer value: '5x'") def test_no_such_option(self): self.assertParseFail(["--boo13"], "no such option: --boo13") def test_long_invalid_integer(self): self.assertParseFail(["--boo=x5"], "option --boo: invalid integer value: 'x5'") def test_empty(self): self.assertParseOK([], {'a': None, 'boo': None, 'foo': None}, []) def test_shortopt_empty_longopt_append(self): self.assertParseOK(["-a", "", "--foo=blah", "--foo="], {'a': "", 'boo': None, 'foo': ["blah", ""]}, []) def test_long_option_append(self): self.assertParseOK(["--foo", "bar", "--foo", "", "--foo=x"], {'a': None, 'boo': None, 'foo': ["bar", "", "x"]}, []) def test_option_argument_joined(self): self.assertParseOK(["-abc"], {'a': "bc", 'boo': None, 'foo': None}, []) def test_option_argument_split(self): self.assertParseOK(["-a", "34"], {'a': "34", 'boo': None, 'foo': None}, []) def test_option_argument_joined_integer(self): self.assertParseOK(["-b34"], {'a': None, 'boo': 34, 'foo': None}, []) def test_option_argument_split_negative_integer(self): self.assertParseOK(["-b", "-5"], {'a': None, 'boo': -5, 'foo': None}, []) def test_long_option_argument_joined(self): self.assertParseOK(["--boo=13"], {'a': None, 'boo': 13, 'foo': None}, []) def test_long_option_argument_split(self): self.assertParseOK(["--boo", "111"], {'a': None, 'boo': 111, 'foo': None}, []) def test_long_option_short_option(self): self.assertParseOK(["--foo=bar", "-axyz"], {'a': 'xyz', 'boo': None, 'foo': ["bar"]}, []) def test_abbrev_long_option(self): self.assertParseOK(["--f=bar", "-axyz"], {'a': 'xyz', 'boo': None, 'foo': ["bar"]}, []) def test_defaults(self): (options, args) = self.parser.parse_args([]) defaults = self.parser.get_default_values() self.assertEqual(vars(defaults), vars(options)) def test_ambiguous_option(self): self.parser.add_option("--foz", action="store", type="string", dest="foo") self.assertParseFail(["--f=bar"], "ambiguous option: --f (--foo, --foz?)") def test_short_and_long_option_split(self): self.assertParseOK(["-a", "xyz", "--foo", "bar"], {'a': 'xyz', 'boo': None, 'foo': ["bar"]}, []) def test_short_option_split_long_option_append(self): self.assertParseOK(["--foo=bar", "-b", "123", "--foo", "baz"], {'a': None, 'boo': 123, 'foo': ["bar", "baz"]}, []) def test_short_option_split_one_positional_arg(self): self.assertParseOK(["-a", "foo", "bar"], {'a': "foo", 'boo': None, 'foo': None}, ["bar"]) def test_short_option_consumes_separator(self): self.assertParseOK(["-a", "--", "foo", "bar"], {'a': "--", 'boo': None, 'foo': None}, ["foo", "bar"]) self.assertParseOK(["-a", "--", "--foo", "bar"], {'a': "--", 'boo': None, 'foo': ["bar"]}, []) def test_short_option_joined_and_separator(self): self.assertParseOK(["-ab", "--", "--foo", "bar"], {'a': "b", 'boo': None, 'foo': None}, ["--foo", "bar"]), def test_hyphen_becomes_positional_arg(self): self.assertParseOK(["-ab", "-", "--foo", "bar"], {'a': "b", 'boo': None, 'foo': ["bar"]}, ["-"]) def test_no_append_versus_append(self): self.assertParseOK(["-b3", "-b", "5", "--foo=bar", "--foo", "baz"], {'a': None, 'boo': 5, 'foo': ["bar", "baz"]}, []) def test_option_consumes_optionlike_string(self): self.assertParseOK(["-a", "-b3"], {'a': "-b3", 'boo': None, 'foo': None}, []) def test_combined_single_invalid_option(self): self.parser.add_option("-t", action="store_true") self.assertParseFail(["-test"], "no such option: -e") class TestBool(BaseTest): def setUp(self): options = [make_option("-v", "--verbose", action="store_true", dest="verbose", default=''), make_option("-q", "--quiet", action="store_false", dest="verbose")] self.parser = OptionParser(option_list = options) def test_bool_default(self): self.assertParseOK([], {'verbose': ''}, []) def test_bool_false(self): (options, args) = self.assertParseOK(["-q"], {'verbose': 0}, []) self.assertTrue(options.verbose is False) def test_bool_true(self): (options, args) = self.assertParseOK(["-v"], {'verbose': 1}, []) self.assertTrue(options.verbose is True) def test_bool_flicker_on_and_off(self): self.assertParseOK(["-qvq", "-q", "-v"], {'verbose': 1}, []) class TestChoice(BaseTest): def setUp(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.parser.add_option("-c", action="store", type="choice", dest="choice", choices=["one", "two", "three"]) def test_valid_choice(self): self.assertParseOK(["-c", "one", "xyz"], {'choice': 'one'}, ["xyz"]) def test_invalid_choice(self): self.assertParseFail(["-c", "four", "abc"], "option -c: invalid choice: 'four' " "(choose from 'one', 'two', 'three')") def test_add_choice_option(self): self.parser.add_option("-d", "--default", choices=["four", "five", "six"]) opt = self.parser.get_option("-d") self.assertEqual(opt.type, "choice") self.assertEqual(opt.action, "store") class TestCount(BaseTest): def setUp(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.v_opt = make_option("-v", action="count", dest="verbose") self.parser.add_option(self.v_opt) self.parser.add_option("--verbose", type="int", dest="verbose") self.parser.add_option("-q", "--quiet", action="store_const", dest="verbose", const=0) def test_empty(self): self.assertParseOK([], {'verbose': None}, []) def test_count_one(self): self.assertParseOK(["-v"], {'verbose': 1}, []) def test_count_three(self): self.assertParseOK(["-vvv"], {'verbose': 3}, []) def test_count_three_apart(self): self.assertParseOK(["-v", "-v", "-v"], {'verbose': 3}, []) def test_count_override_amount(self): self.assertParseOK(["-vvv", "--verbose=2"], {'verbose': 2}, []) def test_count_override_quiet(self): self.assertParseOK(["-vvv", "--verbose=2", "-q"], {'verbose': 0}, []) def test_count_overriding(self): self.assertParseOK(["-vvv", "--verbose=2", "-q", "-v"], {'verbose': 1}, []) def test_count_interspersed_args(self): self.assertParseOK(["--quiet", "3", "-v"], {'verbose': 1}, ["3"]) def test_count_no_interspersed_args(self): self.parser.disable_interspersed_args() self.assertParseOK(["--quiet", "3", "-v"], {'verbose': 0}, ["3", "-v"]) def test_count_no_such_option(self): self.assertParseFail(["-q3", "-v"], "no such option: -3") def test_count_option_no_value(self): self.assertParseFail(["--quiet=3", "-v"], "--quiet option does not take a value") def test_count_with_default(self): self.parser.set_default('verbose', 0) self.assertParseOK([], {'verbose':0}, []) def test_count_overriding_default(self): self.parser.set_default('verbose', 0) self.assertParseOK(["-vvv", "--verbose=2", "-q", "-v"], {'verbose': 1}, []) class TestMultipleArgs(BaseTest): def setUp(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.parser.add_option("-p", "--point", action="store", nargs=3, type="float", dest="point") def test_nargs_with_positional_args(self): self.assertParseOK(["foo", "-p", "1", "2.5", "-4.3", "xyz"], {'point': (1.0, 2.5, -4.3)}, ["foo", "xyz"]) def test_nargs_long_opt(self): self.assertParseOK(["--point", "-1", "2.5", "-0", "xyz"], {'point': (-1.0, 2.5, -0.0)}, ["xyz"]) def test_nargs_invalid_float_value(self): self.assertParseFail(["-p", "1.0", "2x", "3.5"], "option -p: " "invalid floating-point value: '2x'") def test_nargs_required_values(self): self.assertParseFail(["--point", "1.0", "3.5"], "--point option requires 3 arguments") class TestMultipleArgsAppend(BaseTest): def setUp(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.parser.add_option("-p", "--point", action="store", nargs=3, type="float", dest="point") self.parser.add_option("-f", "--foo", action="append", nargs=2, type="int", dest="foo") self.parser.add_option("-z", "--zero", action="append_const", dest="foo", const=(0, 0)) def test_nargs_append(self): self.assertParseOK(["-f", "4", "-3", "blah", "--foo", "1", "666"], {'point': None, 'foo': [(4, -3), (1, 666)]}, ["blah"]) def test_nargs_append_required_values(self): self.assertParseFail(["-f4,3"], "-f option requires 2 arguments") def test_nargs_append_simple(self): self.assertParseOK(["--foo=3", "4"], {'point': None, 'foo':[(3, 4)]}, []) def test_nargs_append_const(self): self.assertParseOK(["--zero", "--foo", "3", "4", "-z"], {'point': None, 'foo':[(0, 0), (3, 4), (0, 0)]}, []) class TestVersion(BaseTest): def test_version(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE, version="%prog 0.1") save_argv = sys.argv[:] try: sys.argv[0] = os.path.join(os.curdir, "foo", "bar") self.assertOutput(["--version"], "bar 0.1\n") finally: sys.argv[:] = save_argv def test_no_version(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.assertParseFail(["--version"], "no such option: --version") # -- Test conflicting default values and parser.parse_args() ----------- class TestConflictingDefaults(BaseTest): """Conflicting default values: the last one should win.""" def setUp(self): self.parser = OptionParser(option_list=[ make_option("-v", action="store_true", dest="verbose", default=1)]) def test_conflict_default(self): self.parser.add_option("-q", action="store_false", dest="verbose", default=0) self.assertParseOK([], {'verbose': 0}, []) def test_conflict_default_none(self): self.parser.add_option("-q", action="store_false", dest="verbose", default=None) self.assertParseOK([], {'verbose': None}, []) class TestOptionGroup(BaseTest): def setUp(self): self.parser = OptionParser(usage=SUPPRESS_USAGE) def test_option_group_create_instance(self): group = OptionGroup(self.parser, "Spam") self.parser.add_option_group(group) group.add_option("--spam", action="store_true", help="spam spam spam spam") self.assertParseOK(["--spam"], {'spam': 1}, []) def test_add_group_no_group(self): self.assertTypeError(self.parser.add_option_group, "not an OptionGroup instance: None", None) def test_add_group_invalid_arguments(self): self.assertTypeError(self.parser.add_option_group, "invalid arguments", None, None) def test_add_group_wrong_parser(self): group = OptionGroup(self.parser, "Spam") group.parser = OptionParser() self.assertRaises(self.parser.add_option_group, (group,), None, ValueError, "invalid OptionGroup (wrong parser)") def test_group_manipulate(self): group = self.parser.add_option_group("Group 2", description="Some more options") group.set_title("Bacon") group.add_option("--bacon", type="int") self.assertTrue(self.parser.get_option_group("--bacon"), group) # -- Test extending and parser.parse_args() ---------------------------- class TestExtendAddTypes(BaseTest): def setUp(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE, option_class=self.MyOption) self.parser.add_option("-a", None, type="string", dest="a") self.parser.add_option("-f", "--file", type="file", dest="file") def tearDown(self): if os.path.isdir(support.TESTFN): os.rmdir(support.TESTFN) elif os.path.isfile(support.TESTFN): os.unlink(support.TESTFN) class MyOption (Option): def check_file(option, opt, value): if not os.path.exists(value): raise OptionValueError("%s: file does not exist" % value) elif not os.path.isfile(value): raise OptionValueError("%s: not a regular file" % value) return value TYPES = Option.TYPES + ("file",) TYPE_CHECKER = copy.copy(Option.TYPE_CHECKER) TYPE_CHECKER["file"] = check_file def test_filetype_ok(self): support.create_empty_file(support.TESTFN) self.assertParseOK(["--file", support.TESTFN, "-afoo"], {'file': support.TESTFN, 'a': 'foo'}, []) def test_filetype_noexist(self): self.assertParseFail(["--file", support.TESTFN, "-afoo"], "%s: file does not exist" % support.TESTFN) def test_filetype_notfile(self): os.mkdir(support.TESTFN) self.assertParseFail(["--file", support.TESTFN, "-afoo"], "%s: not a regular file" % support.TESTFN) class TestExtendAddActions(BaseTest): def setUp(self): options = [self.MyOption("-a", "--apple", action="extend", type="string", dest="apple")] self.parser = OptionParser(option_list=options) class MyOption (Option): ACTIONS = Option.ACTIONS + ("extend",) STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",) TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",) def take_action(self, action, dest, opt, value, values, parser): if action == "extend": lvalue = value.split(",") values.ensure_value(dest, []).extend(lvalue) else: Option.take_action(self, action, dest, opt, parser, value, values) def test_extend_add_action(self): self.assertParseOK(["-afoo,bar", "--apple=blah"], {'apple': ["foo", "bar", "blah"]}, []) def test_extend_add_action_normal(self): self.assertParseOK(["-a", "foo", "-abar", "--apple=x,y"], {'apple': ["foo", "bar", "x", "y"]}, []) # -- Test callbacks and parser.parse_args() ---------------------------- class TestCallback(BaseTest): def setUp(self): options = [make_option("-x", None, action="callback", callback=self.process_opt), make_option("-f", "--file", action="callback", callback=self.process_opt, type="string", dest="filename")] self.parser = OptionParser(option_list=options) def process_opt(self, option, opt, value, parser_): if opt == "-x": self.assertEqual(option._short_opts, ["-x"]) self.assertEqual(option._long_opts, []) self.assertTrue(parser_ is self.parser) self.assertTrue(value is None) self.assertEqual(vars(parser_.values), {'filename': None}) parser_.values.x = 42 elif opt == "--file": self.assertEqual(option._short_opts, ["-f"]) self.assertEqual(option._long_opts, ["--file"]) self.assertTrue(parser_ is self.parser) self.assertEqual(value, "foo") self.assertEqual(vars(parser_.values), {'filename': None, 'x': 42}) setattr(parser_.values, option.dest, value) else: self.fail("Unknown option %r in process_opt." % opt) def test_callback(self): self.assertParseOK(["-x", "--file=foo"], {'filename': "foo", 'x': 42}, []) def test_callback_help(self): # This test was prompted by SF bug #960515 -- the point is # not to inspect the help text, just to make sure that # format_help() doesn't crash. parser = OptionParser(usage=SUPPRESS_USAGE) parser.remove_option("-h") parser.add_option("-t", "--test", action="callback", callback=lambda: None, type="string", help="foo") expected_help = ("Options:\n" " -t TEST, --test=TEST foo\n") self.assertHelp(parser, expected_help) class TestCallbackExtraArgs(BaseTest): def setUp(self): options = [make_option("-p", "--point", action="callback", callback=self.process_tuple, callback_args=(3, int), type="string", dest="points", default=[])] self.parser = OptionParser(option_list=options) def process_tuple(self, option, opt, value, parser_, len, type): self.assertEqual(len, 3) self.assertTrue(type is int) if opt == "-p": self.assertEqual(value, "1,2,3") elif opt == "--point": self.assertEqual(value, "4,5,6") value = tuple(map(type, value.split(","))) getattr(parser_.values, option.dest).append(value) def test_callback_extra_args(self): self.assertParseOK(["-p1,2,3", "--point", "4,5,6"], {'points': [(1,2,3), (4,5,6)]}, []) class TestCallbackMeddleArgs(BaseTest): def setUp(self): options = [make_option(str(x), action="callback", callback=self.process_n, dest='things') for x in range(-1, -6, -1)] self.parser = OptionParser(option_list=options) # Callback that meddles in rargs, largs def process_n(self, option, opt, value, parser_): # option is -3, -5, etc. nargs = int(opt[1:]) rargs = parser_.rargs if len(rargs) < nargs: self.fail("Expected %d arguments for %s option." % (nargs, opt)) dest = parser_.values.ensure_value(option.dest, []) dest.append(tuple(rargs[0:nargs])) parser_.largs.append(nargs) del rargs[0:nargs] def test_callback_meddle_args(self): self.assertParseOK(["-1", "foo", "-3", "bar", "baz", "qux"], {'things': [("foo",), ("bar", "baz", "qux")]}, [1, 3]) def test_callback_meddle_args_separator(self): self.assertParseOK(["-2", "foo", "--"], {'things': [('foo', '--')]}, [2]) class TestCallbackManyArgs(BaseTest): def setUp(self): options = [make_option("-a", "--apple", action="callback", nargs=2, callback=self.process_many, type="string"), make_option("-b", "--bob", action="callback", nargs=3, callback=self.process_many, type="int")] self.parser = OptionParser(option_list=options) def process_many(self, option, opt, value, parser_): if opt == "-a": self.assertEqual(value, ("foo", "bar")) elif opt == "--apple": self.assertEqual(value, ("ding", "dong")) elif opt == "-b": self.assertEqual(value, (1, 2, 3)) elif opt == "--bob": self.assertEqual(value, (-666, 42, 0)) def test_many_args(self): self.assertParseOK(["-a", "foo", "bar", "--apple", "ding", "dong", "-b", "1", "2", "3", "--bob", "-666", "42", "0"], {"apple": None, "bob": None}, []) class TestCallbackCheckAbbrev(BaseTest): def setUp(self): self.parser = OptionParser() self.parser.add_option("--foo-bar", action="callback", callback=self.check_abbrev) def check_abbrev(self, option, opt, value, parser): self.assertEqual(opt, "--foo-bar") def test_abbrev_callback_expansion(self): self.assertParseOK(["--foo"], {}, []) class TestCallbackVarArgs(BaseTest): def setUp(self): options = [make_option("-a", type="int", nargs=2, dest="a"), make_option("-b", action="store_true", dest="b"), make_option("-c", "--callback", action="callback", callback=self.variable_args, dest="c")] self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE, option_list=options) def variable_args(self, option, opt, value, parser): self.assertTrue(value is None) value = [] rargs = parser.rargs while rargs: arg = rargs[0] if ((arg[:2] == "--" and len(arg) > 2) or (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-")): break else: value.append(arg) del rargs[0] setattr(parser.values, option.dest, value) def test_variable_args(self): self.assertParseOK(["-a3", "-5", "--callback", "foo", "bar"], {'a': (3, -5), 'b': None, 'c': ["foo", "bar"]}, []) def test_consume_separator_stop_at_option(self): self.assertParseOK(["-c", "37", "--", "xxx", "-b", "hello"], {'a': None, 'b': True, 'c': ["37", "--", "xxx"]}, ["hello"]) def test_positional_arg_and_variable_args(self): self.assertParseOK(["hello", "-c", "foo", "-", "bar"], {'a': None, 'b': None, 'c':["foo", "-", "bar"]}, ["hello"]) def test_stop_at_option(self): self.assertParseOK(["-c", "foo", "-b"], {'a': None, 'b': True, 'c': ["foo"]}, []) def test_stop_at_invalid_option(self): self.assertParseFail(["-c", "3", "-5", "-a"], "no such option: -5") # -- Test conflict handling and parser.parse_args() -------------------- class ConflictBase(BaseTest): def setUp(self): options = [make_option("-v", "--verbose", action="count", dest="verbose", help="increment verbosity")] self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE, option_list=options) def show_version(self, option, opt, value, parser): parser.values.show_version = 1 class TestConflict(ConflictBase): """Use the default conflict resolution for Optik 1.2: error.""" def assertTrueconflict_error(self, func): err = self.assertRaises( func, ("-v", "--version"), {'action' : "callback", 'callback' : self.show_version, 'help' : "show version"}, OptionConflictError, "option -v/--version: conflicting option string(s): -v") self.assertEqual(err.msg, "conflicting option string(s): -v") self.assertEqual(err.option_id, "-v/--version") def test_conflict_error(self): self.assertTrueconflict_error(self.parser.add_option) def test_conflict_error_group(self): group = OptionGroup(self.parser, "Group 1") self.assertTrueconflict_error(group.add_option) def test_no_such_conflict_handler(self): self.assertRaises( self.parser.set_conflict_handler, ('foo',), None, ValueError, "invalid conflict_resolution value 'foo'") class TestConflictResolve(ConflictBase): def setUp(self): ConflictBase.setUp(self) self.parser.set_conflict_handler("resolve") self.parser.add_option("-v", "--version", action="callback", callback=self.show_version, help="show version") def test_conflict_resolve(self): v_opt = self.parser.get_option("-v") verbose_opt = self.parser.get_option("--verbose") version_opt = self.parser.get_option("--version") self.assertTrue(v_opt is version_opt) self.assertTrue(v_opt is not verbose_opt) self.assertEqual(v_opt._long_opts, ["--version"]) self.assertEqual(version_opt._short_opts, ["-v"]) self.assertEqual(version_opt._long_opts, ["--version"]) self.assertEqual(verbose_opt._short_opts, []) self.assertEqual(verbose_opt._long_opts, ["--verbose"]) def test_conflict_resolve_help(self): self.assertOutput(["-h"], """\ Options: --verbose increment verbosity -h, --help show this help message and exit -v, --version show version """) def test_conflict_resolve_short_opt(self): self.assertParseOK(["-v"], {'verbose': None, 'show_version': 1}, []) def test_conflict_resolve_long_opt(self): self.assertParseOK(["--verbose"], {'verbose': 1}, []) def test_conflict_resolve_long_opts(self): self.assertParseOK(["--verbose", "--version"], {'verbose': 1, 'show_version': 1}, []) class TestConflictOverride(BaseTest): def setUp(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.parser.set_conflict_handler("resolve") self.parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", help="don't do anything") self.parser.add_option("--dry-run", "-n", action="store_const", const=42, dest="dry_run", help="dry run mode") def test_conflict_override_opts(self): opt = self.parser.get_option("--dry-run") self.assertEqual(opt._short_opts, ["-n"]) self.assertEqual(opt._long_opts, ["--dry-run"]) def test_conflict_override_help(self): self.assertOutput(["-h"], """\ Options: -h, --help show this help message and exit -n, --dry-run dry run mode """) def test_conflict_override_args(self): self.assertParseOK(["-n"], {'dry_run': 42}, []) # -- Other testing. ---------------------------------------------------- _expected_help_basic = """\ Usage: bar.py [options] Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit """ _expected_help_long_opts_first = """\ Usage: bar.py [options] Options: -a APPLE throw APPLEs at basket --boo=NUM, -b NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing --help, -h show this help message and exit """ _expected_help_title_formatter = """\ Usage ===== bar.py [options] Options ======= -a APPLE throw APPLEs at basket --boo=NUM, -b NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing --help, -h show this help message and exit """ _expected_help_short_lines = """\ Usage: bar.py [options] Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit """ _expected_very_help_short_lines = """\ Usage: bar.py [options] Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit """ class TestHelp(BaseTest): def setUp(self): self.parser = self.make_parser(80) def make_parser(self, columns): options = [ make_option("-a", type="string", dest='a', metavar="APPLE", help="throw APPLEs at basket"), make_option("-b", "--boo", type="int", dest='boo', metavar="NUM", help= "shout \"boo!\" NUM times (in order to frighten away " "all the evil spirits that cause trouble and mayhem)"), make_option("--foo", action="append", type="string", dest='foo', help="store FOO in the foo list for later fooing"), ] # We need to set COLUMNS for the OptionParser constructor, but # we must restore its original value -- otherwise, this test # screws things up for other tests when it's part of the Python # test suite. with support.EnvironmentVarGuard() as env: env['COLUMNS'] = str(columns) return InterceptingOptionParser(option_list=options) def assertHelpEquals(self, expected_output): save_argv = sys.argv[:] try: # Make optparse believe bar.py is being executed. sys.argv[0] = os.path.join("foo", "bar.py") self.assertOutput(["-h"], expected_output) finally: sys.argv[:] = save_argv def test_help(self): self.assertHelpEquals(_expected_help_basic) def test_help_old_usage(self): self.parser.set_usage("Usage: %prog [options]") self.assertHelpEquals(_expected_help_basic) def test_help_long_opts_first(self): self.parser.formatter.short_first = 0 self.assertHelpEquals(_expected_help_long_opts_first) def test_help_title_formatter(self): with support.EnvironmentVarGuard() as env: env["COLUMNS"] = "80" self.parser.formatter = TitledHelpFormatter() self.assertHelpEquals(_expected_help_title_formatter) def test_wrap_columns(self): # Ensure that wrapping respects $COLUMNS environment variable. # Need to reconstruct the parser, since that's the only time # we look at $COLUMNS. self.parser = self.make_parser(60) self.assertHelpEquals(_expected_help_short_lines) self.parser = self.make_parser(0) self.assertHelpEquals(_expected_very_help_short_lines) def test_help_unicode(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) self.parser.add_option("-a", action="store_true", help="ol\u00E9!") expect = """\ Options: -h, --help show this help message and exit -a ol\u00E9! """ self.assertHelpEquals(expect) def test_help_unicode_description(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE, description="ol\u00E9!") expect = """\ ol\u00E9! Options: -h, --help show this help message and exit """ self.assertHelpEquals(expect) def test_help_description_groups(self): self.parser.set_description( "This is the program description for %prog. %prog has " "an option group as well as single options.") group = OptionGroup( self.parser, "Dangerous Options", "Caution: use of these options is at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") self.parser.add_option_group(group) expect = """\ Usage: bar.py [options] This is the program description for bar.py. bar.py has an option group as well as single options. Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit Dangerous Options: Caution: use of these options is at your own risk. It is believed that some of them bite. -g Group option. """ self.assertHelpEquals(expect) self.parser.epilog = "Please report bugs to /dev/null." self.assertHelpEquals(expect + "\nPlease report bugs to /dev/null.\n") class TestMatchAbbrev(BaseTest): def test_match_abbrev(self): self.assertEqual(_match_abbrev("--f", {"--foz": None, "--foo": None, "--fie": None, "--f": None}), "--f") def test_match_abbrev_error(self): s = "--f" wordmap = {"--foz": None, "--foo": None, "--fie": None} self.assertRaises( _match_abbrev, (s, wordmap), None, BadOptionError, "ambiguous option: --f (--fie, --foo, --foz?)") class TestParseNumber(BaseTest): def setUp(self): self.parser = InterceptingOptionParser() self.parser.add_option("-n", type=int) self.parser.add_option("-l", type=int) def test_parse_num_fail(self): self.assertRaises( _parse_num, ("", int), {}, ValueError, re.compile(r"invalid literal for int().*: '?'?")) self.assertRaises( _parse_num, ("0xOoops", int), {}, ValueError, re.compile(r"invalid literal for int().*: s?'?0xOoops'?")) def test_parse_num_ok(self): self.assertEqual(_parse_num("0", int), 0) self.assertEqual(_parse_num("0x10", int), 16) self.assertEqual(_parse_num("0XA", int), 10) self.assertEqual(_parse_num("010", int), 8) self.assertEqual(_parse_num("0b11", int), 3) self.assertEqual(_parse_num("0b", int), 0) def test_numeric_options(self): self.assertParseOK(["-n", "42", "-l", "0x20"], { "n": 42, "l": 0x20 }, []) self.assertParseOK(["-n", "0b0101", "-l010"], { "n": 5, "l": 8 }, []) self.assertParseFail(["-n008"], "option -n: invalid integer value: '008'") self.assertParseFail(["-l0b0123"], "option -l: invalid integer value: '0b0123'") self.assertParseFail(["-l", "0x12x"], "option -l: invalid integer value: '0x12x'") class MiscTestCase(unittest.TestCase): def test__all__(self): blacklist = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'} support.check__all__(self, optparse, blacklist=blacklist) def test_main(): support.run_unittest(__name__) if __name__ == '__main__': test_main()
62,485
1,665
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_pathlib.py
import collections import io import os import errno import pathlib import pickle import socket import stat import tempfile import unittest from unittest import mock from test import support from test.support import TESTFN, FakePath try: import grp, pwd except ImportError: grp = pwd = None class _BaseFlavourTest(object): def _check_parse_parts(self, arg, expected): f = self.flavour.parse_parts sep = self.flavour.sep altsep = self.flavour.altsep actual = f([x.replace('/', sep) for x in arg]) self.assertEqual(actual, expected) if altsep: actual = f([x.replace('/', altsep) for x in arg]) self.assertEqual(actual, expected) def test_parse_parts_common(self): check = self._check_parse_parts sep = self.flavour.sep # Unanchored parts check([], ('', '', [])) check(['a'], ('', '', ['a'])) check(['a/'], ('', '', ['a'])) check(['a', 'b'], ('', '', ['a', 'b'])) # Expansion check(['a/b'], ('', '', ['a', 'b'])) check(['a/b/'], ('', '', ['a', 'b'])) check(['a', 'b/c', 'd'], ('', '', ['a', 'b', 'c', 'd'])) # Collapsing and stripping excess slashes check(['a', 'b//c', 'd'], ('', '', ['a', 'b', 'c', 'd'])) check(['a', 'b/c/', 'd'], ('', '', ['a', 'b', 'c', 'd'])) # Eliminating standalone dots check(['.'], ('', '', [])) check(['.', '.', 'b'], ('', '', ['b'])) check(['a', '.', 'b'], ('', '', ['a', 'b'])) check(['a', '.', '.'], ('', '', ['a'])) # The first part is anchored check(['/a/b'], ('', sep, [sep, 'a', 'b'])) check(['/a', 'b'], ('', sep, [sep, 'a', 'b'])) check(['/a/', 'b'], ('', sep, [sep, 'a', 'b'])) # Ignoring parts before an anchored part check(['a', '/b', 'c'], ('', sep, [sep, 'b', 'c'])) check(['a', '/b', '/c'], ('', sep, [sep, 'c'])) class PosixFlavourTest(_BaseFlavourTest, unittest.TestCase): flavour = pathlib._posix_flavour def test_parse_parts(self): check = self._check_parse_parts # Collapsing of excess leading slashes, except for the double-slash # special case. check(['//a', 'b'], ('', '//', ['//', 'a', 'b'])) check(['///a', 'b'], ('', '/', ['/', 'a', 'b'])) check(['////a', 'b'], ('', '/', ['/', 'a', 'b'])) # Paths which look like NT paths aren't treated specially check(['c:a'], ('', '', ['c:a'])) check(['c:\\a'], ('', '', ['c:\\a'])) check(['\\a'], ('', '', ['\\a'])) def test_splitroot(self): f = self.flavour.splitroot self.assertEqual(f(''), ('', '', '')) self.assertEqual(f('a'), ('', '', 'a')) self.assertEqual(f('a/b'), ('', '', 'a/b')) self.assertEqual(f('a/b/'), ('', '', 'a/b/')) self.assertEqual(f('/a'), ('', '/', 'a')) self.assertEqual(f('/a/b'), ('', '/', 'a/b')) self.assertEqual(f('/a/b/'), ('', '/', 'a/b/')) # The root is collapsed when there are redundant slashes # except when there are exactly two leading slashes, which # is a special case in POSIX. self.assertEqual(f('//a'), ('', '//', 'a')) self.assertEqual(f('///a'), ('', '/', 'a')) self.assertEqual(f('///a/b'), ('', '/', 'a/b')) # Paths which look like NT paths aren't treated specially self.assertEqual(f('c:/a/b'), ('', '', 'c:/a/b')) self.assertEqual(f('\\/a/b'), ('', '', '\\/a/b')) self.assertEqual(f('\\a\\b'), ('', '', '\\a\\b')) class NTFlavourTest(_BaseFlavourTest, unittest.TestCase): flavour = pathlib._windows_flavour def test_parse_parts(self): check = self._check_parse_parts # First part is anchored check(['c:'], ('c:', '', ['c:'])) check(['c:/'], ('c:', '\\', ['c:\\'])) check(['/'], ('', '\\', ['\\'])) check(['c:a'], ('c:', '', ['c:', 'a'])) check(['c:/a'], ('c:', '\\', ['c:\\', 'a'])) check(['/a'], ('', '\\', ['\\', 'a'])) # UNC paths check(['//a/b'], ('\\\\a\\b', '\\', ['\\\\a\\b\\'])) check(['//a/b/'], ('\\\\a\\b', '\\', ['\\\\a\\b\\'])) check(['//a/b/c'], ('\\\\a\\b', '\\', ['\\\\a\\b\\', 'c'])) # Second part is anchored, so that the first part is ignored check(['a', 'Z:b', 'c'], ('Z:', '', ['Z:', 'b', 'c'])) check(['a', 'Z:/b', 'c'], ('Z:', '\\', ['Z:\\', 'b', 'c'])) # UNC paths check(['a', '//b/c', 'd'], ('\\\\b\\c', '\\', ['\\\\b\\c\\', 'd'])) # Collapsing and stripping excess slashes check(['a', 'Z://b//c/', 'd/'], ('Z:', '\\', ['Z:\\', 'b', 'c', 'd'])) # UNC paths check(['a', '//b/c//', 'd'], ('\\\\b\\c', '\\', ['\\\\b\\c\\', 'd'])) # Extended paths check(['//?/c:/'], ('\\\\?\\c:', '\\', ['\\\\?\\c:\\'])) check(['//?/c:/a'], ('\\\\?\\c:', '\\', ['\\\\?\\c:\\', 'a'])) check(['//?/c:/a', '/b'], ('\\\\?\\c:', '\\', ['\\\\?\\c:\\', 'b'])) # Extended UNC paths (format is "\\?\UNC\server\share") check(['//?/UNC/b/c'], ('\\\\?\\UNC\\b\\c', '\\', ['\\\\?\\UNC\\b\\c\\'])) check(['//?/UNC/b/c/d'], ('\\\\?\\UNC\\b\\c', '\\', ['\\\\?\\UNC\\b\\c\\', 'd'])) # Second part has a root but not drive check(['a', '/b', 'c'], ('', '\\', ['\\', 'b', 'c'])) check(['Z:/a', '/b', 'c'], ('Z:', '\\', ['Z:\\', 'b', 'c'])) check(['//?/Z:/a', '/b', 'c'], ('\\\\?\\Z:', '\\', ['\\\\?\\Z:\\', 'b', 'c'])) def test_splitroot(self): f = self.flavour.splitroot self.assertEqual(f(''), ('', '', '')) self.assertEqual(f('a'), ('', '', 'a')) self.assertEqual(f('a\\b'), ('', '', 'a\\b')) self.assertEqual(f('\\a'), ('', '\\', 'a')) self.assertEqual(f('\\a\\b'), ('', '\\', 'a\\b')) self.assertEqual(f('c:a\\b'), ('c:', '', 'a\\b')) self.assertEqual(f('c:\\a\\b'), ('c:', '\\', 'a\\b')) # Redundant slashes in the root are collapsed self.assertEqual(f('\\\\a'), ('', '\\', 'a')) self.assertEqual(f('\\\\\\a/b'), ('', '\\', 'a/b')) self.assertEqual(f('c:\\\\a'), ('c:', '\\', 'a')) self.assertEqual(f('c:\\\\\\a/b'), ('c:', '\\', 'a/b')) # Valid UNC paths self.assertEqual(f('\\\\a\\b'), ('\\\\a\\b', '\\', '')) self.assertEqual(f('\\\\a\\b\\'), ('\\\\a\\b', '\\', '')) self.assertEqual(f('\\\\a\\b\\c\\d'), ('\\\\a\\b', '\\', 'c\\d')) # These are non-UNC paths (according to ntpath.py and test_ntpath) # However, command.com says such paths are invalid, so it's # difficult to know what the right semantics are self.assertEqual(f('\\\\\\a\\b'), ('', '\\', 'a\\b')) self.assertEqual(f('\\\\a'), ('', '\\', 'a')) # # Tests for the pure classes # class _BasePurePathTest(object): # keys are canonical paths, values are list of tuples of arguments # supposed to produce equal paths equivalences = { 'a/b': [ ('a', 'b'), ('a/', 'b'), ('a', 'b/'), ('a/', 'b/'), ('a/b/',), ('a//b',), ('a//b//',), # empty components get removed ('', 'a', 'b'), ('a', '', 'b'), ('a', 'b', ''), ], '/b/c/d': [ ('a', '/b/c', 'd'), ('a', '///b//c', 'd/'), ('/a', '/b/c', 'd'), # empty components get removed ('/', 'b', '', 'c/d'), ('/', '', 'b/c/d'), ('', '/b/c/d'), ], } def setUp(self): p = self.cls('a') self.flavour = p._flavour self.sep = self.flavour.sep self.altsep = self.flavour.altsep def test_constructor_common(self): P = self.cls p = P('a') self.assertIsInstance(p, P) P('a', 'b', 'c') P('/a', 'b', 'c') P('a/b/c') P('/a/b/c') P(FakePath("a/b/c")) self.assertEqual(P(P('a')), P('a')) self.assertEqual(P(P('a'), 'b'), P('a/b')) self.assertEqual(P(P('a'), P('b')), P('a/b')) self.assertEqual(P(P('a'), P('b'), P('c')), P(FakePath("a/b/c"))) def _check_str_subclass(self, *args): # Issue #21127: it should be possible to construct a PurePath object # from a str subclass instance, and it then gets converted to # a pure str object. class StrSubclass(str): pass P = self.cls p = P(*(StrSubclass(x) for x in args)) self.assertEqual(p, P(*args)) for part in p.parts: self.assertIs(type(part), str) def test_str_subclass_common(self): self._check_str_subclass('') self._check_str_subclass('.') self._check_str_subclass('a') self._check_str_subclass('a/b.txt') self._check_str_subclass('/a/b.txt') def test_join_common(self): P = self.cls p = P('a/b') pp = p.joinpath('c') self.assertEqual(pp, P('a/b/c')) self.assertIs(type(pp), type(p)) pp = p.joinpath('c', 'd') self.assertEqual(pp, P('a/b/c/d')) pp = p.joinpath(P('c')) self.assertEqual(pp, P('a/b/c')) pp = p.joinpath('/c') self.assertEqual(pp, P('/c')) def test_div_common(self): # Basically the same as joinpath() P = self.cls p = P('a/b') pp = p / 'c' self.assertEqual(pp, P('a/b/c')) self.assertIs(type(pp), type(p)) pp = p / 'c/d' self.assertEqual(pp, P('a/b/c/d')) pp = p / 'c' / 'd' self.assertEqual(pp, P('a/b/c/d')) pp = 'c' / p / 'd' self.assertEqual(pp, P('c/a/b/d')) pp = p / P('c') self.assertEqual(pp, P('a/b/c')) pp = p/ '/c' self.assertEqual(pp, P('/c')) def _check_str(self, expected, args): p = self.cls(*args) self.assertEqual(str(p), expected.replace('/', self.sep)) def test_str_common(self): # Canonicalized paths roundtrip for pathstr in ('a', 'a/b', 'a/b/c', '/', '/a/b', '/a/b/c'): self._check_str(pathstr, (pathstr,)) # Special case for the empty path self._check_str('.', ('',)) # Other tests for str() are in test_equivalences() def test_as_posix_common(self): P = self.cls for pathstr in ('a', 'a/b', 'a/b/c', '/', '/a/b', '/a/b/c'): self.assertEqual(P(pathstr).as_posix(), pathstr) # Other tests for as_posix() are in test_equivalences() def test_as_bytes_common(self): sep = os.fsencode(self.sep) P = self.cls self.assertEqual(bytes(P('a/b')), b'a' + sep + b'b') def test_as_uri_common(self): P = self.cls with self.assertRaises(ValueError): P('a').as_uri() with self.assertRaises(ValueError): P().as_uri() def test_repr_common(self): for pathstr in ('a', 'a/b', 'a/b/c', '/', '/a/b', '/a/b/c'): p = self.cls(pathstr) clsname = p.__class__.__name__ r = repr(p) # The repr() is in the form ClassName("forward-slashes path") self.assertTrue(r.startswith(clsname + '('), r) self.assertTrue(r.endswith(')'), r) inner = r[len(clsname) + 1 : -1] self.assertEqual(eval(inner), p.as_posix()) # The repr() roundtrips q = eval(r, pathlib.__dict__) self.assertIs(q.__class__, p.__class__) self.assertEqual(q, p) self.assertEqual(repr(q), r) def test_eq_common(self): P = self.cls self.assertEqual(P('a/b'), P('a/b')) self.assertEqual(P('a/b'), P('a', 'b')) self.assertNotEqual(P('a/b'), P('a')) self.assertNotEqual(P('a/b'), P('/a/b')) self.assertNotEqual(P('a/b'), P()) self.assertNotEqual(P('/a/b'), P('/')) self.assertNotEqual(P(), P('/')) self.assertNotEqual(P(), "") self.assertNotEqual(P(), {}) self.assertNotEqual(P(), int) def test_match_common(self): P = self.cls self.assertRaises(ValueError, P('a').match, '') self.assertRaises(ValueError, P('a').match, '.') # Simple relative pattern self.assertTrue(P('b.py').match('b.py')) self.assertTrue(P('a/b.py').match('b.py')) self.assertTrue(P('/a/b.py').match('b.py')) self.assertFalse(P('a.py').match('b.py')) self.assertFalse(P('b/py').match('b.py')) self.assertFalse(P('/a.py').match('b.py')) self.assertFalse(P('b.py/c').match('b.py')) # Wilcard relative pattern self.assertTrue(P('b.py').match('*.py')) self.assertTrue(P('a/b.py').match('*.py')) self.assertTrue(P('/a/b.py').match('*.py')) self.assertFalse(P('b.pyc').match('*.py')) self.assertFalse(P('b./py').match('*.py')) self.assertFalse(P('b.py/c').match('*.py')) # Multi-part relative pattern self.assertTrue(P('ab/c.py').match('a*/*.py')) self.assertTrue(P('/d/ab/c.py').match('a*/*.py')) self.assertFalse(P('a.py').match('a*/*.py')) self.assertFalse(P('/dab/c.py').match('a*/*.py')) self.assertFalse(P('ab/c.py/d').match('a*/*.py')) # Absolute pattern self.assertTrue(P('/b.py').match('/*.py')) self.assertFalse(P('b.py').match('/*.py')) self.assertFalse(P('a/b.py').match('/*.py')) self.assertFalse(P('/a/b.py').match('/*.py')) # Multi-part absolute pattern self.assertTrue(P('/a/b.py').match('/a/*.py')) self.assertFalse(P('/ab.py').match('/a/*.py')) self.assertFalse(P('/a/b/c.py').match('/a/*.py')) def test_ordering_common(self): # Ordering is tuple-alike def assertLess(a, b): self.assertLess(a, b) self.assertGreater(b, a) P = self.cls a = P('a') b = P('a/b') c = P('abc') d = P('b') assertLess(a, b) assertLess(a, c) assertLess(a, d) assertLess(b, c) assertLess(c, d) P = self.cls a = P('/a') b = P('/a/b') c = P('/abc') d = P('/b') assertLess(a, b) assertLess(a, c) assertLess(a, d) assertLess(b, c) assertLess(c, d) with self.assertRaises(TypeError): P() < {} def test_parts_common(self): # `parts` returns a tuple sep = self.sep P = self.cls p = P('a/b') parts = p.parts self.assertEqual(parts, ('a', 'b')) # The object gets reused self.assertIs(parts, p.parts) # When the path is absolute, the anchor is a separate part p = P('/a/b') parts = p.parts self.assertEqual(parts, (sep, 'a', 'b')) def test_fspath_common(self): P = self.cls p = P('a/b') self._check_str(p.__fspath__(), ('a/b',)) self._check_str(os.fspath(p), ('a/b',)) def test_equivalences(self): for k, tuples in self.equivalences.items(): canon = k.replace('/', self.sep) posix = k.replace(self.sep, '/') if canon != posix: tuples = tuples + [ tuple(part.replace('/', self.sep) for part in t) for t in tuples ] tuples.append((posix, )) pcanon = self.cls(canon) for t in tuples: p = self.cls(*t) self.assertEqual(p, pcanon, "failed with args {}".format(t)) self.assertEqual(hash(p), hash(pcanon)) self.assertEqual(str(p), canon) self.assertEqual(p.as_posix(), posix) def test_parent_common(self): # Relative P = self.cls p = P('a/b/c') self.assertEqual(p.parent, P('a/b')) self.assertEqual(p.parent.parent, P('a')) self.assertEqual(p.parent.parent.parent, P()) self.assertEqual(p.parent.parent.parent.parent, P()) # Anchored p = P('/a/b/c') self.assertEqual(p.parent, P('/a/b')) self.assertEqual(p.parent.parent, P('/a')) self.assertEqual(p.parent.parent.parent, P('/')) self.assertEqual(p.parent.parent.parent.parent, P('/')) def test_parents_common(self): # Relative P = self.cls p = P('a/b/c') par = p.parents self.assertEqual(len(par), 3) self.assertEqual(par[0], P('a/b')) self.assertEqual(par[1], P('a')) self.assertEqual(par[2], P('.')) self.assertEqual(list(par), [P('a/b'), P('a'), P('.')]) with self.assertRaises(IndexError): par[-1] with self.assertRaises(IndexError): par[3] with self.assertRaises(TypeError): par[0] = p # Anchored p = P('/a/b/c') par = p.parents self.assertEqual(len(par), 3) self.assertEqual(par[0], P('/a/b')) self.assertEqual(par[1], P('/a')) self.assertEqual(par[2], P('/')) self.assertEqual(list(par), [P('/a/b'), P('/a'), P('/')]) with self.assertRaises(IndexError): par[3] def test_drive_common(self): P = self.cls self.assertEqual(P('a/b').drive, '') self.assertEqual(P('/a/b').drive, '') self.assertEqual(P('').drive, '') def test_root_common(self): P = self.cls sep = self.sep self.assertEqual(P('').root, '') self.assertEqual(P('a/b').root, '') self.assertEqual(P('/').root, sep) self.assertEqual(P('/a/b').root, sep) def test_anchor_common(self): P = self.cls sep = self.sep self.assertEqual(P('').anchor, '') self.assertEqual(P('a/b').anchor, '') self.assertEqual(P('/').anchor, sep) self.assertEqual(P('/a/b').anchor, sep) def test_name_common(self): P = self.cls self.assertEqual(P('').name, '') self.assertEqual(P('.').name, '') self.assertEqual(P('/').name, '') self.assertEqual(P('a/b').name, 'b') self.assertEqual(P('/a/b').name, 'b') self.assertEqual(P('/a/b/.').name, 'b') self.assertEqual(P('a/b.py').name, 'b.py') self.assertEqual(P('/a/b.py').name, 'b.py') def test_suffix_common(self): P = self.cls self.assertEqual(P('').suffix, '') self.assertEqual(P('.').suffix, '') self.assertEqual(P('..').suffix, '') self.assertEqual(P('/').suffix, '') self.assertEqual(P('a/b').suffix, '') self.assertEqual(P('/a/b').suffix, '') self.assertEqual(P('/a/b/.').suffix, '') self.assertEqual(P('a/b.py').suffix, '.py') self.assertEqual(P('/a/b.py').suffix, '.py') self.assertEqual(P('a/.hgrc').suffix, '') self.assertEqual(P('/a/.hgrc').suffix, '') self.assertEqual(P('a/.hg.rc').suffix, '.rc') self.assertEqual(P('/a/.hg.rc').suffix, '.rc') self.assertEqual(P('a/b.tar.gz').suffix, '.gz') self.assertEqual(P('/a/b.tar.gz').suffix, '.gz') self.assertEqual(P('a/Some name. Ending with a dot.').suffix, '') self.assertEqual(P('/a/Some name. Ending with a dot.').suffix, '') def test_suffixes_common(self): P = self.cls self.assertEqual(P('').suffixes, []) self.assertEqual(P('.').suffixes, []) self.assertEqual(P('/').suffixes, []) self.assertEqual(P('a/b').suffixes, []) self.assertEqual(P('/a/b').suffixes, []) self.assertEqual(P('/a/b/.').suffixes, []) self.assertEqual(P('a/b.py').suffixes, ['.py']) self.assertEqual(P('/a/b.py').suffixes, ['.py']) self.assertEqual(P('a/.hgrc').suffixes, []) self.assertEqual(P('/a/.hgrc').suffixes, []) self.assertEqual(P('a/.hg.rc').suffixes, ['.rc']) self.assertEqual(P('/a/.hg.rc').suffixes, ['.rc']) self.assertEqual(P('a/b.tar.gz').suffixes, ['.tar', '.gz']) self.assertEqual(P('/a/b.tar.gz').suffixes, ['.tar', '.gz']) self.assertEqual(P('a/Some name. Ending with a dot.').suffixes, []) self.assertEqual(P('/a/Some name. Ending with a dot.').suffixes, []) def test_stem_common(self): P = self.cls self.assertEqual(P('').stem, '') self.assertEqual(P('.').stem, '') self.assertEqual(P('..').stem, '..') self.assertEqual(P('/').stem, '') self.assertEqual(P('a/b').stem, 'b') self.assertEqual(P('a/b.py').stem, 'b') self.assertEqual(P('a/.hgrc').stem, '.hgrc') self.assertEqual(P('a/.hg.rc').stem, '.hg') self.assertEqual(P('a/b.tar.gz').stem, 'b.tar') self.assertEqual(P('a/Some name. Ending with a dot.').stem, 'Some name. Ending with a dot.') def test_with_name_common(self): P = self.cls self.assertEqual(P('a/b').with_name('d.xml'), P('a/d.xml')) self.assertEqual(P('/a/b').with_name('d.xml'), P('/a/d.xml')) self.assertEqual(P('a/b.py').with_name('d.xml'), P('a/d.xml')) self.assertEqual(P('/a/b.py').with_name('d.xml'), P('/a/d.xml')) self.assertEqual(P('a/Dot ending.').with_name('d.xml'), P('a/d.xml')) self.assertEqual(P('/a/Dot ending.').with_name('d.xml'), P('/a/d.xml')) self.assertRaises(ValueError, P('').with_name, 'd.xml') self.assertRaises(ValueError, P('.').with_name, 'd.xml') self.assertRaises(ValueError, P('/').with_name, 'd.xml') self.assertRaises(ValueError, P('a/b').with_name, '') self.assertRaises(ValueError, P('a/b').with_name, '/c') self.assertRaises(ValueError, P('a/b').with_name, 'c/') self.assertRaises(ValueError, P('a/b').with_name, 'c/d') def test_with_suffix_common(self): P = self.cls self.assertEqual(P('a/b').with_suffix('.gz'), P('a/b.gz')) self.assertEqual(P('/a/b').with_suffix('.gz'), P('/a/b.gz')) self.assertEqual(P('a/b.py').with_suffix('.gz'), P('a/b.gz')) self.assertEqual(P('/a/b.py').with_suffix('.gz'), P('/a/b.gz')) # Stripping suffix self.assertEqual(P('a/b.py').with_suffix(''), P('a/b')) self.assertEqual(P('/a/b').with_suffix(''), P('/a/b')) # Path doesn't have a "filename" component self.assertRaises(ValueError, P('').with_suffix, '.gz') self.assertRaises(ValueError, P('.').with_suffix, '.gz') self.assertRaises(ValueError, P('/').with_suffix, '.gz') # Invalid suffix self.assertRaises(ValueError, P('a/b').with_suffix, 'gz') self.assertRaises(ValueError, P('a/b').with_suffix, '/') self.assertRaises(ValueError, P('a/b').with_suffix, '.') self.assertRaises(ValueError, P('a/b').with_suffix, '/.gz') self.assertRaises(ValueError, P('a/b').with_suffix, 'c/d') self.assertRaises(ValueError, P('a/b').with_suffix, '.c/.d') self.assertRaises(ValueError, P('a/b').with_suffix, './.d') self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.') def test_relative_to_common(self): P = self.cls p = P('a/b') self.assertRaises(TypeError, p.relative_to) self.assertRaises(TypeError, p.relative_to, b'a') self.assertEqual(p.relative_to(P()), P('a/b')) self.assertEqual(p.relative_to(''), P('a/b')) self.assertEqual(p.relative_to(P('a')), P('b')) self.assertEqual(p.relative_to('a'), P('b')) self.assertEqual(p.relative_to('a/'), P('b')) self.assertEqual(p.relative_to(P('a/b')), P()) self.assertEqual(p.relative_to('a/b'), P()) # With several args self.assertEqual(p.relative_to('a', 'b'), P()) # Unrelated paths self.assertRaises(ValueError, p.relative_to, P('c')) self.assertRaises(ValueError, p.relative_to, P('a/b/c')) self.assertRaises(ValueError, p.relative_to, P('a/c')) self.assertRaises(ValueError, p.relative_to, P('/a')) p = P('/a/b') self.assertEqual(p.relative_to(P('/')), P('a/b')) self.assertEqual(p.relative_to('/'), P('a/b')) self.assertEqual(p.relative_to(P('/a')), P('b')) self.assertEqual(p.relative_to('/a'), P('b')) self.assertEqual(p.relative_to('/a/'), P('b')) self.assertEqual(p.relative_to(P('/a/b')), P()) self.assertEqual(p.relative_to('/a/b'), P()) # Unrelated paths self.assertRaises(ValueError, p.relative_to, P('/c')) self.assertRaises(ValueError, p.relative_to, P('/a/b/c')) self.assertRaises(ValueError, p.relative_to, P('/a/c')) self.assertRaises(ValueError, p.relative_to, P()) self.assertRaises(ValueError, p.relative_to, '') self.assertRaises(ValueError, p.relative_to, P('a')) def test_pickling_common(self): P = self.cls p = P('/a/b') for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): dumped = pickle.dumps(p, proto) pp = pickle.loads(dumped) self.assertIs(pp.__class__, p.__class__) self.assertEqual(pp, p) self.assertEqual(hash(pp), hash(p)) self.assertEqual(str(pp), str(p)) class PurePosixPathTest(_BasePurePathTest, unittest.TestCase): cls = pathlib.PurePosixPath def test_root(self): P = self.cls self.assertEqual(P('/a/b').root, '/') self.assertEqual(P('///a/b').root, '/') # POSIX special case for two leading slashes self.assertEqual(P('//a/b').root, '//') def test_eq(self): P = self.cls self.assertNotEqual(P('a/b'), P('A/b')) self.assertEqual(P('/a'), P('///a')) self.assertNotEqual(P('/a'), P('//a')) def test_as_uri(self): P = self.cls self.assertEqual(P('/').as_uri(), 'file:///') self.assertEqual(P('/a/b.c').as_uri(), 'file:///a/b.c') self.assertEqual(P('/a/b%#c').as_uri(), 'file:///a/b%25%23c') def test_as_uri_non_ascii(self): from urllib.parse import quote_from_bytes P = self.cls try: os.fsencode('\xe9') except UnicodeEncodeError: self.skipTest("\\xe9 cannot be encoded to the filesystem encoding") self.assertEqual(P('/a/b\xe9').as_uri(), 'file:///a/b' + quote_from_bytes(os.fsencode('\xe9'))) def test_match(self): P = self.cls self.assertFalse(P('A.py').match('a.PY')) def test_is_absolute(self): P = self.cls self.assertFalse(P().is_absolute()) self.assertFalse(P('a').is_absolute()) self.assertFalse(P('a/b/').is_absolute()) self.assertTrue(P('/').is_absolute()) self.assertTrue(P('/a').is_absolute()) self.assertTrue(P('/a/b/').is_absolute()) self.assertTrue(P('//a').is_absolute()) self.assertTrue(P('//a/b').is_absolute()) def test_is_reserved(self): P = self.cls self.assertIs(False, P('').is_reserved()) self.assertIs(False, P('/').is_reserved()) self.assertIs(False, P('/foo/bar').is_reserved()) self.assertIs(False, P('/dev/con/PRN/NUL').is_reserved()) def test_join(self): P = self.cls p = P('//a') pp = p.joinpath('b') self.assertEqual(pp, P('//a/b')) pp = P('/a').joinpath('//c') self.assertEqual(pp, P('//c')) pp = P('//a').joinpath('/c') self.assertEqual(pp, P('/c')) def test_div(self): # Basically the same as joinpath() P = self.cls p = P('//a') pp = p / 'b' self.assertEqual(pp, P('//a/b')) pp = P('/a') / '//c' self.assertEqual(pp, P('//c')) pp = P('//a') / '/c' self.assertEqual(pp, P('/c')) class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase): cls = pathlib.PureWindowsPath equivalences = _BasePurePathTest.equivalences.copy() equivalences.update({ 'c:a': [ ('c:', 'a'), ('c:', 'a/'), ('/', 'c:', 'a') ], 'c:/a': [ ('c:/', 'a'), ('c:', '/', 'a'), ('c:', '/a'), ('/z', 'c:/', 'a'), ('//x/y', 'c:/', 'a'), ], '//a/b/': [ ('//a/b',) ], '//a/b/c': [ ('//a/b', 'c'), ('//a/b/', 'c'), ], }) def test_str(self): p = self.cls('a/b/c') self.assertEqual(str(p), 'a\\b\\c') p = self.cls('c:/a/b/c') self.assertEqual(str(p), 'c:\\a\\b\\c') p = self.cls('//a/b') self.assertEqual(str(p), '\\\\a\\b\\') p = self.cls('//a/b/c') self.assertEqual(str(p), '\\\\a\\b\\c') p = self.cls('//a/b/c/d') self.assertEqual(str(p), '\\\\a\\b\\c\\d') def test_str_subclass(self): self._check_str_subclass('c:') self._check_str_subclass('c:a') self._check_str_subclass('c:a\\b.txt') self._check_str_subclass('c:\\') self._check_str_subclass('c:\\a') self._check_str_subclass('c:\\a\\b.txt') self._check_str_subclass('\\\\some\\share') self._check_str_subclass('\\\\some\\share\\a') self._check_str_subclass('\\\\some\\share\\a\\b.txt') def test_eq(self): P = self.cls self.assertEqual(P('c:a/b'), P('c:a/b')) self.assertEqual(P('c:a/b'), P('c:', 'a', 'b')) self.assertNotEqual(P('c:a/b'), P('d:a/b')) self.assertNotEqual(P('c:a/b'), P('c:/a/b')) self.assertNotEqual(P('/a/b'), P('c:/a/b')) # Case-insensitivity self.assertEqual(P('a/B'), P('A/b')) self.assertEqual(P('C:a/B'), P('c:A/b')) self.assertEqual(P('//Some/SHARE/a/B'), P('//somE/share/A/b')) def test_as_uri(self): P = self.cls with self.assertRaises(ValueError): P('/a/b').as_uri() with self.assertRaises(ValueError): P('c:a/b').as_uri() self.assertEqual(P('c:/').as_uri(), 'file:///c:/') self.assertEqual(P('c:/a/b.c').as_uri(), 'file:///c:/a/b.c') self.assertEqual(P('c:/a/b%#c').as_uri(), 'file:///c:/a/b%25%23c') self.assertEqual(P('c:/a/b\xe9').as_uri(), 'file:///c:/a/b%C3%A9') self.assertEqual(P('//some/share/').as_uri(), 'file://some/share/') self.assertEqual(P('//some/share/a/b.c').as_uri(), 'file://some/share/a/b.c') self.assertEqual(P('//some/share/a/b%#c\xe9').as_uri(), 'file://some/share/a/b%25%23c%C3%A9') def test_match_common(self): P = self.cls # Absolute patterns self.assertTrue(P('c:/b.py').match('/*.py')) self.assertTrue(P('c:/b.py').match('c:*.py')) self.assertTrue(P('c:/b.py').match('c:/*.py')) self.assertFalse(P('d:/b.py').match('c:/*.py')) # wrong drive self.assertFalse(P('b.py').match('/*.py')) self.assertFalse(P('b.py').match('c:*.py')) self.assertFalse(P('b.py').match('c:/*.py')) self.assertFalse(P('c:b.py').match('/*.py')) self.assertFalse(P('c:b.py').match('c:/*.py')) self.assertFalse(P('/b.py').match('c:*.py')) self.assertFalse(P('/b.py').match('c:/*.py')) # UNC patterns self.assertTrue(P('//some/share/a.py').match('/*.py')) self.assertTrue(P('//some/share/a.py').match('//some/share/*.py')) self.assertFalse(P('//other/share/a.py').match('//some/share/*.py')) self.assertFalse(P('//some/share/a/b.py').match('//some/share/*.py')) # Case-insensitivity self.assertTrue(P('B.py').match('b.PY')) self.assertTrue(P('c:/a/B.Py').match('C:/A/*.pY')) self.assertTrue(P('//Some/Share/B.Py').match('//somE/sharE/*.pY')) def test_ordering_common(self): # Case-insensitivity def assertOrderedEqual(a, b): self.assertLessEqual(a, b) self.assertGreaterEqual(b, a) P = self.cls p = P('c:A/b') q = P('C:a/B') assertOrderedEqual(p, q) self.assertFalse(p < q) self.assertFalse(p > q) p = P('//some/Share/A/b') q = P('//Some/SHARE/a/B') assertOrderedEqual(p, q) self.assertFalse(p < q) self.assertFalse(p > q) def test_parts(self): P = self.cls p = P('c:a/b') parts = p.parts self.assertEqual(parts, ('c:', 'a', 'b')) p = P('c:/a/b') parts = p.parts self.assertEqual(parts, ('c:\\', 'a', 'b')) p = P('//a/b/c/d') parts = p.parts self.assertEqual(parts, ('\\\\a\\b\\', 'c', 'd')) def test_parent(self): # Anchored P = self.cls p = P('z:a/b/c') self.assertEqual(p.parent, P('z:a/b')) self.assertEqual(p.parent.parent, P('z:a')) self.assertEqual(p.parent.parent.parent, P('z:')) self.assertEqual(p.parent.parent.parent.parent, P('z:')) p = P('z:/a/b/c') self.assertEqual(p.parent, P('z:/a/b')) self.assertEqual(p.parent.parent, P('z:/a')) self.assertEqual(p.parent.parent.parent, P('z:/')) self.assertEqual(p.parent.parent.parent.parent, P('z:/')) p = P('//a/b/c/d') self.assertEqual(p.parent, P('//a/b/c')) self.assertEqual(p.parent.parent, P('//a/b')) self.assertEqual(p.parent.parent.parent, P('//a/b')) def test_parents(self): # Anchored P = self.cls p = P('z:a/b/') par = p.parents self.assertEqual(len(par), 2) self.assertEqual(par[0], P('z:a')) self.assertEqual(par[1], P('z:')) self.assertEqual(list(par), [P('z:a'), P('z:')]) with self.assertRaises(IndexError): par[2] p = P('z:/a/b/') par = p.parents self.assertEqual(len(par), 2) self.assertEqual(par[0], P('z:/a')) self.assertEqual(par[1], P('z:/')) self.assertEqual(list(par), [P('z:/a'), P('z:/')]) with self.assertRaises(IndexError): par[2] p = P('//a/b/c/d') par = p.parents self.assertEqual(len(par), 2) self.assertEqual(par[0], P('//a/b/c')) self.assertEqual(par[1], P('//a/b')) self.assertEqual(list(par), [P('//a/b/c'), P('//a/b')]) with self.assertRaises(IndexError): par[2] def test_drive(self): P = self.cls self.assertEqual(P('c:').drive, 'c:') self.assertEqual(P('c:a/b').drive, 'c:') self.assertEqual(P('c:/').drive, 'c:') self.assertEqual(P('c:/a/b/').drive, 'c:') self.assertEqual(P('//a/b').drive, '\\\\a\\b') self.assertEqual(P('//a/b/').drive, '\\\\a\\b') self.assertEqual(P('//a/b/c/d').drive, '\\\\a\\b') def test_root(self): P = self.cls self.assertEqual(P('c:').root, '') self.assertEqual(P('c:a/b').root, '') self.assertEqual(P('c:/').root, '\\') self.assertEqual(P('c:/a/b/').root, '\\') self.assertEqual(P('//a/b').root, '\\') self.assertEqual(P('//a/b/').root, '\\') self.assertEqual(P('//a/b/c/d').root, '\\') def test_anchor(self): P = self.cls self.assertEqual(P('c:').anchor, 'c:') self.assertEqual(P('c:a/b').anchor, 'c:') self.assertEqual(P('c:/').anchor, 'c:\\') self.assertEqual(P('c:/a/b/').anchor, 'c:\\') self.assertEqual(P('//a/b').anchor, '\\\\a\\b\\') self.assertEqual(P('//a/b/').anchor, '\\\\a\\b\\') self.assertEqual(P('//a/b/c/d').anchor, '\\\\a\\b\\') def test_name(self): P = self.cls self.assertEqual(P('c:').name, '') self.assertEqual(P('c:/').name, '') self.assertEqual(P('c:a/b').name, 'b') self.assertEqual(P('c:/a/b').name, 'b') self.assertEqual(P('c:a/b.py').name, 'b.py') self.assertEqual(P('c:/a/b.py').name, 'b.py') self.assertEqual(P('//My.py/Share.php').name, '') self.assertEqual(P('//My.py/Share.php/a/b').name, 'b') def test_suffix(self): P = self.cls self.assertEqual(P('c:').suffix, '') self.assertEqual(P('c:/').suffix, '') self.assertEqual(P('c:a/b').suffix, '') self.assertEqual(P('c:/a/b').suffix, '') self.assertEqual(P('c:a/b.py').suffix, '.py') self.assertEqual(P('c:/a/b.py').suffix, '.py') self.assertEqual(P('c:a/.hgrc').suffix, '') self.assertEqual(P('c:/a/.hgrc').suffix, '') self.assertEqual(P('c:a/.hg.rc').suffix, '.rc') self.assertEqual(P('c:/a/.hg.rc').suffix, '.rc') self.assertEqual(P('c:a/b.tar.gz').suffix, '.gz') self.assertEqual(P('c:/a/b.tar.gz').suffix, '.gz') self.assertEqual(P('c:a/Some name. Ending with a dot.').suffix, '') self.assertEqual(P('c:/a/Some name. Ending with a dot.').suffix, '') self.assertEqual(P('//My.py/Share.php').suffix, '') self.assertEqual(P('//My.py/Share.php/a/b').suffix, '') def test_suffixes(self): P = self.cls self.assertEqual(P('c:').suffixes, []) self.assertEqual(P('c:/').suffixes, []) self.assertEqual(P('c:a/b').suffixes, []) self.assertEqual(P('c:/a/b').suffixes, []) self.assertEqual(P('c:a/b.py').suffixes, ['.py']) self.assertEqual(P('c:/a/b.py').suffixes, ['.py']) self.assertEqual(P('c:a/.hgrc').suffixes, []) self.assertEqual(P('c:/a/.hgrc').suffixes, []) self.assertEqual(P('c:a/.hg.rc').suffixes, ['.rc']) self.assertEqual(P('c:/a/.hg.rc').suffixes, ['.rc']) self.assertEqual(P('c:a/b.tar.gz').suffixes, ['.tar', '.gz']) self.assertEqual(P('c:/a/b.tar.gz').suffixes, ['.tar', '.gz']) self.assertEqual(P('//My.py/Share.php').suffixes, []) self.assertEqual(P('//My.py/Share.php/a/b').suffixes, []) self.assertEqual(P('c:a/Some name. Ending with a dot.').suffixes, []) self.assertEqual(P('c:/a/Some name. Ending with a dot.').suffixes, []) def test_stem(self): P = self.cls self.assertEqual(P('c:').stem, '') self.assertEqual(P('c:.').stem, '') self.assertEqual(P('c:..').stem, '..') self.assertEqual(P('c:/').stem, '') self.assertEqual(P('c:a/b').stem, 'b') self.assertEqual(P('c:a/b.py').stem, 'b') self.assertEqual(P('c:a/.hgrc').stem, '.hgrc') self.assertEqual(P('c:a/.hg.rc').stem, '.hg') self.assertEqual(P('c:a/b.tar.gz').stem, 'b.tar') self.assertEqual(P('c:a/Some name. Ending with a dot.').stem, 'Some name. Ending with a dot.') def test_with_name(self): P = self.cls self.assertEqual(P('c:a/b').with_name('d.xml'), P('c:a/d.xml')) self.assertEqual(P('c:/a/b').with_name('d.xml'), P('c:/a/d.xml')) self.assertEqual(P('c:a/Dot ending.').with_name('d.xml'), P('c:a/d.xml')) self.assertEqual(P('c:/a/Dot ending.').with_name('d.xml'), P('c:/a/d.xml')) self.assertRaises(ValueError, P('c:').with_name, 'd.xml') self.assertRaises(ValueError, P('c:/').with_name, 'd.xml') self.assertRaises(ValueError, P('//My/Share').with_name, 'd.xml') self.assertRaises(ValueError, P('c:a/b').with_name, 'd:') self.assertRaises(ValueError, P('c:a/b').with_name, 'd:e') self.assertRaises(ValueError, P('c:a/b').with_name, 'd:/e') self.assertRaises(ValueError, P('c:a/b').with_name, '//My/Share') def test_with_suffix(self): P = self.cls self.assertEqual(P('c:a/b').with_suffix('.gz'), P('c:a/b.gz')) self.assertEqual(P('c:/a/b').with_suffix('.gz'), P('c:/a/b.gz')) self.assertEqual(P('c:a/b.py').with_suffix('.gz'), P('c:a/b.gz')) self.assertEqual(P('c:/a/b.py').with_suffix('.gz'), P('c:/a/b.gz')) # Path doesn't have a "filename" component self.assertRaises(ValueError, P('').with_suffix, '.gz') self.assertRaises(ValueError, P('.').with_suffix, '.gz') self.assertRaises(ValueError, P('/').with_suffix, '.gz') self.assertRaises(ValueError, P('//My/Share').with_suffix, '.gz') # Invalid suffix self.assertRaises(ValueError, P('c:a/b').with_suffix, 'gz') self.assertRaises(ValueError, P('c:a/b').with_suffix, '/') self.assertRaises(ValueError, P('c:a/b').with_suffix, '\\') self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c:') self.assertRaises(ValueError, P('c:a/b').with_suffix, '/.gz') self.assertRaises(ValueError, P('c:a/b').with_suffix, '\\.gz') self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c:.gz') self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c/d') self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c\\d') self.assertRaises(ValueError, P('c:a/b').with_suffix, '.c/d') self.assertRaises(ValueError, P('c:a/b').with_suffix, '.c\\d') def test_relative_to(self): P = self.cls p = P('C:Foo/Bar') self.assertEqual(p.relative_to(P('c:')), P('Foo/Bar')) self.assertEqual(p.relative_to('c:'), P('Foo/Bar')) self.assertEqual(p.relative_to(P('c:foO')), P('Bar')) self.assertEqual(p.relative_to('c:foO'), P('Bar')) self.assertEqual(p.relative_to('c:foO/'), P('Bar')) self.assertEqual(p.relative_to(P('c:foO/baR')), P()) self.assertEqual(p.relative_to('c:foO/baR'), P()) # Unrelated paths self.assertRaises(ValueError, p.relative_to, P()) self.assertRaises(ValueError, p.relative_to, '') self.assertRaises(ValueError, p.relative_to, P('d:')) self.assertRaises(ValueError, p.relative_to, P('/')) self.assertRaises(ValueError, p.relative_to, P('Foo')) self.assertRaises(ValueError, p.relative_to, P('/Foo')) self.assertRaises(ValueError, p.relative_to, P('C:/Foo')) self.assertRaises(ValueError, p.relative_to, P('C:Foo/Bar/Baz')) self.assertRaises(ValueError, p.relative_to, P('C:Foo/Baz')) p = P('C:/Foo/Bar') self.assertEqual(p.relative_to(P('c:')), P('/Foo/Bar')) self.assertEqual(p.relative_to('c:'), P('/Foo/Bar')) self.assertEqual(str(p.relative_to(P('c:'))), '\\Foo\\Bar') self.assertEqual(str(p.relative_to('c:')), '\\Foo\\Bar') self.assertEqual(p.relative_to(P('c:/')), P('Foo/Bar')) self.assertEqual(p.relative_to('c:/'), P('Foo/Bar')) self.assertEqual(p.relative_to(P('c:/foO')), P('Bar')) self.assertEqual(p.relative_to('c:/foO'), P('Bar')) self.assertEqual(p.relative_to('c:/foO/'), P('Bar')) self.assertEqual(p.relative_to(P('c:/foO/baR')), P()) self.assertEqual(p.relative_to('c:/foO/baR'), P()) # Unrelated paths self.assertRaises(ValueError, p.relative_to, P('C:/Baz')) self.assertRaises(ValueError, p.relative_to, P('C:/Foo/Bar/Baz')) self.assertRaises(ValueError, p.relative_to, P('C:/Foo/Baz')) self.assertRaises(ValueError, p.relative_to, P('C:Foo')) self.assertRaises(ValueError, p.relative_to, P('d:')) self.assertRaises(ValueError, p.relative_to, P('d:/')) self.assertRaises(ValueError, p.relative_to, P('/')) self.assertRaises(ValueError, p.relative_to, P('/Foo')) self.assertRaises(ValueError, p.relative_to, P('//C/Foo')) # UNC paths p = P('//Server/Share/Foo/Bar') self.assertEqual(p.relative_to(P('//sErver/sHare')), P('Foo/Bar')) self.assertEqual(p.relative_to('//sErver/sHare'), P('Foo/Bar')) self.assertEqual(p.relative_to('//sErver/sHare/'), P('Foo/Bar')) self.assertEqual(p.relative_to(P('//sErver/sHare/Foo')), P('Bar')) self.assertEqual(p.relative_to('//sErver/sHare/Foo'), P('Bar')) self.assertEqual(p.relative_to('//sErver/sHare/Foo/'), P('Bar')) self.assertEqual(p.relative_to(P('//sErver/sHare/Foo/Bar')), P()) self.assertEqual(p.relative_to('//sErver/sHare/Foo/Bar'), P()) # Unrelated paths self.assertRaises(ValueError, p.relative_to, P('/Server/Share/Foo')) self.assertRaises(ValueError, p.relative_to, P('c:/Server/Share/Foo')) self.assertRaises(ValueError, p.relative_to, P('//z/Share/Foo')) self.assertRaises(ValueError, p.relative_to, P('//Server/z/Foo')) def test_is_absolute(self): P = self.cls # Under NT, only paths with both a drive and a root are absolute self.assertFalse(P().is_absolute()) self.assertFalse(P('a').is_absolute()) self.assertFalse(P('a/b/').is_absolute()) self.assertFalse(P('/').is_absolute()) self.assertFalse(P('/a').is_absolute()) self.assertFalse(P('/a/b/').is_absolute()) self.assertFalse(P('c:').is_absolute()) self.assertFalse(P('c:a').is_absolute()) self.assertFalse(P('c:a/b/').is_absolute()) self.assertTrue(P('c:/').is_absolute()) self.assertTrue(P('c:/a').is_absolute()) self.assertTrue(P('c:/a/b/').is_absolute()) # UNC paths are absolute by definition self.assertTrue(P('//a/b').is_absolute()) self.assertTrue(P('//a/b/').is_absolute()) self.assertTrue(P('//a/b/c').is_absolute()) self.assertTrue(P('//a/b/c/d').is_absolute()) def test_join(self): P = self.cls p = P('C:/a/b') pp = p.joinpath('x/y') self.assertEqual(pp, P('C:/a/b/x/y')) pp = p.joinpath('/x/y') self.assertEqual(pp, P('C:/x/y')) # Joining with a different drive => the first path is ignored, even # if the second path is relative. pp = p.joinpath('D:x/y') self.assertEqual(pp, P('D:x/y')) pp = p.joinpath('D:/x/y') self.assertEqual(pp, P('D:/x/y')) pp = p.joinpath('//host/share/x/y') self.assertEqual(pp, P('//host/share/x/y')) # Joining with the same drive => the first path is appended to if # the second path is relative. pp = p.joinpath('c:x/y') self.assertEqual(pp, P('C:/a/b/x/y')) pp = p.joinpath('c:/x/y') self.assertEqual(pp, P('C:/x/y')) def test_div(self): # Basically the same as joinpath() P = self.cls p = P('C:/a/b') self.assertEqual(p / 'x/y', P('C:/a/b/x/y')) self.assertEqual(p / 'x' / 'y', P('C:/a/b/x/y')) self.assertEqual(p / '/x/y', P('C:/x/y')) self.assertEqual(p / '/x' / 'y', P('C:/x/y')) # Joining with a different drive => the first path is ignored, even # if the second path is relative. self.assertEqual(p / 'D:x/y', P('D:x/y')) self.assertEqual(p / 'D:' / 'x/y', P('D:x/y')) self.assertEqual(p / 'D:/x/y', P('D:/x/y')) self.assertEqual(p / 'D:' / '/x/y', P('D:/x/y')) self.assertEqual(p / '//host/share/x/y', P('//host/share/x/y')) # Joining with the same drive => the first path is appended to if # the second path is relative. self.assertEqual(p / 'c:x/y', P('C:/a/b/x/y')) self.assertEqual(p / 'c:/x/y', P('C:/x/y')) def test_is_reserved(self): P = self.cls self.assertIs(False, P('').is_reserved()) self.assertIs(False, P('/').is_reserved()) self.assertIs(False, P('/foo/bar').is_reserved()) self.assertIs(True, P('con').is_reserved()) self.assertIs(True, P('NUL').is_reserved()) self.assertIs(True, P('NUL.txt').is_reserved()) self.assertIs(True, P('com1').is_reserved()) self.assertIs(True, P('com9.bar').is_reserved()) self.assertIs(False, P('bar.com9').is_reserved()) self.assertIs(True, P('lpt1').is_reserved()) self.assertIs(True, P('lpt9.bar').is_reserved()) self.assertIs(False, P('bar.lpt9').is_reserved()) # Only the last component matters self.assertIs(False, P('c:/NUL/con/baz').is_reserved()) # UNC paths are never reserved self.assertIs(False, P('//my/share/nul/con/aux').is_reserved()) class PurePathTest(_BasePurePathTest, unittest.TestCase): cls = pathlib.PurePath def test_concrete_class(self): p = self.cls('a') self.assertIs(type(p), pathlib.PureWindowsPath if os.name == 'nt' else pathlib.PurePosixPath) def test_different_flavours_unequal(self): p = pathlib.PurePosixPath('a') q = pathlib.PureWindowsPath('a') self.assertNotEqual(p, q) def test_different_flavours_unordered(self): p = pathlib.PurePosixPath('a') q = pathlib.PureWindowsPath('a') with self.assertRaises(TypeError): p < q with self.assertRaises(TypeError): p <= q with self.assertRaises(TypeError): p > q with self.assertRaises(TypeError): p >= q # # Tests for the concrete classes # # Make sure any symbolic links in the base test path are resolved BASE = os.path.realpath(TESTFN) join = lambda *x: os.path.join(BASE, *x) rel_join = lambda *x: os.path.join(TESTFN, *x) def symlink_skip_reason(): return "no system support for symlinks" if not pathlib.supports_symlinks: return "no system support for symlinks" try: os.symlink(__file__, BASE) except OSError as e: return str(e) else: support.unlink(BASE) return None symlink_skip_reason = symlink_skip_reason() only_nt = unittest.skipIf(os.name != 'nt', 'test requires a Windows-compatible system') only_posix = unittest.skipIf(os.name == 'nt', 'test requires a POSIX-compatible system') with_symlinks = unittest.skipIf(symlink_skip_reason, symlink_skip_reason) @only_posix class PosixPathAsPureTest(PurePosixPathTest): cls = pathlib.PosixPath @only_nt class WindowsPathAsPureTest(PureWindowsPathTest): cls = pathlib.WindowsPath def test_owner(self): P = self.cls with self.assertRaises(NotImplementedError): P('c:/').owner() def test_group(self): P = self.cls with self.assertRaises(NotImplementedError): P('c:/').group() class _BasePathTest(object): """Tests for the FS-accessing functionalities of the Path classes.""" # (BASE) # | # |-- brokenLink -> non-existing # |-- dirA # | `-- linkC -> ../dirB # |-- dirB # | |-- fileB # | `-- linkD -> ../dirB # |-- dirC # | |-- dirD # | | `-- fileD # | `-- fileC # |-- dirE # No permissions # |-- fileA # |-- linkA -> fileA # `-- linkB -> dirB # def setUp(self): def cleanup(): os.chmod(join('dirE'), 0o777) support.rmtree(BASE) self.addCleanup(cleanup) os.mkdir(BASE) os.mkdir(join('dirA')) os.mkdir(join('dirB')) os.mkdir(join('dirC')) os.mkdir(join('dirC', 'dirD')) os.mkdir(join('dirE')) with open(join('fileA'), 'wb') as f: f.write(b"this is file A\n") with open(join('dirB', 'fileB'), 'wb') as f: f.write(b"this is file B\n") with open(join('dirC', 'fileC'), 'wb') as f: f.write(b"this is file C\n") with open(join('dirC', 'dirD', 'fileD'), 'wb') as f: f.write(b"this is file D\n") os.chmod(join('dirE'), 0) if not symlink_skip_reason: # Relative symlinks os.symlink('fileA', join('linkA')) os.symlink('non-existing', join('brokenLink')) self.dirlink('dirB', join('linkB')) self.dirlink(os.path.join('..', 'dirB'), join('dirA', 'linkC')) # This one goes upwards, creating a loop self.dirlink(os.path.join('..', 'dirB'), join('dirB', 'linkD')) if os.name == 'nt': # Workaround for http://bugs.python.org/issue13772 def dirlink(self, src, dest): os.symlink(src, dest, target_is_directory=True) else: def dirlink(self, src, dest): os.symlink(src, dest) def assertSame(self, path_a, path_b): self.assertTrue(os.path.samefile(str(path_a), str(path_b)), "%r and %r don't point to the same file" % (path_a, path_b)) def assertFileNotFound(self, func, *args, **kwargs): with self.assertRaises(FileNotFoundError) as cm: func(*args, **kwargs) self.assertEqual(cm.exception.errno, errno.ENOENT) def _test_cwd(self, p): q = self.cls(os.getcwd()) self.assertEqual(p, q) self.assertEqual(str(p), str(q)) self.assertIs(type(p), type(q)) self.assertTrue(p.is_absolute()) def test_cwd(self): p = self.cls.cwd() self._test_cwd(p) def _test_home(self, p): q = self.cls(os.path.expanduser('~')) self.assertEqual(p, q) self.assertEqual(str(p), str(q)) self.assertIs(type(p), type(q)) self.assertTrue(p.is_absolute()) def test_home(self): p = self.cls.home() self._test_home(p) def test_samefile(self): fileA_path = os.path.join(BASE, 'fileA') fileB_path = os.path.join(BASE, 'dirB', 'fileB') p = self.cls(fileA_path) pp = self.cls(fileA_path) q = self.cls(fileB_path) self.assertTrue(p.samefile(fileA_path)) self.assertTrue(p.samefile(pp)) self.assertFalse(p.samefile(fileB_path)) self.assertFalse(p.samefile(q)) # Test the non-existent file case non_existent = os.path.join(BASE, 'foo') r = self.cls(non_existent) self.assertRaises(FileNotFoundError, p.samefile, r) self.assertRaises(FileNotFoundError, p.samefile, non_existent) self.assertRaises(FileNotFoundError, r.samefile, p) self.assertRaises(FileNotFoundError, r.samefile, non_existent) self.assertRaises(FileNotFoundError, r.samefile, r) self.assertRaises(FileNotFoundError, r.samefile, non_existent) def test_empty_path(self): # The empty path points to '.' p = self.cls('') self.assertEqual(p.stat(), os.stat('.')) def test_expanduser_common(self): P = self.cls p = P('~') self.assertEqual(p.expanduser(), P(os.path.expanduser('~'))) p = P('foo') self.assertEqual(p.expanduser(), p) p = P('/~') self.assertEqual(p.expanduser(), p) p = P('../~') self.assertEqual(p.expanduser(), p) p = P(P('').absolute().anchor) / '~' self.assertEqual(p.expanduser(), p) def test_exists(self): P = self.cls p = P(BASE) self.assertIs(True, p.exists()) self.assertIs(True, (p / 'dirA').exists()) self.assertIs(True, (p / 'fileA').exists()) self.assertIs(False, (p / 'fileA' / 'bah').exists()) if not symlink_skip_reason: self.assertIs(True, (p / 'linkA').exists()) self.assertIs(True, (p / 'linkB').exists()) self.assertIs(True, (p / 'linkB' / 'fileB').exists()) self.assertIs(False, (p / 'linkA' / 'bah').exists()) self.assertIs(False, (p / 'foo').exists()) self.assertIs(False, P('/xyzzy').exists()) def test_open_common(self): p = self.cls(BASE) with (p / 'fileA').open('r') as f: self.assertIsInstance(f, io.TextIOBase) self.assertEqual(f.read(), "this is file A\n") with (p / 'fileA').open('rb') as f: self.assertIsInstance(f, io.BufferedIOBase) self.assertEqual(f.read().strip(), b"this is file A") with (p / 'fileA').open('rb', buffering=0) as f: self.assertIsInstance(f, io.RawIOBase) self.assertEqual(f.read().strip(), b"this is file A") def test_read_write_bytes(self): p = self.cls(BASE) (p / 'fileA').write_bytes(b'abcdefg') self.assertEqual((p / 'fileA').read_bytes(), b'abcdefg') # check that trying to write str does not truncate the file self.assertRaises(TypeError, (p / 'fileA').write_bytes, 'somestr') self.assertEqual((p / 'fileA').read_bytes(), b'abcdefg') def test_read_write_text(self): p = self.cls(BASE) (p / 'fileA').write_text('äbcdefg', encoding='latin-1') self.assertEqual((p / 'fileA').read_text( encoding='utf-8', errors='ignore'), 'bcdefg') # check that trying to write bytes does not truncate the file self.assertRaises(TypeError, (p / 'fileA').write_text, b'somebytes') self.assertEqual((p / 'fileA').read_text(encoding='latin-1'), 'äbcdefg') def test_iterdir(self): P = self.cls p = P(BASE) it = p.iterdir() paths = set(it) expected = ['dirA', 'dirB', 'dirC', 'dirE', 'fileA'] if not symlink_skip_reason: expected += ['linkA', 'linkB', 'brokenLink'] self.assertEqual(paths, { P(BASE, q) for q in expected }) @with_symlinks def test_iterdir_symlink(self): # __iter__ on a symlink to a directory P = self.cls p = P(BASE, 'linkB') paths = set(p.iterdir()) expected = { P(BASE, 'linkB', q) for q in ['fileB', 'linkD'] } self.assertEqual(paths, expected) def test_iterdir_nodir(self): # __iter__ on something that is not a directory p = self.cls(BASE, 'fileA') with self.assertRaises(OSError) as cm: next(p.iterdir()) # ENOENT or EINVAL under Windows, ENOTDIR otherwise # (see issue #12802) self.assertIn(cm.exception.errno, (errno.ENOTDIR, errno.ENOENT, errno.EINVAL)) def test_glob_common(self): def _check(glob, expected): self.assertEqual(set(glob), { P(BASE, q) for q in expected }) P = self.cls p = P(BASE) it = p.glob("fileA") self.assertIsInstance(it, collections.Iterator) _check(it, ["fileA"]) _check(p.glob("fileB"), []) _check(p.glob("dir*/file*"), ["dirB/fileB", "dirC/fileC"]) if symlink_skip_reason: _check(p.glob("*A"), ['dirA', 'fileA']) else: _check(p.glob("*A"), ['dirA', 'fileA', 'linkA']) if symlink_skip_reason: _check(p.glob("*B/*"), ['dirB/fileB']) else: _check(p.glob("*B/*"), ['dirB/fileB', 'dirB/linkD', 'linkB/fileB', 'linkB/linkD']) if symlink_skip_reason: _check(p.glob("*/fileB"), ['dirB/fileB']) else: _check(p.glob("*/fileB"), ['dirB/fileB', 'linkB/fileB']) def test_rglob_common(self): def _check(glob, expected): self.assertEqual(set(glob), { P(BASE, q) for q in expected }) P = self.cls p = P(BASE) it = p.rglob("fileA") self.assertIsInstance(it, collections.Iterator) _check(it, ["fileA"]) _check(p.rglob("fileB"), ["dirB/fileB"]) _check(p.rglob("*/fileA"), []) if symlink_skip_reason: _check(p.rglob("*/fileB"), ["dirB/fileB"]) else: _check(p.rglob("*/fileB"), ["dirB/fileB", "dirB/linkD/fileB", "linkB/fileB", "dirA/linkC/fileB"]) _check(p.rglob("file*"), ["fileA", "dirB/fileB", "dirC/fileC", "dirC/dirD/fileD"]) p = P(BASE, "dirC") _check(p.rglob("file*"), ["dirC/fileC", "dirC/dirD/fileD"]) _check(p.rglob("*/*"), ["dirC/dirD/fileD"]) @with_symlinks def test_rglob_symlink_loop(self): # Don't get fooled by symlink loops (Issue #26012) P = self.cls p = P(BASE) given = set(p.rglob('*')) expect = {'brokenLink', 'dirA', 'dirA/linkC', 'dirB', 'dirB/fileB', 'dirB/linkD', 'dirC', 'dirC/dirD', 'dirC/dirD/fileD', 'dirC/fileC', 'dirE', 'fileA', 'linkA', 'linkB', } self.assertEqual(given, {p / x for x in expect}) def test_glob_dotdot(self): # ".." is not special in globs P = self.cls p = P(BASE) self.assertEqual(set(p.glob("..")), { P(BASE, "..") }) self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") }) self.assertEqual(set(p.glob("../xyzzy")), set()) def _check_resolve(self, p, expected, strict=True): q = p.resolve(strict) self.assertEqual(q, expected) # this can be used to check both relative and absolute resolutions _check_resolve_relative = _check_resolve_absolute = _check_resolve @with_symlinks def test_resolve_common(self): P = self.cls p = P(BASE, 'foo') with self.assertRaises(OSError) as cm: p.resolve(strict=True) self.assertEqual(cm.exception.errno, errno.ENOENT) # Non-strict self.assertEqual(str(p.resolve(strict=False)), os.path.join(BASE, 'foo')) p = P(BASE, 'foo', 'in', 'spam') self.assertEqual(str(p.resolve(strict=False)), os.path.join(BASE, 'foo', 'in', 'spam')) p = P(BASE, '..', 'foo', 'in', 'spam') self.assertEqual(str(p.resolve(strict=False)), os.path.abspath(os.path.join('foo', 'in', 'spam'))) # These are all relative symlinks p = P(BASE, 'dirB', 'fileB') self._check_resolve_relative(p, p) p = P(BASE, 'linkA') self._check_resolve_relative(p, P(BASE, 'fileA')) p = P(BASE, 'dirA', 'linkC', 'fileB') self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB')) p = P(BASE, 'dirB', 'linkD', 'fileB') self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB')) # Non-strict p = P(BASE, 'dirA', 'linkC', 'fileB', 'foo', 'in', 'spam') self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB', 'foo', 'in', 'spam'), False) p = P(BASE, 'dirA', 'linkC', '..', 'foo', 'in', 'spam') if os.name == 'nt': # In Windows, if linkY points to dirB, 'dirA\linkY\..' # resolves to 'dirA' without resolving linkY first. self._check_resolve_relative(p, P(BASE, 'dirA', 'foo', 'in', 'spam'), False) else: # In Posix, if linkY points to dirB, 'dirA/linkY/..' # resolves to 'dirB/..' first before resolving to parent of dirB. self._check_resolve_relative(p, P(BASE, 'foo', 'in', 'spam'), False) # Now create absolute symlinks d = support._longpath(tempfile.mkdtemp(suffix='-dirD')) self.addCleanup(support.rmtree, d) os.symlink(os.path.join(d), join('dirA', 'linkX')) os.symlink(join('dirB'), os.path.join(d, 'linkY')) p = P(BASE, 'dirA', 'linkX', 'linkY', 'fileB') self._check_resolve_absolute(p, P(BASE, 'dirB', 'fileB')) # Non-strict p = P(BASE, 'dirA', 'linkX', 'linkY', 'foo', 'in', 'spam') self._check_resolve_relative(p, P(BASE, 'dirB', 'foo', 'in', 'spam'), False) p = P(BASE, 'dirA', 'linkX', 'linkY', '..', 'foo', 'in', 'spam') if os.name == 'nt': # In Windows, if linkY points to dirB, 'dirA\linkY\..' # resolves to 'dirA' without resolving linkY first. self._check_resolve_relative(p, P(d, 'foo', 'in', 'spam'), False) else: # In Posix, if linkY points to dirB, 'dirA/linkY/..' # resolves to 'dirB/..' first before resolving to parent of dirB. self._check_resolve_relative(p, P(BASE, 'foo', 'in', 'spam'), False) @with_symlinks def test_resolve_dot(self): # See https://bitbucket.org/pitrou/pathlib/issue/9/pathresolve-fails-on-complex-symlinks p = self.cls(BASE) self.dirlink('.', join('0')) self.dirlink(os.path.join('0', '0'), join('1')) self.dirlink(os.path.join('1', '1'), join('2')) q = p / '2' self.assertEqual(q.resolve(strict=True), p) r = q / '3' / '4' self.assertRaises(FileNotFoundError, r.resolve, strict=True) # Non-strict self.assertEqual(r.resolve(strict=False), p / '3' / '4') def test_with(self): p = self.cls(BASE) it = p.iterdir() it2 = p.iterdir() next(it2) with p: pass # I/O operation on closed path self.assertRaises(ValueError, next, it) self.assertRaises(ValueError, next, it2) self.assertRaises(ValueError, p.open) self.assertRaises(ValueError, p.resolve) self.assertRaises(ValueError, p.absolute) self.assertRaises(ValueError, p.__enter__) def test_chmod(self): p = self.cls(BASE) / 'fileA' mode = p.stat().st_mode # Clear writable bit new_mode = mode & ~0o222 p.chmod(new_mode) self.assertEqual(p.stat().st_mode, new_mode) # Set writable bit new_mode = mode | 0o222 p.chmod(new_mode) self.assertEqual(p.stat().st_mode, new_mode) # XXX also need a test for lchmod def test_stat(self): p = self.cls(BASE) / 'fileA' st = p.stat() self.assertEqual(p.stat(), st) # Change file mode by flipping write bit p.chmod(st.st_mode ^ 0o222) self.addCleanup(p.chmod, st.st_mode) self.assertNotEqual(p.stat(), st) @with_symlinks def test_lstat(self): p = self.cls(BASE)/ 'linkA' st = p.stat() self.assertNotEqual(st, p.lstat()) def test_lstat_nosymlink(self): p = self.cls(BASE) / 'fileA' st = p.stat() self.assertEqual(st, p.lstat()) @unittest.skipUnless(pwd, "the pwd module is needed for this test") def test_owner(self): p = self.cls(BASE) / 'fileA' uid = p.stat().st_uid try: name = pwd.getpwuid(uid).pw_name except KeyError: self.skipTest( "user %d doesn't have an entry in the system database" % uid) self.assertEqual(name, p.owner()) @unittest.skipUnless(grp, "the grp module is needed for this test") def test_group(self): p = self.cls(BASE) / 'fileA' gid = p.stat().st_gid try: name = grp.getgrgid(gid).gr_name except KeyError: self.skipTest( "group %d doesn't have an entry in the system database" % gid) self.assertEqual(name, p.group()) def test_unlink(self): p = self.cls(BASE) / 'fileA' p.unlink() self.assertFileNotFound(p.stat) self.assertFileNotFound(p.unlink) def test_rmdir(self): p = self.cls(BASE) / 'dirA' for q in p.iterdir(): q.unlink() p.rmdir() self.assertFileNotFound(p.stat) self.assertFileNotFound(p.unlink) def test_rename(self): P = self.cls(BASE) p = P / 'fileA' size = p.stat().st_size # Renaming to another path q = P / 'dirA' / 'fileAA' p.rename(q) self.assertEqual(q.stat().st_size, size) self.assertFileNotFound(p.stat) # Renaming to a str of a relative path r = rel_join('fileAAA') q.rename(r) self.assertEqual(os.stat(r).st_size, size) self.assertFileNotFound(q.stat) def test_replace(self): P = self.cls(BASE) p = P / 'fileA' size = p.stat().st_size # Replacing a non-existing path q = P / 'dirA' / 'fileAA' p.replace(q) self.assertEqual(q.stat().st_size, size) self.assertFileNotFound(p.stat) # Replacing another (existing) path r = rel_join('dirB', 'fileB') q.replace(r) self.assertEqual(os.stat(r).st_size, size) self.assertFileNotFound(q.stat) def test_touch_common(self): P = self.cls(BASE) p = P / 'newfileA' self.assertFalse(p.exists()) p.touch() self.assertTrue(p.exists()) st = p.stat() old_mtime = st.st_mtime old_mtime_ns = st.st_mtime_ns # Rewind the mtime sufficiently far in the past to work around # filesystem-specific timestamp granularity. os.utime(str(p), (old_mtime - 10, old_mtime - 10)) # The file mtime should be refreshed by calling touch() again p.touch() st = p.stat() self.assertGreaterEqual(st.st_mtime_ns, old_mtime_ns) self.assertGreaterEqual(st.st_mtime, old_mtime) # Now with exist_ok=False p = P / 'newfileB' self.assertFalse(p.exists()) p.touch(mode=0o700, exist_ok=False) self.assertTrue(p.exists()) self.assertRaises(OSError, p.touch, exist_ok=False) def test_touch_nochange(self): P = self.cls(BASE) p = P / 'fileA' p.touch() with p.open('rb') as f: self.assertEqual(f.read().strip(), b"this is file A") def test_mkdir(self): P = self.cls(BASE) p = P / 'newdirA' self.assertFalse(p.exists()) p.mkdir() self.assertTrue(p.exists()) self.assertTrue(p.is_dir()) with self.assertRaises(OSError) as cm: p.mkdir() self.assertEqual(cm.exception.errno, errno.EEXIST) def test_mkdir_parents(self): # Creating a chain of directories p = self.cls(BASE, 'newdirB', 'newdirC') self.assertFalse(p.exists()) with self.assertRaises(OSError) as cm: p.mkdir() self.assertEqual(cm.exception.errno, errno.ENOENT) p.mkdir(parents=True) self.assertTrue(p.exists()) self.assertTrue(p.is_dir()) with self.assertRaises(OSError) as cm: p.mkdir(parents=True) self.assertEqual(cm.exception.errno, errno.EEXIST) # test `mode` arg mode = stat.S_IMODE(p.stat().st_mode) # default mode p = self.cls(BASE, 'newdirD', 'newdirE') p.mkdir(0o555, parents=True) self.assertTrue(p.exists()) self.assertTrue(p.is_dir()) if os.name != 'nt': # the directory's permissions follow the mode argument self.assertEqual(stat.S_IMODE(p.stat().st_mode), 0o7555 & mode) # the parent's permissions follow the default process settings self.assertEqual(stat.S_IMODE(p.parent.stat().st_mode), mode) def test_mkdir_exist_ok(self): p = self.cls(BASE, 'dirB') st_ctime_first = p.stat().st_ctime self.assertTrue(p.exists()) self.assertTrue(p.is_dir()) with self.assertRaises(FileExistsError) as cm: p.mkdir() self.assertEqual(cm.exception.errno, errno.EEXIST) p.mkdir(exist_ok=True) self.assertTrue(p.exists()) self.assertEqual(p.stat().st_ctime, st_ctime_first) def test_mkdir_exist_ok_with_parent(self): p = self.cls(BASE, 'dirC') self.assertTrue(p.exists()) with self.assertRaises(FileExistsError) as cm: p.mkdir() self.assertEqual(cm.exception.errno, errno.EEXIST) p = p / 'newdirC' p.mkdir(parents=True) st_ctime_first = p.stat().st_ctime self.assertTrue(p.exists()) with self.assertRaises(FileExistsError) as cm: p.mkdir(parents=True) self.assertEqual(cm.exception.errno, errno.EEXIST) p.mkdir(parents=True, exist_ok=True) self.assertTrue(p.exists()) self.assertEqual(p.stat().st_ctime, st_ctime_first) def test_mkdir_exist_ok_root(self): # Issue #25803: A drive root could raise PermissionError on Windows self.cls('/').resolve().mkdir(exist_ok=True) self.cls('/').resolve().mkdir(parents=True, exist_ok=True) @only_nt # XXX: not sure how to test this on POSIX def test_mkdir_with_unknown_drive(self): for d in 'ZYXWVUTSRQPONMLKJIHGFEDCBA': p = self.cls(d + ':\\') if not p.is_dir(): break else: self.skipTest("cannot find a drive that doesn't exist") with self.assertRaises(OSError): (p / 'child' / 'path').mkdir(parents=True) def test_mkdir_with_child_file(self): p = self.cls(BASE, 'dirB', 'fileB') self.assertTrue(p.exists()) # An exception is raised when the last path component is an existing # regular file, regardless of whether exist_ok is true or not. with self.assertRaises(FileExistsError) as cm: p.mkdir(parents=True) self.assertEqual(cm.exception.errno, errno.EEXIST) with self.assertRaises(FileExistsError) as cm: p.mkdir(parents=True, exist_ok=True) self.assertEqual(cm.exception.errno, errno.EEXIST) def test_mkdir_no_parents_file(self): p = self.cls(BASE, 'fileA') self.assertTrue(p.exists()) # An exception is raised when the last path component is an existing # regular file, regardless of whether exist_ok is true or not. with self.assertRaises(FileExistsError) as cm: p.mkdir() self.assertEqual(cm.exception.errno, errno.EEXIST) with self.assertRaises(FileExistsError) as cm: p.mkdir(exist_ok=True) self.assertEqual(cm.exception.errno, errno.EEXIST) def test_mkdir_concurrent_parent_creation(self): for pattern_num in range(32): p = self.cls(BASE, 'dirCPC%d' % pattern_num) self.assertFalse(p.exists()) def my_mkdir(path, mode=0o777): path = str(path) # Emulate another process that would create the directory # just before we try to create it ourselves. We do it # in all possible pattern combinations, assuming that this # function is called at most 5 times (dirCPC/dir1/dir2, # dirCPC/dir1, dirCPC, dirCPC/dir1, dirCPC/dir1/dir2). if pattern.pop(): os.mkdir(path, mode) # from another process concurrently_created.add(path) os.mkdir(path, mode) # our real call pattern = [bool(pattern_num & (1 << n)) for n in range(5)] concurrently_created = set() p12 = p / 'dir1' / 'dir2' try: with mock.patch("pathlib._normal_accessor.mkdir", my_mkdir): p12.mkdir(parents=True, exist_ok=False) except FileExistsError: self.assertIn(str(p12), concurrently_created) else: self.assertNotIn(str(p12), concurrently_created) self.assertTrue(p.exists()) @with_symlinks def test_symlink_to(self): P = self.cls(BASE) target = P / 'fileA' # Symlinking a path target link = P / 'dirA' / 'linkAA' link.symlink_to(target) self.assertEqual(link.stat(), target.stat()) self.assertNotEqual(link.lstat(), target.stat()) # Symlinking a str target link = P / 'dirA' / 'linkAAA' link.symlink_to(str(target)) self.assertEqual(link.stat(), target.stat()) self.assertNotEqual(link.lstat(), target.stat()) self.assertFalse(link.is_dir()) # Symlinking to a directory target = P / 'dirB' link = P / 'dirA' / 'linkAAAA' link.symlink_to(target, target_is_directory=True) self.assertEqual(link.stat(), target.stat()) self.assertNotEqual(link.lstat(), target.stat()) self.assertTrue(link.is_dir()) self.assertTrue(list(link.iterdir())) def test_is_dir(self): P = self.cls(BASE) self.assertTrue((P / 'dirA').is_dir()) self.assertFalse((P / 'fileA').is_dir()) self.assertFalse((P / 'non-existing').is_dir()) self.assertFalse((P / 'fileA' / 'bah').is_dir()) if not symlink_skip_reason: self.assertFalse((P / 'linkA').is_dir()) self.assertTrue((P / 'linkB').is_dir()) self.assertFalse((P/ 'brokenLink').is_dir()) def test_is_file(self): P = self.cls(BASE) self.assertTrue((P / 'fileA').is_file()) self.assertFalse((P / 'dirA').is_file()) self.assertFalse((P / 'non-existing').is_file()) self.assertFalse((P / 'fileA' / 'bah').is_file()) if not symlink_skip_reason: self.assertTrue((P / 'linkA').is_file()) self.assertFalse((P / 'linkB').is_file()) self.assertFalse((P/ 'brokenLink').is_file()) def test_is_symlink(self): P = self.cls(BASE) self.assertFalse((P / 'fileA').is_symlink()) self.assertFalse((P / 'dirA').is_symlink()) self.assertFalse((P / 'non-existing').is_symlink()) self.assertFalse((P / 'fileA' / 'bah').is_symlink()) if not symlink_skip_reason: self.assertTrue((P / 'linkA').is_symlink()) self.assertTrue((P / 'linkB').is_symlink()) self.assertTrue((P/ 'brokenLink').is_symlink()) def test_is_fifo_false(self): P = self.cls(BASE) self.assertFalse((P / 'fileA').is_fifo()) self.assertFalse((P / 'dirA').is_fifo()) self.assertFalse((P / 'non-existing').is_fifo()) self.assertFalse((P / 'fileA' / 'bah').is_fifo()) @unittest.skipUnless(hasattr(os, "mkfifo"), "os.mkfifo() required") def test_is_fifo_true(self): P = self.cls(BASE, 'myfifo') try: os.mkfifo(str(P)) except PermissionError as e: self.skipTest('os.mkfifo(): %s' % e) self.assertTrue(P.is_fifo()) self.assertFalse(P.is_socket()) self.assertFalse(P.is_file()) def test_is_socket_false(self): P = self.cls(BASE) self.assertFalse((P / 'fileA').is_socket()) self.assertFalse((P / 'dirA').is_socket()) self.assertFalse((P / 'non-existing').is_socket()) self.assertFalse((P / 'fileA' / 'bah').is_socket()) @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required") def test_is_socket_true(self): P = self.cls(BASE, 'mysock') sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.addCleanup(sock.close) try: sock.bind(str(P)) except OSError as e: if (isinstance(e, PermissionError) or "AF_UNIX path too long" in str(e)): self.skipTest("cannot bind Unix socket: " + str(e)) self.assertTrue(P.is_socket()) self.assertFalse(P.is_fifo()) self.assertFalse(P.is_file()) def test_is_block_device_false(self): P = self.cls(BASE) self.assertFalse((P / 'fileA').is_block_device()) self.assertFalse((P / 'dirA').is_block_device()) self.assertFalse((P / 'non-existing').is_block_device()) self.assertFalse((P / 'fileA' / 'bah').is_block_device()) def test_is_char_device_false(self): P = self.cls(BASE) self.assertFalse((P / 'fileA').is_char_device()) self.assertFalse((P / 'dirA').is_char_device()) self.assertFalse((P / 'non-existing').is_char_device()) self.assertFalse((P / 'fileA' / 'bah').is_char_device()) def test_is_char_device_true(self): # Under Unix, /dev/null should generally be a char device P = self.cls('/dev/null') if not P.exists(): self.skipTest("/dev/null required") self.assertTrue(P.is_char_device()) self.assertFalse(P.is_block_device()) self.assertFalse(P.is_file()) def test_pickling_common(self): p = self.cls(BASE, 'fileA') for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): dumped = pickle.dumps(p, proto) pp = pickle.loads(dumped) self.assertEqual(pp.stat(), p.stat()) def test_parts_interning(self): P = self.cls p = P('/usr/bin/foo') q = P('/usr/local/bin') # 'usr' self.assertIs(p.parts[1], q.parts[1]) # 'bin' self.assertIs(p.parts[2], q.parts[3]) def _check_complex_symlinks(self, link0_target): # Test solving a non-looping chain of symlinks (issue #19887) P = self.cls(BASE) self.dirlink(os.path.join('link0', 'link0'), join('link1')) self.dirlink(os.path.join('link1', 'link1'), join('link2')) self.dirlink(os.path.join('link2', 'link2'), join('link3')) self.dirlink(link0_target, join('link0')) # Resolve absolute paths p = (P / 'link0').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) p = (P / 'link1').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) p = (P / 'link2').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) p = (P / 'link3').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) # Resolve relative paths old_path = os.getcwd() os.chdir(BASE) try: p = self.cls('link0').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) p = self.cls('link1').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) p = self.cls('link2').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) p = self.cls('link3').resolve() self.assertEqual(p, P) self.assertEqual(str(p), BASE) finally: os.chdir(old_path) @with_symlinks def test_complex_symlinks_absolute(self): self._check_complex_symlinks(BASE) @with_symlinks def test_complex_symlinks_relative(self): self._check_complex_symlinks('.') @with_symlinks def test_complex_symlinks_relative_dot_dot(self): self._check_complex_symlinks(os.path.join('dirA', '..')) class PathTest(_BasePathTest, unittest.TestCase): cls = pathlib.Path def test_concrete_class(self): p = self.cls('a') self.assertIs(type(p), pathlib.WindowsPath if os.name == 'nt' else pathlib.PosixPath) def test_unsupported_flavour(self): if os.name == 'nt': self.assertRaises(NotImplementedError, pathlib.PosixPath) else: self.assertRaises(NotImplementedError, pathlib.WindowsPath) def test_glob_empty_pattern(self): p = self.cls() with self.assertRaisesRegex(ValueError, 'Unacceptable pattern'): list(p.glob('')) @only_posix class PosixPathTest(_BasePathTest, unittest.TestCase): cls = pathlib.PosixPath def _check_symlink_loop(self, *args, strict=True): path = self.cls(*args) with self.assertRaises(RuntimeError): print(path.resolve(strict)) def test_open_mode(self): old_mask = os.umask(0) self.addCleanup(os.umask, old_mask) p = self.cls(BASE) with (p / 'new_file').open('wb'): pass st = os.stat(join('new_file')) self.assertEqual(stat.S_IMODE(st.st_mode), 0o666) os.umask(0o022) with (p / 'other_new_file').open('wb'): pass st = os.stat(join('other_new_file')) self.assertEqual(stat.S_IMODE(st.st_mode), 0o644) def test_touch_mode(self): old_mask = os.umask(0) self.addCleanup(os.umask, old_mask) p = self.cls(BASE) (p / 'new_file').touch() st = os.stat(join('new_file')) self.assertEqual(stat.S_IMODE(st.st_mode), 0o666) os.umask(0o022) (p / 'other_new_file').touch() st = os.stat(join('other_new_file')) self.assertEqual(stat.S_IMODE(st.st_mode), 0o644) (p / 'masked_new_file').touch(mode=0o750) st = os.stat(join('masked_new_file')) self.assertEqual(stat.S_IMODE(st.st_mode), 0o750) @with_symlinks def test_resolve_loop(self): # Loops with relative symlinks os.symlink('linkX/inside', join('linkX')) self._check_symlink_loop(BASE, 'linkX') os.symlink('linkY', join('linkY')) self._check_symlink_loop(BASE, 'linkY') os.symlink('linkZ/../linkZ', join('linkZ')) self._check_symlink_loop(BASE, 'linkZ') # Non-strict self._check_symlink_loop(BASE, 'linkZ', 'foo', strict=False) # Loops with absolute symlinks os.symlink(join('linkU/inside'), join('linkU')) self._check_symlink_loop(BASE, 'linkU') os.symlink(join('linkV'), join('linkV')) self._check_symlink_loop(BASE, 'linkV') os.symlink(join('linkW/../linkW'), join('linkW')) self._check_symlink_loop(BASE, 'linkW') # Non-strict self._check_symlink_loop(BASE, 'linkW', 'foo', strict=False) def test_glob(self): P = self.cls p = P(BASE) given = set(p.glob("FILEa")) expect = set() if not support.fs_is_case_insensitive(BASE) else given self.assertEqual(given, expect) self.assertEqual(set(p.glob("FILEa*")), set()) def test_rglob(self): P = self.cls p = P(BASE, "dirC") given = set(p.rglob("FILEd")) expect = set() if not support.fs_is_case_insensitive(BASE) else given self.assertEqual(given, expect) self.assertEqual(set(p.rglob("FILEd*")), set()) @unittest.skipUnless(hasattr(pwd, 'getpwall'), 'pwd module does not expose getpwall()') def test_expanduser(self): P = self.cls support.import_module('pwd') import pwd pwdent = pwd.getpwuid(os.getuid()) username = pwdent.pw_name userhome = pwdent.pw_dir.rstrip('/') or '/' # find arbitrary different user (if exists) for pwdent in pwd.getpwall(): othername = pwdent.pw_name otherhome = pwdent.pw_dir.rstrip('/') if othername != username and otherhome: break else: othername = username otherhome = userhome p1 = P('~/Documents') p2 = P('~' + username + '/Documents') p3 = P('~' + othername + '/Documents') p4 = P('../~' + username + '/Documents') p5 = P('/~' + username + '/Documents') p6 = P('') p7 = P('~fakeuser/Documents') with support.EnvironmentVarGuard() as env: env.pop('HOME', None) self.assertEqual(p1.expanduser(), P(userhome) / 'Documents') self.assertEqual(p2.expanduser(), P(userhome) / 'Documents') self.assertEqual(p3.expanduser(), P(otherhome) / 'Documents') self.assertEqual(p4.expanduser(), p4) self.assertEqual(p5.expanduser(), p5) self.assertEqual(p6.expanduser(), p6) self.assertRaises(RuntimeError, p7.expanduser) env['HOME'] = '/tmp' self.assertEqual(p1.expanduser(), P('/tmp/Documents')) self.assertEqual(p2.expanduser(), P(userhome) / 'Documents') self.assertEqual(p3.expanduser(), P(otherhome) / 'Documents') self.assertEqual(p4.expanduser(), p4) self.assertEqual(p5.expanduser(), p5) self.assertEqual(p6.expanduser(), p6) self.assertRaises(RuntimeError, p7.expanduser) @only_nt class WindowsPathTest(_BasePathTest, unittest.TestCase): cls = pathlib.WindowsPath def test_glob(self): P = self.cls p = P(BASE) self.assertEqual(set(p.glob("FILEa")), { P(BASE, "fileA") }) def test_rglob(self): P = self.cls p = P(BASE, "dirC") self.assertEqual(set(p.rglob("FILEd")), { P(BASE, "dirC/dirD/fileD") }) def test_expanduser(self): P = self.cls with support.EnvironmentVarGuard() as env: env.pop('HOME', None) env.pop('USERPROFILE', None) env.pop('HOMEPATH', None) env.pop('HOMEDRIVE', None) env['USERNAME'] = 'alice' # test that the path returns unchanged p1 = P('~/My Documents') p2 = P('~alice/My Documents') p3 = P('~bob/My Documents') p4 = P('/~/My Documents') p5 = P('d:~/My Documents') p6 = P('') self.assertRaises(RuntimeError, p1.expanduser) self.assertRaises(RuntimeError, p2.expanduser) self.assertRaises(RuntimeError, p3.expanduser) self.assertEqual(p4.expanduser(), p4) self.assertEqual(p5.expanduser(), p5) self.assertEqual(p6.expanduser(), p6) def check(): env.pop('USERNAME', None) self.assertEqual(p1.expanduser(), P('C:/Users/alice/My Documents')) self.assertRaises(KeyError, p2.expanduser) env['USERNAME'] = 'alice' self.assertEqual(p2.expanduser(), P('C:/Users/alice/My Documents')) self.assertEqual(p3.expanduser(), P('C:/Users/bob/My Documents')) self.assertEqual(p4.expanduser(), p4) self.assertEqual(p5.expanduser(), p5) self.assertEqual(p6.expanduser(), p6) # test the first lookup key in the env vars env['HOME'] = 'C:\\Users\\alice' check() # test that HOMEPATH is available instead env.pop('HOME', None) env['HOMEPATH'] = 'C:\\Users\\alice' check() env['HOMEDRIVE'] = 'C:\\' env['HOMEPATH'] = 'Users\\alice' check() env.pop('HOMEDRIVE', None) env.pop('HOMEPATH', None) env['USERPROFILE'] = 'C:\\Users\\alice' check() if __name__ == "__main__": unittest.main()
90,501
2,254
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_ctypes.py
import unittest from test.support import import_module ctypes_test = import_module('ctypes.test') load_tests = ctypes_test.load_tests if __name__ == "__main__": unittest.main()
184
10
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_threadsignals.py
"""PyUnit testing that threads honor our signal semantics""" import unittest import signal import os import sys from test import support thread = support.import_module('_thread') import time if (sys.platform[:3] == 'win'): raise unittest.SkipTest("Can't test signal on %s" % sys.platform) process_pid = os.getpid() signalled_all=thread.allocate_lock() USING_PTHREAD_COND = (sys.thread_info.name == 'pthread' and sys.thread_info.lock == 'mutex+cond') def registerSignals(for_usr1, for_usr2, for_alrm): usr1 = signal.signal(signal.SIGUSR1, for_usr1) usr2 = signal.signal(signal.SIGUSR2, for_usr2) alrm = signal.signal(signal.SIGALRM, for_alrm) return usr1, usr2, alrm # The signal handler. Just note that the signal occurred and # from who. def handle_signals(sig,frame): signal_blackboard[sig]['tripped'] += 1 signal_blackboard[sig]['tripped_by'] = thread.get_ident() # a function that will be spawned as a separate thread. def send_signals(): os.kill(process_pid, signal.SIGUSR1) os.kill(process_pid, signal.SIGUSR2) signalled_all.release() class ThreadSignals(unittest.TestCase): def test_signals(self): with support.wait_threads_exit(): # Test signal handling semantics of threads. # We spawn a thread, have the thread send two signals, and # wait for it to finish. Check that we got both signals # and that they were run by the main thread. signalled_all.acquire() self.spawnSignallingThread() signalled_all.acquire() # the signals that we asked the kernel to send # will come back, but we don't know when. # (it might even be after the thread exits # and might be out of order.) If we haven't seen # the signals yet, send yet another signal and # wait for it return. if signal_blackboard[signal.SIGUSR1]['tripped'] == 0 \ or signal_blackboard[signal.SIGUSR2]['tripped'] == 0: try: signal.alarm(1) signal.pause() finally: signal.alarm(0) self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1) self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'], thread.get_ident()) self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1) self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'], thread.get_ident()) signalled_all.release() def spawnSignallingThread(self): thread.start_new_thread(send_signals, ()) def alarm_interrupt(self, sig, frame): raise KeyboardInterrupt @unittest.skipIf(USING_PTHREAD_COND, 'POSIX condition variables cannot be interrupted') @unittest.skipIf(sys.platform.startswith('linux') and not sys.thread_info.version, 'Issue 34004: musl does not allow interruption of locks ' 'by signals.') # Issue #20564: sem_timedwait() cannot be interrupted on OpenBSD @unittest.skipIf(sys.platform.startswith('openbsd'), 'lock cannot be interrupted on OpenBSD') def test_lock_acquire_interruption(self): # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck # in a deadlock. # XXX this test can fail when the legacy (non-semaphore) implementation # of locks is used in thread_pthread.h, see issue #11223. oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt) try: lock = thread.allocate_lock() lock.acquire() signal.alarm(1) t1 = time.time() self.assertRaises(KeyboardInterrupt, lock.acquire, timeout=5) dt = time.time() - t1 # Checking that KeyboardInterrupt was raised is not sufficient. # We want to assert that lock.acquire() was interrupted because # of the signal, not that the signal handler was called immediately # after timeout return of lock.acquire() (which can fool assertRaises). self.assertLess(dt, 3.0) finally: signal.alarm(0) signal.signal(signal.SIGALRM, oldalrm) @unittest.skipIf(USING_PTHREAD_COND, 'POSIX condition variables cannot be interrupted') @unittest.skipIf(sys.platform.startswith('linux') and not sys.thread_info.version, 'Issue 34004: musl does not allow interruption of locks ' 'by signals.') # Issue #20564: sem_timedwait() cannot be interrupted on OpenBSD @unittest.skipIf(sys.platform.startswith('openbsd'), 'lock cannot be interrupted on OpenBSD') def test_rlock_acquire_interruption(self): # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck # in a deadlock. # XXX this test can fail when the legacy (non-semaphore) implementation # of locks is used in thread_pthread.h, see issue #11223. oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt) try: rlock = thread.RLock() # For reentrant locks, the initial acquisition must be in another # thread. def other_thread(): rlock.acquire() with support.wait_threads_exit(): thread.start_new_thread(other_thread, ()) # Wait until we can't acquire it without blocking... while rlock.acquire(blocking=False): rlock.release() time.sleep(0.01) signal.alarm(1) t1 = time.time() self.assertRaises(KeyboardInterrupt, rlock.acquire, timeout=5) dt = time.time() - t1 # See rationale above in test_lock_acquire_interruption self.assertLess(dt, 3.0) finally: signal.alarm(0) signal.signal(signal.SIGALRM, oldalrm) def acquire_retries_on_intr(self, lock): self.sig_recvd = False def my_handler(signal, frame): self.sig_recvd = True old_handler = signal.signal(signal.SIGUSR1, my_handler) try: def other_thread(): # Acquire the lock in a non-main thread, so this test works for # RLocks. lock.acquire() # Wait until the main thread is blocked in the lock acquire, and # then wake it up with this. time.sleep(0.5) os.kill(process_pid, signal.SIGUSR1) # Let the main thread take the interrupt, handle it, and retry # the lock acquisition. Then we'll let it run. time.sleep(0.5) lock.release() with support.wait_threads_exit(): thread.start_new_thread(other_thread, ()) # Wait until we can't acquire it without blocking... while lock.acquire(blocking=False): lock.release() time.sleep(0.01) result = lock.acquire() # Block while we receive a signal. self.assertTrue(self.sig_recvd) self.assertTrue(result) finally: signal.signal(signal.SIGUSR1, old_handler) def test_lock_acquire_retries_on_intr(self): self.acquire_retries_on_intr(thread.allocate_lock()) def test_rlock_acquire_retries_on_intr(self): self.acquire_retries_on_intr(thread.RLock()) def test_interrupted_timed_acquire(self): # Test to make sure we recompute lock acquisition timeouts when we # receive a signal. Check this by repeatedly interrupting a lock # acquire in the main thread, and make sure that the lock acquire times # out after the right amount of time. # NOTE: this test only behaves as expected if C signals get delivered # to the main thread. Otherwise lock.acquire() itself doesn't get # interrupted and the test trivially succeeds. self.start = None self.end = None self.sigs_recvd = 0 done = thread.allocate_lock() done.acquire() lock = thread.allocate_lock() lock.acquire() def my_handler(signum, frame): self.sigs_recvd += 1 old_handler = signal.signal(signal.SIGUSR1, my_handler) try: def timed_acquire(): self.start = time.time() lock.acquire(timeout=0.5) self.end = time.time() def send_signals(): for _ in range(40): time.sleep(0.02) os.kill(process_pid, signal.SIGUSR1) done.release() with support.wait_threads_exit(): # Send the signals from the non-main thread, since the main thread # is the only one that can process signals. thread.start_new_thread(send_signals, ()) timed_acquire() # Wait for thread to finish done.acquire() # This allows for some timing and scheduling imprecision self.assertLess(self.end - self.start, 2.0) self.assertGreater(self.end - self.start, 0.3) # If the signal is received several times before PyErr_CheckSignals() # is called, the handler will get called less than 40 times. Just # check it's been called at least once. self.assertGreater(self.sigs_recvd, 0) finally: signal.signal(signal.SIGUSR1, old_handler) def test_main(): global signal_blackboard signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } oldsigs = registerSignals(handle_signals, handle_signals, handle_signals) try: support.run_unittest(ThreadSignals) finally: registerSignals(*oldsigs) if __name__ == '__main__': test_main()
10,321
248
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/curses_tests.py
#!/usr/bin/env python3 # # $Id: ncurses.py 36559 2004-07-18 05:56:09Z tim_one $ # # Interactive test suite for the curses module. # This script displays various things and the user should verify whether # they display correctly. # import curses from curses import textpad def test_textpad(stdscr, insert_mode=False): ncols, nlines = 8, 3 uly, ulx = 3, 2 if insert_mode: mode = 'insert mode' else: mode = 'overwrite mode' stdscr.addstr(uly-3, ulx, "Use Ctrl-G to end editing (%s)." % mode) stdscr.addstr(uly-2, ulx, "Be sure to try typing in the lower-right corner.") win = curses.newwin(nlines, ncols, uly, ulx) textpad.rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols) stdscr.refresh() box = textpad.Textbox(win, insert_mode) contents = box.edit() stdscr.addstr(uly+ncols+2, 0, "Text entered in the box\n") stdscr.addstr(repr(contents)) stdscr.addstr('\n') stdscr.addstr('Press any key') stdscr.getch() for i in range(3): stdscr.move(uly+ncols+2 + i, 0) stdscr.clrtoeol() def main(stdscr): stdscr.clear() test_textpad(stdscr, False) test_textpad(stdscr, True) if __name__ == '__main__': curses.wrapper(main)
1,242
47
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_decorators.py
import unittest def funcattrs(**kwds): def decorate(func): func.__dict__.update(kwds) return func return decorate class MiscDecorators (object): @staticmethod def author(name): def decorate(func): func.__dict__['author'] = name return func return decorate # ----------------------------------------------- class DbcheckError (Exception): def __init__(self, exprstr, func, args, kwds): # A real version of this would set attributes here Exception.__init__(self, "dbcheck %r failed (func=%s args=%s kwds=%s)" % (exprstr, func, args, kwds)) def dbcheck(exprstr, globals=None, locals=None): "Decorator to implement debugging assertions" def decorate(func): expr = compile(exprstr, "dbcheck-%s" % func.__name__, "eval") def check(*args, **kwds): if not eval(expr, globals, locals): raise DbcheckError(exprstr, func, args, kwds) return func(*args, **kwds) return check return decorate # ----------------------------------------------- def countcalls(counts): "Decorator to count calls to a function" def decorate(func): func_name = func.__name__ counts[func_name] = 0 def call(*args, **kwds): counts[func_name] += 1 return func(*args, **kwds) call.__name__ = func_name return call return decorate # ----------------------------------------------- def memoize(func): saved = {} def call(*args): try: return saved[args] except KeyError: res = func(*args) saved[args] = res return res except TypeError: # Unhashable argument return func(*args) call.__name__ = func.__name__ return call # ----------------------------------------------- class TestDecorators(unittest.TestCase): def test_single(self): class C(object): @staticmethod def foo(): return 42 self.assertEqual(C.foo(), 42) self.assertEqual(C().foo(), 42) def test_staticmethod_function(self): @staticmethod def notamethod(x): return x self.assertRaises(TypeError, notamethod, 1) def test_dotted(self): decorators = MiscDecorators() @decorators.author('Cleese') def foo(): return 42 self.assertEqual(foo(), 42) self.assertEqual(foo.author, 'Cleese') def test_argforms(self): # A few tests of argument passing, as we use restricted form # of expressions for decorators. def noteargs(*args, **kwds): def decorate(func): setattr(func, 'dbval', (args, kwds)) return func return decorate args = ( 'Now', 'is', 'the', 'time' ) kwds = dict(one=1, two=2) @noteargs(*args, **kwds) def f1(): return 42 self.assertEqual(f1(), 42) self.assertEqual(f1.dbval, (args, kwds)) @noteargs('terry', 'gilliam', eric='idle', john='cleese') def f2(): return 84 self.assertEqual(f2(), 84) self.assertEqual(f2.dbval, (('terry', 'gilliam'), dict(eric='idle', john='cleese'))) @noteargs(1, 2,) def f3(): pass self.assertEqual(f3.dbval, ((1, 2), {})) def test_dbcheck(self): @dbcheck('args[1] is not None') def f(a, b): return a + b self.assertEqual(f(1, 2), 3) self.assertRaises(DbcheckError, f, 1, None) def test_memoize(self): counts = {} @memoize @countcalls(counts) def double(x): return x * 2 self.assertEqual(double.__name__, 'double') self.assertEqual(counts, dict(double=0)) # Only the first call with a given argument bumps the call count: # self.assertEqual(double(2), 4) self.assertEqual(counts['double'], 1) self.assertEqual(double(2), 4) self.assertEqual(counts['double'], 1) self.assertEqual(double(3), 6) self.assertEqual(counts['double'], 2) # Unhashable arguments do not get memoized: # self.assertEqual(double([10]), [10, 10]) self.assertEqual(counts['double'], 3) self.assertEqual(double([10]), [10, 10]) self.assertEqual(counts['double'], 4) def test_errors(self): # Test syntax restrictions - these are all compile-time errors: # for expr in [ "1+2", "x[3]", "(1, 2)" ]: # Sanity check: is expr is a valid expression by itself? compile(expr, "testexpr", "exec") codestr = "@%s\ndef f(): pass" % expr self.assertRaises(SyntaxError, compile, codestr, "test", "exec") # You can't put multiple decorators on a single line: # self.assertRaises(SyntaxError, compile, "@f1 @f2\ndef f(): pass", "test", "exec") # Test runtime errors def unimp(func): raise NotImplementedError context = dict(nullval=None, unimp=unimp) for expr, exc in [ ("undef", NameError), ("nullval", TypeError), ("nullval.attr", AttributeError), ("unimp", NotImplementedError)]: codestr = "@%s\ndef f(): pass\nassert f() is None" % expr code = compile(codestr, "test", "exec") self.assertRaises(exc, eval, code, context) def test_double(self): class C(object): @funcattrs(abc=1, xyz="haha") @funcattrs(booh=42) def foo(self): return 42 self.assertEqual(C().foo(), 42) self.assertEqual(C.foo.abc, 1) self.assertEqual(C.foo.xyz, "haha") self.assertEqual(C.foo.booh, 42) def test_order(self): # Test that decorators are applied in the proper order to the function # they are decorating. def callnum(num): """Decorator factory that returns a decorator that replaces the passed-in function with one that returns the value of 'num'""" def deco(func): return lambda: num return deco @callnum(2) @callnum(1) def foo(): return 42 self.assertEqual(foo(), 2, "Application order of decorators is incorrect") def test_eval_order(self): # Evaluating a decorated function involves four steps for each # decorator-maker (the function that returns a decorator): # # 1: Evaluate the decorator-maker name # 2: Evaluate the decorator-maker arguments (if any) # 3: Call the decorator-maker to make a decorator # 4: Call the decorator # # When there are multiple decorators, these steps should be # performed in the above order for each decorator, but we should # iterate through the decorators in the reverse of the order they # appear in the source. actions = [] def make_decorator(tag): actions.append('makedec' + tag) def decorate(func): actions.append('calldec' + tag) return func return decorate class NameLookupTracer (object): def __init__(self, index): self.index = index def __getattr__(self, fname): if fname == 'make_decorator': opname, res = ('evalname', make_decorator) elif fname == 'arg': opname, res = ('evalargs', str(self.index)) else: assert False, "Unknown attrname %s" % fname actions.append('%s%d' % (opname, self.index)) return res c1, c2, c3 = map(NameLookupTracer, [ 1, 2, 3 ]) expected_actions = [ 'evalname1', 'evalargs1', 'makedec1', 'evalname2', 'evalargs2', 'makedec2', 'evalname3', 'evalargs3', 'makedec3', 'calldec3', 'calldec2', 'calldec1' ] actions = [] @c1.make_decorator(c1.arg) @c2.make_decorator(c2.arg) @c3.make_decorator(c3.arg) def foo(): return 42 self.assertEqual(foo(), 42) self.assertEqual(actions, expected_actions) # Test the equivalence claim in chapter 7 of the reference manual. # actions = [] def bar(): return 42 bar = c1.make_decorator(c1.arg)(c2.make_decorator(c2.arg)(c3.make_decorator(c3.arg)(bar))) self.assertEqual(bar(), 42) self.assertEqual(actions, expected_actions) class TestClassDecorators(unittest.TestCase): def test_simple(self): def plain(x): x.extra = 'Hello' return x @plain class C(object): pass self.assertEqual(C.extra, 'Hello') def test_double(self): def ten(x): x.extra = 10 return x def add_five(x): x.extra += 5 return x @add_five @ten class C(object): pass self.assertEqual(C.extra, 15) def test_order(self): def applied_first(x): x.extra = 'first' return x def applied_second(x): x.extra = 'second' return x @applied_second @applied_first class C(object): pass self.assertEqual(C.extra, 'second') if __name__ == "__main__": unittest.main()
9,704
305
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_call.py
import collections import datetime import unittest from test.support import cpython_only try: import _testcapi except ImportError: _testcapi = None class FunctionCalls(unittest.TestCase): def test_kwargs_order(self): # bpo-34320: **kwargs should preserve order of passed OrderedDict od = collections.OrderedDict([('a', 1), ('b', 2)]) od.move_to_end('a') expected = list(od.items()) def fn(**kw): return kw res = fn(**od) self.assertIsInstance(res, dict) self.assertEqual(list(res.items()), expected) # The test cases here cover several paths through the function calling # code. They depend on the METH_XXX flag that is used to define a C # function, which can't be verified from Python. If the METH_XXX decl # for a C function changes, these tests may not cover the right paths. class CFunctionCalls(unittest.TestCase): def test_varargs0(self): self.assertRaises(TypeError, {}.__contains__) def test_varargs1(self): {}.__contains__(0) def test_varargs2(self): self.assertRaises(TypeError, {}.__contains__, 0, 1) def test_varargs0_ext(self): try: {}.__contains__(*()) except TypeError: pass def test_varargs1_ext(self): {}.__contains__(*(0,)) def test_varargs2_ext(self): try: {}.__contains__(*(1, 2)) except TypeError: pass else: raise RuntimeError def test_varargs0_kw(self): self.assertRaises(TypeError, {}.__contains__, x=2) def test_varargs1_kw(self): self.assertRaises(TypeError, {}.__contains__, x=2) def test_varargs2_kw(self): self.assertRaises(TypeError, {}.__contains__, x=2, y=2) def test_oldargs0_0(self): {}.keys() def test_oldargs0_1(self): self.assertRaises(TypeError, {}.keys, 0) def test_oldargs0_2(self): self.assertRaises(TypeError, {}.keys, 0, 1) def test_oldargs0_0_ext(self): {}.keys(*()) def test_oldargs0_1_ext(self): try: {}.keys(*(0,)) except TypeError: pass else: raise RuntimeError def test_oldargs0_2_ext(self): try: {}.keys(*(1, 2)) except TypeError: pass else: raise RuntimeError def test_oldargs0_0_kw(self): try: {}.keys(x=2) except TypeError: pass else: raise RuntimeError def test_oldargs0_1_kw(self): self.assertRaises(TypeError, {}.keys, x=2) def test_oldargs0_2_kw(self): self.assertRaises(TypeError, {}.keys, x=2, y=2) def test_oldargs1_0(self): self.assertRaises(TypeError, [].count) def test_oldargs1_1(self): [].count(1) def test_oldargs1_2(self): self.assertRaises(TypeError, [].count, 1, 2) def test_oldargs1_0_ext(self): try: [].count(*()) except TypeError: pass else: raise RuntimeError def test_oldargs1_1_ext(self): [].count(*(1,)) def test_oldargs1_2_ext(self): try: [].count(*(1, 2)) except TypeError: pass else: raise RuntimeError def test_oldargs1_0_kw(self): self.assertRaises(TypeError, [].count, x=2) def test_oldargs1_1_kw(self): self.assertRaises(TypeError, [].count, {}, x=2) def test_oldargs1_2_kw(self): self.assertRaises(TypeError, [].count, x=2, y=2) def pyfunc(arg1, arg2): return [arg1, arg2] def pyfunc_noarg(): return "noarg" class PythonClass: def method(self, arg1, arg2): return [arg1, arg2] def method_noarg(self): return "noarg" @classmethod def class_method(cls): return "classmethod" @staticmethod def static_method(): return "staticmethod" PYTHON_INSTANCE = PythonClass() IGNORE_RESULT = object() @cpython_only class FastCallTests(unittest.TestCase): # Test calls with positional arguments CALLS_POSARGS = ( # (func, args: tuple, result) # Python function with 2 arguments (pyfunc, (1, 2), [1, 2]), # Python function without argument (pyfunc_noarg, (), "noarg"), # Python class methods (PythonClass.class_method, (), "classmethod"), (PythonClass.static_method, (), "staticmethod"), # Python instance methods (PYTHON_INSTANCE.method, (1, 2), [1, 2]), (PYTHON_INSTANCE.method_noarg, (), "noarg"), (PYTHON_INSTANCE.class_method, (), "classmethod"), (PYTHON_INSTANCE.static_method, (), "staticmethod"), # C function: METH_NOARGS (globals, (), IGNORE_RESULT), # C function: METH_O (id, ("hello",), IGNORE_RESULT), # C function: METH_VARARGS (dir, (1,), IGNORE_RESULT), # C function: METH_VARARGS | METH_KEYWORDS (min, (5, 9), 5), # C function: METH_FASTCALL (divmod, (1000, 33), (30, 10)), # C type static method: METH_FASTCALL | METH_CLASS (int.from_bytes, (b'\x01\x00', 'little'), 1), # bpo-30524: Test that calling a C type static method with no argument # doesn't crash (ignore the result): METH_FASTCALL | METH_CLASS (datetime.datetime.now, (), IGNORE_RESULT), ) # Test calls with positional and keyword arguments CALLS_KWARGS = ( # (func, args: tuple, kwargs: dict, result) # Python function with 2 arguments (pyfunc, (1,), {'arg2': 2}, [1, 2]), (pyfunc, (), {'arg1': 1, 'arg2': 2}, [1, 2]), # Python instance methods (PYTHON_INSTANCE.method, (1,), {'arg2': 2}, [1, 2]), (PYTHON_INSTANCE.method, (), {'arg1': 1, 'arg2': 2}, [1, 2]), # C function: METH_VARARGS | METH_KEYWORDS (max, ([],), {'default': 9}, 9), # C type static method: METH_FASTCALL | METH_CLASS (int.from_bytes, (b'\x01\x00',), {'byteorder': 'little'}, 1), (int.from_bytes, (), {'bytes': b'\x01\x00', 'byteorder': 'little'}, 1), ) def check_result(self, result, expected): if expected is IGNORE_RESULT: return self.assertEqual(result, expected) def test_fastcall(self): # Test _PyObject_FastCall() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): result = _testcapi.pyobject_fastcall(func, args) self.check_result(result, expected) if not args: # args=NULL, nargs=0 result = _testcapi.pyobject_fastcall(func, None) self.check_result(result, expected) def test_fastcall_dict(self): # Test _PyObject_FastCallDict() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): # kwargs=NULL result = _testcapi.pyobject_fastcalldict(func, args, None) self.check_result(result, expected) # kwargs={} result = _testcapi.pyobject_fastcalldict(func, args, {}) self.check_result(result, expected) if not args: # args=NULL, nargs=0, kwargs=NULL result = _testcapi.pyobject_fastcalldict(func, None, None) self.check_result(result, expected) # args=NULL, nargs=0, kwargs={} result = _testcapi.pyobject_fastcalldict(func, None, {}) self.check_result(result, expected) for func, args, kwargs, expected in self.CALLS_KWARGS: with self.subTest(func=func, args=args, kwargs=kwargs): result = _testcapi.pyobject_fastcalldict(func, args, kwargs) self.check_result(result, expected) def test_fastcall_keywords(self): # Test _PyObject_FastCallKeywords() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): # kwnames=NULL result = _testcapi.pyobject_fastcallkeywords(func, args, None) self.check_result(result, expected) # kwnames=() result = _testcapi.pyobject_fastcallkeywords(func, args, ()) self.check_result(result, expected) if not args: # kwnames=NULL result = _testcapi.pyobject_fastcallkeywords(func, None, None) self.check_result(result, expected) # kwnames=() result = _testcapi.pyobject_fastcallkeywords(func, None, ()) self.check_result(result, expected) for func, args, kwargs, expected in self.CALLS_KWARGS: with self.subTest(func=func, args=args, kwargs=kwargs): kwnames = tuple(kwargs.keys()) args = args + tuple(kwargs.values()) result = _testcapi.pyobject_fastcallkeywords(func, args, kwnames) self.check_result(result, expected) if __name__ == "__main__": unittest.main()
9,307
321
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_idle.py
import unittest from test.support import import_module # For 3.6, skip test_idle if threads are not supported. import_module('threading') # Imported by PyShell, imports _thread. # Skip test_idle if _tkinter wasn't built, if tkinter is missing, # if tcl/tk is not the 8.5+ needed for ttk widgets, # or if idlelib is missing (not installed). tk = import_module('tkinter') # imports _tkinter if tk.TkVersion < 8.5: raise unittest.SkipTest("IDLE requires tk 8.5 or later.") idlelib = import_module('idlelib') # Before importing and executing more of idlelib, # tell IDLE to avoid changing the environment. idlelib.testing = True # Unittest.main and test.libregrtest.runtest.runtest_inner # call load_tests, when present here, to discover tests to run. from idlelib.idle_test import load_tests if __name__ == '__main__': tk.NoDefaultRoot() unittest.main(exit=False) tk._support_default_root = 1 tk._default_root = None
941
28
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_msilib.py
""" Test suite for the code in msilib """ import os.path import unittest from test.support import TESTFN, import_module, unlink msilib = import_module('msilib') import msilib.schema def init_database(): path = TESTFN + '.msi' db = msilib.init_database( path, msilib.schema, 'Python Tests', 'product_code', '1.0', 'PSF', ) return db, path class MsiDatabaseTestCase(unittest.TestCase): def test_view_fetch_returns_none(self): db, db_path = init_database() properties = [] view = db.OpenView('SELECT Property, Value FROM Property') view.Execute(None) while True: record = view.Fetch() if record is None: break properties.append(record.GetString(1)) view.Close() self.assertEqual( properties, [ 'ProductName', 'ProductCode', 'ProductVersion', 'Manufacturer', 'ProductLanguage', ] ) self.addCleanup(unlink, db_path) def test_database_open_failed(self): with self.assertRaises(msilib.MSIError) as cm: msilib.OpenDatabase('non-existent.msi', msilib.MSIDBOPEN_READONLY) self.assertEqual(str(cm.exception), 'open failed') def test_database_create_failed(self): db_path = os.path.join(TESTFN, 'test.msi') with self.assertRaises(msilib.MSIError) as cm: msilib.OpenDatabase(db_path, msilib.MSIDBOPEN_CREATE) self.assertEqual(str(cm.exception), 'create failed') def test_get_property_vt_empty(self): db, db_path = init_database() summary = db.GetSummaryInformation(0) self.assertIsNone(summary.GetProperty(msilib.PID_SECURITY)) del db self.addCleanup(unlink, db_path) class Test_make_id(unittest.TestCase): #http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx """The Identifier data type is a text string. Identifiers may contain the ASCII characters A-Z (a-z), digits, underscores (_), or periods (.). However, every identifier must begin with either a letter or an underscore. """ def test_is_no_change_required(self): self.assertEqual( msilib.make_id("short"), "short") self.assertEqual( msilib.make_id("nochangerequired"), "nochangerequired") self.assertEqual( msilib.make_id("one.dot"), "one.dot") self.assertEqual( msilib.make_id("_"), "_") self.assertEqual( msilib.make_id("a"), "a") #self.assertEqual( # msilib.make_id(""), "") def test_invalid_first_char(self): self.assertEqual( msilib.make_id("9.short"), "_9.short") self.assertEqual( msilib.make_id(".short"), "_.short") def test_invalid_any_char(self): self.assertEqual( msilib.make_id(".s\x82ort"), "_.s_ort") self.assertEqual ( msilib.make_id(".s\x82o?*+rt"), "_.s_o___rt") if __name__ == '__main__': unittest.main()
3,113
100
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_global.py
"""Verify that warnings are issued for global statements following use.""" from test.support import run_unittest, check_syntax_error, check_warnings import unittest import warnings class GlobalTests(unittest.TestCase): def setUp(self): self._warnings_manager = check_warnings() self._warnings_manager.__enter__() warnings.filterwarnings("error", module="<test string>") def tearDown(self): self._warnings_manager.__exit__(None, None, None) def test1(self): prog_text_1 = """\ def wrong1(): a = 1 b = 2 global a global b """ check_syntax_error(self, prog_text_1, lineno=4, offset=4) def test2(self): prog_text_2 = """\ def wrong2(): print(x) global x """ check_syntax_error(self, prog_text_2, lineno=3, offset=4) def test3(self): prog_text_3 = """\ def wrong3(): print(x) x = 2 global x """ check_syntax_error(self, prog_text_3, lineno=4, offset=4) def test4(self): prog_text_4 = """\ global x x = 2 """ # this should work compile(prog_text_4, "<test string>", "exec") def test_main(): with warnings.catch_warnings(): warnings.filterwarnings("error", module="<test string>") run_unittest(GlobalTests) if __name__ == "__main__": test_main()
1,340
62
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/pickletester.py
import cosmo import collections import copyreg # import dbm import io import functools import pickle import pickletools import struct import sys import unittest import weakref from http.cookies import SimpleCookie from test import support from test.support import ( TestFailed, TESTFN, run_with_locale, no_tracing, _2G, _4G, bigmemtest, ) from pickle import bytes_types requires_32b = unittest.skipUnless(sys.maxsize < 2**32, "test is only meaningful on 32-bit builds") # Tests that try a number of pickle protocols should have a # for proto in protocols: # kind of outer loop. protocols = range(pickle.HIGHEST_PROTOCOL + 1) # Return True if opcode code appears in the pickle, else False. def opcode_in_pickle(code, pickle): for op, dummy, dummy in pickletools.genops(pickle): if op.code == code.decode("latin-1"): return True return False # Return the number of times opcode code appears in pickle. def count_opcode(code, pickle): n = 0 for op, dummy, dummy in pickletools.genops(pickle): if op.code == code.decode("latin-1"): n += 1 return n class UnseekableIO(io.BytesIO): def peek(self, *args): raise NotImplementedError def seekable(self): return False def seek(self, *args): raise io.UnsupportedOperation def tell(self): raise io.UnsupportedOperation # We can't very well test the extension registry without putting known stuff # in it, but we have to be careful to restore its original state. Code # should do this: # # e = ExtensionSaver(extension_code) # try: # fiddle w/ the extension registry's stuff for extension_code # finally: # e.restore() class ExtensionSaver: # Remember current registration for code (if any), and remove it (if # there is one). def __init__(self, code): self.code = code if code in copyreg._inverted_registry: self.pair = copyreg._inverted_registry[code] copyreg.remove_extension(self.pair[0], self.pair[1], code) else: self.pair = None # Restore previous registration for code. def restore(self): code = self.code curpair = copyreg._inverted_registry.get(code) if curpair is not None: copyreg.remove_extension(curpair[0], curpair[1], code) pair = self.pair if pair is not None: copyreg.add_extension(pair[0], pair[1], code) class C: def __eq__(self, other): return self.__dict__ == other.__dict__ class D(C): def __init__(self, arg): pass class E(C): def __getinitargs__(self): return () class H(object): pass # Hashable mutable key class K(object): def __init__(self, value): self.value = value def __reduce__(self): # Shouldn't support the recursion itself return K, (self.value,) import __main__ __main__.C = C C.__module__ = "__main__" __main__.D = D D.__module__ = "__main__" __main__.E = E E.__module__ = "__main__" __main__.H = H H.__module__ = "__main__" __main__.K = K K.__module__ = "__main__" class myint(int): def __init__(self, x): self.str = str(x) class initarg(C): def __init__(self, a, b): self.a = a self.b = b def __getinitargs__(self): return self.a, self.b class metaclass(type): pass class use_metaclass(object, metaclass=metaclass): pass class pickling_metaclass(type): def __eq__(self, other): return (type(self) == type(other) and self.reduce_args == other.reduce_args) def __reduce__(self): return (create_dynamic_class, self.reduce_args) def create_dynamic_class(name, bases): result = pickling_metaclass(name, bases, dict()) result.reduce_args = (name, bases) return result # DATA0 .. DATA4 are the pickles we expect under the various protocols, for # the object returned by create_data(). DATA0 = ( b'(lp0\nL0L\naL1L\naF2.0\n' b'ac__builtin__\ncomple' b'x\np1\n(F3.0\nF0.0\ntp2\n' b'Rp3\naL1L\naL-1L\naL255' b'L\naL-255L\naL-256L\naL' b'65535L\naL-65535L\naL-' b'65536L\naL2147483647L' b'\naL-2147483647L\naL-2' b'147483648L\na(Vabc\np4' b'\ng4\nccopy_reg\n_recon' b'structor\np5\n(c__main' b'__\nC\np6\nc__builtin__' b'\nobject\np7\nNtp8\nRp9\n' b'(dp10\nVfoo\np11\nL1L\ns' b'Vbar\np12\nL2L\nsbg9\ntp' b'13\nag13\naL5L\na.' ) # Disassembly of DATA0 DATA0_DIS = """\ 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: L LONG 0 9: a APPEND 10: L LONG 1 14: a APPEND 15: F FLOAT 2.0 20: a APPEND 21: c GLOBAL '__builtin__ complex' 42: p PUT 1 45: ( MARK 46: F FLOAT 3.0 51: F FLOAT 0.0 56: t TUPLE (MARK at 45) 57: p PUT 2 60: R REDUCE 61: p PUT 3 64: a APPEND 65: L LONG 1 69: a APPEND 70: L LONG -1 75: a APPEND 76: L LONG 255 82: a APPEND 83: L LONG -255 90: a APPEND 91: L LONG -256 98: a APPEND 99: L LONG 65535 107: a APPEND 108: L LONG -65535 117: a APPEND 118: L LONG -65536 127: a APPEND 128: L LONG 2147483647 141: a APPEND 142: L LONG -2147483647 156: a APPEND 157: L LONG -2147483648 171: a APPEND 172: ( MARK 173: V UNICODE 'abc' 178: p PUT 4 181: g GET 4 184: c GLOBAL 'copy_reg _reconstructor' 209: p PUT 5 212: ( MARK 213: c GLOBAL '__main__ C' 225: p PUT 6 228: c GLOBAL '__builtin__ object' 248: p PUT 7 251: N NONE 252: t TUPLE (MARK at 212) 253: p PUT 8 256: R REDUCE 257: p PUT 9 260: ( MARK 261: d DICT (MARK at 260) 262: p PUT 10 266: V UNICODE 'foo' 271: p PUT 11 275: L LONG 1 279: s SETITEM 280: V UNICODE 'bar' 285: p PUT 12 289: L LONG 2 293: s SETITEM 294: b BUILD 295: g GET 9 298: t TUPLE (MARK at 172) 299: p PUT 13 303: a APPEND 304: g GET 13 308: a APPEND 309: L LONG 5 313: a APPEND 314: . STOP highest protocol among opcodes = 0 """ DATA1 = ( b']q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c__' b'builtin__\ncomplex\nq\x01' b'(G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00t' b'q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xffJ' b'\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff' b'\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00ab' b'cq\x04h\x04ccopy_reg\n_reco' b'nstructor\nq\x05(c__main' b'__\nC\nq\x06c__builtin__\n' b'object\nq\x07Ntq\x08Rq\t}q\n(' b'X\x03\x00\x00\x00fooq\x0bK\x01X\x03\x00\x00\x00bar' b'q\x0cK\x02ubh\ttq\rh\rK\x05e.' ) # Disassembly of DATA1 DATA1_DIS = """\ 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: K BININT1 0 6: K BININT1 1 8: G BINFLOAT 2.0 17: c GLOBAL '__builtin__ complex' 38: q BINPUT 1 40: ( MARK 41: G BINFLOAT 3.0 50: G BINFLOAT 0.0 59: t TUPLE (MARK at 40) 60: q BINPUT 2 62: R REDUCE 63: q BINPUT 3 65: K BININT1 1 67: J BININT -1 72: K BININT1 255 74: J BININT -255 79: J BININT -256 84: M BININT2 65535 87: J BININT -65535 92: J BININT -65536 97: J BININT 2147483647 102: J BININT -2147483647 107: J BININT -2147483648 112: ( MARK 113: X BINUNICODE 'abc' 121: q BINPUT 4 123: h BINGET 4 125: c GLOBAL 'copy_reg _reconstructor' 150: q BINPUT 5 152: ( MARK 153: c GLOBAL '__main__ C' 165: q BINPUT 6 167: c GLOBAL '__builtin__ object' 187: q BINPUT 7 189: N NONE 190: t TUPLE (MARK at 152) 191: q BINPUT 8 193: R REDUCE 194: q BINPUT 9 196: } EMPTY_DICT 197: q BINPUT 10 199: ( MARK 200: X BINUNICODE 'foo' 208: q BINPUT 11 210: K BININT1 1 212: X BINUNICODE 'bar' 220: q BINPUT 12 222: K BININT1 2 224: u SETITEMS (MARK at 199) 225: b BUILD 226: h BINGET 9 228: t TUPLE (MARK at 112) 229: q BINPUT 13 231: h BINGET 13 233: K BININT1 5 235: e APPENDS (MARK at 3) 236: . STOP highest protocol among opcodes = 1 """ DATA2 = ( b'\x80\x02]q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c' b'__builtin__\ncomplex\n' b'q\x01G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00' b'\x86q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xff' b'J\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff' b'\xff\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00a' b'bcq\x04h\x04c__main__\nC\nq\x05' b')\x81q\x06}q\x07(X\x03\x00\x00\x00fooq\x08K\x01' b'X\x03\x00\x00\x00barq\tK\x02ubh\x06tq\nh' b'\nK\x05e.' ) # Disassembly of DATA2 DATA2_DIS = """\ 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: ( MARK 6: K BININT1 0 8: K BININT1 1 10: G BINFLOAT 2.0 19: c GLOBAL '__builtin__ complex' 40: q BINPUT 1 42: G BINFLOAT 3.0 51: G BINFLOAT 0.0 60: \x86 TUPLE2 61: q BINPUT 2 63: R REDUCE 64: q BINPUT 3 66: K BININT1 1 68: J BININT -1 73: K BININT1 255 75: J BININT -255 80: J BININT -256 85: M BININT2 65535 88: J BININT -65535 93: J BININT -65536 98: J BININT 2147483647 103: J BININT -2147483647 108: J BININT -2147483648 113: ( MARK 114: X BINUNICODE 'abc' 122: q BINPUT 4 124: h BINGET 4 126: c GLOBAL '__main__ C' 138: q BINPUT 5 140: ) EMPTY_TUPLE 141: \x81 NEWOBJ 142: q BINPUT 6 144: } EMPTY_DICT 145: q BINPUT 7 147: ( MARK 148: X BINUNICODE 'foo' 156: q BINPUT 8 158: K BININT1 1 160: X BINUNICODE 'bar' 168: q BINPUT 9 170: K BININT1 2 172: u SETITEMS (MARK at 147) 173: b BUILD 174: h BINGET 6 176: t TUPLE (MARK at 113) 177: q BINPUT 10 179: h BINGET 10 181: K BININT1 5 183: e APPENDS (MARK at 5) 184: . STOP highest protocol among opcodes = 2 """ DATA3 = ( b'\x80\x03]q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c' b'builtins\ncomplex\nq\x01G' b'@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00\x86q\x02' b'Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xffJ\x00\xff' b'\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff\xff\x7f' b'J\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00abcq' b'\x04h\x04c__main__\nC\nq\x05)\x81q' b'\x06}q\x07(X\x03\x00\x00\x00barq\x08K\x02X\x03\x00' b'\x00\x00fooq\tK\x01ubh\x06tq\nh\nK\x05' b'e.' ) # Disassembly of DATA3 DATA3_DIS = """\ 0: \x80 PROTO 3 2: ] EMPTY_LIST 3: q BINPUT 0 5: ( MARK 6: K BININT1 0 8: K BININT1 1 10: G BINFLOAT 2.0 19: c GLOBAL 'builtins complex' 37: q BINPUT 1 39: G BINFLOAT 3.0 48: G BINFLOAT 0.0 57: \x86 TUPLE2 58: q BINPUT 2 60: R REDUCE 61: q BINPUT 3 63: K BININT1 1 65: J BININT -1 70: K BININT1 255 72: J BININT -255 77: J BININT -256 82: M BININT2 65535 85: J BININT -65535 90: J BININT -65536 95: J BININT 2147483647 100: J BININT -2147483647 105: J BININT -2147483648 110: ( MARK 111: X BINUNICODE 'abc' 119: q BINPUT 4 121: h BINGET 4 123: c GLOBAL '__main__ C' 135: q BINPUT 5 137: ) EMPTY_TUPLE 138: \x81 NEWOBJ 139: q BINPUT 6 141: } EMPTY_DICT 142: q BINPUT 7 144: ( MARK 145: X BINUNICODE 'bar' 153: q BINPUT 8 155: K BININT1 2 157: X BINUNICODE 'foo' 165: q BINPUT 9 167: K BININT1 1 169: u SETITEMS (MARK at 144) 170: b BUILD 171: h BINGET 6 173: t TUPLE (MARK at 110) 174: q BINPUT 10 176: h BINGET 10 178: K BININT1 5 180: e APPENDS (MARK at 5) 181: . STOP highest protocol among opcodes = 2 """ DATA4 = ( b'\x80\x04\x95\xa8\x00\x00\x00\x00\x00\x00\x00]\x94(K\x00K\x01G@' b'\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x07' b'complex\x94\x93\x94G@\x08\x00\x00\x00\x00\x00\x00G' b'\x00\x00\x00\x00\x00\x00\x00\x00\x86\x94R\x94K\x01J\xff\xff\xff\xffK' b'\xffJ\x01\xff\xff\xffJ\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ' b'\x00\x00\xff\xffJ\xff\xff\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(' b'\x8c\x03abc\x94h\x06\x8c\x08__main__\x94\x8c' b'\x01C\x94\x93\x94)\x81\x94}\x94(\x8c\x03bar\x94K\x02\x8c' b'\x03foo\x94K\x01ubh\nt\x94h\x0eK\x05e.' ) # Disassembly of DATA4 DATA4_DIS = """\ 0: \x80 PROTO 4 2: \x95 FRAME 168 11: ] EMPTY_LIST 12: \x94 MEMOIZE 13: ( MARK 14: K BININT1 0 16: K BININT1 1 18: G BINFLOAT 2.0 27: \x8c SHORT_BINUNICODE 'builtins' 37: \x94 MEMOIZE 38: \x8c SHORT_BINUNICODE 'complex' 47: \x94 MEMOIZE 48: \x93 STACK_GLOBAL 49: \x94 MEMOIZE 50: G BINFLOAT 3.0 59: G BINFLOAT 0.0 68: \x86 TUPLE2 69: \x94 MEMOIZE 70: R REDUCE 71: \x94 MEMOIZE 72: K BININT1 1 74: J BININT -1 79: K BININT1 255 81: J BININT -255 86: J BININT -256 91: M BININT2 65535 94: J BININT -65535 99: J BININT -65536 104: J BININT 2147483647 109: J BININT -2147483647 114: J BININT -2147483648 119: ( MARK 120: \x8c SHORT_BINUNICODE 'abc' 125: \x94 MEMOIZE 126: h BINGET 6 128: \x8c SHORT_BINUNICODE '__main__' 138: \x94 MEMOIZE 139: \x8c SHORT_BINUNICODE 'C' 142: \x94 MEMOIZE 143: \x93 STACK_GLOBAL 144: \x94 MEMOIZE 145: ) EMPTY_TUPLE 146: \x81 NEWOBJ 147: \x94 MEMOIZE 148: } EMPTY_DICT 149: \x94 MEMOIZE 150: ( MARK 151: \x8c SHORT_BINUNICODE 'bar' 156: \x94 MEMOIZE 157: K BININT1 2 159: \x8c SHORT_BINUNICODE 'foo' 164: \x94 MEMOIZE 165: K BININT1 1 167: u SETITEMS (MARK at 150) 168: b BUILD 169: h BINGET 10 171: t TUPLE (MARK at 119) 172: \x94 MEMOIZE 173: h BINGET 14 175: K BININT1 5 177: e APPENDS (MARK at 13) 178: . STOP highest protocol among opcodes = 4 """ # set([1,2]) pickled from 2.x with protocol 2 DATA_SET = b'\x80\x02c__builtin__\nset\nq\x00]q\x01(K\x01K\x02e\x85q\x02Rq\x03.' # xrange(5) pickled from 2.x with protocol 2 DATA_XRANGE = b'\x80\x02c__builtin__\nxrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02.' # a SimpleCookie() object pickled from 2.x with protocol 2 DATA_COOKIE = (b'\x80\x02cCookie\nSimpleCookie\nq\x00)\x81q\x01U\x03key' b'q\x02cCookie\nMorsel\nq\x03)\x81q\x04(U\x07commentq\x05U' b'\x00q\x06U\x06domainq\x07h\x06U\x06secureq\x08h\x06U\x07' b'expiresq\th\x06U\x07max-ageq\nh\x06U\x07versionq\x0bh\x06U' b'\x04pathq\x0ch\x06U\x08httponlyq\rh\x06u}q\x0e(U\x0b' b'coded_valueq\x0fU\x05valueq\x10h\x10h\x10h\x02h\x02ubs}q\x11b.') # set([3]) pickled from 2.x with protocol 2 DATA_SET2 = b'\x80\x02c__builtin__\nset\nq\x00]q\x01K\x03a\x85q\x02Rq\x03.' python2_exceptions_without_args = ( ArithmeticError, AssertionError, AttributeError, BaseException, BufferError, BytesWarning, DeprecationWarning, EOFError, EnvironmentError, Exception, FloatingPointError, FutureWarning, GeneratorExit, IOError, ImportError, ImportWarning, IndentationError, IndexError, KeyError, KeyboardInterrupt, LookupError, MemoryError, NameError, NotImplementedError, OSError, OverflowError, PendingDeprecationWarning, ReferenceError, RuntimeError, RuntimeWarning, # StandardError is gone in Python 3, we map it to Exception StopIteration, SyntaxError, SyntaxWarning, SystemError, SystemExit, TabError, TypeError, UnboundLocalError, UnicodeError, UnicodeWarning, UserWarning, ValueError, Warning, ZeroDivisionError, ) exception_pickle = b'\x80\x02cexceptions\n?\nq\x00)Rq\x01.' # UnicodeEncodeError object pickled from 2.x with protocol 2 DATA_UEERR = (b'\x80\x02cexceptions\nUnicodeEncodeError\n' b'q\x00(U\x05asciiq\x01X\x03\x00\x00\x00fooq\x02K\x00K\x01' b'U\x03badq\x03tq\x04Rq\x05.') def create_data(): c = C() c.foo = 1 c.bar = 2 x = [0, 1, 2.0, 3.0+0j] # Append some integer test cases at cPickle.c's internal size # cutoffs. uint1max = 0xff uint2max = 0xffff int4max = 0x7fffffff x.extend([1, -1, uint1max, -uint1max, -uint1max-1, uint2max, -uint2max, -uint2max-1, int4max, -int4max, -int4max-1]) y = ('abc', 'abc', c, c) x.append(y) x.append(y) x.append(5) return x class AbstractUnpickleTests(unittest.TestCase): # Subclass must define self.loads. _testdata = create_data() def assert_is_copy(self, obj, objcopy, msg=None): """Utility method to verify if two objects are copies of each others. """ if msg is None: msg = "{!r} is not a copy of {!r}".format(obj, objcopy) self.assertEqual(obj, objcopy, msg=msg) self.assertIs(type(obj), type(objcopy), msg=msg) if hasattr(obj, '__dict__'): self.assertDictEqual(obj.__dict__, objcopy.__dict__, msg=msg) self.assertIsNot(obj.__dict__, objcopy.__dict__, msg=msg) if hasattr(obj, '__slots__'): self.assertListEqual(obj.__slots__, objcopy.__slots__, msg=msg) for slot in obj.__slots__: self.assertEqual( hasattr(obj, slot), hasattr(objcopy, slot), msg=msg) self.assertEqual(getattr(obj, slot, None), getattr(objcopy, slot, None), msg=msg) def check_unpickling_error(self, errors, data): with self.subTest(data=data), \ self.assertRaises(errors): try: self.loads(data) except BaseException as exc: if support.verbose > 1: print('%-32r - %s: %s' % (data, exc.__class__.__name__, exc)) raise def test_load_from_data0(self): self.assert_is_copy(self._testdata, self.loads(DATA0)) def test_load_from_data1(self): self.assert_is_copy(self._testdata, self.loads(DATA1)) def test_load_from_data2(self): self.assert_is_copy(self._testdata, self.loads(DATA2)) def test_load_from_data3(self): self.assert_is_copy(self._testdata, self.loads(DATA3)) def test_load_from_data4(self): self.assert_is_copy(self._testdata, self.loads(DATA4)) def test_load_classic_instance(self): # See issue5180. Test loading 2.x pickles that # contain an instance of old style class. for X, args in [(C, ()), (D, ('x',)), (E, ())]: xname = X.__name__.encode('ascii') # Protocol 0 (text mode pickle): """ 0: ( MARK 1: i INST '__main__ X' (MARK at 0) 13: p PUT 0 16: ( MARK 17: d DICT (MARK at 16) 18: p PUT 1 21: b BUILD 22: . STOP """ pickle0 = (b"(i__main__\n" b"X\n" b"p0\n" b"(dp1\nb.").replace(b'X', xname) self.assert_is_copy(X(*args), self.loads(pickle0)) # Protocol 1 (binary mode pickle) """ 0: ( MARK 1: c GLOBAL '__main__ X' 13: q BINPUT 0 15: o OBJ (MARK at 0) 16: q BINPUT 1 18: } EMPTY_DICT 19: q BINPUT 2 21: b BUILD 22: . STOP """ pickle1 = (b'(c__main__\n' b'X\n' b'q\x00oq\x01}q\x02b.').replace(b'X', xname) self.assert_is_copy(X(*args), self.loads(pickle1)) # Protocol 2 (pickle2 = b'\x80\x02' + pickle1) """ 0: \x80 PROTO 2 2: ( MARK 3: c GLOBAL '__main__ X' 15: q BINPUT 0 17: o OBJ (MARK at 2) 18: q BINPUT 1 20: } EMPTY_DICT 21: q BINPUT 2 23: b BUILD 24: . STOP """ pickle2 = (b'\x80\x02(c__main__\n' b'X\n' b'q\x00oq\x01}q\x02b.').replace(b'X', xname) self.assert_is_copy(X(*args), self.loads(pickle2)) def test_maxint64(self): maxint64 = (1 << 63) - 1 data = b'I' + str(maxint64).encode("ascii") + b'\n.' got = self.loads(data) self.assert_is_copy(maxint64, got) # Try too with a bogus literal. data = b'I' + str(maxint64).encode("ascii") + b'JUNK\n.' self.check_unpickling_error(ValueError, data) def test_unpickle_from_2x(self): # Unpickle non-trivial data from Python 2.x. loaded = self.loads(DATA_SET) self.assertEqual(loaded, set([1, 2])) loaded = self.loads(DATA_XRANGE) self.assertEqual(type(loaded), type(range(0))) self.assertEqual(list(loaded), list(range(5))) loaded = self.loads(DATA_COOKIE) self.assertEqual(type(loaded), SimpleCookie) self.assertEqual(list(loaded.keys()), ["key"]) self.assertEqual(loaded["key"].value, "value") # Exception objects without arguments pickled from 2.x with protocol 2 for exc in python2_exceptions_without_args: data = exception_pickle.replace(b'?', exc.__name__.encode("ascii")) loaded = self.loads(data) self.assertIs(type(loaded), exc) # StandardError is mapped to Exception, test that separately loaded = self.loads(exception_pickle.replace(b'?', b'StandardError')) self.assertIs(type(loaded), Exception) loaded = self.loads(DATA_UEERR) self.assertIs(type(loaded), UnicodeEncodeError) self.assertEqual(loaded.object, "foo") self.assertEqual(loaded.encoding, "ascii") self.assertEqual(loaded.start, 0) self.assertEqual(loaded.end, 1) self.assertEqual(loaded.reason, "bad") def test_load_python2_str_as_bytes(self): # From Python 2: pickle.dumps('a\x00\xa0', protocol=0) self.assertEqual(self.loads(b"S'a\\x00\\xa0'\n.", encoding="bytes"), b'a\x00\xa0') # From Python 2: pickle.dumps('a\x00\xa0', protocol=1) self.assertEqual(self.loads(b'U\x03a\x00\xa0.', encoding="bytes"), b'a\x00\xa0') # From Python 2: pickle.dumps('a\x00\xa0', protocol=2) self.assertEqual(self.loads(b'\x80\x02U\x03a\x00\xa0.', encoding="bytes"), b'a\x00\xa0') def test_load_python2_unicode_as_str(self): # From Python 2: pickle.dumps(u'π', protocol=0) self.assertEqual(self.loads(b'V\\u03c0\n.', encoding='bytes'), 'π') # From Python 2: pickle.dumps(u'π', protocol=1) self.assertEqual(self.loads(b'X\x02\x00\x00\x00\xcf\x80.', encoding="bytes"), 'π') # From Python 2: pickle.dumps(u'π', protocol=2) self.assertEqual(self.loads(b'\x80\x02X\x02\x00\x00\x00\xcf\x80.', encoding="bytes"), 'π') def test_load_long_python2_str_as_bytes(self): # From Python 2: pickle.dumps('x' * 300, protocol=1) self.assertEqual(self.loads(pickle.BINSTRING + struct.pack("<I", 300) + b'x' * 300 + pickle.STOP, encoding='bytes'), b'x' * 300) def test_constants(self): self.assertIsNone(self.loads(b'N.')) self.assertIs(self.loads(b'\x88.'), True) self.assertIs(self.loads(b'\x89.'), False) self.assertIs(self.loads(b'I01\n.'), True) self.assertIs(self.loads(b'I00\n.'), False) def test_empty_bytestring(self): # issue 11286 empty = self.loads(b'\x80\x03U\x00q\x00.', encoding='koi8-r') self.assertEqual(empty, '') def test_short_binbytes(self): dumped = b'\x80\x03C\x04\xe2\x82\xac\x00.' self.assertEqual(self.loads(dumped), b'\xe2\x82\xac\x00') def test_binbytes(self): dumped = b'\x80\x03B\x04\x00\x00\x00\xe2\x82\xac\x00.' self.assertEqual(self.loads(dumped), b'\xe2\x82\xac\x00') @requires_32b def test_negative_32b_binbytes(self): # On 32-bit builds, a BINBYTES of 2**31 or more is refused dumped = b'\x80\x03B\xff\xff\xff\xffxyzq\x00.' self.check_unpickling_error((pickle.UnpicklingError, OverflowError), dumped) @requires_32b def test_negative_32b_binunicode(self): # On 32-bit builds, a BINUNICODE of 2**31 or more is refused dumped = b'\x80\x03X\xff\xff\xff\xffxyzq\x00.' self.check_unpickling_error((pickle.UnpicklingError, OverflowError), dumped) def test_short_binunicode(self): dumped = b'\x80\x04\x8c\x04\xe2\x82\xac\x00.' self.assertEqual(self.loads(dumped), '\u20ac\x00') def test_misc_get(self): self.check_unpickling_error(KeyError, b'g0\np0') self.assert_is_copy([(100,), (100,)], self.loads(b'((Kdtp0\nh\x00l.))')) def test_binbytes8(self): dumped = b'\x80\x04\x8e\4\0\0\0\0\0\0\0\xe2\x82\xac\x00.' self.assertEqual(self.loads(dumped), b'\xe2\x82\xac\x00') def test_binunicode8(self): dumped = b'\x80\x04\x8d\4\0\0\0\0\0\0\0\xe2\x82\xac\x00.' self.assertEqual(self.loads(dumped), '\u20ac\x00') @requires_32b def test_large_32b_binbytes8(self): dumped = b'\x80\x04\x8e\4\0\0\0\1\0\0\0\xe2\x82\xac\x00.' self.check_unpickling_error((pickle.UnpicklingError, OverflowError), dumped) @requires_32b def test_large_32b_binunicode8(self): dumped = b'\x80\x04\x8d\4\0\0\0\1\0\0\0\xe2\x82\xac\x00.' self.check_unpickling_error((pickle.UnpicklingError, OverflowError), dumped) def test_get(self): pickled = b'((lp100000\ng100000\nt.' unpickled = self.loads(pickled) self.assertEqual(unpickled, ([],)*2) self.assertIs(unpickled[0], unpickled[1]) def test_binget(self): pickled = b'(]q\xffh\xfft.' unpickled = self.loads(pickled) self.assertEqual(unpickled, ([],)*2) self.assertIs(unpickled[0], unpickled[1]) def test_long_binget(self): pickled = b'(]r\x00\x00\x01\x00j\x00\x00\x01\x00t.' unpickled = self.loads(pickled) self.assertEqual(unpickled, ([],)*2) self.assertIs(unpickled[0], unpickled[1]) def test_dup(self): pickled = b'((l2t.' unpickled = self.loads(pickled) self.assertEqual(unpickled, ([],)*2) self.assertIs(unpickled[0], unpickled[1]) def test_negative_put(self): # Issue #12847 dumped = b'Va\np-1\n.' self.check_unpickling_error(ValueError, dumped) @requires_32b def test_negative_32b_binput(self): # Issue #12847 dumped = b'\x80\x03X\x01\x00\x00\x00ar\xff\xff\xff\xff.' self.check_unpickling_error(ValueError, dumped) def test_badly_escaped_string(self): self.check_unpickling_error(ValueError, b"S'\\'\n.") def test_badly_quoted_string(self): # Issue #17710 badpickles = [b"S'\n.", b'S"\n.', b'S\' \n.', b'S" \n.', b'S\'"\n.', b'S"\'\n.', b"S' ' \n.", b'S" " \n.', b"S ''\n.", b'S ""\n.', b'S \n.', b'S\n.', b'S.'] for p in badpickles: self.check_unpickling_error(pickle.UnpicklingError, p) def test_correctly_quoted_string(self): goodpickles = [(b"S''\n.", ''), (b'S""\n.', ''), (b'S"\\n"\n.', '\n'), (b"S'\\n'\n.", '\n')] for p, expected in goodpickles: self.assertEqual(self.loads(p), expected) def test_frame_readline(self): pickled = b'\x80\x04\x95\x05\x00\x00\x00\x00\x00\x00\x00I42\n.' # 0: \x80 PROTO 4 # 2: \x95 FRAME 5 # 11: I INT 42 # 15: . STOP self.assertEqual(self.loads(pickled), 42) def test_compat_unpickle(self): # xrange(1, 7) pickled = b'\x80\x02c__builtin__\nxrange\nK\x01K\x07K\x01\x87R.' unpickled = self.loads(pickled) self.assertIs(type(unpickled), range) self.assertEqual(unpickled, range(1, 7)) self.assertEqual(list(unpickled), [1, 2, 3, 4, 5, 6]) # reduce pickled = b'\x80\x02c__builtin__\nreduce\n.' self.assertIs(self.loads(pickled), functools.reduce) # whichdb.whichdb pickled = b'\x80\x02cwhichdb\nwhichdb\n.' # self.assertIs(self.loads(pickled), dbm.whichdb) # Exception(), StandardError() for name in (b'Exception', b'StandardError'): pickled = (b'\x80\x02cexceptions\n' + name + b'\nU\x03ugh\x85R.') unpickled = self.loads(pickled) self.assertIs(type(unpickled), Exception) self.assertEqual(str(unpickled), 'ugh') # UserDict.UserDict({1: 2}), UserDict.IterableUserDict({1: 2}) for name in (b'UserDict', b'IterableUserDict'): pickled = (b'\x80\x02(cUserDict\n' + name + b'\no}U\x04data}K\x01K\x02ssb.') unpickled = self.loads(pickled) self.assertIs(type(unpickled), collections.UserDict) self.assertEqual(unpickled, collections.UserDict({1: 2})) def test_bad_reduce(self): self.assertEqual(self.loads(b'cbuiltins\nint\n)R.'), 0) self.check_unpickling_error(TypeError, b'N)R.') self.check_unpickling_error(TypeError, b'cbuiltins\nint\nNR.') def test_bad_newobj(self): error = (pickle.UnpicklingError, TypeError) self.assertEqual(self.loads(b'cbuiltins\nint\n)\x81.'), 0) self.check_unpickling_error(error, b'cbuiltins\nlen\n)\x81.') self.check_unpickling_error(error, b'cbuiltins\nint\nN\x81.') def test_bad_newobj_ex(self): error = (pickle.UnpicklingError, TypeError) self.assertEqual(self.loads(b'cbuiltins\nint\n)}\x92.'), 0) self.check_unpickling_error(error, b'cbuiltins\nlen\n)}\x92.') self.check_unpickling_error(error, b'cbuiltins\nint\nN}\x92.') self.check_unpickling_error(error, b'cbuiltins\nint\n)N\x92.') def test_bad_stack(self): badpickles = [ b'.', # STOP b'0', # POP b'1', # POP_MARK b'2', # DUP b'(2', b'R', # REDUCE b')R', b'a', # APPEND b'Na', b'b', # BUILD b'Nb', b'd', # DICT b'e', # APPENDS b'(e', b'ibuiltins\nlist\n', # INST b'l', # LIST b'o', # OBJ b'(o', b'p1\n', # PUT b'q\x00', # BINPUT b'r\x00\x00\x00\x00', # LONG_BINPUT b's', # SETITEM b'Ns', b'NNs', b't', # TUPLE b'u', # SETITEMS b'(u', b'}(Nu', b'\x81', # NEWOBJ b')\x81', b'\x85', # TUPLE1 b'\x86', # TUPLE2 b'N\x86', b'\x87', # TUPLE3 b'N\x87', b'NN\x87', b'\x90', # ADDITEMS b'(\x90', b'\x91', # FROZENSET b'\x92', # NEWOBJ_EX b')}\x92', b'\x93', # STACK_GLOBAL b'Vlist\n\x93', b'\x94', # MEMOIZE ] for p in badpickles: self.check_unpickling_error(self.bad_stack_errors, p) def test_bad_mark(self): badpickles = [ b'N(.', # STOP b'N(2', # DUP b'cbuiltins\nlist\n)(R', # REDUCE b'cbuiltins\nlist\n()R', b']N(a', # APPEND # BUILD b'cbuiltins\nValueError\n)R}(b', b'cbuiltins\nValueError\n)R(}b', b'(Nd', # DICT b'N(p1\n', # PUT b'N(q\x00', # BINPUT b'N(r\x00\x00\x00\x00', # LONG_BINPUT b'}NN(s', # SETITEM b'}N(Ns', b'}(NNs', b'}((u', # SETITEMS b'cbuiltins\nlist\n)(\x81', # NEWOBJ b'cbuiltins\nlist\n()\x81', b'N(\x85', # TUPLE1 b'NN(\x86', # TUPLE2 b'N(N\x86', b'NNN(\x87', # TUPLE3 b'NN(N\x87', b'N(NN\x87', b']((\x90', # ADDITEMS # NEWOBJ_EX b'cbuiltins\nlist\n)}(\x92', b'cbuiltins\nlist\n)(}\x92', b'cbuiltins\nlist\n()}\x92', # STACK_GLOBAL b'Vbuiltins\n(Vlist\n\x93', b'Vbuiltins\nVlist\n(\x93', b'N(\x94', # MEMOIZE ] for p in badpickles: self.check_unpickling_error(self.bad_stack_errors, p) def test_truncated_data(self): self.check_unpickling_error(EOFError, b'') self.check_unpickling_error(EOFError, b'N') badpickles = [ b'B', # BINBYTES b'B\x03\x00\x00', b'B\x03\x00\x00\x00', b'B\x03\x00\x00\x00ab', b'C', # SHORT_BINBYTES b'C\x03', b'C\x03ab', b'F', # FLOAT b'F0.0', b'F0.00', b'G', # BINFLOAT b'G\x00\x00\x00\x00\x00\x00\x00', b'I', # INT b'I0', b'J', # BININT b'J\x00\x00\x00', b'K', # BININT1 b'L', # LONG b'L0', b'L10', b'L0L', b'L10L', b'M', # BININT2 b'M\x00', # b'P', # PERSID # b'Pabc', b'S', # STRING b"S'abc'", b'T', # BINSTRING b'T\x03\x00\x00', b'T\x03\x00\x00\x00', b'T\x03\x00\x00\x00ab', b'U', # SHORT_BINSTRING b'U\x03', b'U\x03ab', b'V', # UNICODE b'Vabc', b'X', # BINUNICODE b'X\x03\x00\x00', b'X\x03\x00\x00\x00', b'X\x03\x00\x00\x00ab', b'(c', # GLOBAL b'(cbuiltins', b'(cbuiltins\n', b'(cbuiltins\nlist', b'Ng', # GET b'Ng0', b'(i', # INST b'(ibuiltins', b'(ibuiltins\n', b'(ibuiltins\nlist', b'Nh', # BINGET b'Nj', # LONG_BINGET b'Nj\x00\x00\x00', b'Np', # PUT b'Np0', b'Nq', # BINPUT b'Nr', # LONG_BINPUT b'Nr\x00\x00\x00', b'\x80', # PROTO b'\x82', # EXT1 b'\x83', # EXT2 b'\x84\x01', b'\x84', # EXT4 b'\x84\x01\x00\x00', b'\x8a', # LONG1 b'\x8b', # LONG4 b'\x8b\x00\x00\x00', b'\x8c', # SHORT_BINUNICODE b'\x8c\x03', b'\x8c\x03ab', b'\x8d', # BINUNICODE8 b'\x8d\x03\x00\x00\x00\x00\x00\x00', b'\x8d\x03\x00\x00\x00\x00\x00\x00\x00', b'\x8d\x03\x00\x00\x00\x00\x00\x00\x00ab', b'\x8e', # BINBYTES8 b'\x8e\x03\x00\x00\x00\x00\x00\x00', b'\x8e\x03\x00\x00\x00\x00\x00\x00\x00', b'\x8e\x03\x00\x00\x00\x00\x00\x00\x00ab', b'\x95', # FRAME b'\x95\x02\x00\x00\x00\x00\x00\x00', b'\x95\x02\x00\x00\x00\x00\x00\x00\x00', b'\x95\x02\x00\x00\x00\x00\x00\x00\x00N', ] for p in badpickles: self.check_unpickling_error(self.truncated_errors, p) class AbstractPickleTests(unittest.TestCase): # Subclass must define self.dumps, self.loads. optimized = False _testdata = AbstractUnpickleTests._testdata def setUp(self): pass assert_is_copy = AbstractUnpickleTests.assert_is_copy def test_misc(self): # test various datatypes not tested by testdata for proto in protocols: x = myint(4) s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) x = (1, ()) s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) x = initarg(1, x) s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) # XXX test __reduce__ protocol? def test_roundtrip_equality(self): expected = self._testdata for proto in protocols: s = self.dumps(expected, proto) got = self.loads(s) self.assert_is_copy(expected, got) # There are gratuitous differences between pickles produced by # pickle and cPickle, largely because cPickle starts PUT indices at # 1 and pickle starts them at 0. See XXX comment in cPickle's put2() -- # there's a comment with an exclamation point there whose meaning # is a mystery. cPickle also suppresses PUT for objects with a refcount # of 1. def dont_test_disassembly(self): from io import StringIO from pickletools import dis for proto, expected in (0, DATA0_DIS), (1, DATA1_DIS): s = self.dumps(self._testdata, proto) filelike = StringIO() dis(s, out=filelike) got = filelike.getvalue() self.assertEqual(expected, got) def test_recursive_list(self): l = [] l.append(l) for proto in protocols: s = self.dumps(l, proto) x = self.loads(s) self.assertIsInstance(x, list) self.assertEqual(len(x), 1) self.assertIs(x[0], x) def test_recursive_tuple_and_list(self): t = ([],) t[0].append(t) for proto in protocols: s = self.dumps(t, proto) x = self.loads(s) self.assertIsInstance(x, tuple) self.assertEqual(len(x), 1) self.assertIsInstance(x[0], list) self.assertEqual(len(x[0]), 1) self.assertIs(x[0][0], x) def test_recursive_dict(self): d = {} d[1] = d for proto in protocols: s = self.dumps(d, proto) x = self.loads(s) self.assertIsInstance(x, dict) self.assertEqual(list(x.keys()), [1]) self.assertIs(x[1], x) def test_recursive_dict_key(self): d = {} k = K(d) d[k] = 1 for proto in protocols: s = self.dumps(d, proto) x = self.loads(s) self.assertIsInstance(x, dict) self.assertEqual(len(x.keys()), 1) self.assertIsInstance(list(x.keys())[0], K) self.assertIs(list(x.keys())[0].value, x) def test_recursive_set(self): y = set() k = K(y) y.add(k) for proto in range(4, pickle.HIGHEST_PROTOCOL + 1): s = self.dumps(y, proto) x = self.loads(s) self.assertIsInstance(x, set) self.assertEqual(len(x), 1) self.assertIsInstance(list(x)[0], K) self.assertIs(list(x)[0].value, x) def test_recursive_list_subclass(self): y = MyList() y.append(y) for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): s = self.dumps(y, proto) x = self.loads(s) self.assertIsInstance(x, MyList) self.assertEqual(len(x), 1) self.assertIs(x[0], x) def test_recursive_dict_subclass(self): d = MyDict() d[1] = d for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): s = self.dumps(d, proto) x = self.loads(s) self.assertIsInstance(x, MyDict) self.assertEqual(list(x.keys()), [1]) self.assertIs(x[1], x) def test_recursive_dict_subclass_key(self): d = MyDict() k = K(d) d[k] = 1 for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): s = self.dumps(d, proto) x = self.loads(s) self.assertIsInstance(x, MyDict) self.assertEqual(len(list(x.keys())), 1) self.assertIsInstance(list(x.keys())[0], K) self.assertIs(list(x.keys())[0].value, x) def test_recursive_inst(self): i = C() i.attr = i for proto in protocols: s = self.dumps(i, proto) x = self.loads(s) self.assertIsInstance(x, C) self.assertEqual(dir(x), dir(i)) self.assertIs(x.attr, x) def test_recursive_multi(self): l = [] d = {1:l} i = C() i.attr = d l.append(i) for proto in protocols: s = self.dumps(l, proto) x = self.loads(s) self.assertIsInstance(x, list) self.assertEqual(len(x), 1) self.assertEqual(dir(x[0]), dir(i)) self.assertEqual(list(x[0].attr.keys()), [1]) self.assertTrue(x[0].attr[1] is x) def check_recursive_collection_and_inst(self, factory): h = H() y = factory([h]) h.attr = y for proto in protocols: s = self.dumps(y, proto) x = self.loads(s) self.assertIsInstance(x, type(y)) self.assertEqual(len(x), 1) self.assertIsInstance(list(x)[0], H) self.assertIs(list(x)[0].attr, x) def test_recursive_list_and_inst(self): self.check_recursive_collection_and_inst(list) def test_recursive_tuple_and_inst(self): self.check_recursive_collection_and_inst(tuple) def test_recursive_dict_and_inst(self): self.check_recursive_collection_and_inst(dict.fromkeys) def test_recursive_set_and_inst(self): self.check_recursive_collection_and_inst(set) def test_recursive_frozenset_and_inst(self): self.check_recursive_collection_and_inst(frozenset) def test_recursive_list_subclass_and_inst(self): self.check_recursive_collection_and_inst(MyList) def test_recursive_tuple_subclass_and_inst(self): self.check_recursive_collection_and_inst(MyTuple) def test_recursive_dict_subclass_and_inst(self): self.check_recursive_collection_and_inst(MyDict.fromkeys) def test_recursive_set_subclass_and_inst(self): self.check_recursive_collection_and_inst(MySet) def test_recursive_frozenset_subclass_and_inst(self): self.check_recursive_collection_and_inst(MyFrozenSet) def test_unicode(self): endcases = ['', '<\\u>', '<\\\u1234>', '<\n>', '<\\>', '<\\\U00012345>', # surrogates '<\udc80>'] for proto in protocols: for u in endcases: p = self.dumps(u, proto) u2 = self.loads(p) self.assert_is_copy(u, u2) def test_unicode_high_plane(self): t = '\U00012345' for proto in protocols: p = self.dumps(t, proto) t2 = self.loads(p) self.assert_is_copy(t, t2) def test_bytes(self): for proto in protocols: for s in b'', b'xyz', b'xyz'*100: p = self.dumps(s, proto) self.assert_is_copy(s, self.loads(p)) for s in [bytes([i]) for i in range(256)]: p = self.dumps(s, proto) self.assert_is_copy(s, self.loads(p)) for s in [bytes([i, i]) for i in range(256)]: p = self.dumps(s, proto) self.assert_is_copy(s, self.loads(p)) def test_ints(self): for proto in protocols: n = sys.maxsize while n: for expected in (-n, n): s = self.dumps(expected, proto) n2 = self.loads(s) self.assert_is_copy(expected, n2) n = n >> 1 def test_long(self): for proto in protocols: # 256 bytes is where LONG4 begins. for nbits in 1, 8, 8*254, 8*255, 8*256, 8*257: nbase = 1 << nbits for npos in nbase-1, nbase, nbase+1: for n in npos, -npos: pickle = self.dumps(n, proto) got = self.loads(pickle) self.assert_is_copy(n, got) # Try a monster. This is quadratic-time in protos 0 & 1, so don't # bother with those. nbase = int("deadbeeffeedface", 16) nbase += nbase << 1000000 for n in nbase, -nbase: p = self.dumps(n, 2) got = self.loads(p) # assert_is_copy is very expensive here as it precomputes # a failure message by computing the repr() of n and got, # we just do the check ourselves. self.assertIs(type(got), int) self.assertEqual(n, got) def test_float(self): test_values = [0.0, 4.94e-324, 1e-310, 7e-308, 6.626e-34, 0.1, 0.5, 3.14, 263.44582062374053, 6.022e23, 1e30] test_values = test_values + [-x for x in test_values] for proto in protocols: for value in test_values: pickle = self.dumps(value, proto) got = self.loads(pickle) self.assert_is_copy(value, got) @run_with_locale('LC_ALL', 'de_DE', 'fr_FR') def test_float_format(self): # make sure that floats are formatted locale independent with proto 0 self.assertEqual(self.dumps(1.2, 0)[0:3], b'F1.') def test_reduce(self): for proto in protocols: inst = AAA() dumped = self.dumps(inst, proto) loaded = self.loads(dumped) self.assertEqual(loaded, REDUCE_A) def test_getinitargs(self): for proto in protocols: inst = initarg(1, 2) dumped = self.dumps(inst, proto) loaded = self.loads(dumped) self.assert_is_copy(inst, loaded) def test_metaclass(self): a = use_metaclass() for proto in protocols: s = self.dumps(a, proto) b = self.loads(s) self.assertEqual(a.__class__, b.__class__) def test_dynamic_class(self): a = create_dynamic_class("my_dynamic_class", (object,)) copyreg.pickle(pickling_metaclass, pickling_metaclass.__reduce__) for proto in protocols: s = self.dumps(a, proto) b = self.loads(s) self.assertEqual(a, b) self.assertIs(type(a), type(b)) def test_structseq(self): import time import os t = time.localtime() for proto in protocols: s = self.dumps(t, proto) u = self.loads(s) self.assert_is_copy(t, u) if hasattr(os, "stat"): t = os.stat(os.curdir) s = self.dumps(t, proto) u = self.loads(s) self.assert_is_copy(t, u) if hasattr(os, "statvfs"): t = os.statvfs(os.curdir) s = self.dumps(t, proto) u = self.loads(s) self.assert_is_copy(t, u) def test_ellipsis(self): for proto in protocols: s = self.dumps(..., proto) u = self.loads(s) self.assertIs(..., u) def test_notimplemented(self): for proto in protocols: s = self.dumps(NotImplemented, proto) u = self.loads(s) self.assertIs(NotImplemented, u) def test_singleton_types(self): # Issue #6477: Test that types of built-in singletons can be pickled. singletons = [None, ..., NotImplemented] for singleton in singletons: for proto in protocols: s = self.dumps(type(singleton), proto) u = self.loads(s) self.assertIs(type(singleton), u) # Tests for protocol 2 def test_proto(self): for proto in protocols: pickled = self.dumps(None, proto) if proto >= 2: proto_header = pickle.PROTO + bytes([proto]) self.assertTrue(pickled.startswith(proto_header)) else: self.assertEqual(count_opcode(pickle.PROTO, pickled), 0) oob = protocols[-1] + 1 # a future protocol build_none = pickle.NONE + pickle.STOP badpickle = pickle.PROTO + bytes([oob]) + build_none try: self.loads(badpickle) except ValueError as err: self.assertIn("unsupported pickle protocol", str(err)) else: self.fail("expected bad protocol number to raise ValueError") def test_long1(self): x = 12345678910111213141516178920 for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) self.assertEqual(opcode_in_pickle(pickle.LONG1, s), proto >= 2) def test_long4(self): x = 12345678910111213141516178920 << (256*8) for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) self.assertEqual(opcode_in_pickle(pickle.LONG4, s), proto >= 2) def test_short_tuples(self): # Map (proto, len(tuple)) to expected opcode. expected_opcode = {(0, 0): pickle.TUPLE, (0, 1): pickle.TUPLE, (0, 2): pickle.TUPLE, (0, 3): pickle.TUPLE, (0, 4): pickle.TUPLE, (1, 0): pickle.EMPTY_TUPLE, (1, 1): pickle.TUPLE, (1, 2): pickle.TUPLE, (1, 3): pickle.TUPLE, (1, 4): pickle.TUPLE, (2, 0): pickle.EMPTY_TUPLE, (2, 1): pickle.TUPLE1, (2, 2): pickle.TUPLE2, (2, 3): pickle.TUPLE3, (2, 4): pickle.TUPLE, (3, 0): pickle.EMPTY_TUPLE, (3, 1): pickle.TUPLE1, (3, 2): pickle.TUPLE2, (3, 3): pickle.TUPLE3, (3, 4): pickle.TUPLE, } a = () b = (1,) c = (1, 2) d = (1, 2, 3) e = (1, 2, 3, 4) for proto in protocols: for x in a, b, c, d, e: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) expected = expected_opcode[min(proto, 3), len(x)] self.assertTrue(opcode_in_pickle(expected, s)) def test_singletons(self): # Map (proto, singleton) to expected opcode. expected_opcode = {(0, None): pickle.NONE, (1, None): pickle.NONE, (2, None): pickle.NONE, (3, None): pickle.NONE, (0, True): pickle.INT, (1, True): pickle.INT, (2, True): pickle.NEWTRUE, (3, True): pickle.NEWTRUE, (0, False): pickle.INT, (1, False): pickle.INT, (2, False): pickle.NEWFALSE, (3, False): pickle.NEWFALSE, } for proto in protocols: for x in None, False, True: s = self.dumps(x, proto) y = self.loads(s) self.assertTrue(x is y, (proto, x, s, y)) expected = expected_opcode[min(proto, 3), x] self.assertTrue(opcode_in_pickle(expected, s)) def test_newobj_tuple(self): x = MyTuple([1, 2, 3]) x.foo = 42 x.bar = "hello" for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) def test_newobj_list(self): x = MyList([1, 2, 3]) x.foo = 42 x.bar = "hello" for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) def test_newobj_generic(self): for proto in protocols: for C in myclasses: B = C.__base__ x = C(C.sample) x.foo = 42 s = self.dumps(x, proto) y = self.loads(s) detail = (proto, C, B, x, y, type(y)) self.assert_is_copy(x, y) # XXX revisit self.assertEqual(B(x), B(y), detail) self.assertEqual(x.__dict__, y.__dict__, detail) def test_newobj_proxies(self): # NEWOBJ should use the __class__ rather than the raw type classes = myclasses[:] # Cannot create weakproxies to these classes for c in (MyInt, MyTuple): classes.remove(c) for proto in protocols: for C in classes: B = C.__base__ x = C(C.sample) x.foo = 42 p = weakref.proxy(x) s = self.dumps(p, proto) y = self.loads(s) self.assertEqual(type(y), type(x)) # rather than type(p) detail = (proto, C, B, x, y, type(y)) self.assertEqual(B(x), B(y), detail) self.assertEqual(x.__dict__, y.__dict__, detail) def test_newobj_not_class(self): # Issue 24552 global SimpleNewObj save = SimpleNewObj o = SimpleNewObj.__new__(SimpleNewObj) b = self.dumps(o, 4) try: SimpleNewObj = 42 self.assertRaises((TypeError, pickle.UnpicklingError), self.loads, b) finally: SimpleNewObj = save # Register a type with copyreg, with extension code extcode. Pickle # an object of that type. Check that the resulting pickle uses opcode # (EXT[124]) under proto 2, and not in proto 1. def produce_global_ext(self, extcode, opcode): e = ExtensionSaver(extcode) try: copyreg.add_extension(__name__, "MyList", extcode) x = MyList([1, 2, 3]) x.foo = 42 x.bar = "hello" # Dump using protocol 1 for comparison. s1 = self.dumps(x, 1) self.assertIn(__name__.encode("utf-8"), s1) self.assertIn(b"MyList", s1) self.assertFalse(opcode_in_pickle(opcode, s1)) y = self.loads(s1) self.assert_is_copy(x, y) # Dump using protocol 2 for test. s2 = self.dumps(x, 2) self.assertNotIn(__name__.encode("utf-8"), s2) self.assertNotIn(b"MyList", s2) self.assertEqual(opcode_in_pickle(opcode, s2), True, repr(s2)) y = self.loads(s2) self.assert_is_copy(x, y) finally: e.restore() def test_global_ext1(self): self.produce_global_ext(0x00000001, pickle.EXT1) # smallest EXT1 code self.produce_global_ext(0x000000ff, pickle.EXT1) # largest EXT1 code def test_global_ext2(self): self.produce_global_ext(0x00000100, pickle.EXT2) # smallest EXT2 code self.produce_global_ext(0x0000ffff, pickle.EXT2) # largest EXT2 code self.produce_global_ext(0x0000abcd, pickle.EXT2) # check endianness def test_global_ext4(self): self.produce_global_ext(0x00010000, pickle.EXT4) # smallest EXT4 code self.produce_global_ext(0x7fffffff, pickle.EXT4) # largest EXT4 code self.produce_global_ext(0x12abcdef, pickle.EXT4) # check endianness def test_list_chunking(self): n = 10 # too small to chunk x = list(range(n)) for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) num_appends = count_opcode(pickle.APPENDS, s) self.assertEqual(num_appends, proto > 0) n = 2500 # expect at least two chunks when proto > 0 x = list(range(n)) for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) num_appends = count_opcode(pickle.APPENDS, s) if proto == 0: self.assertEqual(num_appends, 0) else: self.assertTrue(num_appends >= 2) def test_dict_chunking(self): n = 10 # too small to chunk x = dict.fromkeys(range(n)) for proto in protocols: s = self.dumps(x, proto) self.assertIsInstance(s, bytes_types) y = self.loads(s) self.assert_is_copy(x, y) num_setitems = count_opcode(pickle.SETITEMS, s) self.assertEqual(num_setitems, proto > 0) n = 2500 # expect at least two chunks when proto > 0 x = dict.fromkeys(range(n)) for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) num_setitems = count_opcode(pickle.SETITEMS, s) if proto == 0: self.assertEqual(num_setitems, 0) else: self.assertTrue(num_setitems >= 2) def test_set_chunking(self): n = 10 # too small to chunk x = set(range(n)) for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) num_additems = count_opcode(pickle.ADDITEMS, s) if proto < 4: self.assertEqual(num_additems, 0) else: self.assertEqual(num_additems, 1) n = 2500 # expect at least two chunks when proto >= 4 x = set(range(n)) for proto in protocols: s = self.dumps(x, proto) y = self.loads(s) self.assert_is_copy(x, y) num_additems = count_opcode(pickle.ADDITEMS, s) if proto < 4: self.assertEqual(num_additems, 0) else: self.assertGreaterEqual(num_additems, 2) def test_simple_newobj(self): x = SimpleNewObj.__new__(SimpleNewObj, 0xface) # avoid __init__ x.abc = 666 for proto in protocols: with self.subTest(proto=proto): s = self.dumps(x, proto) if proto < 1: self.assertIn(b'\nL64206', s) # LONG else: self.assertIn(b'M\xce\xfa', s) # BININT2 self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s), 2 <= proto) self.assertFalse(opcode_in_pickle(pickle.NEWOBJ_EX, s)) y = self.loads(s) # will raise TypeError if __init__ called self.assert_is_copy(x, y) def test_complex_newobj(self): x = ComplexNewObj.__new__(ComplexNewObj, 0xface) # avoid __init__ x.abc = 666 for proto in protocols: with self.subTest(proto=proto): s = self.dumps(x, proto) if proto < 1: self.assertIn(b'\nL64206', s) # LONG elif proto < 2: self.assertIn(b'M\xce\xfa', s) # BININT2 elif proto < 4: self.assertIn(b'X\x04\x00\x00\x00FACE', s) # BINUNICODE else: self.assertIn(b'\x8c\x04FACE', s) # SHORT_BINUNICODE self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s), 2 <= proto) self.assertFalse(opcode_in_pickle(pickle.NEWOBJ_EX, s)) y = self.loads(s) # will raise TypeError if __init__ called self.assert_is_copy(x, y) def test_complex_newobj_ex(self): x = ComplexNewObjEx.__new__(ComplexNewObjEx, 0xface) # avoid __init__ x.abc = 666 for proto in protocols: with self.subTest(proto=proto): s = self.dumps(x, proto) if proto < 1: self.assertIn(b'\nL64206', s) # LONG elif proto < 2: self.assertIn(b'M\xce\xfa', s) # BININT2 elif proto < 4: self.assertIn(b'X\x04\x00\x00\x00FACE', s) # BINUNICODE else: self.assertIn(b'\x8c\x04FACE', s) # SHORT_BINUNICODE self.assertFalse(opcode_in_pickle(pickle.NEWOBJ, s)) self.assertEqual(opcode_in_pickle(pickle.NEWOBJ_EX, s), 4 <= proto) y = self.loads(s) # will raise TypeError if __init__ called self.assert_is_copy(x, y) def test_newobj_list_slots(self): x = SlotList([1, 2, 3]) x.foo = 42 x.bar = "hello" s = self.dumps(x, 2) y = self.loads(s) self.assert_is_copy(x, y) def test_reduce_overrides_default_reduce_ex(self): for proto in protocols: x = REX_one() self.assertEqual(x._reduce_called, 0) s = self.dumps(x, proto) self.assertEqual(x._reduce_called, 1) y = self.loads(s) self.assertEqual(y._reduce_called, 0) def test_reduce_ex_called(self): for proto in protocols: x = REX_two() self.assertEqual(x._proto, None) s = self.dumps(x, proto) self.assertEqual(x._proto, proto) y = self.loads(s) self.assertEqual(y._proto, None) def test_reduce_ex_overrides_reduce(self): for proto in protocols: x = REX_three() self.assertEqual(x._proto, None) s = self.dumps(x, proto) self.assertEqual(x._proto, proto) y = self.loads(s) self.assertEqual(y._proto, None) def test_reduce_ex_calls_base(self): for proto in protocols: x = REX_four() self.assertEqual(x._proto, None) s = self.dumps(x, proto) self.assertEqual(x._proto, proto) y = self.loads(s) self.assertEqual(y._proto, proto) def test_reduce_calls_base(self): for proto in protocols: x = REX_five() self.assertEqual(x._reduce_called, 0) s = self.dumps(x, proto) self.assertEqual(x._reduce_called, 1) y = self.loads(s) self.assertEqual(y._reduce_called, 1) @no_tracing @unittest.skipIf(True, "disabled recursion checking + slow in asan, dbg") def test_bad_getattr(self): # Issue #3514: crash when there is an infinite loop in __getattr__ x = BadGetattr() for proto in protocols: self.assertRaises(RuntimeError, self.dumps, x, proto) def test_reduce_bad_iterator(self): # Issue4176: crash when 4th and 5th items of __reduce__() # are not iterators class C(object): def __reduce__(self): # 4th item is not an iterator return list, (), None, [], None class D(object): def __reduce__(self): # 5th item is not an iterator return dict, (), None, None, [] # Python implementation is less strict and also accepts iterables. for proto in protocols: try: self.dumps(C(), proto) except pickle.PicklingError: pass try: self.dumps(D(), proto) except pickle.PicklingError: pass def test_many_puts_and_gets(self): # Test that internal data structures correctly deal with lots of # puts/gets. keys = ("aaa" + str(i) for i in range(100)) large_dict = dict((k, [4, 5, 6]) for k in keys) obj = [dict(large_dict), dict(large_dict), dict(large_dict)] for proto in protocols: with self.subTest(proto=proto): dumped = self.dumps(obj, proto) loaded = self.loads(dumped) self.assert_is_copy(obj, loaded) def test_attribute_name_interning(self): # Test that attribute names of pickled objects are interned when # unpickling. for proto in protocols: x = C() x.foo = 42 x.bar = "hello" s = self.dumps(x, proto) y = self.loads(s) x_keys = sorted(x.__dict__) y_keys = sorted(y.__dict__) for x_key, y_key in zip(x_keys, y_keys): self.assertIs(x_key, y_key) def test_pickle_to_2x(self): # Pickle non-trivial data with protocol 2, expecting that it yields # the same result as Python 2.x did. # NOTE: this test is a bit too strong since we can produce different # bytecode that 2.x will still understand. dumped = self.dumps(range(5), 2) self.assertEqual(dumped, DATA_XRANGE) dumped = self.dumps(set([3]), 2) self.assertEqual(dumped, DATA_SET2) def test_large_pickles(self): # Test the correctness of internal buffering routines when handling # large data. for proto in protocols: data = (1, min, b'xy' * (30 * 1024), len) dumped = self.dumps(data, proto) loaded = self.loads(dumped) self.assertEqual(len(loaded), len(data)) self.assertEqual(loaded, data) def test_int_pickling_efficiency(self): # Test compacity of int representation (see issue #12744) for proto in protocols: with self.subTest(proto=proto): pickles = [self.dumps(2**n, proto) for n in range(70)] sizes = list(map(len, pickles)) # the size function is monotonic self.assertEqual(sorted(sizes), sizes) if proto >= 2: for p in pickles: self.assertFalse(opcode_in_pickle(pickle.LONG, p)) def _check_pickling_with_opcode(self, obj, opcode, proto): pickled = self.dumps(obj, proto) self.assertTrue(opcode_in_pickle(opcode, pickled)) unpickled = self.loads(pickled) self.assertEqual(obj, unpickled) def test_appends_on_non_lists(self): # Issue #17720 obj = REX_six([1, 2, 3]) for proto in protocols: if proto == 0: self._check_pickling_with_opcode(obj, pickle.APPEND, proto) else: self._check_pickling_with_opcode(obj, pickle.APPENDS, proto) def test_setitems_on_non_dicts(self): obj = REX_seven({1: -1, 2: -2, 3: -3}) for proto in protocols: if proto == 0: self._check_pickling_with_opcode(obj, pickle.SETITEM, proto) else: self._check_pickling_with_opcode(obj, pickle.SETITEMS, proto) # Exercise framing (proto >= 4) for significant workloads FRAME_SIZE_TARGET = 64 * 1024 def check_frame_opcodes(self, pickled): """ Check the arguments of FRAME opcodes in a protocol 4+ pickle. """ frame_opcode_size = 9 last_arg = last_pos = None for op, arg, pos in pickletools.genops(pickled): if op.name != 'FRAME': continue if last_pos is not None: # The previous frame's size should be equal to the number # of bytes up to the current frame. frame_size = pos - last_pos - frame_opcode_size self.assertEqual(frame_size, last_arg) last_arg, last_pos = arg, pos # The last frame's size should be equal to the number of bytes up # to the pickle's end. frame_size = len(pickled) - last_pos - frame_opcode_size self.assertEqual(frame_size, last_arg) def test_framing_many_objects(self): obj = list(range(10**5)) for proto in range(4, pickle.HIGHEST_PROTOCOL + 1): with self.subTest(proto=proto): pickled = self.dumps(obj, proto) unpickled = self.loads(pickled) self.assertEqual(obj, unpickled) bytes_per_frame = (len(pickled) / count_opcode(pickle.FRAME, pickled)) self.assertGreater(bytes_per_frame, self.FRAME_SIZE_TARGET / 2) self.assertLessEqual(bytes_per_frame, self.FRAME_SIZE_TARGET * 1) self.check_frame_opcodes(pickled) @unittest.skipIf(cosmo.MODE in ("asan", "dbg"), "extremely slow in asan mode") def test_framing_large_objects(self): N = 1024 * 1024 obj = [b'x' * N, b'y' * N, b'z' * N] for proto in range(4, pickle.HIGHEST_PROTOCOL + 1): with self.subTest(proto=proto): pickled = self.dumps(obj, proto) unpickled = self.loads(pickled) self.assertEqual(obj, unpickled) n_frames = count_opcode(pickle.FRAME, pickled) self.assertGreaterEqual(n_frames, len(obj)) self.check_frame_opcodes(pickled) def test_optional_frames(self): if pickle.HIGHEST_PROTOCOL < 4: return def remove_frames(pickled, keep_frame=None): """Remove frame opcodes from the given pickle.""" frame_starts = [] # 1 byte for the opcode and 8 for the argument frame_opcode_size = 9 for opcode, _, pos in pickletools.genops(pickled): if opcode.name == 'FRAME': frame_starts.append(pos) newpickle = bytearray() last_frame_end = 0 for i, pos in enumerate(frame_starts): if keep_frame and keep_frame(i): continue newpickle += pickled[last_frame_end:pos] last_frame_end = pos + frame_opcode_size newpickle += pickled[last_frame_end:] return newpickle frame_size = self.FRAME_SIZE_TARGET num_frames = 20 obj = [bytes([i]) * frame_size for i in range(num_frames)] for proto in range(4, pickle.HIGHEST_PROTOCOL + 1): pickled = self.dumps(obj, proto) frameless_pickle = remove_frames(pickled) self.assertEqual(count_opcode(pickle.FRAME, frameless_pickle), 0) self.assertEqual(obj, self.loads(frameless_pickle)) some_frames_pickle = remove_frames(pickled, lambda i: i % 2) self.assertLess(count_opcode(pickle.FRAME, some_frames_pickle), count_opcode(pickle.FRAME, pickled)) self.assertEqual(obj, self.loads(some_frames_pickle)) def test_nested_names(self): global Nested class Nested: class A: class B: class C: pass for proto in range(pickle.HIGHEST_PROTOCOL + 1): for obj in [Nested.A, Nested.A.B, Nested.A.B.C]: with self.subTest(proto=proto, obj=obj): unpickled = self.loads(self.dumps(obj, proto)) self.assertIs(obj, unpickled) def test_recursive_nested_names(self): global Recursive class Recursive: pass Recursive.mod = sys.modules[Recursive.__module__] Recursive.__qualname__ = 'Recursive.mod.Recursive' for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.subTest(proto=proto): unpickled = self.loads(self.dumps(Recursive, proto)) self.assertIs(unpickled, Recursive) del Recursive.mod # break reference loop def test_py_methods(self): global PyMethodsTest class PyMethodsTest: @staticmethod def cheese(): return "cheese" @classmethod def wine(cls): assert cls is PyMethodsTest return "wine" def biscuits(self): assert isinstance(self, PyMethodsTest) return "biscuits" class Nested: "Nested class" @staticmethod def ketchup(): return "ketchup" @classmethod def maple(cls): assert cls is PyMethodsTest.Nested return "maple" def pie(self): assert isinstance(self, PyMethodsTest.Nested) return "pie" py_methods = ( PyMethodsTest.cheese, PyMethodsTest.wine, PyMethodsTest().biscuits, PyMethodsTest.Nested.ketchup, PyMethodsTest.Nested.maple, PyMethodsTest.Nested().pie ) py_unbound_methods = ( (PyMethodsTest.biscuits, PyMethodsTest), (PyMethodsTest.Nested.pie, PyMethodsTest.Nested) ) for proto in range(pickle.HIGHEST_PROTOCOL + 1): for method in py_methods: with self.subTest(proto=proto, method=method): unpickled = self.loads(self.dumps(method, proto)) self.assertEqual(method(), unpickled()) for method, cls in py_unbound_methods: obj = cls() with self.subTest(proto=proto, method=method): unpickled = self.loads(self.dumps(method, proto)) self.assertEqual(method(obj), unpickled(obj)) def test_c_methods(self): global Subclass class Subclass(tuple): class Nested(str): pass c_methods = ( # bound built-in method ("abcd".index, ("c",)), # unbound built-in method (str.index, ("abcd", "c")), # bound "slot" method ([1, 2, 3].__len__, ()), # unbound "slot" method (list.__len__, ([1, 2, 3],)), # bound "coexist" method ({1, 2}.__contains__, (2,)), # unbound "coexist" method (set.__contains__, ({1, 2}, 2)), # built-in class method (dict.fromkeys, (("a", 1), ("b", 2))), # built-in static method (bytearray.maketrans, (b"abc", b"xyz")), # subclass methods (Subclass([1,2,2]).count, (2,)), (Subclass.count, (Subclass([1,2,2]), 2)), (Subclass.Nested("sweet").count, ("e",)), (Subclass.Nested.count, (Subclass.Nested("sweet"), "e")), ) for proto in range(pickle.HIGHEST_PROTOCOL + 1): for method, args in c_methods: with self.subTest(proto=proto, method=method): unpickled = self.loads(self.dumps(method, proto)) self.assertEqual(method(*args), unpickled(*args)) def test_compat_pickle(self): tests = [ (range(1, 7), '__builtin__', 'xrange'), (map(int, '123'), 'itertools', 'imap'), (functools.reduce, '__builtin__', 'reduce'), # (dbm.whichdb, 'whichdb', 'whichdb'), (Exception(), 'exceptions', 'Exception'), (collections.UserDict(), 'UserDict', 'IterableUserDict'), (collections.UserList(), 'UserList', 'UserList'), (collections.defaultdict(), 'collections', 'defaultdict'), ] for val, mod, name in tests: for proto in range(3): with self.subTest(type=type(val), proto=proto): pickled = self.dumps(val, proto) self.assertIn(('c%s\n%s' % (mod, name)).encode(), pickled) self.assertIs(type(self.loads(pickled)), type(val)) def test_local_lookup_error(self): # Test that whichmodule() errors out cleanly when looking up # an assumed globally-reachable object fails. def f(): pass # Since the function is local, lookup will fail for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises((AttributeError, pickle.PicklingError)): pickletools.dis(self.dumps(f, proto)) # Same without a __module__ attribute (exercises a different path # in _pickle.c). del f.__module__ for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises((AttributeError, pickle.PicklingError)): pickletools.dis(self.dumps(f, proto)) # Yet a different path. f.__name__ = f.__qualname__ for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises((AttributeError, pickle.PicklingError)): pickletools.dis(self.dumps(f, proto)) class BigmemPickleTests(unittest.TestCase): # Binary protocols can serialize longs of up to 2GB-1 @bigmemtest(size=_2G, memuse=3.6, dry_run=False) def test_huge_long_32b(self, size): data = 1 << (8 * size) try: for proto in protocols: if proto < 2: continue with self.subTest(proto=proto): with self.assertRaises((ValueError, OverflowError)): self.dumps(data, protocol=proto) finally: data = None # Protocol 3 can serialize up to 4GB-1 as a bytes object # (older protocols don't have a dedicated opcode for bytes and are # too inefficient) @bigmemtest(size=_2G, memuse=2.5, dry_run=False) def test_huge_bytes_32b(self, size): data = b"abcd" * (size // 4) try: for proto in protocols: if proto < 3: continue with self.subTest(proto=proto): try: pickled = self.dumps(data, protocol=proto) header = (pickle.BINBYTES + struct.pack("<I", len(data))) data_start = pickled.index(data) self.assertEqual( header, pickled[data_start-len(header):data_start]) finally: pickled = None finally: data = None @bigmemtest(size=_4G, memuse=2.5, dry_run=False) def test_huge_bytes_64b(self, size): data = b"acbd" * (size // 4) try: for proto in protocols: if proto < 3: continue with self.subTest(proto=proto): if proto == 3: # Protocol 3 does not support large bytes objects. # Verify that we do not crash when processing one. with self.assertRaises((ValueError, OverflowError)): self.dumps(data, protocol=proto) continue try: pickled = self.dumps(data, protocol=proto) header = (pickle.BINBYTES8 + struct.pack("<Q", len(data))) data_start = pickled.index(data) self.assertEqual( header, pickled[data_start-len(header):data_start]) finally: pickled = None finally: data = None # All protocols use 1-byte per printable ASCII character; we add another # byte because the encoded form has to be copied into the internal buffer. @bigmemtest(size=_2G, memuse=8, dry_run=False) def test_huge_str_32b(self, size): data = "abcd" * (size // 4) try: for proto in protocols: if proto == 0: continue with self.subTest(proto=proto): try: pickled = self.dumps(data, protocol=proto) header = (pickle.BINUNICODE + struct.pack("<I", len(data))) data_start = pickled.index(b'abcd') self.assertEqual( header, pickled[data_start-len(header):data_start]) self.assertEqual((pickled.rindex(b"abcd") + len(b"abcd") - pickled.index(b"abcd")), len(data)) finally: pickled = None finally: data = None # BINUNICODE (protocols 1, 2 and 3) cannot carry more than 2**32 - 1 bytes # of utf-8 encoded unicode. BINUNICODE8 (protocol 4) supports these huge # unicode strings however. @bigmemtest(size=_4G, memuse=8, dry_run=False) def test_huge_str_64b(self, size): data = "abcd" * (size // 4) try: for proto in protocols: if proto == 0: continue with self.subTest(proto=proto): if proto < 4: with self.assertRaises((ValueError, OverflowError)): self.dumps(data, protocol=proto) continue try: pickled = self.dumps(data, protocol=proto) header = (pickle.BINUNICODE8 + struct.pack("<Q", len(data))) data_start = pickled.index(b'abcd') self.assertEqual( header, pickled[data_start-len(header):data_start]) self.assertEqual((pickled.rindex(b"abcd") + len(b"abcd") - pickled.index(b"abcd")), len(data)) finally: pickled = None finally: data = None # Test classes for reduce_ex class REX_one(object): """No __reduce_ex__ here, but inheriting it from object""" _reduce_called = 0 def __reduce__(self): self._reduce_called = 1 return REX_one, () class REX_two(object): """No __reduce__ here, but inheriting it from object""" _proto = None def __reduce_ex__(self, proto): self._proto = proto return REX_two, () class REX_three(object): _proto = None def __reduce_ex__(self, proto): self._proto = proto return REX_two, () def __reduce__(self): raise TestFailed("This __reduce__ shouldn't be called") class REX_four(object): """Calling base class method should succeed""" _proto = None def __reduce_ex__(self, proto): self._proto = proto return object.__reduce_ex__(self, proto) class REX_five(object): """This one used to fail with infinite recursion""" _reduce_called = 0 def __reduce__(self): self._reduce_called = 1 return object.__reduce__(self) class REX_six(object): """This class is used to check the 4th argument (list iterator) of the reduce protocol. """ def __init__(self, items=None): self.items = items if items is not None else [] def __eq__(self, other): return type(self) is type(other) and self.items == other.items def append(self, item): self.items.append(item) def __reduce__(self): return type(self), (), None, iter(self.items), None class REX_seven(object): """This class is used to check the 5th argument (dict iterator) of the reduce protocol. """ def __init__(self, table=None): self.table = table if table is not None else {} def __eq__(self, other): return type(self) is type(other) and self.table == other.table def __setitem__(self, key, value): self.table[key] = value def __reduce__(self): return type(self), (), None, None, iter(self.table.items()) # Test classes for newobj class MyInt(int): sample = 1 class MyFloat(float): sample = 1.0 class MyComplex(complex): sample = 1.0 + 0.0j class MyStr(str): sample = "hello" class MyUnicode(str): sample = "hello \u1234" class MyTuple(tuple): sample = (1, 2, 3) class MyList(list): sample = [1, 2, 3] class MyDict(dict): sample = {"a": 1, "b": 2} class MySet(set): sample = {"a", "b"} class MyFrozenSet(frozenset): sample = frozenset({"a", "b"}) myclasses = [MyInt, MyFloat, MyComplex, MyStr, MyUnicode, MyTuple, MyList, MyDict, MySet, MyFrozenSet] class SlotList(MyList): __slots__ = ["foo"] class SimpleNewObj(int): def __init__(self, *args, **kwargs): # raise an error, to make sure this isn't called raise TypeError("SimpleNewObj.__init__() didn't expect to get called") def __eq__(self, other): return int(self) == int(other) and self.__dict__ == other.__dict__ class ComplexNewObj(SimpleNewObj): def __getnewargs__(self): return ('%X' % self, 16) class ComplexNewObjEx(SimpleNewObj): def __getnewargs_ex__(self): return ('%X' % self,), {'base': 16} class BadGetattr: def __getattr__(self, key): self.foo class AbstractPickleModuleTests(unittest.TestCase): def test_dump_closed_file(self): import os f = open(TESTFN, "wb") try: f.close() self.assertRaises(ValueError, self.dump, 123, f) finally: os.remove(TESTFN) def test_load_closed_file(self): import os f = open(TESTFN, "wb") try: f.close() self.assertRaises(ValueError, self.dump, 123, f) finally: os.remove(TESTFN) def test_load_from_and_dump_to_file(self): stream = io.BytesIO() data = [123, {}, 124] self.dump(data, stream) stream.seek(0) unpickled = self.load(stream) self.assertEqual(unpickled, data) def test_highest_protocol(self): # Of course this needs to be changed when HIGHEST_PROTOCOL changes. self.assertEqual(pickle.HIGHEST_PROTOCOL, 4) def test_callapi(self): f = io.BytesIO() # With and without keyword arguments self.dump(123, f, -1) self.dump(123, file=f, protocol=-1) self.dumps(123, -1) self.dumps(123, protocol=-1) self.Pickler(f, -1) self.Pickler(f, protocol=-1) def test_bad_init(self): # Test issue3664 (pickle can segfault from a badly initialized Pickler). # Override initialization without calling __init__() of the superclass. class BadPickler(self.Pickler): def __init__(self): pass class BadUnpickler(self.Unpickler): def __init__(self): pass self.assertRaises(pickle.PicklingError, BadPickler().dump, 0) self.assertRaises(pickle.UnpicklingError, BadUnpickler().load) class AbstractPersistentPicklerTests(unittest.TestCase): # This class defines persistent_id() and persistent_load() # functions that should be used by the pickler. All even integers # are pickled using persistent ids. def persistent_id(self, object): if isinstance(object, int) and object % 2 == 0: self.id_count += 1 return str(object) elif object == "test_false_value": self.false_count += 1 return "" else: return None def persistent_load(self, oid): if not oid: self.load_false_count += 1 return "test_false_value" else: self.load_count += 1 object = int(oid) assert object % 2 == 0 return object def test_persistence(self): L = list(range(10)) + ["test_false_value"] for proto in protocols: self.id_count = 0 self.false_count = 0 self.load_false_count = 0 self.load_count = 0 self.assertEqual(self.loads(self.dumps(L, proto)), L) self.assertEqual(self.id_count, 5) self.assertEqual(self.false_count, 1) self.assertEqual(self.load_count, 5) self.assertEqual(self.load_false_count, 1) class AbstractIdentityPersistentPicklerTests(unittest.TestCase): def persistent_id(self, obj): return obj def persistent_load(self, pid): return pid def _check_return_correct_type(self, obj, proto): unpickled = self.loads(self.dumps(obj, proto)) self.assertIsInstance(unpickled, type(obj)) self.assertEqual(unpickled, obj) def test_return_correct_type(self): for proto in protocols: # Protocol 0 supports only ASCII strings. if proto == 0: self._check_return_correct_type("abc", 0) else: for obj in [b"abc\n", "abc\n", -1, -1.1 * 0.1, str]: self._check_return_correct_type(obj, proto) def test_protocol0_is_ascii_only(self): non_ascii_str = "\N{EMPTY SET}" self.assertRaises(pickle.PicklingError, self.dumps, non_ascii_str, 0) pickled = pickle.PERSID + non_ascii_str.encode('utf-8') + b'\n.' self.assertRaises(pickle.UnpicklingError, self.loads, pickled) class AbstractPicklerUnpicklerObjectTests(unittest.TestCase): pickler_class = None unpickler_class = None def setUp(self): assert self.pickler_class assert self.unpickler_class def test_clear_pickler_memo(self): # To test whether clear_memo() has any effect, we pickle an object, # then pickle it again without clearing the memo; the two serialized # forms should be different. If we clear_memo() and then pickle the # object again, the third serialized form should be identical to the # first one we obtained. data = ["abcdefg", "abcdefg", 44] for proto in protocols: f = io.BytesIO() pickler = self.pickler_class(f, proto) pickler.dump(data) first_pickled = f.getvalue() # Reset BytesIO object. f.seek(0) f.truncate() pickler.dump(data) second_pickled = f.getvalue() # Reset the Pickler and BytesIO objects. pickler.clear_memo() f.seek(0) f.truncate() pickler.dump(data) third_pickled = f.getvalue() self.assertNotEqual(first_pickled, second_pickled) self.assertEqual(first_pickled, third_pickled) def test_priming_pickler_memo(self): # Verify that we can set the Pickler's memo attribute. data = ["abcdefg", "abcdefg", 44] f = io.BytesIO() pickler = self.pickler_class(f) pickler.dump(data) first_pickled = f.getvalue() f = io.BytesIO() primed = self.pickler_class(f) primed.memo = pickler.memo primed.dump(data) primed_pickled = f.getvalue() self.assertNotEqual(first_pickled, primed_pickled) def test_priming_unpickler_memo(self): # Verify that we can set the Unpickler's memo attribute. data = ["abcdefg", "abcdefg", 44] f = io.BytesIO() pickler = self.pickler_class(f) pickler.dump(data) first_pickled = f.getvalue() f = io.BytesIO() primed = self.pickler_class(f) primed.memo = pickler.memo primed.dump(data) primed_pickled = f.getvalue() unpickler = self.unpickler_class(io.BytesIO(first_pickled)) unpickled_data1 = unpickler.load() self.assertEqual(unpickled_data1, data) primed = self.unpickler_class(io.BytesIO(primed_pickled)) primed.memo = unpickler.memo unpickled_data2 = primed.load() primed.memo.clear() self.assertEqual(unpickled_data2, data) self.assertTrue(unpickled_data2 is unpickled_data1) def test_reusing_unpickler_objects(self): data1 = ["abcdefg", "abcdefg", 44] f = io.BytesIO() pickler = self.pickler_class(f) pickler.dump(data1) pickled1 = f.getvalue() data2 = ["abcdefg", 44, 44] f = io.BytesIO() pickler = self.pickler_class(f) pickler.dump(data2) pickled2 = f.getvalue() f = io.BytesIO() f.write(pickled1) f.seek(0) unpickler = self.unpickler_class(f) self.assertEqual(unpickler.load(), data1) f.seek(0) f.truncate() f.write(pickled2) f.seek(0) self.assertEqual(unpickler.load(), data2) def _check_multiple_unpicklings(self, ioclass): for proto in protocols: with self.subTest(proto=proto): data1 = [(x, str(x)) for x in range(2000)] + [b"abcde", len] f = ioclass() pickler = self.pickler_class(f, protocol=proto) pickler.dump(data1) pickled = f.getvalue() N = 5 f = ioclass(pickled * N) unpickler = self.unpickler_class(f) for i in range(N): if f.seekable(): pos = f.tell() self.assertEqual(unpickler.load(), data1) if f.seekable(): self.assertEqual(f.tell(), pos + len(pickled)) self.assertRaises(EOFError, unpickler.load) def test_multiple_unpicklings_seekable(self): self._check_multiple_unpicklings(io.BytesIO) def test_multiple_unpicklings_unseekable(self): self._check_multiple_unpicklings(UnseekableIO) def test_unpickling_buffering_readline(self): # Issue #12687: the unpickler's buffering logic could fail with # text mode opcodes. data = list(range(10)) for proto in protocols: for buf_size in range(1, 11): f = io.BufferedRandom(io.BytesIO(), buffer_size=buf_size) pickler = self.pickler_class(f, protocol=proto) pickler.dump(data) f.seek(0) unpickler = self.unpickler_class(f) self.assertEqual(unpickler.load(), data) # Tests for dispatch_table attribute REDUCE_A = 'reduce_A' class AAA(object): def __reduce__(self): return str, (REDUCE_A,) class BBB(object): pass class AbstractDispatchTableTests(unittest.TestCase): def test_default_dispatch_table(self): # No dispatch_table attribute by default f = io.BytesIO() p = self.pickler_class(f, 0) with self.assertRaises(AttributeError): p.dispatch_table self.assertFalse(hasattr(p, 'dispatch_table')) def test_class_dispatch_table(self): # A dispatch_table attribute can be specified class-wide dt = self.get_dispatch_table() class MyPickler(self.pickler_class): dispatch_table = dt def dumps(obj, protocol=None): f = io.BytesIO() p = MyPickler(f, protocol) self.assertEqual(p.dispatch_table, dt) p.dump(obj) return f.getvalue() self._test_dispatch_table(dumps, dt) def test_instance_dispatch_table(self): # A dispatch_table attribute can also be specified instance-wide dt = self.get_dispatch_table() def dumps(obj, protocol=None): f = io.BytesIO() p = self.pickler_class(f, protocol) p.dispatch_table = dt self.assertEqual(p.dispatch_table, dt) p.dump(obj) return f.getvalue() self._test_dispatch_table(dumps, dt) def _test_dispatch_table(self, dumps, dispatch_table): def custom_load_dump(obj): return pickle.loads(dumps(obj, 0)) def default_load_dump(obj): return pickle.loads(pickle.dumps(obj, 0)) # pickling complex numbers using protocol 0 relies on copyreg # so check pickling a complex number still works z = 1 + 2j self.assertEqual(custom_load_dump(z), z) self.assertEqual(default_load_dump(z), z) # modify pickling of complex REDUCE_1 = 'reduce_1' def reduce_1(obj): return str, (REDUCE_1,) dispatch_table[complex] = reduce_1 self.assertEqual(custom_load_dump(z), REDUCE_1) self.assertEqual(default_load_dump(z), z) # check picklability of AAA and BBB a = AAA() b = BBB() self.assertEqual(custom_load_dump(a), REDUCE_A) self.assertIsInstance(custom_load_dump(b), BBB) self.assertEqual(default_load_dump(a), REDUCE_A) self.assertIsInstance(default_load_dump(b), BBB) # modify pickling of BBB dispatch_table[BBB] = reduce_1 self.assertEqual(custom_load_dump(a), REDUCE_A) self.assertEqual(custom_load_dump(b), REDUCE_1) self.assertEqual(default_load_dump(a), REDUCE_A) self.assertIsInstance(default_load_dump(b), BBB) # revert pickling of BBB and modify pickling of AAA REDUCE_2 = 'reduce_2' def reduce_2(obj): return str, (REDUCE_2,) dispatch_table[AAA] = reduce_2 del dispatch_table[BBB] self.assertEqual(custom_load_dump(a), REDUCE_2) self.assertIsInstance(custom_load_dump(b), BBB) self.assertEqual(default_load_dump(a), REDUCE_A) self.assertIsInstance(default_load_dump(b), BBB) if __name__ == "__main__": # Print some stuff that can be used to rewrite DATA{0,1,2} from pickletools import dis x = create_data() for i in range(pickle.HIGHEST_PROTOCOL+1): p = pickle.dumps(x, i) print("DATA{0} = (".format(i)) for j in range(0, len(p), 20): b = bytes(p[j:j+20]) print(" {0!r}".format(b)) print(")") print() print("# Disassembly of DATA{0}".format(i)) print("DATA{0}_DIS = \"\"\"\\".format(i)) dis(p) print("\"\"\"") print()
103,678
2,946
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_itertools.py
import unittest from test import support from itertools import * import weakref from decimal import Decimal from fractions import Fraction import operator import random import copy import pickle from functools import reduce import sys import struct maxsize = support.MAX_Py_ssize_t minsize = -maxsize-1 # [jart] test disabled for usingh a laugh out loud amount of cpu and memory def lzip(*args): return list(zip(*args)) def onearg(x): 'Test function of one argument' return 2*x def errfunc(*args): 'Test function that raises an error' raise ValueError def gen3(): 'Non-restartable source sequence' for i in (0, 1, 2): yield i def isEven(x): 'Test predicate' return x%2==0 def isOdd(x): 'Test predicate' return x%2==1 def tupleize(*args): return args def irange(n): for i in range(n): yield i class StopNow: 'Class emulating an empty iterable.' def __iter__(self): return self def __next__(self): raise StopIteration def take(n, seq): 'Convenience function for partially consuming a long of infinite iterable' return list(islice(seq, n)) def prod(iterable): return reduce(operator.mul, iterable, 1) def fact(n): 'Factorial' return prod(range(1, n+1)) # root level methods for pickling ability def testR(r): return r[0] def testR2(r): return r[2] def underten(x): return x<10 picklecopiers = [lambda s, proto=proto: pickle.loads(pickle.dumps(s, proto)) for proto in range(pickle.HIGHEST_PROTOCOL + 1)] class TestBasicOps(unittest.TestCase): def pickletest(self, protocol, it, stop=4, take=1, compare=None): """Test that an iterator is the same after pickling, also when part-consumed""" def expand(it, i=0): # Recursively expand iterables, within sensible bounds if i > 10: raise RuntimeError("infinite recursion encountered") if isinstance(it, str): return it try: l = list(islice(it, stop)) except TypeError: return it # can't expand it return [expand(e, i+1) for e in l] # Test the initial copy against the original dump = pickle.dumps(it, protocol) i2 = pickle.loads(dump) self.assertEqual(type(it), type(i2)) a, b = expand(it), expand(i2) self.assertEqual(a, b) if compare: c = expand(compare) self.assertEqual(a, c) # Take from the copy, and create another copy and compare them. i3 = pickle.loads(dump) took = 0 try: for i in range(take): next(i3) took += 1 except StopIteration: pass #in case there is less data than 'take' dump = pickle.dumps(i3, protocol) i4 = pickle.loads(dump) a, b = expand(i3), expand(i4) self.assertEqual(a, b) if compare: c = expand(compare[took:]) self.assertEqual(a, c); def test_accumulate(self): self.assertEqual(list(accumulate(range(10))), # one positional arg [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) self.assertEqual(list(accumulate(iterable=range(10))), # kw arg [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]) for typ in int, complex, Decimal, Fraction: # multiple types self.assertEqual( list(accumulate(map(typ, range(10)))), list(map(typ, [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]))) self.assertEqual(list(accumulate('abc')), ['a', 'ab', 'abc']) # works with non-numeric self.assertEqual(list(accumulate([])), []) # empty iterable self.assertEqual(list(accumulate([7])), [7]) # iterable of length one self.assertRaises(TypeError, accumulate, range(10), 5, 6) # too many args self.assertRaises(TypeError, accumulate) # too few args self.assertRaises(TypeError, accumulate, x=range(10)) # unexpected kwd arg self.assertRaises(TypeError, list, accumulate([1, []])) # args that don't add s = [2, 8, 9, 5, 7, 0, 3, 4, 1, 6] self.assertEqual(list(accumulate(s, min)), [2, 2, 2, 2, 2, 0, 0, 0, 0, 0]) self.assertEqual(list(accumulate(s, max)), [2, 8, 9, 9, 9, 9, 9, 9, 9, 9]) self.assertEqual(list(accumulate(s, operator.mul)), [2, 16, 144, 720, 5040, 0, 0, 0, 0, 0]) with self.assertRaises(TypeError): list(accumulate(s, chr)) # unary-operation for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, accumulate(range(10))) # test pickling def test_chain(self): def chain2(*iterables): 'Pure python version in the docs' for it in iterables: for element in it: yield element for c in (chain, chain2): self.assertEqual(list(c('abc', 'def')), list('abcdef')) self.assertEqual(list(c('abc')), list('abc')) self.assertEqual(list(c('')), []) self.assertEqual(take(4, c('abc', 'def')), list('abcd')) self.assertRaises(TypeError, list,c(2, 3)) def test_chain_from_iterable(self): self.assertEqual(list(chain.from_iterable(['abc', 'def'])), list('abcdef')) self.assertEqual(list(chain.from_iterable(['abc'])), list('abc')) self.assertEqual(list(chain.from_iterable([''])), []) self.assertEqual(take(4, chain.from_iterable(['abc', 'def'])), list('abcd')) self.assertRaises(TypeError, list, chain.from_iterable([2, 3])) def test_chain_reducible(self): for oper in [copy.deepcopy] + picklecopiers: it = chain('abc', 'def') self.assertEqual(list(oper(it)), list('abcdef')) self.assertEqual(next(it), 'a') self.assertEqual(list(oper(it)), list('bcdef')) self.assertEqual(list(oper(chain(''))), []) self.assertEqual(take(4, oper(chain('abc', 'def'))), list('abcd')) self.assertRaises(TypeError, list, oper(chain(2, 3))) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, chain('abc', 'def'), compare=list('abcdef')) def test_chain_setstate(self): self.assertRaises(TypeError, chain().__setstate__, ()) self.assertRaises(TypeError, chain().__setstate__, []) self.assertRaises(TypeError, chain().__setstate__, 0) self.assertRaises(TypeError, chain().__setstate__, ([],)) self.assertRaises(TypeError, chain().__setstate__, (iter([]), [])) it = chain() it.__setstate__((iter(['abc', 'def']),)) self.assertEqual(list(it), ['a', 'b', 'c', 'd', 'e', 'f']) it = chain() it.__setstate__((iter(['abc', 'def']), iter(['ghi']))) self.assertEqual(list(it), ['ghi', 'a', 'b', 'c', 'd', 'e', 'f']) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations(self): self.assertRaises(TypeError, combinations, 'abc') # missing r argument self.assertRaises(TypeError, combinations, 'abc', 2, 1) # too many arguments self.assertRaises(TypeError, combinations, None) # pool is not iterable self.assertRaises(ValueError, combinations, 'abc', -2) # r is negative for op in [lambda a:a] + picklecopiers: self.assertEqual(list(op(combinations('abc', 32))), []) # r > n self.assertEqual(list(op(combinations('ABCD', 2))), [('A','B'), ('A','C'), ('A','D'), ('B','C'), ('B','D'), ('C','D')]) testIntermediate = combinations('ABCD', 2) next(testIntermediate) self.assertEqual(list(op(testIntermediate)), [('A','C'), ('A','D'), ('B','C'), ('B','D'), ('C','D')]) self.assertEqual(list(op(combinations(range(4), 3))), [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]) testIntermediate = combinations(range(4), 3) next(testIntermediate) self.assertEqual(list(op(testIntermediate)), [(0,1,3), (0,2,3), (1,2,3)]) def combinations1(iterable, r): 'Pure python version shown in the docs' pool = tuple(iterable) n = len(pool) if r > n: return indices = list(range(r)) yield tuple(pool[i] for i in indices) while 1: for i in reversed(range(r)): if indices[i] != i + n - r: break else: return indices[i] += 1 for j in range(i+1, r): indices[j] = indices[j-1] + 1 yield tuple(pool[i] for i in indices) def combinations2(iterable, r): 'Pure python version shown in the docs' pool = tuple(iterable) n = len(pool) for indices in permutations(range(n), r): if sorted(indices) == list(indices): yield tuple(pool[i] for i in indices) def combinations3(iterable, r): 'Pure python version from cwr()' pool = tuple(iterable) n = len(pool) for indices in combinations_with_replacement(range(n), r): if len(set(indices)) == r: yield tuple(pool[i] for i in indices) for n in range(7): values = [5*x-12 for x in range(n)] for r in range(n+2): result = list(combinations(values, r)) self.assertEqual(len(result), 0 if r>n else fact(n) / fact(r) / fact(n-r)) # right number of combs self.assertEqual(len(result), len(set(result))) # no repeats self.assertEqual(result, sorted(result)) # lexicographic order for c in result: self.assertEqual(len(c), r) # r-length combinations self.assertEqual(len(set(c)), r) # no duplicate elements self.assertEqual(list(c), sorted(c)) # keep original ordering self.assertTrue(all(e in values for e in c)) # elements taken from input iterable self.assertEqual(list(c), [e for e in values if e in c]) # comb is a subsequence of the input iterable self.assertEqual(result, list(combinations1(values, r))) # matches first pure python version self.assertEqual(result, list(combinations2(values, r))) # matches second pure python version self.assertEqual(result, list(combinations3(values, r))) # matches second pure python version for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, combinations(values, r)) # test pickling @support.bigaddrspacetest @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations_overflow(self): with self.assertRaises((OverflowError, MemoryError)): combinations("AA", 2**29) # Test implementation detail: tuple re-use @support.impl_detail("tuple reuse is specific to CPython") def test_combinations_tuple_reuse(self): self.assertEqual(len(set(map(id, combinations('abcde', 3)))), 1) self.assertNotEqual(len(set(map(id, list(combinations('abcde', 3))))), 1) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations_with_replacement(self): cwr = combinations_with_replacement self.assertRaises(TypeError, cwr, 'abc') # missing r argument self.assertRaises(TypeError, cwr, 'abc', 2, 1) # too many arguments self.assertRaises(TypeError, cwr, None) # pool is not iterable self.assertRaises(ValueError, cwr, 'abc', -2) # r is negative for op in [lambda a:a] + picklecopiers: self.assertEqual(list(op(cwr('ABC', 2))), [('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')]) testIntermediate = cwr('ABC', 2) next(testIntermediate) self.assertEqual(list(op(testIntermediate)), [('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')]) def cwr1(iterable, r): 'Pure python version shown in the docs' # number items returned: (n+r-1)! / r! / (n-1)! when n>0 pool = tuple(iterable) n = len(pool) if not n and r: return indices = [0] * r yield tuple(pool[i] for i in indices) while 1: for i in reversed(range(r)): if indices[i] != n - 1: break else: return indices[i:] = [indices[i] + 1] * (r - i) yield tuple(pool[i] for i in indices) def cwr2(iterable, r): 'Pure python version shown in the docs' pool = tuple(iterable) n = len(pool) for indices in product(range(n), repeat=r): if sorted(indices) == list(indices): yield tuple(pool[i] for i in indices) def numcombs(n, r): if not n: return 0 if r else 1 return fact(n+r-1) / fact(r)/ fact(n-1) for n in range(7): values = [5*x-12 for x in range(n)] for r in range(n+2): result = list(cwr(values, r)) self.assertEqual(len(result), numcombs(n, r)) # right number of combs self.assertEqual(len(result), len(set(result))) # no repeats self.assertEqual(result, sorted(result)) # lexicographic order regular_combs = list(combinations(values, r)) # compare to combs without replacement if n == 0 or r <= 1: self.assertEqual(result, regular_combs) # cases that should be identical else: self.assertTrue(set(result) >= set(regular_combs)) # rest should be supersets of regular combs for c in result: self.assertEqual(len(c), r) # r-length combinations noruns = [k for k,v in groupby(c)] # combo without consecutive repeats self.assertEqual(len(noruns), len(set(noruns))) # no repeats other than consecutive self.assertEqual(list(c), sorted(c)) # keep original ordering self.assertTrue(all(e in values for e in c)) # elements taken from input iterable self.assertEqual(noruns, [e for e in values if e in c]) # comb is a subsequence of the input iterable self.assertEqual(result, list(cwr1(values, r))) # matches first pure python version self.assertEqual(result, list(cwr2(values, r))) # matches second pure python version for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, cwr(values,r)) # test pickling @support.bigaddrspacetest @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations_with_replacement_overflow(self): with self.assertRaises((OverflowError, MemoryError)): combinations_with_replacement("AA", 2**30) # Test implementation detail: tuple re-use @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') @support.impl_detail("tuple reuse is specific to CPython") def test_combinations_with_replacement_tuple_reuse(self): cwr = combinations_with_replacement self.assertEqual(len(set(map(id, cwr('abcde', 3)))), 1) self.assertNotEqual(len(set(map(id, list(cwr('abcde', 3))))), 1) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_permutations(self): self.assertRaises(TypeError, permutations) # too few arguments self.assertRaises(TypeError, permutations, 'abc', 2, 1) # too many arguments self.assertRaises(TypeError, permutations, None) # pool is not iterable self.assertRaises(ValueError, permutations, 'abc', -2) # r is negative self.assertEqual(list(permutations('abc', 32)), []) # r > n self.assertRaises(TypeError, permutations, 'abc', 's') # r is not an int or None self.assertEqual(list(permutations(range(3), 2)), [(0,1), (0,2), (1,0), (1,2), (2,0), (2,1)]) def permutations1(iterable, r=None): 'Pure python version shown in the docs' pool = tuple(iterable) n = len(pool) r = n if r is None else r if r > n: return indices = list(range(n)) cycles = list(range(n-r+1, n+1))[::-1] yield tuple(pool[i] for i in indices[:r]) while n: for i in reversed(range(r)): cycles[i] -= 1 if cycles[i] == 0: indices[i:] = indices[i+1:] + indices[i:i+1] cycles[i] = n - i else: j = cycles[i] indices[i], indices[-j] = indices[-j], indices[i] yield tuple(pool[i] for i in indices[:r]) break else: return def permutations2(iterable, r=None): 'Pure python version shown in the docs' pool = tuple(iterable) n = len(pool) r = n if r is None else r for indices in product(range(n), repeat=r): if len(set(indices)) == r: yield tuple(pool[i] for i in indices) for n in range(7): values = [5*x-12 for x in range(n)] for r in range(n+2): result = list(permutations(values, r)) self.assertEqual(len(result), 0 if r>n else fact(n) / fact(n-r)) # right number of perms self.assertEqual(len(result), len(set(result))) # no repeats self.assertEqual(result, sorted(result)) # lexicographic order for p in result: self.assertEqual(len(p), r) # r-length permutations self.assertEqual(len(set(p)), r) # no duplicate elements self.assertTrue(all(e in values for e in p)) # elements taken from input iterable self.assertEqual(result, list(permutations1(values, r))) # matches first pure python version self.assertEqual(result, list(permutations2(values, r))) # matches second pure python version if r == n: self.assertEqual(result, list(permutations(values, None))) # test r as None self.assertEqual(result, list(permutations(values))) # test default r for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, permutations(values, r)) # test pickling @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') @support.bigaddrspacetest def test_permutations_overflow(self): with self.assertRaises((OverflowError, MemoryError)): permutations("A", 2**30) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') @support.impl_detail("tuple reuse is specific to CPython") def test_permutations_tuple_reuse(self): self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1) self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3))))), 1) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinatorics(self): # Test relationships between product(), permutations(), # combinations() and combinations_with_replacement(). for n in range(6): s = 'ABCDEFG'[:n] for r in range(8): prod = list(product(s, repeat=r)) cwr = list(combinations_with_replacement(s, r)) perm = list(permutations(s, r)) comb = list(combinations(s, r)) # Check size self.assertEqual(len(prod), n**r) self.assertEqual(len(cwr), (fact(n+r-1) / fact(r)/ fact(n-1)) if n else (not r)) self.assertEqual(len(perm), 0 if r>n else fact(n) / fact(n-r)) self.assertEqual(len(comb), 0 if r>n else fact(n) / fact(r) / fact(n-r)) # Check lexicographic order without repeated tuples self.assertEqual(prod, sorted(set(prod))) self.assertEqual(cwr, sorted(set(cwr))) self.assertEqual(perm, sorted(set(perm))) self.assertEqual(comb, sorted(set(comb))) # Check interrelationships self.assertEqual(cwr, [t for t in prod if sorted(t)==list(t)]) # cwr: prods which are sorted self.assertEqual(perm, [t for t in prod if len(set(t))==r]) # perm: prods with no dups self.assertEqual(comb, [t for t in perm if sorted(t)==list(t)]) # comb: perms that are sorted self.assertEqual(comb, [t for t in cwr if len(set(t))==r]) # comb: cwrs without dups self.assertEqual(comb, list(filter(set(cwr).__contains__, perm))) # comb: perm that is a cwr self.assertEqual(comb, list(filter(set(perm).__contains__, cwr))) # comb: cwr that is a perm self.assertEqual(comb, sorted(set(cwr) & set(perm))) # comb: both a cwr and a perm def test_compress(self): self.assertEqual(list(compress(data='ABCDEF', selectors=[1,0,1,0,1,1])), list('ACEF')) self.assertEqual(list(compress('ABCDEF', [1,0,1,0,1,1])), list('ACEF')) self.assertEqual(list(compress('ABCDEF', [0,0,0,0,0,0])), list('')) self.assertEqual(list(compress('ABCDEF', [1,1,1,1,1,1])), list('ABCDEF')) self.assertEqual(list(compress('ABCDEF', [1,0,1])), list('AC')) self.assertEqual(list(compress('ABC', [0,1,1,1,1,1])), list('BC')) n = 10000 data = chain.from_iterable(repeat(range(6), n)) selectors = chain.from_iterable(repeat((0, 1))) self.assertEqual(list(compress(data, selectors)), [1,3,5] * n) self.assertRaises(TypeError, compress, None, range(6)) # 1st arg not iterable self.assertRaises(TypeError, compress, range(6), None) # 2nd arg not iterable self.assertRaises(TypeError, compress, range(6)) # too few args self.assertRaises(TypeError, compress, range(6), None) # too many args # check copy, deepcopy, pickle for op in [lambda a:copy.copy(a), lambda a:copy.deepcopy(a)] + picklecopiers: for data, selectors, result1, result2 in [ ('ABCDEF', [1,0,1,0,1,1], 'ACEF', 'CEF'), ('ABCDEF', [0,0,0,0,0,0], '', ''), ('ABCDEF', [1,1,1,1,1,1], 'ABCDEF', 'BCDEF'), ('ABCDEF', [1,0,1], 'AC', 'C'), ('ABC', [0,1,1,1,1,1], 'BC', 'C'), ]: self.assertEqual(list(op(compress(data=data, selectors=selectors))), list(result1)) self.assertEqual(list(op(compress(data, selectors))), list(result1)) testIntermediate = compress(data, selectors) if result1: next(testIntermediate) self.assertEqual(list(op(testIntermediate)), list(result2)) def test_count(self): self.assertEqual(lzip('abc',count()), [('a', 0), ('b', 1), ('c', 2)]) self.assertEqual(lzip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)]) self.assertEqual(take(2, lzip('abc',count(3))), [('a', 3), ('b', 4)]) self.assertEqual(take(2, zip('abc',count(-1))), [('a', -1), ('b', 0)]) self.assertEqual(take(2, zip('abc',count(-3))), [('a', -3), ('b', -2)]) self.assertRaises(TypeError, count, 2, 3, 4) self.assertRaises(TypeError, count, 'a') self.assertEqual(take(10, count(maxsize-5)), list(range(maxsize-5, maxsize+5))) self.assertEqual(take(10, count(-maxsize-5)), list(range(-maxsize-5, -maxsize+5))) self.assertEqual(take(3, count(3.25)), [3.25, 4.25, 5.25]) self.assertEqual(take(3, count(3.25-4j)), [3.25-4j, 4.25-4j, 5.25-4j]) self.assertEqual(take(3, count(Decimal('1.1'))), [Decimal('1.1'), Decimal('2.1'), Decimal('3.1')]) self.assertEqual(take(3, count(Fraction(2, 3))), [Fraction(2, 3), Fraction(5, 3), Fraction(8, 3)]) BIGINT = 1<<1000 self.assertEqual(take(3, count(BIGINT)), [BIGINT, BIGINT+1, BIGINT+2]) c = count(3) self.assertEqual(repr(c), 'count(3)') next(c) self.assertEqual(repr(c), 'count(4)') c = count(-9) self.assertEqual(repr(c), 'count(-9)') next(c) self.assertEqual(next(c), -8) self.assertEqual(repr(count(10.25)), 'count(10.25)') self.assertEqual(repr(count(10.0)), 'count(10.0)') self.assertEqual(type(next(count(10.0))), float) for i in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 10, sys.maxsize-5, sys.maxsize+5): # Test repr r1 = repr(count(i)) r2 = 'count(%r)'.__mod__(i) self.assertEqual(r1, r2) # check copy, deepcopy, pickle for value in -3, 3, maxsize-5, maxsize+5: c = count(value) self.assertEqual(next(copy.copy(c)), value) self.assertEqual(next(copy.deepcopy(c)), value) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, count(value)) #check proper internal error handling for large "step' sizes count(1, maxsize+5); sys.exc_info() def test_count_with_stride(self): self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)]) self.assertEqual(lzip('abc',count(start=2,step=3)), [('a', 2), ('b', 5), ('c', 8)]) self.assertEqual(lzip('abc',count(step=-1)), [('a', 0), ('b', -1), ('c', -2)]) self.assertRaises(TypeError, count, 'a', 'b') self.assertEqual(lzip('abc',count(2,0)), [('a', 2), ('b', 2), ('c', 2)]) self.assertEqual(lzip('abc',count(2,1)), [('a', 2), ('b', 3), ('c', 4)]) self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)]) self.assertEqual(take(20, count(maxsize-15, 3)), take(20, range(maxsize-15, maxsize+100, 3))) self.assertEqual(take(20, count(-maxsize-15, 3)), take(20, range(-maxsize-15,-maxsize+100, 3))) self.assertEqual(take(3, count(10, maxsize+5)), list(range(10, 10+3*(maxsize+5), maxsize+5))) self.assertEqual(take(3, count(2, 1.25)), [2, 3.25, 4.5]) self.assertEqual(take(3, count(2, 3.25-4j)), [2, 5.25-4j, 8.5-8j]) self.assertEqual(take(3, count(Decimal('1.1'), Decimal('.1'))), [Decimal('1.1'), Decimal('1.2'), Decimal('1.3')]) self.assertEqual(take(3, count(Fraction(2,3), Fraction(1,7))), [Fraction(2,3), Fraction(17,21), Fraction(20,21)]) BIGINT = 1<<1000 self.assertEqual(take(3, count(step=BIGINT)), [0, BIGINT, 2*BIGINT]) self.assertEqual(repr(take(3, count(10, 2.5))), repr([10, 12.5, 15.0])) c = count(3, 5) self.assertEqual(repr(c), 'count(3, 5)') next(c) self.assertEqual(repr(c), 'count(8, 5)') c = count(-9, 0) self.assertEqual(repr(c), 'count(-9, 0)') next(c) self.assertEqual(repr(c), 'count(-9, 0)') c = count(-9, -3) self.assertEqual(repr(c), 'count(-9, -3)') next(c) self.assertEqual(repr(c), 'count(-12, -3)') self.assertEqual(repr(c), 'count(-12, -3)') self.assertEqual(repr(count(10.5, 1.25)), 'count(10.5, 1.25)') self.assertEqual(repr(count(10.5, 1)), 'count(10.5)') # suppress step=1 when it's an int self.assertEqual(repr(count(10.5, 1.00)), 'count(10.5, 1.0)') # do show float values lilke 1.0 self.assertEqual(repr(count(10, 1.00)), 'count(10, 1.0)') c = count(10, 1.0) self.assertEqual(type(next(c)), int) self.assertEqual(type(next(c)), float) for i in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 10, sys.maxsize-5, sys.maxsize+5): for j in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 1, 10, sys.maxsize-5, sys.maxsize+5): # Test repr r1 = repr(count(i, j)) if j == 1: r2 = ('count(%r)' % i) else: r2 = ('count(%r, %r)' % (i, j)) self.assertEqual(r1, r2) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, count(i, j)) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) self.assertEqual(list(cycle('')), []) self.assertRaises(TypeError, cycle) self.assertRaises(TypeError, cycle, 5) self.assertEqual(list(islice(cycle(gen3()),10)), [0,1,2,0,1,2,0,1,2,0]) # check copy, deepcopy, pickle c = cycle('abc') self.assertEqual(next(c), 'a') #simple copy currently not supported, because __reduce__ returns #an internal iterator #self.assertEqual(take(10, copy.copy(c)), list('bcabcabcab')) self.assertEqual(take(10, copy.deepcopy(c)), list('bcabcabcab')) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.assertEqual(take(10, pickle.loads(pickle.dumps(c, proto))), list('bcabcabcab')) next(c) self.assertEqual(take(10, pickle.loads(pickle.dumps(c, proto))), list('cabcabcabc')) next(c) next(c) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, cycle('abc')) for proto in range(pickle.HIGHEST_PROTOCOL + 1): # test with partial consumed input iterable it = iter('abcde') c = cycle(it) _ = [next(c) for i in range(2)] # consume 2 of 5 inputs p = pickle.dumps(c, proto) d = pickle.loads(p) # rebuild the cycle object self.assertEqual(take(20, d), list('cdeabcdeabcdeabcdeab')) # test with completely consumed input iterable it = iter('abcde') c = cycle(it) _ = [next(c) for i in range(7)] # consume 7 of 5 inputs p = pickle.dumps(c, proto) d = pickle.loads(p) # rebuild the cycle object self.assertEqual(take(20, d), list('cdeabcdeabcdeabcdeab')) def test_cycle_setstate(self): # Verify both modes for restoring state # Mode 0 is efficient. It uses an incompletely consumed input # iterator to build a cycle object and then passes in state with # a list of previously consumed values. There is no data # overlap between the two. c = cycle('defg') c.__setstate__((list('abc'), 0)) self.assertEqual(take(20, c), list('defgabcdefgabcdefgab')) # Mode 1 is inefficient. It starts with a cycle object built # from an iterator over the remaining elements in a partial # cycle and then passes in state with all of the previously # seen values (this overlaps values included in the iterator). c = cycle('defg') c.__setstate__((list('abcdefg'), 1)) self.assertEqual(take(20, c), list('defgabcdefgabcdefgab')) # The first argument to setstate needs to be a tuple with self.assertRaises(TypeError): cycle('defg').__setstate__([list('abcdefg'), 0]) # The first argument in the setstate tuple must be a list with self.assertRaises(TypeError): c = cycle('defg') c.__setstate__((tuple('defg'), 0)) take(20, c) # The second argument in the setstate tuple must be an int with self.assertRaises(TypeError): cycle('defg').__setstate__((list('abcdefg'), 'x')) self.assertRaises(TypeError, cycle('').__setstate__, ()) self.assertRaises(TypeError, cycle('').__setstate__, ([],)) def test_groupby(self): # Check whether it accepts arguments correctly self.assertEqual([], list(groupby([]))) self.assertEqual([], list(groupby([], key=id))) self.assertRaises(TypeError, list, groupby('abc', [])) self.assertRaises(TypeError, groupby, None) self.assertRaises(TypeError, groupby, 'abc', lambda x:x, 10) # Check normal input s = [(0, 10, 20), (0, 11,21), (0,12,21), (1,13,21), (1,14,22), (2,15,22), (3,16,23), (3,17,23)] dup = [] for k, g in groupby(s, lambda r:r[0]): for elem in g: self.assertEqual(k, elem[0]) dup.append(elem) self.assertEqual(s, dup) # Check normal pickled for proto in range(pickle.HIGHEST_PROTOCOL + 1): dup = [] for k, g in pickle.loads(pickle.dumps(groupby(s, testR), proto)): for elem in g: self.assertEqual(k, elem[0]) dup.append(elem) self.assertEqual(s, dup) # Check nested case dup = [] for k, g in groupby(s, testR): for ik, ig in groupby(g, testR2): for elem in ig: self.assertEqual(k, elem[0]) self.assertEqual(ik, elem[2]) dup.append(elem) self.assertEqual(s, dup) # Check nested and pickled for proto in range(pickle.HIGHEST_PROTOCOL + 1): dup = [] for k, g in pickle.loads(pickle.dumps(groupby(s, testR), proto)): for ik, ig in pickle.loads(pickle.dumps(groupby(g, testR2), proto)): for elem in ig: self.assertEqual(k, elem[0]) self.assertEqual(ik, elem[2]) dup.append(elem) self.assertEqual(s, dup) # Check case where inner iterator is not used keys = [k for k, g in groupby(s, testR)] expectedkeys = set([r[0] for r in s]) self.assertEqual(set(keys), expectedkeys) self.assertEqual(len(keys), len(expectedkeys)) # Exercise pipes and filters style s = 'abracadabra' # sort s | uniq r = [k for k, g in groupby(sorted(s))] self.assertEqual(r, ['a', 'b', 'c', 'd', 'r']) # sort s | uniq -d r = [k for k, g in groupby(sorted(s)) if list(islice(g,1,2))] self.assertEqual(r, ['a', 'b', 'r']) # sort s | uniq -c r = [(len(list(g)), k) for k, g in groupby(sorted(s))] self.assertEqual(r, [(5, 'a'), (2, 'b'), (1, 'c'), (1, 'd'), (2, 'r')]) # sort s | uniq -c | sort -rn | head -3 r = sorted([(len(list(g)) , k) for k, g in groupby(sorted(s))], reverse=True)[:3] self.assertEqual(r, [(5, 'a'), (2, 'r'), (2, 'b')]) # iter.__next__ failure class ExpectedError(Exception): pass def delayed_raise(n=0): for i in range(n): yield 'yo' raise ExpectedError def gulp(iterable, keyp=None, func=list): return [func(g) for k, g in groupby(iterable, keyp)] # iter.__next__ failure on outer object self.assertRaises(ExpectedError, gulp, delayed_raise(0)) # iter.__next__ failure on inner object self.assertRaises(ExpectedError, gulp, delayed_raise(1)) # __eq__ failure class DummyCmp: def __eq__(self, dst): raise ExpectedError s = [DummyCmp(), DummyCmp(), None] # __eq__ failure on outer object self.assertRaises(ExpectedError, gulp, s, func=id) # __eq__ failure on inner object self.assertRaises(ExpectedError, gulp, s) # keyfunc failure def keyfunc(obj): if keyfunc.skip > 0: keyfunc.skip -= 1 return obj else: raise ExpectedError # keyfunc failure on outer object keyfunc.skip = 0 self.assertRaises(ExpectedError, gulp, [None], keyfunc) keyfunc.skip = 1 self.assertRaises(ExpectedError, gulp, [None, None], keyfunc) def test_filter(self): self.assertEqual(list(filter(isEven, range(6))), [0,2,4]) self.assertEqual(list(filter(None, [0,1,0,2,0])), [1,2]) self.assertEqual(list(filter(bool, [0,1,0,2,0])), [1,2]) self.assertEqual(take(4, filter(isEven, count())), [0,2,4,6]) self.assertRaises(TypeError, filter) self.assertRaises(TypeError, filter, lambda x:x) self.assertRaises(TypeError, filter, lambda x:x, range(6), 7) self.assertRaises(TypeError, filter, isEven, 3) self.assertRaises(TypeError, next, filter(range(6), range(6))) # check copy, deepcopy, pickle ans = [0,2,4] c = filter(isEven, range(6)) self.assertEqual(list(copy.copy(c)), ans) c = filter(isEven, range(6)) self.assertEqual(list(copy.deepcopy(c)), ans) for proto in range(pickle.HIGHEST_PROTOCOL + 1): c = filter(isEven, range(6)) self.assertEqual(list(pickle.loads(pickle.dumps(c, proto))), ans) next(c) self.assertEqual(list(pickle.loads(pickle.dumps(c, proto))), ans[1:]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): c = filter(isEven, range(6)) self.pickletest(proto, c) def test_filterfalse(self): self.assertEqual(list(filterfalse(isEven, range(6))), [1,3,5]) self.assertEqual(list(filterfalse(None, [0,1,0,2,0])), [0,0,0]) self.assertEqual(list(filterfalse(bool, [0,1,0,2,0])), [0,0,0]) self.assertEqual(take(4, filterfalse(isEven, count())), [1,3,5,7]) self.assertRaises(TypeError, filterfalse) self.assertRaises(TypeError, filterfalse, lambda x:x) self.assertRaises(TypeError, filterfalse, lambda x:x, range(6), 7) self.assertRaises(TypeError, filterfalse, isEven, 3) self.assertRaises(TypeError, next, filterfalse(range(6), range(6))) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, filterfalse(isEven, range(6))) def test_zip(self): # XXX This is rather silly now that builtin zip() calls zip()... ans = [(x,y) for x, y in zip('abc',count())] self.assertEqual(ans, [('a', 0), ('b', 1), ('c', 2)]) self.assertEqual(list(zip('abc', range(6))), lzip('abc', range(6))) self.assertEqual(list(zip('abcdef', range(3))), lzip('abcdef', range(3))) self.assertEqual(take(3,zip('abcdef', count())), lzip('abcdef', range(3))) self.assertEqual(list(zip('abcdef')), lzip('abcdef')) self.assertEqual(list(zip()), lzip()) self.assertRaises(TypeError, zip, 3) self.assertRaises(TypeError, zip, range(3), 3) self.assertEqual([tuple(list(pair)) for pair in zip('abc', 'def')], lzip('abc', 'def')) self.assertEqual([pair for pair in zip('abc', 'def')], lzip('abc', 'def')) @support.impl_detail("tuple reuse is specific to CPython") def test_zip_tuple_reuse(self): ids = list(map(id, zip('abc', 'def'))) self.assertEqual(min(ids), max(ids)) ids = list(map(id, list(zip('abc', 'def')))) self.assertEqual(len(dict.fromkeys(ids)), len(ids)) # check copy, deepcopy, pickle ans = [(x,y) for x, y in copy.copy(zip('abc',count()))] self.assertEqual(ans, [('a', 0), ('b', 1), ('c', 2)]) ans = [(x,y) for x, y in copy.deepcopy(zip('abc',count()))] self.assertEqual(ans, [('a', 0), ('b', 1), ('c', 2)]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): ans = [(x,y) for x, y in pickle.loads(pickle.dumps(zip('abc',count()), proto))] self.assertEqual(ans, [('a', 0), ('b', 1), ('c', 2)]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): testIntermediate = zip('abc',count()) next(testIntermediate) ans = [(x,y) for x, y in pickle.loads(pickle.dumps(testIntermediate, proto))] self.assertEqual(ans, [('b', 1), ('c', 2)]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, zip('abc', count())) def test_ziplongest(self): for args in [ ['abc', range(6)], [range(6), 'abc'], [range(1000), range(2000,2100), range(3000,3050)], [range(1000), range(0), range(3000,3050), range(1200), range(1500)], [range(1000), range(0), range(3000,3050), range(1200), range(1500), range(0)], ]: target = [tuple([arg[i] if i < len(arg) else None for arg in args]) for i in range(max(map(len, args)))] self.assertEqual(list(zip_longest(*args)), target) self.assertEqual(list(zip_longest(*args, **{})), target) target = [tuple((e is None and 'X' or e) for e in t) for t in target] # Replace None fills with 'X' self.assertEqual(list(zip_longest(*args, **dict(fillvalue='X'))), target) self.assertEqual(take(3,zip_longest('abcdef', count())), list(zip('abcdef', range(3)))) # take 3 from infinite input self.assertEqual(list(zip_longest()), list(zip())) self.assertEqual(list(zip_longest([])), list(zip([]))) self.assertEqual(list(zip_longest('abcdef')), list(zip('abcdef'))) self.assertEqual(list(zip_longest('abc', 'defg', **{})), list(zip(list('abc')+[None], 'defg'))) # empty keyword dict self.assertRaises(TypeError, zip_longest, 3) self.assertRaises(TypeError, zip_longest, range(3), 3) for stmt in [ "zip_longest('abc', fv=1)", "zip_longest('abc', fillvalue=1, bogus_keyword=None)", ]: try: eval(stmt, globals(), locals()) except TypeError: pass else: self.fail('Did not raise Type in: ' + stmt) self.assertEqual([tuple(list(pair)) for pair in zip_longest('abc', 'def')], list(zip('abc', 'def'))) self.assertEqual([pair for pair in zip_longest('abc', 'def')], list(zip('abc', 'def'))) @support.impl_detail("tuple reuse is specific to CPython") def test_zip_longest_tuple_reuse(self): ids = list(map(id, zip_longest('abc', 'def'))) self.assertEqual(min(ids), max(ids)) ids = list(map(id, list(zip_longest('abc', 'def')))) self.assertEqual(len(dict.fromkeys(ids)), len(ids)) def test_zip_longest_pickling(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, zip_longest("abc", "def")) self.pickletest(proto, zip_longest("abc", "defgh")) self.pickletest(proto, zip_longest("abc", "defgh", fillvalue=1)) self.pickletest(proto, zip_longest("", "defgh")) def test_bug_7244(self): class Repeater: # this class is similar to itertools.repeat def __init__(self, o, t, e): self.o = o self.t = int(t) self.e = e def __iter__(self): # its iterator is itself return self def __next__(self): if self.t > 0: self.t -= 1 return self.o else: raise self.e # Formerly this code in would fail in debug mode # with Undetected Error and Stop Iteration r1 = Repeater(1, 3, StopIteration) r2 = Repeater(2, 4, StopIteration) def run(r1, r2): result = [] for i, j in zip_longest(r1, r2, fillvalue=0): with support.captured_output('stdout'): print((i, j)) result.append((i, j)) return result self.assertEqual(run(r1, r2), [(1,2), (1,2), (1,2), (0,2)]) # Formerly, the RuntimeError would be lost # and StopIteration would stop as expected r1 = Repeater(1, 3, RuntimeError) r2 = Repeater(2, 4, StopIteration) it = zip_longest(r1, r2, fillvalue=0) self.assertEqual(next(it), (1, 2)) self.assertEqual(next(it), (1, 2)) self.assertEqual(next(it), (1, 2)) self.assertRaises(RuntimeError, next, it) def test_product(self): for args, result in [ ([], [()]), # zero iterables (['ab'], [('a',), ('b',)]), # one iterable ([range(2), range(3)], [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)]), # two iterables ([range(0), range(2), range(3)], []), # first iterable with zero length ([range(2), range(0), range(3)], []), # middle iterable with zero length ([range(2), range(3), range(0)], []), # last iterable with zero length ]: self.assertEqual(list(product(*args)), result) for r in range(4): self.assertEqual(list(product(*(args*r))), list(product(*args, **dict(repeat=r)))) self.assertEqual(len(list(product(*[range(7)]*6))), 7**6) self.assertRaises(TypeError, product, range(6), None) def product1(*args, **kwds): pools = list(map(tuple, args)) * kwds.get('repeat', 1) n = len(pools) if n == 0: yield () return if any(len(pool) == 0 for pool in pools): return indices = [0] * n yield tuple(pool[i] for pool, i in zip(pools, indices)) while 1: for i in reversed(range(n)): # right to left if indices[i] == len(pools[i]) - 1: continue indices[i] += 1 for j in range(i+1, n): indices[j] = 0 yield tuple(pool[i] for pool, i in zip(pools, indices)) break else: return def product2(*args, **kwds): 'Pure python version used in docs' pools = list(map(tuple, args)) * kwds.get('repeat', 1) result = [[]] for pool in pools: result = [x+[y] for x in result for y in pool] for prod in result: yield tuple(prod) argtypes = ['', 'abc', '', range(0), range(4), dict(a=1, b=2, c=3), set('abcdefg'), range(11), tuple(range(13))] for i in range(100): args = [random.choice(argtypes) for j in range(random.randrange(5))] expected_len = prod(map(len, args)) self.assertEqual(len(list(product(*args))), expected_len) self.assertEqual(list(product(*args)), list(product1(*args))) self.assertEqual(list(product(*args)), list(product2(*args))) args = map(iter, args) self.assertEqual(len(list(product(*args))), expected_len) @support.bigaddrspacetest def test_product_overflow(self): with self.assertRaises((OverflowError, MemoryError)): product(*(['ab']*2**5), repeat=2**25) @support.impl_detail("tuple reuse is specific to CPython") def test_product_tuple_reuse(self): self.assertEqual(len(set(map(id, product('abc', 'def')))), 1) self.assertNotEqual(len(set(map(id, list(product('abc', 'def'))))), 1) def test_product_pickling(self): # check copy, deepcopy, pickle for args, result in [ ([], [()]), # zero iterables (['ab'], [('a',), ('b',)]), # one iterable ([range(2), range(3)], [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)]), # two iterables ([range(0), range(2), range(3)], []), # first iterable with zero length ([range(2), range(0), range(3)], []), # middle iterable with zero length ([range(2), range(3), range(0)], []), # last iterable with zero length ]: self.assertEqual(list(copy.copy(product(*args))), result) self.assertEqual(list(copy.deepcopy(product(*args))), result) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, product(*args)) def test_product_issue_25021(self): # test that indices are properly clamped to the length of the tuples p = product((1, 2),(3,)) p.__setstate__((0, 0x1000)) # will access tuple element 1 if not clamped self.assertEqual(next(p), (2, 3)) # test that empty tuple in the list will result in an immediate StopIteration p = product((1, 2), (), (3,)) p.__setstate__((0, 0, 0x1000)) # will access tuple element 1 if not clamped self.assertRaises(StopIteration, next, p) def test_repeat(self): self.assertEqual(list(repeat(object='a', times=3)), ['a', 'a', 'a']) self.assertEqual(lzip(range(3),repeat('a')), [(0, 'a'), (1, 'a'), (2, 'a')]) self.assertEqual(list(repeat('a', 3)), ['a', 'a', 'a']) self.assertEqual(take(3, repeat('a')), ['a', 'a', 'a']) self.assertEqual(list(repeat('a', 0)), []) self.assertEqual(list(repeat('a', -3)), []) self.assertRaises(TypeError, repeat) self.assertRaises(TypeError, repeat, None, 3, 4) self.assertRaises(TypeError, repeat, None, 'a') r = repeat(1+0j) self.assertEqual(repr(r), 'repeat((1+0j))') r = repeat(1+0j, 5) self.assertEqual(repr(r), 'repeat((1+0j), 5)') list(r) self.assertEqual(repr(r), 'repeat((1+0j), 0)') # check copy, deepcopy, pickle c = repeat(object='a', times=10) self.assertEqual(next(c), 'a') self.assertEqual(take(2, copy.copy(c)), list('a' * 2)) self.assertEqual(take(2, copy.deepcopy(c)), list('a' * 2)) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, repeat(object='a', times=10)) def test_repeat_with_negative_times(self): self.assertEqual(repr(repeat('a', -1)), "repeat('a', 0)") self.assertEqual(repr(repeat('a', -2)), "repeat('a', 0)") self.assertEqual(repr(repeat('a', times=-1)), "repeat('a', 0)") self.assertEqual(repr(repeat('a', times=-2)), "repeat('a', 0)") def test_map(self): self.assertEqual(list(map(operator.pow, range(3), range(1,7))), [0**1, 1**2, 2**3]) self.assertEqual(list(map(tupleize, 'abc', range(5))), [('a',0),('b',1),('c',2)]) self.assertEqual(list(map(tupleize, 'abc', count())), [('a',0),('b',1),('c',2)]) self.assertEqual(take(2,map(tupleize, 'abc', count())), [('a',0),('b',1)]) self.assertEqual(list(map(operator.pow, [])), []) self.assertRaises(TypeError, map) self.assertRaises(TypeError, list, map(None, range(3), range(3))) self.assertRaises(TypeError, map, operator.neg) self.assertRaises(TypeError, next, map(10, range(5))) self.assertRaises(ValueError, next, map(errfunc, [4], [5])) self.assertRaises(TypeError, next, map(onearg, [4], [5])) # check copy, deepcopy, pickle ans = [('a',0),('b',1),('c',2)] c = map(tupleize, 'abc', count()) self.assertEqual(list(copy.copy(c)), ans) c = map(tupleize, 'abc', count()) self.assertEqual(list(copy.deepcopy(c)), ans) for proto in range(pickle.HIGHEST_PROTOCOL + 1): c = map(tupleize, 'abc', count()) self.pickletest(proto, c) def test_starmap(self): self.assertEqual(list(starmap(operator.pow, zip(range(3), range(1,7)))), [0**1, 1**2, 2**3]) self.assertEqual(take(3, starmap(operator.pow, zip(count(), count(1)))), [0**1, 1**2, 2**3]) self.assertEqual(list(starmap(operator.pow, [])), []) self.assertEqual(list(starmap(operator.pow, [iter([4,5])])), [4**5]) self.assertRaises(TypeError, list, starmap(operator.pow, [None])) self.assertRaises(TypeError, starmap) self.assertRaises(TypeError, starmap, operator.pow, [(4,5)], 'extra') self.assertRaises(TypeError, next, starmap(10, [(4,5)])) self.assertRaises(ValueError, next, starmap(errfunc, [(4,5)])) self.assertRaises(TypeError, next, starmap(onearg, [(4,5)])) # check copy, deepcopy, pickle ans = [0**1, 1**2, 2**3] c = starmap(operator.pow, zip(range(3), range(1,7))) self.assertEqual(list(copy.copy(c)), ans) c = starmap(operator.pow, zip(range(3), range(1,7))) self.assertEqual(list(copy.deepcopy(c)), ans) for proto in range(pickle.HIGHEST_PROTOCOL + 1): c = starmap(operator.pow, zip(range(3), range(1,7))) self.pickletest(proto, c) def test_islice(self): for args in [ # islice(args) should agree with range(args) (10, 20, 3), (10, 3, 20), (10, 20), (10, 10), (10, 3), (20,) ]: self.assertEqual(list(islice(range(100), *args)), list(range(*args))) for args, tgtargs in [ # Stop when seqn is exhausted ((10, 110, 3), ((10, 100, 3))), ((10, 110), ((10, 100))), ((110,), (100,)) ]: self.assertEqual(list(islice(range(100), *args)), list(range(*tgtargs))) # Test stop=None self.assertEqual(list(islice(range(10), None)), list(range(10))) self.assertEqual(list(islice(range(10), None, None)), list(range(10))) self.assertEqual(list(islice(range(10), None, None, None)), list(range(10))) self.assertEqual(list(islice(range(10), 2, None)), list(range(2, 10))) self.assertEqual(list(islice(range(10), 1, None, 2)), list(range(1, 10, 2))) # Test number of items consumed SF #1171417 it = iter(range(10)) self.assertEqual(list(islice(it, 3)), list(range(3))) self.assertEqual(list(it), list(range(3, 10))) it = iter(range(10)) self.assertEqual(list(islice(it, 3, 3)), []) self.assertEqual(list(it), list(range(3, 10))) # Test invalid arguments ra = range(10) self.assertRaises(TypeError, islice, ra) self.assertRaises(TypeError, islice, ra, 1, 2, 3, 4) self.assertRaises(ValueError, islice, ra, -5, 10, 1) self.assertRaises(ValueError, islice, ra, 1, -5, -1) self.assertRaises(ValueError, islice, ra, 1, 10, -1) self.assertRaises(ValueError, islice, ra, 1, 10, 0) self.assertRaises(ValueError, islice, ra, 'a') self.assertRaises(ValueError, islice, ra, 'a', 1) self.assertRaises(ValueError, islice, ra, 1, 'a') self.assertRaises(ValueError, islice, ra, 'a', 1, 1) self.assertRaises(ValueError, islice, ra, 1, 'a', 1) self.assertEqual(len(list(islice(count(), 1, 10, maxsize))), 1) # Issue #10323: Less islice in a predictable state c = count() self.assertEqual(list(islice(c, 1, 3, 50)), [1]) self.assertEqual(next(c), 3) # check copy, deepcopy, pickle for args in [ # islice(args) should agree with range(args) (10, 20, 3), (10, 3, 20), (10, 20), (10, 3), (20,) ]: self.assertEqual(list(copy.copy(islice(range(100), *args))), list(range(*args))) self.assertEqual(list(copy.deepcopy(islice(range(100), *args))), list(range(*args))) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, islice(range(100), *args)) # Issue #21321: check source iterator is not referenced # from islice() after the latter has been exhausted it = (x for x in (1, 2)) wr = weakref.ref(it) it = islice(it, 1) self.assertIsNotNone(wr()) list(it) # exhaust the iterator support.gc_collect() self.assertIsNone(wr()) def test_takewhile(self): data = [1, 3, 5, 20, 2, 4, 6, 8] self.assertEqual(list(takewhile(underten, data)), [1, 3, 5]) self.assertEqual(list(takewhile(underten, [])), []) self.assertRaises(TypeError, takewhile) self.assertRaises(TypeError, takewhile, operator.pow) self.assertRaises(TypeError, takewhile, operator.pow, [(4,5)], 'extra') self.assertRaises(TypeError, next, takewhile(10, [(4,5)])) self.assertRaises(ValueError, next, takewhile(errfunc, [(4,5)])) t = takewhile(bool, [1, 1, 1, 0, 0, 0]) self.assertEqual(list(t), [1, 1, 1]) self.assertRaises(StopIteration, next, t) # check copy, deepcopy, pickle self.assertEqual(list(copy.copy(takewhile(underten, data))), [1, 3, 5]) self.assertEqual(list(copy.deepcopy(takewhile(underten, data))), [1, 3, 5]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, takewhile(underten, data)) def test_dropwhile(self): data = [1, 3, 5, 20, 2, 4, 6, 8] self.assertEqual(list(dropwhile(underten, data)), [20, 2, 4, 6, 8]) self.assertEqual(list(dropwhile(underten, [])), []) self.assertRaises(TypeError, dropwhile) self.assertRaises(TypeError, dropwhile, operator.pow) self.assertRaises(TypeError, dropwhile, operator.pow, [(4,5)], 'extra') self.assertRaises(TypeError, next, dropwhile(10, [(4,5)])) self.assertRaises(ValueError, next, dropwhile(errfunc, [(4,5)])) # check copy, deepcopy, pickle self.assertEqual(list(copy.copy(dropwhile(underten, data))), [20, 2, 4, 6, 8]) self.assertEqual(list(copy.deepcopy(dropwhile(underten, data))), [20, 2, 4, 6, 8]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, dropwhile(underten, data)) def test_tee(self): n = 200 a, b = tee([]) # test empty iterator self.assertEqual(list(a), []) self.assertEqual(list(b), []) a, b = tee(irange(n)) # test 100% interleaved self.assertEqual(lzip(a,b), lzip(range(n), range(n))) a, b = tee(irange(n)) # test 0% interleaved self.assertEqual(list(a), list(range(n))) self.assertEqual(list(b), list(range(n))) a, b = tee(irange(n)) # test dealloc of leading iterator for i in range(100): self.assertEqual(next(a), i) del a self.assertEqual(list(b), list(range(n))) a, b = tee(irange(n)) # test dealloc of trailing iterator for i in range(100): self.assertEqual(next(a), i) del b self.assertEqual(list(a), list(range(100, n))) for j in range(5): # test randomly interleaved order = [0]*n + [1]*n random.shuffle(order) lists = ([], []) its = tee(irange(n)) for i in order: value = next(its[i]) lists[i].append(value) self.assertEqual(lists[0], list(range(n))) self.assertEqual(lists[1], list(range(n))) # test argument format checking self.assertRaises(TypeError, tee) self.assertRaises(TypeError, tee, 3) self.assertRaises(TypeError, tee, [1,2], 'x') self.assertRaises(TypeError, tee, [1,2], 3, 'x') # tee object should be instantiable a, b = tee('abc') c = type(a)('def') self.assertEqual(list(c), list('def')) # test long-lagged and multi-way split a, b, c = tee(range(2000), 3) for i in range(100): self.assertEqual(next(a), i) self.assertEqual(list(b), list(range(2000))) self.assertEqual([next(c), next(c)], list(range(2))) self.assertEqual(list(a), list(range(100,2000))) self.assertEqual(list(c), list(range(2,2000))) # test values of n self.assertRaises(TypeError, tee, 'abc', 'invalid') self.assertRaises(ValueError, tee, [], -1) for n in range(5): result = tee('abc', n) self.assertEqual(type(result), tuple) self.assertEqual(len(result), n) self.assertEqual([list(x) for x in result], [list('abc')]*n) # tee pass-through to copyable iterator a, b = tee('abc') c, d = tee(a) self.assertTrue(a is c) # test tee_new t1, t2 = tee('abc') tnew = type(t1) self.assertRaises(TypeError, tnew) self.assertRaises(TypeError, tnew, 10) t3 = tnew(t1) self.assertTrue(list(t1) == list(t2) == list(t3) == list('abc')) # test that tee objects are weak referencable a, b = tee(range(10)) p = weakref.proxy(a) self.assertEqual(getattr(p, '__class__'), type(b)) del a self.assertRaises(ReferenceError, getattr, p, '__class__') ans = list('abc') long_ans = list(range(10000)) # check copy a, b = tee('abc') self.assertEqual(list(copy.copy(a)), ans) self.assertEqual(list(copy.copy(b)), ans) a, b = tee(list(range(10000))) self.assertEqual(list(copy.copy(a)), long_ans) self.assertEqual(list(copy.copy(b)), long_ans) # check partially consumed copy a, b = tee('abc') take(2, a) take(1, b) self.assertEqual(list(copy.copy(a)), ans[2:]) self.assertEqual(list(copy.copy(b)), ans[1:]) self.assertEqual(list(a), ans[2:]) self.assertEqual(list(b), ans[1:]) a, b = tee(range(10000)) take(100, a) take(60, b) self.assertEqual(list(copy.copy(a)), long_ans[100:]) self.assertEqual(list(copy.copy(b)), long_ans[60:]) self.assertEqual(list(a), long_ans[100:]) self.assertEqual(list(b), long_ans[60:]) # check deepcopy a, b = tee('abc') self.assertEqual(list(copy.deepcopy(a)), ans) self.assertEqual(list(copy.deepcopy(b)), ans) self.assertEqual(list(a), ans) self.assertEqual(list(b), ans) a, b = tee(range(10000)) self.assertEqual(list(copy.deepcopy(a)), long_ans) self.assertEqual(list(copy.deepcopy(b)), long_ans) self.assertEqual(list(a), long_ans) self.assertEqual(list(b), long_ans) # check partially consumed deepcopy a, b = tee('abc') take(2, a) take(1, b) self.assertEqual(list(copy.deepcopy(a)), ans[2:]) self.assertEqual(list(copy.deepcopy(b)), ans[1:]) self.assertEqual(list(a), ans[2:]) self.assertEqual(list(b), ans[1:]) a, b = tee(range(10000)) take(100, a) take(60, b) self.assertEqual(list(copy.deepcopy(a)), long_ans[100:]) self.assertEqual(list(copy.deepcopy(b)), long_ans[60:]) self.assertEqual(list(a), long_ans[100:]) self.assertEqual(list(b), long_ans[60:]) # check pickle for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, iter(tee('abc'))) a, b = tee('abc') self.pickletest(proto, a, compare=ans) self.pickletest(proto, b, compare=ans) # Issue 13454: Crash when deleting backward iterator from tee() def test_tee_del_backward(self): forward, backward = tee(repeat(None, 20000000)) try: any(forward) # exhaust the iterator del backward except: del forward, backward raise def test_StopIteration(self): self.assertRaises(StopIteration, next, zip()) for f in (chain, cycle, zip, groupby): self.assertRaises(StopIteration, next, f([])) self.assertRaises(StopIteration, next, f(StopNow())) self.assertRaises(StopIteration, next, islice([], None)) self.assertRaises(StopIteration, next, islice(StopNow(), None)) p, q = tee([]) self.assertRaises(StopIteration, next, p) self.assertRaises(StopIteration, next, q) p, q = tee(StopNow()) self.assertRaises(StopIteration, next, p) self.assertRaises(StopIteration, next, q) self.assertRaises(StopIteration, next, repeat(None, 0)) for f in (filter, filterfalse, map, takewhile, dropwhile, starmap): self.assertRaises(StopIteration, next, f(lambda x:x, [])) self.assertRaises(StopIteration, next, f(lambda x:x, StopNow())) class TestExamples(unittest.TestCase): def test_accumulate(self): self.assertEqual(list(accumulate([1,2,3,4,5])), [1, 3, 6, 10, 15]) def test_accumulate_reducible(self): # check copy, deepcopy, pickle data = [1, 2, 3, 4, 5] accumulated = [1, 3, 6, 10, 15] for proto in range(pickle.HIGHEST_PROTOCOL + 1): it = accumulate(data) self.assertEqual(list(pickle.loads(pickle.dumps(it, proto))), accumulated[:]) self.assertEqual(next(it), 1) self.assertEqual(list(pickle.loads(pickle.dumps(it, proto))), accumulated[1:]) it = accumulate(data) self.assertEqual(next(it), 1) self.assertEqual(list(copy.deepcopy(it)), accumulated[1:]) self.assertEqual(list(copy.copy(it)), accumulated[1:]) def test_accumulate_reducible_none(self): # Issue #25718: total is None it = accumulate([None, None, None], operator.is_) self.assertEqual(next(it), None) for proto in range(pickle.HIGHEST_PROTOCOL + 1): it_copy = pickle.loads(pickle.dumps(it, proto)) self.assertEqual(list(it_copy), [True, False]) self.assertEqual(list(copy.deepcopy(it)), [True, False]) self.assertEqual(list(copy.copy(it)), [True, False]) def test_chain(self): self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF') def test_chain_from_iterable(self): self.assertEqual(''.join(chain.from_iterable(['ABC', 'DEF'])), 'ABCDEF') def test_combinations(self): self.assertEqual(list(combinations('ABCD', 2)), [('A','B'), ('A','C'), ('A','D'), ('B','C'), ('B','D'), ('C','D')]) self.assertEqual(list(combinations(range(4), 3)), [(0,1,2), (0,1,3), (0,2,3), (1,2,3)]) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations_with_replacement(self): self.assertEqual(list(combinations_with_replacement('ABC', 2)), [('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')]) def test_compress(self): self.assertEqual(list(compress('ABCDEF', [1,0,1,0,1,1])), list('ACEF')) def test_count(self): self.assertEqual(list(islice(count(10), 5)), [10, 11, 12, 13, 14]) def test_cycle(self): self.assertEqual(list(islice(cycle('ABCD'), 12)), list('ABCDABCDABCD')) def test_dropwhile(self): self.assertEqual(list(dropwhile(lambda x: x<5, [1,4,6,4,1])), [6,4,1]) def test_groupby(self): self.assertEqual([k for k, g in groupby('AAAABBBCCDAABBB')], list('ABCDAB')) self.assertEqual([(list(g)) for k, g in groupby('AAAABBBCCD')], [list('AAAA'), list('BBB'), list('CC'), list('D')]) def test_filter(self): self.assertEqual(list(filter(lambda x: x%2, range(10))), [1,3,5,7,9]) def test_filterfalse(self): self.assertEqual(list(filterfalse(lambda x: x%2, range(10))), [0,2,4,6,8]) def test_map(self): self.assertEqual(list(map(pow, (2,3,10), (5,2,3))), [32, 9, 1000]) def test_islice(self): self.assertEqual(list(islice('ABCDEFG', 2)), list('AB')) self.assertEqual(list(islice('ABCDEFG', 2, 4)), list('CD')) self.assertEqual(list(islice('ABCDEFG', 2, None)), list('CDEFG')) self.assertEqual(list(islice('ABCDEFG', 0, None, 2)), list('ACEG')) def test_zip(self): self.assertEqual(list(zip('ABCD', 'xy')), [('A', 'x'), ('B', 'y')]) def test_zip_longest(self): self.assertEqual(list(zip_longest('ABCD', 'xy', fillvalue='-')), [('A', 'x'), ('B', 'y'), ('C', '-'), ('D', '-')]) def test_permutations(self): self.assertEqual(list(permutations('ABCD', 2)), list(map(tuple, 'AB AC AD BA BC BD CA CB CD DA DB DC'.split()))) self.assertEqual(list(permutations(range(3))), [(0,1,2), (0,2,1), (1,0,2), (1,2,0), (2,0,1), (2,1,0)]) def test_product(self): self.assertEqual(list(product('ABCD', 'xy')), list(map(tuple, 'Ax Ay Bx By Cx Cy Dx Dy'.split()))) self.assertEqual(list(product(range(2), repeat=3)), [(0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)]) def test_repeat(self): self.assertEqual(list(repeat(10, 3)), [10, 10, 10]) def test_stapmap(self): self.assertEqual(list(starmap(pow, [(2,5), (3,2), (10,3)])), [32, 9, 1000]) def test_takewhile(self): self.assertEqual(list(takewhile(lambda x: x<5, [1,4,6,4,1])), [1,4]) class TestPurePythonRoughEquivalents(unittest.TestCase): @staticmethod def islice(iterable, *args): s = slice(*args) start, stop, step = s.start or 0, s.stop or sys.maxsize, s.step or 1 it = iter(range(start, stop, step)) try: nexti = next(it) except StopIteration: # Consume *iterable* up to the *start* position. for i, element in zip(range(start), iterable): pass return try: for i, element in enumerate(iterable): if i == nexti: yield element nexti = next(it) except StopIteration: # Consume to *stop*. for i, element in zip(range(i + 1, stop), iterable): pass def test_islice_recipe(self): self.assertEqual(list(self.islice('ABCDEFG', 2)), list('AB')) self.assertEqual(list(self.islice('ABCDEFG', 2, 4)), list('CD')) self.assertEqual(list(self.islice('ABCDEFG', 2, None)), list('CDEFG')) self.assertEqual(list(self.islice('ABCDEFG', 0, None, 2)), list('ACEG')) # Test items consumed. it = iter(range(10)) self.assertEqual(list(self.islice(it, 3)), list(range(3))) self.assertEqual(list(it), list(range(3, 10))) it = iter(range(10)) self.assertEqual(list(self.islice(it, 3, 3)), []) self.assertEqual(list(it), list(range(3, 10))) # Test that slice finishes in predictable state. c = count() self.assertEqual(list(self.islice(c, 1, 3, 50)), [1]) self.assertEqual(next(c), 3) class TestGC(unittest.TestCase): def makecycle(self, iterator, container): container.append(iterator) next(iterator) del container, iterator def test_accumulate(self): a = [] self.makecycle(accumulate([1,2,a,3]), a) def test_chain(self): a = [] self.makecycle(chain(a), a) def test_chain_from_iterable(self): a = [] self.makecycle(chain.from_iterable([a]), a) def test_combinations(self): a = [] self.makecycle(combinations([1,2,a,3], 3), a) def test_combinations_with_replacement(self): a = [] self.makecycle(combinations_with_replacement([1,2,a,3], 3), a) def test_compress(self): a = [] self.makecycle(compress('ABCDEF', [1,0,1,0,1,0]), a) def test_count(self): a = [] Int = type('Int', (int,), dict(x=a)) self.makecycle(count(Int(0), Int(1)), a) def test_cycle(self): a = [] self.makecycle(cycle([a]*2), a) def test_dropwhile(self): a = [] self.makecycle(dropwhile(bool, [0, a, a]), a) def test_groupby(self): a = [] self.makecycle(groupby([a]*2, lambda x:x), a) def test_issue2246(self): # Issue 2246 -- the _grouper iterator was not included in GC n = 10 keyfunc = lambda x: x for i, j in groupby(range(n), key=keyfunc): keyfunc.__dict__.setdefault('x',[]).append(j) def test_filter(self): a = [] self.makecycle(filter(lambda x:True, [a]*2), a) def test_filterfalse(self): a = [] self.makecycle(filterfalse(lambda x:False, a), a) def test_zip(self): a = [] self.makecycle(zip([a]*2, [a]*3), a) def test_zip_longest(self): a = [] self.makecycle(zip_longest([a]*2, [a]*3), a) b = [a, None] self.makecycle(zip_longest([a]*2, [a]*3, fillvalue=b), a) def test_map(self): a = [] self.makecycle(map(lambda x:x, [a]*2), a) def test_islice(self): a = [] self.makecycle(islice([a]*2, None), a) def test_permutations(self): a = [] self.makecycle(permutations([1,2,a,3], 3), a) def test_product(self): a = [] self.makecycle(product([1,2,a,3], repeat=3), a) def test_repeat(self): a = [] self.makecycle(repeat(a), a) def test_starmap(self): a = [] self.makecycle(starmap(lambda *t: t, [(a,a)]*2), a) def test_takewhile(self): a = [] self.makecycle(takewhile(bool, [1, 0, a, a]), a) def R(seqn): 'Regular generator' for i in seqn: yield i class G: 'Sequence using __getitem__' def __init__(self, seqn): self.seqn = seqn def __getitem__(self, i): return self.seqn[i] class I: 'Sequence using iterator protocol' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 return v class Ig: 'Sequence using iterator protocol defined with a generator' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): for val in self.seqn: yield val class X: 'Missing __getitem__ and __iter__' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 return v class N: 'Iterator missing __next__()' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self class E: 'Test propagation of exceptions' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self def __next__(self): 3 // 0 class S: 'Test immediate stop' def __init__(self, seqn): pass def __iter__(self): return self def __next__(self): raise StopIteration def L(seqn): 'Test multiple tiers of iterators' return chain(map(lambda x:x, R(Ig(G(seqn))))) class TestVariousIteratorArgs(unittest.TestCase): def test_accumulate(self): s = [1,2,3,4,5] r = [1,3,6,10,15] n = len(s) for g in (G, I, Ig, L, R): self.assertEqual(list(accumulate(g(s))), r) self.assertEqual(list(accumulate(S(s))), []) self.assertRaises(TypeError, accumulate, X(s)) self.assertRaises(TypeError, accumulate, N(s)) self.assertRaises(ZeroDivisionError, list, accumulate(E(s))) def test_chain(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(chain(g(s))), list(g(s))) self.assertEqual(list(chain(g(s), g(s))), list(g(s))+list(g(s))) self.assertRaises(TypeError, list, chain(X(s))) self.assertRaises(TypeError, list, chain(N(s))) self.assertRaises(ZeroDivisionError, list, chain(E(s))) def test_compress(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): n = len(s) for g in (G, I, Ig, S, L, R): self.assertEqual(list(compress(g(s), repeat(1))), list(g(s))) self.assertRaises(TypeError, compress, X(s), repeat(1)) self.assertRaises(TypeError, compress, N(s), repeat(1)) self.assertRaises(ZeroDivisionError, list, compress(E(s), repeat(1))) def test_product(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): self.assertRaises(TypeError, product, X(s)) self.assertRaises(TypeError, product, N(s)) self.assertRaises(ZeroDivisionError, product, E(s)) def test_cycle(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgtlen = len(s) * 3 expected = list(g(s))*3 actual = list(islice(cycle(g(s)), tgtlen)) self.assertEqual(actual, expected) self.assertRaises(TypeError, cycle, X(s)) self.assertRaises(TypeError, cycle, N(s)) self.assertRaises(ZeroDivisionError, list, cycle(E(s))) def test_groupby(self): for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual([k for k, sb in groupby(g(s))], list(g(s))) self.assertRaises(TypeError, groupby, X(s)) self.assertRaises(TypeError, groupby, N(s)) self.assertRaises(ZeroDivisionError, list, groupby(E(s))) def test_filter(self): for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(filter(isEven, g(s))), [x for x in g(s) if isEven(x)]) self.assertRaises(TypeError, filter, isEven, X(s)) self.assertRaises(TypeError, filter, isEven, N(s)) self.assertRaises(ZeroDivisionError, list, filter(isEven, E(s))) def test_filterfalse(self): for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(filterfalse(isEven, g(s))), [x for x in g(s) if isOdd(x)]) self.assertRaises(TypeError, filterfalse, isEven, X(s)) self.assertRaises(TypeError, filterfalse, isEven, N(s)) self.assertRaises(ZeroDivisionError, list, filterfalse(isEven, E(s))) def test_zip(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(zip(g(s))), lzip(g(s))) self.assertEqual(list(zip(g(s), g(s))), lzip(g(s), g(s))) self.assertRaises(TypeError, zip, X(s)) self.assertRaises(TypeError, zip, N(s)) self.assertRaises(ZeroDivisionError, list, zip(E(s))) def test_ziplongest(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(zip_longest(g(s))), list(zip(g(s)))) self.assertEqual(list(zip_longest(g(s), g(s))), list(zip(g(s), g(s)))) self.assertRaises(TypeError, zip_longest, X(s)) self.assertRaises(TypeError, zip_longest, N(s)) self.assertRaises(ZeroDivisionError, list, zip_longest(E(s))) def test_map(self): for s in (range(10), range(0), range(100), (7,11), range(20,50,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(map(onearg, g(s))), [onearg(x) for x in g(s)]) self.assertEqual(list(map(operator.pow, g(s), g(s))), [x**x for x in g(s)]) self.assertRaises(TypeError, map, onearg, X(s)) self.assertRaises(TypeError, map, onearg, N(s)) self.assertRaises(ZeroDivisionError, list, map(onearg, E(s))) def test_islice(self): for s in ("12345", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(islice(g(s),1,None,2)), list(g(s))[1::2]) self.assertRaises(TypeError, islice, X(s), 10) self.assertRaises(TypeError, islice, N(s), 10) self.assertRaises(ZeroDivisionError, list, islice(E(s), 10)) def test_starmap(self): for s in (range(10), range(0), range(100), (7,11), range(20,50,5)): for g in (G, I, Ig, S, L, R): ss = lzip(s, s) self.assertEqual(list(starmap(operator.pow, g(ss))), [x**x for x in g(s)]) self.assertRaises(TypeError, starmap, operator.pow, X(ss)) self.assertRaises(TypeError, starmap, operator.pow, N(ss)) self.assertRaises(ZeroDivisionError, list, starmap(operator.pow, E(ss))) def test_takewhile(self): for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgt = [] for elem in g(s): if not isEven(elem): break tgt.append(elem) self.assertEqual(list(takewhile(isEven, g(s))), tgt) self.assertRaises(TypeError, takewhile, isEven, X(s)) self.assertRaises(TypeError, takewhile, isEven, N(s)) self.assertRaises(ZeroDivisionError, list, takewhile(isEven, E(s))) def test_dropwhile(self): for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgt = [] for elem in g(s): if not tgt and isOdd(elem): continue tgt.append(elem) self.assertEqual(list(dropwhile(isOdd, g(s))), tgt) self.assertRaises(TypeError, dropwhile, isOdd, X(s)) self.assertRaises(TypeError, dropwhile, isOdd, N(s)) self.assertRaises(ZeroDivisionError, list, dropwhile(isOdd, E(s))) def test_tee(self): for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)): for g in (G, I, Ig, S, L, R): it1, it2 = tee(g(s)) self.assertEqual(list(it1), list(g(s))) self.assertEqual(list(it2), list(g(s))) self.assertRaises(TypeError, tee, X(s)) self.assertRaises(TypeError, tee, N(s)) self.assertRaises(ZeroDivisionError, list, tee(E(s))[0]) class LengthTransparency(unittest.TestCase): def test_repeat(self): self.assertEqual(operator.length_hint(repeat(None, 50)), 50) self.assertEqual(operator.length_hint(repeat(None, 0)), 0) self.assertEqual(operator.length_hint(repeat(None), 12), 12) def test_repeat_with_negative_times(self): self.assertEqual(operator.length_hint(repeat(None, -1)), 0) self.assertEqual(operator.length_hint(repeat(None, -2)), 0) self.assertEqual(operator.length_hint(repeat(None, times=-1)), 0) self.assertEqual(operator.length_hint(repeat(None, times=-2)), 0) class RegressionTests(unittest.TestCase): def test_sf_793826(self): # Fix Armin Rigo's successful efforts to wreak havoc def mutatingtuple(tuple1, f, tuple2): # this builds a tuple t which is a copy of tuple1, # then calls f(t), then mutates t to be equal to tuple2 # (needs len(tuple1) == len(tuple2)). def g(value, first=[1]): if first: del first[:] f(next(z)) return value items = list(tuple2) items[1:1] = list(tuple1) gen = map(g, items) z = zip(*[gen]*len(tuple1)) next(z) def f(t): global T T = t first[:] = list(T) first = [] mutatingtuple((1,2,3), f, (4,5,6)) second = list(T) self.assertEqual(first, second) def test_sf_950057(self): # Make sure that chain() and cycle() catch exceptions immediately # rather than when shifting between input sources def gen1(): hist.append(0) yield 1 hist.append(1) raise AssertionError hist.append(2) def gen2(x): hist.append(3) yield 2 hist.append(4) hist = [] self.assertRaises(AssertionError, list, chain(gen1(), gen2(False))) self.assertEqual(hist, [0,1]) hist = [] self.assertRaises(AssertionError, list, chain(gen1(), gen2(True))) self.assertEqual(hist, [0,1]) hist = [] self.assertRaises(AssertionError, list, cycle(gen1())) self.assertEqual(hist, [0,1]) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_long_chain_of_empty_iterables(self): # Make sure itertools.chain doesn't run into recursion limits when # dealing with long chains of empty iterables. Even with a high # number this would probably only fail in Py_DEBUG mode. it = chain.from_iterable(() for unused in range(10000000)) with self.assertRaises(StopIteration): next(it) def test_issue30347_1(self): def f(n): if n == 5: list(b) return n != 6 for (k, b) in groupby(range(10), f): list(b) # shouldn't crash def test_issue30347_2(self): class K: def __init__(self, v): pass def __eq__(self, other): nonlocal i i += 1 if i == 1: next(g, None) return True i = 0 g = next(groupby(range(10), K))[1] for j in range(2): next(g, None) # shouldn't crash class SubclassWithKwargsTest(unittest.TestCase): def test_keywords_in_subclass(self): # count is not subclassable... for cls in (repeat, zip, filter, filterfalse, chain, map, starmap, islice, takewhile, dropwhile, cycle, compress): class Subclass(cls): def __init__(self, newarg=None, *args): cls.__init__(self, *args) try: Subclass(newarg=1) except TypeError as err: # we expect type errors because of wrong argument count self.assertNotIn("does not take keyword arguments", err.args[0]) @support.cpython_only class SizeofTest(unittest.TestCase): def setUp(self): self.ssize_t = struct.calcsize('n') check_sizeof = support.check_sizeof def test_product_sizeof(self): basesize = support.calcobjsize('3Pi') check = self.check_sizeof check(product('ab', '12'), basesize + 2 * self.ssize_t) check(product(*(('abc',) * 10)), basesize + 10 * self.ssize_t) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations_sizeof(self): basesize = support.calcobjsize('3Pni') check = self.check_sizeof check(combinations('abcd', 3), basesize + 3 * self.ssize_t) check(combinations(range(10), 4), basesize + 4 * self.ssize_t) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_combinations_with_replacement_sizeof(self): cwr = combinations_with_replacement basesize = support.calcobjsize('3Pni') check = self.check_sizeof check(cwr('abcd', 3), basesize + 3 * self.ssize_t) check(cwr(range(10), 4), basesize + 4 * self.ssize_t) @unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota') def test_permutations_sizeof(self): basesize = support.calcobjsize('4Pni') check = self.check_sizeof check(permutations('abcd'), basesize + 4 * self.ssize_t + 4 * self.ssize_t) check(permutations('abcd', 3), basesize + 4 * self.ssize_t + 3 * self.ssize_t) check(permutations('abcde', 3), basesize + 5 * self.ssize_t + 3 * self.ssize_t) check(permutations(range(10), 4), basesize + 10 * self.ssize_t + 4 * self.ssize_t) libreftest = """ Doctest for examples in the library reference: libitertools.tex >>> amounts = [120.15, 764.05, 823.14] >>> for checknum, amount in zip(count(1200), amounts): ... print('Check %d is for $%.2f' % (checknum, amount)) ... Check 1200 is for $120.15 Check 1201 is for $764.05 Check 1202 is for $823.14 >>> import operator >>> for cube in map(operator.pow, range(1,4), repeat(3)): ... print(cube) ... 1 8 27 >>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele'] >>> for name in islice(reportlines, 3, None, 2): ... print(name.title()) ... Alex Laura Martin Walter Samuele >>> from operator import itemgetter >>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3) >>> di = sorted(sorted(d.items()), key=itemgetter(1)) >>> for k, g in groupby(di, itemgetter(1)): ... print(k, list(map(itemgetter(0), g))) ... 1 ['a', 'c', 'e'] 2 ['b', 'd', 'f'] 3 ['g'] # Find runs of consecutive numbers using groupby. The key to the solution # is differencing with a range so that consecutive numbers all appear in # same group. >>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28] >>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]): ... print(list(map(operator.itemgetter(1), g))) ... [1] [4, 5, 6] [10] [15, 16, 17, 18] [22] [25, 26, 27, 28] >>> def take(n, iterable): ... "Return first n items of the iterable as a list" ... return list(islice(iterable, n)) >>> def prepend(value, iterator): ... "Prepend a single value in front of an iterator" ... # prepend(1, [2, 3, 4]) -> 1 2 3 4 ... return chain([value], iterator) >>> def enumerate(iterable, start=0): ... return zip(count(start), iterable) >>> def tabulate(function, start=0): ... "Return function(0), function(1), ..." ... return map(function, count(start)) >>> import collections >>> def consume(iterator, n=None): ... "Advance the iterator n-steps ahead. If n is None, consume entirely." ... # Use functions that consume iterators at C speed. ... if n is None: ... # feed the entire iterator into a zero-length deque ... collections.deque(iterator, maxlen=0) ... else: ... # advance to the empty slice starting at position n ... next(islice(iterator, n, n), None) >>> def nth(iterable, n, default=None): ... "Returns the nth item or a default value" ... return next(islice(iterable, n, None), default) >>> def all_equal(iterable): ... "Returns True if all the elements are equal to each other" ... g = groupby(iterable) ... return next(g, True) and not next(g, False) >>> def quantify(iterable, pred=bool): ... "Count how many times the predicate is true" ... return sum(map(pred, iterable)) >>> def padnone(iterable): ... "Returns the sequence elements and then returns None indefinitely" ... return chain(iterable, repeat(None)) >>> def ncycles(iterable, n): ... "Returns the sequence elements n times" ... return chain(*repeat(iterable, n)) >>> def dotproduct(vec1, vec2): ... return sum(map(operator.mul, vec1, vec2)) >>> def flatten(listOfLists): ... return list(chain.from_iterable(listOfLists)) >>> def repeatfunc(func, times=None, *args): ... "Repeat calls to func with specified arguments." ... " Example: repeatfunc(random.random)" ... if times is None: ... return starmap(func, repeat(args)) ... else: ... return starmap(func, repeat(args, times)) >>> def pairwise(iterable): ... "s -> (s0,s1), (s1,s2), (s2, s3), ..." ... a, b = tee(iterable) ... try: ... next(b) ... except StopIteration: ... pass ... return zip(a, b) >>> def grouper(n, iterable, fillvalue=None): ... "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" ... args = [iter(iterable)] * n ... return zip_longest(*args, fillvalue=fillvalue) >>> def roundrobin(*iterables): ... "roundrobin('ABC', 'D', 'EF') --> A D E B F C" ... # Recipe credited to George Sakkis ... pending = len(iterables) ... nexts = cycle(iter(it).__next__ for it in iterables) ... while pending: ... try: ... for next in nexts: ... yield next() ... except StopIteration: ... pending -= 1 ... nexts = cycle(islice(nexts, pending)) >>> def powerset(iterable): ... "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)" ... s = list(iterable) ... return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) >>> def unique_everseen(iterable, key=None): ... "List unique elements, preserving order. Remember all elements ever seen." ... # unique_everseen('AAAABBBCCDAABBB') --> A B C D ... # unique_everseen('ABBCcAD', str.lower) --> A B C D ... seen = set() ... seen_add = seen.add ... if key is None: ... for element in iterable: ... if element not in seen: ... seen_add(element) ... yield element ... else: ... for element in iterable: ... k = key(element) ... if k not in seen: ... seen_add(k) ... yield element >>> def unique_justseen(iterable, key=None): ... "List unique elements, preserving order. Remember only the element just seen." ... # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B ... # unique_justseen('ABBCcAD', str.lower) --> A B C A D ... return map(next, map(itemgetter(1), groupby(iterable, key))) >>> def first_true(iterable, default=False, pred=None): ... '''Returns the first true value in the iterable. ... ... If no true value is found, returns *default* ... ... If *pred* is not None, returns the first item ... for which pred(item) is true. ... ... ''' ... # first_true([a,b,c], x) --> a or b or c or x ... # first_true([a,b], x, f) --> a if f(a) else b if f(b) else x ... return next(filter(pred, iterable), default) >>> def nth_combination(iterable, r, index): ... 'Equivalent to list(combinations(iterable, r))[index]' ... pool = tuple(iterable) ... n = len(pool) ... if r < 0 or r > n: ... raise ValueError ... c = 1 ... k = min(r, n-r) ... for i in range(1, k+1): ... c = c * (n - k + i) // i ... if index < 0: ... index += c ... if index < 0 or index >= c: ... raise IndexError ... result = [] ... while r: ... c, n, r = c*r//n, n-1, r-1 ... while index >= c: ... index -= c ... c, n = c*(n-r)//n, n-1 ... result.append(pool[-1-n]) ... return tuple(result) This is not part of the examples but it tests to make sure the definitions perform as purported. >>> take(10, count()) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(prepend(1, [2, 3, 4])) [1, 2, 3, 4] >>> list(enumerate('abc')) [(0, 'a'), (1, 'b'), (2, 'c')] >>> list(islice(tabulate(lambda x: 2*x), 4)) [0, 2, 4, 6] >>> it = iter(range(10)) >>> consume(it, 3) >>> next(it) 3 >>> consume(it) >>> next(it, 'Done') 'Done' >>> nth('abcde', 3) 'd' >>> nth('abcde', 9) is None True >>> [all_equal(s) for s in ('', 'A', 'AAAA', 'AAAB', 'AAABA')] [True, True, True, False, False] >>> quantify(range(99), lambda x: x%2==0) 50 >>> a = [[1, 2, 3], [4, 5, 6]] >>> flatten(a) [1, 2, 3, 4, 5, 6] >>> list(repeatfunc(pow, 5, 2, 3)) [8, 8, 8, 8, 8] >>> import random >>> take(5, map(int, repeatfunc(random.random))) [0, 0, 0, 0, 0] >>> list(pairwise('abcd')) [('a', 'b'), ('b', 'c'), ('c', 'd')] >>> list(pairwise([])) [] >>> list(pairwise('a')) [] >>> list(islice(padnone('abc'), 0, 6)) ['a', 'b', 'c', None, None, None] >>> list(ncycles('abc', 3)) ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c'] >>> dotproduct([1,2,3], [4,5,6]) 32 >>> list(grouper(3, 'abcdefg', 'x')) [('a', 'b', 'c'), ('d', 'e', 'f'), ('g', 'x', 'x')] >>> list(roundrobin('abc', 'd', 'ef')) ['a', 'd', 'e', 'b', 'f', 'c'] >>> list(powerset([1,2,3])) [(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)] >>> all(len(list(powerset(range(n)))) == 2**n for n in range(18)) True >>> list(powerset('abcde')) == sorted(sorted(set(powerset('abcde'))), key=len) True >>> list(unique_everseen('AAAABBBCCDAABBB')) ['A', 'B', 'C', 'D'] >>> list(unique_everseen('ABBCcAD', str.lower)) ['A', 'B', 'C', 'D'] >>> list(unique_justseen('AAAABBBCCDAABBB')) ['A', 'B', 'C', 'D', 'A', 'B'] >>> list(unique_justseen('ABBCcAD', str.lower)) ['A', 'B', 'C', 'A', 'D'] >>> first_true('ABC0DEF1', '9', str.isdigit) '0' >>> population = 'ABCDEFGH' >>> for r in range(len(population) + 1): ... seq = list(combinations(population, r)) ... for i in range(len(seq)): ... assert nth_combination(population, r, i) == seq[i] ... for i in range(-len(seq), 0): ... assert nth_combination(population, r, i) == seq[i] """ __test__ = {'libreftest' : libreftest} def test_main(verbose=None): test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC, RegressionTests, LengthTransparency, SubclassWithKwargsTest, TestExamples, TestPurePythonRoughEquivalents, SizeofTest) support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc import os # [jart] it's sooo slow and isn't actually a test if os.isatty(2): for i in range(len(counts)): support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) # doctest the examples in the library reference support.run_doctest(sys.modules[__name__], verbose) if __name__ == "__main__": test_main(verbose=True)
100,412
2,467
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_atexit.py
import sys import cosmo import unittest import io import atexit from test import support from test.support import script_helper ### helpers def h1(): print("h1") def h2(): print("h2") def h3(): print("h3") def h4(*args, **kwargs): print("h4", args, kwargs) def raise1(): raise TypeError def raise2(): raise SystemError def exit(): raise SystemExit class GeneralTest(unittest.TestCase): def setUp(self): self.save_stdout = sys.stdout self.save_stderr = sys.stderr self.stream = io.StringIO() sys.stdout = sys.stderr = self.stream atexit._clear() def tearDown(self): sys.stdout = self.save_stdout sys.stderr = self.save_stderr atexit._clear() def test_args(self): # be sure args are handled properly atexit.register(h1) atexit.register(h4) atexit.register(h4, 4, kw="abc") atexit._run_exitfuncs() self.assertEqual(self.stream.getvalue(), "h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n") def test_badargs(self): atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0) self.assertRaises(TypeError, atexit._run_exitfuncs) def test_order(self): # be sure handlers are executed in reverse order atexit.register(h1) atexit.register(h2) atexit.register(h3) atexit._run_exitfuncs() self.assertEqual(self.stream.getvalue(), "h3\nh2\nh1\n") def test_raise(self): # be sure raises are handled properly atexit.register(raise1) atexit.register(raise2) self.assertRaises(TypeError, atexit._run_exitfuncs) def test_raise_unnormalized(self): # Issue #10756: Make sure that an unnormalized exception is # handled properly atexit.register(lambda: 1 / 0) self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs) self.assertIn("ZeroDivisionError", self.stream.getvalue()) def test_exit(self): # be sure a SystemExit is handled properly atexit.register(exit) self.assertRaises(SystemExit, atexit._run_exitfuncs) self.assertEqual(self.stream.getvalue(), '') def test_print_tracebacks(self): # Issue #18776: the tracebacks should be printed when errors occur. def f(): 1/0 # one def g(): 1/0 # two def h(): 1/0 # three atexit.register(f) atexit.register(g) atexit.register(h) self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs) stderr = self.stream.getvalue() self.assertEqual(stderr.count("ZeroDivisionError"), 3) if "tiny" not in cosmo.MODE: self.assertIn("# one", stderr) self.assertIn("# two", stderr) self.assertIn("# three", stderr) def test_stress(self): a = [0] def inc(): a[0] += 1 for i in range(128): atexit.register(inc) atexit._run_exitfuncs() self.assertEqual(a[0], 128) def test_clear(self): a = [0] def inc(): a[0] += 1 atexit.register(inc) atexit._clear() atexit._run_exitfuncs() self.assertEqual(a[0], 0) def test_unregister(self): a = [0] def inc(): a[0] += 1 def dec(): a[0] -= 1 for i in range(4): atexit.register(inc) atexit.register(dec) atexit.unregister(inc) atexit._run_exitfuncs() self.assertEqual(a[0], -1) def test_bound_methods(self): l = [] atexit.register(l.append, 5) atexit._run_exitfuncs() self.assertEqual(l, [5]) atexit.unregister(l.append) atexit._run_exitfuncs() self.assertEqual(l, [5]) def test_shutdown(self): # Actually test the shutdown mechanism in a subprocess code = """if 1: import atexit def f(msg): print(msg) atexit.register(f, "one") atexit.register(f, "two") """ res = script_helper.assert_python_ok("-c", code) self.assertEqual(res.out.decode().splitlines(), ["two", "one"]) self.assertFalse(res.err) @support.cpython_only class SubinterpreterTest(unittest.TestCase): def test_callbacks_leak(self): # This test shows a leak in refleak mode if atexit doesn't # take care to free callbacks in its per-subinterpreter module # state. n = atexit._ncallbacks() code = r"""if 1: import atexit def f(): pass atexit.register(f) del atexit """ ret = support.run_in_subinterp(code) self.assertEqual(ret, 0) self.assertEqual(atexit._ncallbacks(), n) def test_callbacks_leak_refcycle(self): # Similar to the above, but with a refcycle through the atexit # module. n = atexit._ncallbacks() code = r"""if 1: import atexit def f(): pass atexit.register(f) atexit.__atexit = atexit """ ret = support.run_in_subinterp(code) self.assertEqual(ret, 0) self.assertEqual(atexit._ncallbacks(), n) if __name__ == "__main__": unittest.main()
5,430
211
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_secrets.py
"""Test the secrets module. As most of the functions in secrets are thin wrappers around functions defined elsewhere, we don't need to test them exhaustively. """ import secrets import unittest import string # === Unit tests === class Compare_Digest_Tests(unittest.TestCase): """Test secrets.compare_digest function.""" def test_equal(self): # Test compare_digest functionality with equal (byte/text) strings. for s in ("a", "bcd", "xyz123"): a = s*100 b = s*100 self.assertTrue(secrets.compare_digest(a, b)) self.assertTrue(secrets.compare_digest(a.encode('utf-8'), b.encode('utf-8'))) def test_unequal(self): # Test compare_digest functionality with unequal (byte/text) strings. self.assertFalse(secrets.compare_digest("abc", "abcd")) self.assertFalse(secrets.compare_digest(b"abc", b"abcd")) for s in ("x", "mn", "a1b2c3"): a = s*100 + "q" b = s*100 + "k" self.assertFalse(secrets.compare_digest(a, b)) self.assertFalse(secrets.compare_digest(a.encode('utf-8'), b.encode('utf-8'))) def test_bad_types(self): # Test that compare_digest raises with mixed types. a = 'abcde' b = a.encode('utf-8') assert isinstance(a, str) assert isinstance(b, bytes) self.assertRaises(TypeError, secrets.compare_digest, a, b) self.assertRaises(TypeError, secrets.compare_digest, b, a) def test_bool(self): # Test that compare_digest returns a bool. self.assertIsInstance(secrets.compare_digest("abc", "abc"), bool) self.assertIsInstance(secrets.compare_digest("abc", "xyz"), bool) class Random_Tests(unittest.TestCase): """Test wrappers around SystemRandom methods.""" def test_randbits(self): # Test randbits. errmsg = "randbits(%d) returned %d" for numbits in (3, 12, 30): for i in range(6): n = secrets.randbits(numbits) self.assertTrue(0 <= n < 2**numbits, errmsg % (numbits, n)) def test_choice(self): # Test choice. items = [1, 2, 4, 8, 16, 32, 64] for i in range(10): self.assertTrue(secrets.choice(items) in items) def test_randbelow(self): # Test randbelow. for i in range(2, 10): self.assertIn(secrets.randbelow(i), range(i)) self.assertRaises(ValueError, secrets.randbelow, 0) self.assertRaises(ValueError, secrets.randbelow, -1) class Token_Tests(unittest.TestCase): """Test token functions.""" def test_token_defaults(self): # Test that token_* functions handle default size correctly. for func in (secrets.token_bytes, secrets.token_hex, secrets.token_urlsafe): with self.subTest(func=func): name = func.__name__ try: func() except TypeError: self.fail("%s cannot be called with no argument" % name) try: func(None) except TypeError: self.fail("%s cannot be called with None" % name) size = secrets.DEFAULT_ENTROPY self.assertEqual(len(secrets.token_bytes(None)), size) self.assertEqual(len(secrets.token_hex(None)), 2*size) def test_token_bytes(self): # Test token_bytes. for n in (1, 8, 17, 100): with self.subTest(n=n): self.assertIsInstance(secrets.token_bytes(n), bytes) self.assertEqual(len(secrets.token_bytes(n)), n) def test_token_hex(self): # Test token_hex. for n in (1, 12, 25, 90): with self.subTest(n=n): s = secrets.token_hex(n) self.assertIsInstance(s, str) self.assertEqual(len(s), 2*n) self.assertTrue(all(c in string.hexdigits for c in s)) def test_token_urlsafe(self): # Test token_urlsafe. legal = string.ascii_letters + string.digits + '-_' for n in (1, 11, 28, 76): with self.subTest(n=n): s = secrets.token_urlsafe(n) self.assertIsInstance(s, str) self.assertTrue(all(c in legal for c in s)) if __name__ == '__main__': unittest.main()
4,381
125
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_mailcap.py
import mailcap import os import copy import test.support import unittest # Location of mailcap file MAILCAPFILE = test.support.findfile("mailcap.txt") # Dict to act as mock mailcap entry for this test # The keys and values should match the contents of MAILCAPFILE MAILCAPDICT = { 'application/x-movie': [{'compose': 'moviemaker %s', 'x11-bitmap': '"/usr/lib/Zmail/bitmaps/movie.xbm"', 'description': '"Movie"', 'view': 'movieplayer %s', 'lineno': 4}], 'application/*': [{'copiousoutput': '', 'view': 'echo "This is \\"%t\\" but is 50 \\% Greek to me" \\; cat %s', 'lineno': 5}], 'audio/basic': [{'edit': 'audiocompose %s', 'compose': 'audiocompose %s', 'description': '"An audio fragment"', 'view': 'showaudio %s', 'lineno': 6}], 'video/mpeg': [{'view': 'mpeg_play %s', 'lineno': 13}], 'application/postscript': [{'needsterminal': '', 'view': 'ps-to-terminal %s', 'lineno': 1}, {'compose': 'idraw %s', 'view': 'ps-to-terminal %s', 'lineno': 2}], 'application/x-dvi': [{'view': 'xdvi %s', 'lineno': 3}], 'message/external-body': [{'composetyped': 'extcompose %s', 'description': '"A reference to data stored in an external location"', 'needsterminal': '', 'view': 'showexternal %s %{access-type} %{name} %{site} %{directory} %{mode} %{server}', 'lineno': 10}], 'text/richtext': [{'test': 'test "`echo %{charset} | tr \'[A-Z]\' \'[a-z]\'`" = iso-8859-8', 'copiousoutput': '', 'view': 'shownonascii iso-8859-8 -e richtext -p %s', 'lineno': 11}], 'image/x-xwindowdump': [{'view': 'display %s', 'lineno': 9}], 'audio/*': [{'view': '/usr/local/bin/showaudio %t', 'lineno': 7}], 'video/*': [{'view': 'animate %s', 'lineno': 12}], 'application/frame': [{'print': '"cat %s | lp"', 'view': 'showframe %s', 'lineno': 0}], 'image/rgb': [{'view': 'display %s', 'lineno': 8}] } # For backwards compatibility, readmailcapfile() and lookup() still support # the old version of mailcapdict without line numbers. MAILCAPDICT_DEPRECATED = copy.deepcopy(MAILCAPDICT) for entry_list in MAILCAPDICT_DEPRECATED.values(): for entry in entry_list: entry.pop('lineno') class HelperFunctionTest(unittest.TestCase): def test_listmailcapfiles(self): # The return value for listmailcapfiles() will vary by system. # So verify that listmailcapfiles() returns a list of strings that is of # non-zero length. mcfiles = mailcap.listmailcapfiles() self.assertIsInstance(mcfiles, list) for m in mcfiles: self.assertIsInstance(m, str) with test.support.EnvironmentVarGuard() as env: # According to RFC 1524, if MAILCAPS env variable exists, use that # and only that. if "MAILCAPS" in env: env_mailcaps = env["MAILCAPS"].split(os.pathsep) else: env_mailcaps = ["/testdir1/.mailcap", "/testdir2/mailcap"] env["MAILCAPS"] = os.pathsep.join(env_mailcaps) mcfiles = mailcap.listmailcapfiles() self.assertEqual(env_mailcaps, mcfiles) def test_readmailcapfile(self): # Test readmailcapfile() using test file. It should match MAILCAPDICT. with open(MAILCAPFILE, 'r') as mcf: with self.assertWarns(DeprecationWarning): d = mailcap.readmailcapfile(mcf) self.assertDictEqual(d, MAILCAPDICT_DEPRECATED) def test_lookup(self): # Test without key expected = [{'view': 'animate %s', 'lineno': 12}, {'view': 'mpeg_play %s', 'lineno': 13}] actual = mailcap.lookup(MAILCAPDICT, 'video/mpeg') self.assertListEqual(expected, actual) # Test with key key = 'compose' expected = [{'edit': 'audiocompose %s', 'compose': 'audiocompose %s', 'description': '"An audio fragment"', 'view': 'showaudio %s', 'lineno': 6}] actual = mailcap.lookup(MAILCAPDICT, 'audio/basic', key) self.assertListEqual(expected, actual) # Test on user-defined dicts without line numbers expected = [{'view': 'mpeg_play %s'}, {'view': 'animate %s'}] actual = mailcap.lookup(MAILCAPDICT_DEPRECATED, 'video/mpeg') self.assertListEqual(expected, actual) def test_subst(self): plist = ['id=1', 'number=2', 'total=3'] # test case: ([field, MIMEtype, filename, plist=[]], <expected string>) test_cases = [ (["", "audio/*", "foo.txt"], ""), (["echo foo", "audio/*", "foo.txt"], "echo foo"), (["echo %s", "audio/*", "foo.txt"], "echo foo.txt"), (["echo %t", "audio/*", "foo.txt"], "echo audio/*"), (["echo \\%t", "audio/*", "foo.txt"], "echo %t"), (["echo foo", "audio/*", "foo.txt", plist], "echo foo"), (["echo %{total}", "audio/*", "foo.txt", plist], "echo 3") ] for tc in test_cases: self.assertEqual(mailcap.subst(*tc[0]), tc[1]) class GetcapsTest(unittest.TestCase): def test_mock_getcaps(self): # Test mailcap.getcaps() using mock mailcap file in this dir. # Temporarily override any existing system mailcap file by pointing the # MAILCAPS environment variable to our mock file. with test.support.EnvironmentVarGuard() as env: env["MAILCAPS"] = MAILCAPFILE caps = mailcap.getcaps() self.assertDictEqual(caps, MAILCAPDICT) def test_system_mailcap(self): # Test mailcap.getcaps() with mailcap file(s) on system, if any. caps = mailcap.getcaps() self.assertIsInstance(caps, dict) mailcapfiles = mailcap.listmailcapfiles() existingmcfiles = [mcf for mcf in mailcapfiles if os.path.exists(mcf)] if existingmcfiles: # At least 1 mailcap file exists, so test that. for (k, v) in caps.items(): self.assertIsInstance(k, str) self.assertIsInstance(v, list) for e in v: self.assertIsInstance(e, dict) else: # No mailcap files on system. getcaps() should return empty dict. self.assertEqual({}, caps) class FindmatchTest(unittest.TestCase): def test_findmatch(self): # default findmatch arguments c = MAILCAPDICT fname = "foo.txt" plist = ["access-type=default", "name=john", "site=python.org", "directory=/tmp", "mode=foo", "server=bar"] audio_basic_entry = { 'edit': 'audiocompose %s', 'compose': 'audiocompose %s', 'description': '"An audio fragment"', 'view': 'showaudio %s', 'lineno': 6 } audio_entry = {"view": "/usr/local/bin/showaudio %t", 'lineno': 7} video_entry = {'view': 'animate %s', 'lineno': 12} message_entry = { 'composetyped': 'extcompose %s', 'description': '"A reference to data stored in an external location"', 'needsterminal': '', 'view': 'showexternal %s %{access-type} %{name} %{site} %{directory} %{mode} %{server}', 'lineno': 10, } # test case: (findmatch args, findmatch keyword args, expected output) # positional args: caps, MIMEtype # keyword args: key="view", filename="/dev/null", plist=[] # output: (command line, mailcap entry) cases = [ ([{}, "video/mpeg"], {}, (None, None)), ([c, "foo/bar"], {}, (None, None)), ([c, "video/mpeg"], {}, ('animate /dev/null', video_entry)), ([c, "audio/basic", "edit"], {}, ("audiocompose /dev/null", audio_basic_entry)), ([c, "audio/basic", "compose"], {}, ("audiocompose /dev/null", audio_basic_entry)), ([c, "audio/basic", "description"], {}, ('"An audio fragment"', audio_basic_entry)), ([c, "audio/basic", "foobar"], {}, (None, None)), ([c, "video/*"], {"filename": fname}, ("animate %s" % fname, video_entry)), ([c, "audio/basic", "compose"], {"filename": fname}, ("audiocompose %s" % fname, audio_basic_entry)), ([c, "audio/basic"], {"key": "description", "filename": fname}, ('"An audio fragment"', audio_basic_entry)), ([c, "audio/*"], {"filename": fname}, ("/usr/local/bin/showaudio audio/*", audio_entry)), ([c, "message/external-body"], {"plist": plist}, ("showexternal /dev/null default john python.org /tmp foo bar", message_entry)) ] self._run_cases(cases) @unittest.skipUnless(os.name == "posix", "Requires 'test' command on system") def test_test(self): # findmatch() will automatically check any "test" conditions and skip # the entry if the check fails. caps = {"test/pass": [{"test": "test 1 -eq 1"}], "test/fail": [{"test": "test 1 -eq 0"}]} # test case: (findmatch args, findmatch keyword args, expected output) # positional args: caps, MIMEtype, key ("test") # keyword args: N/A # output: (command line, mailcap entry) cases = [ # findmatch will return the mailcap entry for test/pass because it evaluates to true ([caps, "test/pass", "test"], {}, ("test 1 -eq 1", {"test": "test 1 -eq 1"})), # findmatch will return None because test/fail evaluates to false ([caps, "test/fail", "test"], {}, (None, None)) ] self._run_cases(cases) def _run_cases(self, cases): for c in cases: self.assertEqual(mailcap.findmatch(*c[0], **c[1]), c[2]) if __name__ == '__main__': unittest.main()
10,117
240
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_coroutines.py
import contextlib import copy import inspect import pickle import sys import cosmo import types import unittest import warnings from test import support class AsyncYieldFrom: def __init__(self, obj): self.obj = obj def __await__(self): yield from self.obj class AsyncYield: def __init__(self, value): self.value = value def __await__(self): yield self.value def run_async(coro): assert coro.__class__ in {types.GeneratorType, types.CoroutineType} buffer = [] result = None while True: try: buffer.append(coro.send(None)) except StopIteration as ex: result = ex.args[0] if ex.args else None break return buffer, result def run_async__await__(coro): assert coro.__class__ is types.CoroutineType aw = coro.__await__() buffer = [] result = None i = 0 while True: try: if i % 2: buffer.append(next(aw)) else: buffer.append(aw.send(None)) i += 1 except StopIteration as ex: result = ex.args[0] if ex.args else None break return buffer, result @contextlib.contextmanager def silence_coro_gc(): with warnings.catch_warnings(): warnings.simplefilter("ignore") yield support.gc_collect() class AsyncBadSyntaxTest(unittest.TestCase): def test_badsyntax_1(self): samples = [ """def foo(): await something() """, """await something()""", """async def foo(): yield from [] """, """async def foo(): await await fut """, """async def foo(a=await something()): pass """, """async def foo(a:await something()): pass """, """async def foo(): def bar(): [i async for i in els] """, """async def foo(): def bar(): [await i for i in els] """, """async def foo(): def bar(): [i for i in els async for b in els] """, """async def foo(): def bar(): [i for i in els for c in b async for b in els] """, """async def foo(): def bar(): [i for i in els async for b in els for c in b] """, """async def foo(): def bar(): [i for i in els for b in await els] """, """async def foo(): def bar(): [i for i in els for b in els if await b] """, """async def foo(): def bar(): [i for i in await els] """, """async def foo(): def bar(): [i for i in els if await i] """, """def bar(): [i async for i in els] """, """def bar(): [await i for i in els] """, """def bar(): [i for i in els async for b in els] """, """def bar(): [i for i in els for c in b async for b in els] """, """def bar(): [i for i in els async for b in els for c in b] """, """def bar(): [i for i in els for b in await els] """, """def bar(): [i for i in els for b in els if await b] """, """def bar(): [i for i in await els] """, """def bar(): [i for i in els if await i] """, """async def foo(): await """, """async def foo(): def bar(): pass await = 1 """, """async def foo(): def bar(): pass await = 1 """, """async def foo(): def bar(): pass if 1: await = 1 """, """def foo(): async def bar(): pass if 1: await a """, """def foo(): async def bar(): pass await a """, """def foo(): def baz(): pass async def bar(): pass await a """, """def foo(): def baz(): pass # 456 async def bar(): pass # 123 await a """, """async def foo(): def baz(): pass # 456 async def bar(): pass # 123 await = 2 """, """def foo(): def baz(): pass async def bar(): pass await a """, """async def foo(): def baz(): pass async def bar(): pass await = 2 """, """async def foo(): def async(): pass """, """async def foo(): def await(): pass """, """async def foo(): def bar(): await """, """async def foo(): return lambda async: await """, """async def foo(): return lambda a: await """, """await a()""", """async def foo(a=await b): pass """, """async def foo(a:await b): pass """, """def baz(): async def foo(a=await b): pass """, """async def foo(async): pass """, """async def foo(): def bar(): def baz(): async = 1 """, """async def foo(): def bar(): def baz(): pass async = 1 """, """def foo(): async def bar(): async def baz(): pass def baz(): 42 async = 1 """, """async def foo(): def bar(): def baz(): pass\nawait foo() """, """def foo(): def bar(): async def baz(): pass\nawait foo() """, """async def foo(await): pass """, """def foo(): async def bar(): pass await a """, """def foo(): async def bar(): pass\nawait a """] for code in samples: with self.subTest(code=code), self.assertRaises(SyntaxError): compile(code, "<test>", "exec") def test_badsyntax_2(self): samples = [ """def foo(): await = 1 """, """class Bar: def async(): pass """, """class Bar: async = 1 """, """class async: pass """, """class await: pass """, """import math as await""", """def async(): pass""", """def foo(*, await=1): pass""" """async = 1""", """print(await=1)""" ] for code in samples: with self.subTest(code=code), self.assertWarnsRegex( DeprecationWarning, "'await' will become reserved keywords"): compile(code, "<test>", "exec") def test_badsyntax_3(self): with self.assertRaises(DeprecationWarning): with warnings.catch_warnings(): warnings.simplefilter("error") compile("async = 1", "<test>", "exec") def test_goodsyntax_1(self): # Tests for issue 24619 samples = [ '''def foo(await): async def foo(): pass async def foo(): pass return await + 1 ''', '''def foo(await): async def foo(): pass async def foo(): pass return await + 1 ''', '''def foo(await): async def foo(): pass async def foo(): pass return await + 1 ''', '''def foo(await): """spam""" async def foo(): \ pass # 123 async def foo(): pass # 456 return await + 1 ''', '''def foo(await): def foo(): pass def foo(): pass async def bar(): return await_ await_ = await try: bar().send(None) except StopIteration as ex: return ex.args[0] + 1 ''' ] for code in samples: with self.subTest(code=code): loc = {} with warnings.catch_warnings(): warnings.simplefilter("ignore") exec(code, loc, loc) self.assertEqual(loc['foo'](10), 11) class TokenizerRegrTest(unittest.TestCase): def test_oneline_defs(self): buf = [] for i in range(500): buf.append('def i{i}(): return {i}'.format(i=i)) buf = '\n'.join(buf) # Test that 500 consequent, one-line defs is OK ns = {} exec(buf, ns, ns) self.assertEqual(ns['i499'](), 499) # Test that 500 consequent, one-line defs *and* # one 'async def' following them is OK buf += '\nasync def foo():\n return' ns = {} exec(buf, ns, ns) self.assertEqual(ns['i499'](), 499) self.assertTrue(inspect.iscoroutinefunction(ns['foo'])) class CoroutineTest(unittest.TestCase): def test_gen_1(self): def gen(): yield self.assertFalse(hasattr(gen, '__await__')) def test_func_1(self): async def foo(): return 10 f = foo() self.assertIsInstance(f, types.CoroutineType) self.assertTrue(bool(foo.__code__.co_flags & inspect.CO_COROUTINE)) self.assertFalse(bool(foo.__code__.co_flags & inspect.CO_GENERATOR)) self.assertTrue(bool(f.cr_code.co_flags & inspect.CO_COROUTINE)) self.assertFalse(bool(f.cr_code.co_flags & inspect.CO_GENERATOR)) self.assertEqual(run_async(f), ([], 10)) self.assertEqual(run_async__await__(foo()), ([], 10)) def bar(): pass self.assertFalse(bool(bar.__code__.co_flags & inspect.CO_COROUTINE)) def test_func_2(self): async def foo(): raise StopIteration with self.assertRaisesRegex( RuntimeError, "coroutine raised StopIteration"): run_async(foo()) def test_func_3(self): async def foo(): raise StopIteration with silence_coro_gc(): self.assertRegex(repr(foo()), '^<coroutine object.* at 0x.*>$') def test_func_4(self): async def foo(): raise StopIteration check = lambda: self.assertRaisesRegex( TypeError, "'coroutine' object is not iterable") with check(): list(foo()) with check(): tuple(foo()) with check(): sum(foo()) with check(): iter(foo()) with silence_coro_gc(), check(): for i in foo(): pass with silence_coro_gc(), check(): [i for i in foo()] def test_func_5(self): @types.coroutine def bar(): yield 1 async def foo(): await bar() check = lambda: self.assertRaisesRegex( TypeError, "'coroutine' object is not iterable") with check(): for el in foo(): pass # the following should pass without an error for el in bar(): self.assertEqual(el, 1) self.assertEqual([el for el in bar()], [1]) self.assertEqual(tuple(bar()), (1,)) self.assertEqual(next(iter(bar())), 1) def test_func_6(self): @types.coroutine def bar(): yield 1 yield 2 async def foo(): await bar() f = foo() self.assertEqual(f.send(None), 1) self.assertEqual(f.send(None), 2) with self.assertRaises(StopIteration): f.send(None) def test_func_7(self): async def bar(): return 10 def foo(): yield from bar() with silence_coro_gc(), self.assertRaisesRegex( TypeError, "cannot 'yield from' a coroutine object in a non-coroutine generator"): list(foo()) def test_func_8(self): @types.coroutine def bar(): return (yield from foo()) async def foo(): return 'spam' self.assertEqual(run_async(bar()), ([], 'spam') ) def test_func_9(self): async def foo(): pass with self.assertWarnsRegex( RuntimeWarning, "coroutine '.*test_func_9.*foo' was never awaited"): foo() support.gc_collect() def test_func_10(self): N = 0 @types.coroutine def gen(): nonlocal N try: a = yield yield (a ** 2) except ZeroDivisionError: N += 100 raise finally: N += 1 async def foo(): await gen() coro = foo() aw = coro.__await__() self.assertIs(aw, iter(aw)) next(aw) self.assertEqual(aw.send(10), 100) self.assertEqual(N, 0) aw.close() self.assertEqual(N, 1) coro = foo() aw = coro.__await__() next(aw) with self.assertRaises(ZeroDivisionError): aw.throw(ZeroDivisionError, None, None) self.assertEqual(N, 102) def test_func_11(self): async def func(): pass coro = func() # Test that PyCoro_Type and _PyCoroWrapper_Type types were properly # initialized self.assertIn('__await__', dir(coro)) self.assertIn('__iter__', dir(coro.__await__())) self.assertIn('coroutine_wrapper', repr(coro.__await__())) coro.close() # avoid RuntimeWarning def test_func_12(self): async def g(): i = me.send(None) await foo me = g() with self.assertRaisesRegex(ValueError, "coroutine already executing"): me.send(None) def test_func_13(self): async def g(): pass with self.assertRaisesRegex( TypeError, "can't send non-None value to a just-started coroutine"): g().send('spam') def test_func_14(self): @types.coroutine def gen(): yield async def coro(): try: await gen() except GeneratorExit: await gen() c = coro() c.send(None) with self.assertRaisesRegex(RuntimeError, "coroutine ignored GeneratorExit"): c.close() def test_func_15(self): # See http://bugs.python.org/issue25887 for details async def spammer(): return 'spam' async def reader(coro): return await coro spammer_coro = spammer() with self.assertRaisesRegex(StopIteration, 'spam'): reader(spammer_coro).send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): reader(spammer_coro).send(None) def test_func_16(self): # See http://bugs.python.org/issue25887 for details @types.coroutine def nop(): yield async def send(): await nop() return 'spam' async def read(coro): await nop() return await coro spammer = send() reader = read(spammer) reader.send(None) reader.send(None) with self.assertRaisesRegex(Exception, 'ham'): reader.throw(Exception('ham')) reader = read(spammer) reader.send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): reader.send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): reader.throw(Exception('wat')) def test_func_17(self): # See http://bugs.python.org/issue25887 for details async def coroutine(): return 'spam' coro = coroutine() with self.assertRaisesRegex(StopIteration, 'spam'): coro.send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): coro.send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): coro.throw(Exception('wat')) # Closing a coroutine shouldn't raise any exception even if it's # already closed/exhausted (similar to generators) coro.close() coro.close() def test_func_18(self): # See http://bugs.python.org/issue25887 for details async def coroutine(): return 'spam' coro = coroutine() await_iter = coro.__await__() it = iter(await_iter) with self.assertRaisesRegex(StopIteration, 'spam'): it.send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): it.send(None) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): # Although the iterator protocol requires iterators to # raise another StopIteration here, we don't want to do # that. In this particular case, the iterator will raise # a RuntimeError, so that 'yield from' and 'await' # expressions will trigger the error, instead of silently # ignoring the call. next(it) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): it.throw(Exception('wat')) with self.assertRaisesRegex(RuntimeError, 'cannot reuse already awaited coroutine'): it.throw(Exception('wat')) # Closing a coroutine shouldn't raise any exception even if it's # already closed/exhausted (similar to generators) it.close() it.close() def test_func_19(self): CHK = 0 @types.coroutine def foo(): nonlocal CHK yield try: yield except GeneratorExit: CHK += 1 async def coroutine(): await foo() coro = coroutine() coro.send(None) coro.send(None) self.assertEqual(CHK, 0) coro.close() self.assertEqual(CHK, 1) for _ in range(3): # Closing a coroutine shouldn't raise any exception even if it's # already closed/exhausted (similar to generators) coro.close() self.assertEqual(CHK, 1) def test_coro_wrapper_send_tuple(self): async def foo(): return (10,) result = run_async__await__(foo()) self.assertEqual(result, ([], (10,))) def test_coro_wrapper_send_stop_iterator(self): async def foo(): return StopIteration(10) result = run_async__await__(foo()) self.assertIsInstance(result[1], StopIteration) self.assertEqual(result[1].value, 10) def test_cr_await(self): @types.coroutine def a(): self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_RUNNING) self.assertIsNone(coro_b.cr_await) yield self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_RUNNING) self.assertIsNone(coro_b.cr_await) async def c(): await a() async def b(): self.assertIsNone(coro_b.cr_await) await c() self.assertIsNone(coro_b.cr_await) coro_b = b() self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_CREATED) self.assertIsNone(coro_b.cr_await) coro_b.send(None) self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_SUSPENDED) self.assertEqual(coro_b.cr_await.cr_await.gi_code.co_name, 'a') with self.assertRaises(StopIteration): coro_b.send(None) # complete coroutine self.assertEqual(inspect.getcoroutinestate(coro_b), inspect.CORO_CLOSED) self.assertIsNone(coro_b.cr_await) @unittest.skipIf("tiny" in cosmo.MODE, "docstrings stripped in MODE=tiny") def test_corotype_1(self): ct = types.CoroutineType self.assertIn('into coroutine', ct.send.__doc__) self.assertIn('inside coroutine', ct.close.__doc__) self.assertIn('in coroutine', ct.throw.__doc__) self.assertIn('of the coroutine', ct.__dict__['__name__'].__doc__) self.assertIn('of the coroutine', ct.__dict__['__qualname__'].__doc__) self.assertEqual(ct.__name__, 'coroutine') async def f(): pass c = f() self.assertIn('coroutine object', repr(c)) c.close() def test_await_1(self): async def foo(): await 1 with self.assertRaisesRegex(TypeError, "object int can.t.*await"): run_async(foo()) def test_await_2(self): async def foo(): await [] with self.assertRaisesRegex(TypeError, "object list can.t.*await"): run_async(foo()) def test_await_3(self): async def foo(): await AsyncYieldFrom([1, 2, 3]) self.assertEqual(run_async(foo()), ([1, 2, 3], None)) self.assertEqual(run_async__await__(foo()), ([1, 2, 3], None)) def test_await_4(self): async def bar(): return 42 async def foo(): return await bar() self.assertEqual(run_async(foo()), ([], 42)) def test_await_5(self): class Awaitable: def __await__(self): return async def foo(): return (await Awaitable()) with self.assertRaisesRegex( TypeError, "__await__.*returned non-iterator of type"): run_async(foo()) def test_await_6(self): class Awaitable: def __await__(self): return iter([52]) async def foo(): return (await Awaitable()) self.assertEqual(run_async(foo()), ([52], None)) def test_await_7(self): class Awaitable: def __await__(self): yield 42 return 100 async def foo(): return (await Awaitable()) self.assertEqual(run_async(foo()), ([42], 100)) def test_await_8(self): class Awaitable: pass async def foo(): return await Awaitable() with self.assertRaisesRegex( TypeError, "object Awaitable can't be used in 'await' expression"): run_async(foo()) def test_await_9(self): def wrap(): return bar async def bar(): return 42 async def foo(): b = bar() db = {'b': lambda: wrap} class DB: b = wrap return (await bar() + await wrap()() + await db['b']()()() + await bar() * 1000 + await DB.b()()) async def foo2(): return -await bar() self.assertEqual(run_async(foo()), ([], 42168)) self.assertEqual(run_async(foo2()), ([], -42)) def test_await_10(self): async def baz(): return 42 async def bar(): return baz() async def foo(): return await (await bar()) self.assertEqual(run_async(foo()), ([], 42)) def test_await_11(self): def ident(val): return val async def bar(): return 'spam' async def foo(): return ident(val=await bar()) async def foo2(): return await bar(), 'ham' self.assertEqual(run_async(foo2()), ([], ('spam', 'ham'))) def test_await_12(self): async def coro(): return 'spam' class Awaitable: def __await__(self): return coro() async def foo(): return await Awaitable() with self.assertRaisesRegex( TypeError, r"__await__\(\) returned a coroutine"): run_async(foo()) def test_await_13(self): class Awaitable: def __await__(self): return self async def foo(): return await Awaitable() with self.assertRaisesRegex( TypeError, "__await__.*returned non-iterator of type"): run_async(foo()) def test_await_14(self): class Wrapper: # Forces the interpreter to use CoroutineType.__await__ def __init__(self, coro): assert coro.__class__ is types.CoroutineType self.coro = coro def __await__(self): return self.coro.__await__() class FutureLike: def __await__(self): return (yield) class Marker(Exception): pass async def coro1(): try: return await FutureLike() except ZeroDivisionError: raise Marker async def coro2(): return await Wrapper(coro1()) c = coro2() c.send(None) with self.assertRaisesRegex(StopIteration, 'spam'): c.send('spam') c = coro2() c.send(None) with self.assertRaises(Marker): c.throw(ZeroDivisionError) def test_await_15(self): @types.coroutine def nop(): yield async def coroutine(): await nop() async def waiter(coro): await coro coro = coroutine() coro.send(None) with self.assertRaisesRegex(RuntimeError, "coroutine is being awaited already"): waiter(coro).send(None) def test_await_16(self): # See https://bugs.python.org/issue29600 for details. async def f(): return ValueError() async def g(): try: raise KeyError except: return await f() _, result = run_async(g()) self.assertIsNone(result.__context__) def test_with_1(self): class Manager: def __init__(self, name): self.name = name async def __aenter__(self): await AsyncYieldFrom(['enter-1-' + self.name, 'enter-2-' + self.name]) return self async def __aexit__(self, *args): await AsyncYieldFrom(['exit-1-' + self.name, 'exit-2-' + self.name]) if self.name == 'B': return True async def foo(): async with Manager("A") as a, Manager("B") as b: await AsyncYieldFrom([('managers', a.name, b.name)]) 1/0 f = foo() result, _ = run_async(f) self.assertEqual( result, ['enter-1-A', 'enter-2-A', 'enter-1-B', 'enter-2-B', ('managers', 'A', 'B'), 'exit-1-B', 'exit-2-B', 'exit-1-A', 'exit-2-A'] ) async def foo(): async with Manager("A") as a, Manager("C") as c: await AsyncYieldFrom([('managers', a.name, c.name)]) 1/0 with self.assertRaises(ZeroDivisionError): run_async(foo()) def test_with_2(self): class CM: def __aenter__(self): pass async def foo(): async with CM(): pass with self.assertRaisesRegex(AttributeError, '__aexit__'): run_async(foo()) def test_with_3(self): class CM: def __aexit__(self): pass async def foo(): async with CM(): pass with self.assertRaisesRegex(AttributeError, '__aenter__'): run_async(foo()) def test_with_4(self): class CM: def __enter__(self): pass def __exit__(self): pass async def foo(): async with CM(): pass with self.assertRaisesRegex(AttributeError, '__aexit__'): run_async(foo()) # TODO(jart,ahgamut): Figure out this error. @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "No docstrings in MODE=tiny/rel") @unittest.skipIf("tiny" in cosmo.MODE, "") def test_with_5(self): # While this test doesn't make a lot of sense, # it's a regression test for an early bug with opcodes # generation class CM: async def __aenter__(self): return self async def __aexit__(self, *exc): pass async def func(): async with CM(): assert (1, ) == 1 with self.assertRaises(AssertionError): run_async(func()) def test_with_6(self): class CM: def __aenter__(self): return 123 def __aexit__(self, *e): return 456 async def foo(): async with CM(): pass with self.assertRaisesRegex( TypeError, "'async with' received an object from __aenter__ " "that does not implement __await__: int"): # it's important that __aexit__ wasn't called run_async(foo()) def test_with_7(self): class CM: async def __aenter__(self): return self def __aexit__(self, *e): return 444 # Exit with exception async def foo(): async with CM(): 1/0 try: run_async(foo()) except TypeError as exc: self.assertRegex( exc.args[0], "'async with' received an object from __aexit__ " "that does not implement __await__: int") self.assertTrue(exc.__context__ is not None) self.assertTrue(isinstance(exc.__context__, ZeroDivisionError)) else: self.fail('invalid asynchronous context manager did not fail') def test_with_8(self): CNT = 0 class CM: async def __aenter__(self): return self def __aexit__(self, *e): return 456 # Normal exit async def foo(): nonlocal CNT async with CM(): CNT += 1 with self.assertRaisesRegex( TypeError, "'async with' received an object from __aexit__ " "that does not implement __await__: int"): run_async(foo()) self.assertEqual(CNT, 1) # Exit with 'break' async def foo(): nonlocal CNT for i in range(2): async with CM(): CNT += 1 break with self.assertRaisesRegex( TypeError, "'async with' received an object from __aexit__ " "that does not implement __await__: int"): run_async(foo()) self.assertEqual(CNT, 2) # Exit with 'continue' async def foo(): nonlocal CNT for i in range(2): async with CM(): CNT += 1 continue with self.assertRaisesRegex( TypeError, "'async with' received an object from __aexit__ " "that does not implement __await__: int"): run_async(foo()) self.assertEqual(CNT, 3) # Exit with 'return' async def foo(): nonlocal CNT async with CM(): CNT += 1 return with self.assertRaisesRegex( TypeError, "'async with' received an object from __aexit__ " "that does not implement __await__: int"): run_async(foo()) self.assertEqual(CNT, 4) def test_with_9(self): CNT = 0 class CM: async def __aenter__(self): return self async def __aexit__(self, *e): 1/0 async def foo(): nonlocal CNT async with CM(): CNT += 1 with self.assertRaises(ZeroDivisionError): run_async(foo()) self.assertEqual(CNT, 1) def test_with_10(self): CNT = 0 class CM: async def __aenter__(self): return self async def __aexit__(self, *e): 1/0 async def foo(): nonlocal CNT async with CM(): async with CM(): raise RuntimeError try: run_async(foo()) except ZeroDivisionError as exc: self.assertTrue(exc.__context__ is not None) self.assertTrue(isinstance(exc.__context__, ZeroDivisionError)) self.assertTrue(isinstance(exc.__context__.__context__, RuntimeError)) else: self.fail('exception from __aexit__ did not propagate') def test_with_11(self): CNT = 0 class CM: async def __aenter__(self): raise NotImplementedError async def __aexit__(self, *e): 1/0 async def foo(): nonlocal CNT async with CM(): raise RuntimeError try: run_async(foo()) except NotImplementedError as exc: self.assertTrue(exc.__context__ is None) else: self.fail('exception from __aenter__ did not propagate') def test_with_12(self): CNT = 0 class CM: async def __aenter__(self): return self async def __aexit__(self, *e): return True async def foo(): nonlocal CNT async with CM() as cm: self.assertIs(cm.__class__, CM) raise RuntimeError run_async(foo()) def test_with_13(self): CNT = 0 class CM: async def __aenter__(self): 1/0 async def __aexit__(self, *e): return True async def foo(): nonlocal CNT CNT += 1 async with CM(): CNT += 1000 CNT += 10000 with self.assertRaises(ZeroDivisionError): run_async(foo()) self.assertEqual(CNT, 1) def test_for_1(self): aiter_calls = 0 class AsyncIter: def __init__(self): self.i = 0 async def __aiter__(self): nonlocal aiter_calls aiter_calls += 1 return self async def __anext__(self): self.i += 1 if not (self.i % 10): await AsyncYield(self.i * 10) if self.i > 100: raise StopAsyncIteration return self.i, self.i buffer = [] async def test1(): with self.assertWarnsRegex(DeprecationWarning, "legacy"): async for i1, i2 in AsyncIter(): buffer.append(i1 + i2) yielded, _ = run_async(test1()) # Make sure that __aiter__ was called only once self.assertEqual(aiter_calls, 1) self.assertEqual(yielded, [i * 100 for i in range(1, 11)]) self.assertEqual(buffer, [i*2 for i in range(1, 101)]) buffer = [] async def test2(): nonlocal buffer with self.assertWarnsRegex(DeprecationWarning, "legacy"): async for i in AsyncIter(): buffer.append(i[0]) if i[0] == 20: break else: buffer.append('what?') buffer.append('end') yielded, _ = run_async(test2()) # Make sure that __aiter__ was called only once self.assertEqual(aiter_calls, 2) self.assertEqual(yielded, [100, 200]) self.assertEqual(buffer, [i for i in range(1, 21)] + ['end']) buffer = [] async def test3(): nonlocal buffer with self.assertWarnsRegex(DeprecationWarning, "legacy"): async for i in AsyncIter(): if i[0] > 20: continue buffer.append(i[0]) else: buffer.append('what?') buffer.append('end') yielded, _ = run_async(test3()) # Make sure that __aiter__ was called only once self.assertEqual(aiter_calls, 3) self.assertEqual(yielded, [i * 100 for i in range(1, 11)]) self.assertEqual(buffer, [i for i in range(1, 21)] + ['what?', 'end']) def test_for_2(self): tup = (1, 2, 3) refs_before = sys.getrefcount(tup) async def foo(): async for i in tup: print('never going to happen') with self.assertRaisesRegex( TypeError, "async for' requires an object.*__aiter__.*tuple"): run_async(foo()) self.assertEqual(sys.getrefcount(tup), refs_before) def test_for_3(self): class I: def __aiter__(self): return self aiter = I() refs_before = sys.getrefcount(aiter) async def foo(): async for i in aiter: print('never going to happen') with self.assertRaisesRegex( TypeError, r"async for' received an invalid object.*__aiter.*\: I"): run_async(foo()) self.assertEqual(sys.getrefcount(aiter), refs_before) def test_for_4(self): class I: def __aiter__(self): return self def __anext__(self): return () aiter = I() refs_before = sys.getrefcount(aiter) async def foo(): async for i in aiter: print('never going to happen') with self.assertRaisesRegex( TypeError, "async for' received an invalid object.*__anext__.*tuple"): run_async(foo()) self.assertEqual(sys.getrefcount(aiter), refs_before) def test_for_5(self): class I: async def __aiter__(self): return self def __anext__(self): return 123 async def foo(): with self.assertWarnsRegex(DeprecationWarning, "legacy"): async for i in I(): print('never going to happen') with self.assertRaisesRegex( TypeError, "async for' received an invalid object.*__anext.*int"): run_async(foo()) def test_for_6(self): I = 0 class Manager: async def __aenter__(self): nonlocal I I += 10000 async def __aexit__(self, *args): nonlocal I I += 100000 class Iterable: def __init__(self): self.i = 0 def __aiter__(self): return self async def __anext__(self): if self.i > 10: raise StopAsyncIteration self.i += 1 return self.i ############## manager = Manager() iterable = Iterable() mrefs_before = sys.getrefcount(manager) irefs_before = sys.getrefcount(iterable) async def main(): nonlocal I async with manager: async for i in iterable: I += 1 I += 1000 with warnings.catch_warnings(): warnings.simplefilter("error") # Test that __aiter__ that returns an asynchronous iterator # directly does not throw any warnings. run_async(main()) self.assertEqual(I, 111011) self.assertEqual(sys.getrefcount(manager), mrefs_before) self.assertEqual(sys.getrefcount(iterable), irefs_before) ############## async def main(): nonlocal I async with Manager(): async for i in Iterable(): I += 1 I += 1000 async with Manager(): async for i in Iterable(): I += 1 I += 1000 run_async(main()) self.assertEqual(I, 333033) ############## async def main(): nonlocal I async with Manager(): I += 100 async for i in Iterable(): I += 1 else: I += 10000000 I += 1000 async with Manager(): I += 100 async for i in Iterable(): I += 1 else: I += 10000000 I += 1000 run_async(main()) self.assertEqual(I, 20555255) def test_for_7(self): CNT = 0 class AI: async def __aiter__(self): 1/0 async def foo(): nonlocal CNT with self.assertWarnsRegex(DeprecationWarning, "legacy"): async for i in AI(): CNT += 1 CNT += 10 with self.assertRaises(ZeroDivisionError): run_async(foo()) self.assertEqual(CNT, 0) def test_for_8(self): CNT = 0 class AI: def __aiter__(self): 1/0 async def foo(): nonlocal CNT async for i in AI(): CNT += 1 CNT += 10 with self.assertRaises(ZeroDivisionError): with warnings.catch_warnings(): warnings.simplefilter("error") # Test that if __aiter__ raises an exception it propagates # without any kind of warning. run_async(foo()) self.assertEqual(CNT, 0) def test_for_9(self): # Test that DeprecationWarning can safely be converted into # an exception (__aiter__ should not have a chance to raise # a ZeroDivisionError.) class AI: async def __aiter__(self): 1/0 async def foo(): async for i in AI(): pass with self.assertRaises(DeprecationWarning): with warnings.catch_warnings(): warnings.simplefilter("error") run_async(foo()) def test_for_10(self): # Test that DeprecationWarning can safely be converted into # an exception. class AI: async def __aiter__(self): pass async def foo(): async for i in AI(): pass with self.assertRaises(DeprecationWarning): with warnings.catch_warnings(): warnings.simplefilter("error") run_async(foo()) def test_for_11(self): class F: def __aiter__(self): return self def __anext__(self): return self def __await__(self): 1 / 0 async def main(): async for _ in F(): pass with self.assertRaisesRegex(TypeError, 'an invalid object from __anext__') as c: main().send(None) err = c.exception self.assertIsInstance(err.__cause__, ZeroDivisionError) def test_for_12(self): class F: def __aiter__(self): return self def __await__(self): 1 / 0 async def main(): async for _ in F(): pass with self.assertRaisesRegex(TypeError, 'an invalid object from __aiter__') as c: main().send(None) err = c.exception self.assertIsInstance(err.__cause__, ZeroDivisionError) def test_for_tuple(self): class Done(Exception): pass class AIter(tuple): i = 0 def __aiter__(self): return self async def __anext__(self): if self.i >= len(self): raise StopAsyncIteration self.i += 1 return self[self.i - 1] result = [] async def foo(): async for i in AIter([42]): result.append(i) raise Done with self.assertRaises(Done): foo().send(None) self.assertEqual(result, [42]) def test_for_stop_iteration(self): class Done(Exception): pass class AIter(StopIteration): i = 0 def __aiter__(self): return self async def __anext__(self): if self.i: raise StopAsyncIteration self.i += 1 return self.value result = [] async def foo(): async for i in AIter(42): result.append(i) raise Done with self.assertRaises(Done): foo().send(None) self.assertEqual(result, [42]) def test_comp_1(self): async def f(i): return i async def run_list(): return [await c for c in [f(1), f(41)]] async def run_set(): return {await c for c in [f(1), f(41)]} async def run_dict1(): return {await c: 'a' for c in [f(1), f(41)]} async def run_dict2(): return {i: await c for i, c in enumerate([f(1), f(41)])} self.assertEqual(run_async(run_list()), ([], [1, 41])) self.assertEqual(run_async(run_set()), ([], {1, 41})) self.assertEqual(run_async(run_dict1()), ([], {1: 'a', 41: 'a'})) self.assertEqual(run_async(run_dict2()), ([], {0: 1, 1: 41})) def test_comp_2(self): async def f(i): return i async def run_list(): return [s for c in [f(''), f('abc'), f(''), f(['de', 'fg'])] for s in await c] self.assertEqual( run_async(run_list()), ([], ['a', 'b', 'c', 'de', 'fg'])) async def run_set(): return {d for c in [f([f([10, 30]), f([20])])] for s in await c for d in await s} self.assertEqual( run_async(run_set()), ([], {10, 20, 30})) async def run_set2(): return {await s for c in [f([f(10), f(20)])] for s in await c} self.assertEqual( run_async(run_set2()), ([], {10, 20})) def test_comp_3(self): async def f(it): for i in it: yield i async def run_list(): return [i + 1 async for i in f([10, 20])] self.assertEqual( run_async(run_list()), ([], [11, 21])) async def run_set(): return {i + 1 async for i in f([10, 20])} self.assertEqual( run_async(run_set()), ([], {11, 21})) async def run_dict(): return {i + 1: i + 2 async for i in f([10, 20])} self.assertEqual( run_async(run_dict()), ([], {11: 12, 21: 22})) async def run_gen(): gen = (i + 1 async for i in f([10, 20])) return [g + 100 async for g in gen] self.assertEqual( run_async(run_gen()), ([], [111, 121])) def test_comp_4(self): async def f(it): for i in it: yield i async def run_list(): return [i + 1 async for i in f([10, 20]) if i > 10] self.assertEqual( run_async(run_list()), ([], [21])) async def run_set(): return {i + 1 async for i in f([10, 20]) if i > 10} self.assertEqual( run_async(run_set()), ([], {21})) async def run_dict(): return {i + 1: i + 2 async for i in f([10, 20]) if i > 10} self.assertEqual( run_async(run_dict()), ([], {21: 22})) async def run_gen(): gen = (i + 1 async for i in f([10, 20]) if i > 10) return [g + 100 async for g in gen] self.assertEqual( run_async(run_gen()), ([], [121])) def test_comp_4_2(self): async def f(it): for i in it: yield i async def run_list(): return [i + 10 async for i in f(range(5)) if 0 < i < 4] self.assertEqual( run_async(run_list()), ([], [11, 12, 13])) async def run_set(): return {i + 10 async for i in f(range(5)) if 0 < i < 4} self.assertEqual( run_async(run_set()), ([], {11, 12, 13})) async def run_dict(): return {i + 10: i + 100 async for i in f(range(5)) if 0 < i < 4} self.assertEqual( run_async(run_dict()), ([], {11: 101, 12: 102, 13: 103})) async def run_gen(): gen = (i + 10 async for i in f(range(5)) if 0 < i < 4) return [g + 100 async for g in gen] self.assertEqual( run_async(run_gen()), ([], [111, 112, 113])) def test_comp_5(self): async def f(it): for i in it: yield i async def run_list(): return [i + 1 for pair in ([10, 20], [30, 40]) if pair[0] > 10 async for i in f(pair) if i > 30] self.assertEqual( run_async(run_list()), ([], [41])) def test_comp_6(self): async def f(it): for i in it: yield i async def run_list(): return [i + 1 async for seq in f([(10, 20), (30,)]) for i in seq] self.assertEqual( run_async(run_list()), ([], [11, 21, 31])) def test_comp_7(self): async def f(): yield 1 yield 2 raise Exception('aaa') async def run_list(): return [i async for i in f()] with self.assertRaisesRegex(Exception, 'aaa'): run_async(run_list()) def test_comp_8(self): async def f(): return [i for i in [1, 2, 3]] self.assertEqual( run_async(f()), ([], [1, 2, 3])) def test_comp_9(self): async def gen(): yield 1 yield 2 async def f(): l = [i async for i in gen()] return [i for i in l] self.assertEqual( run_async(f()), ([], [1, 2])) def test_comp_10(self): async def f(): xx = {i for i in [1, 2, 3]} return {x: x for x in xx} self.assertEqual( run_async(f()), ([], {1: 1, 2: 2, 3: 3})) def test_copy(self): async def func(): pass coro = func() with self.assertRaises(TypeError): copy.copy(coro) aw = coro.__await__() try: with self.assertRaises(TypeError): copy.copy(aw) finally: aw.close() def test_pickle(self): async def func(): pass coro = func() for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises((TypeError, pickle.PicklingError)): pickle.dumps(coro, proto) aw = coro.__await__() try: for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.assertRaises((TypeError, pickle.PicklingError)): pickle.dumps(aw, proto) finally: aw.close() def test_fatal_coro_warning(self): # Issue 27811 async def func(): pass with warnings.catch_warnings(), support.captured_stderr() as stderr: warnings.filterwarnings("error") func() support.gc_collect() self.assertIn("was never awaited", stderr.getvalue()) class CoroAsyncIOCompatTest(unittest.TestCase): def test_asyncio_1(self): # asyncio cannot be imported when Python is compiled without thread # support asyncio = support.import_module('asyncio') class MyException(Exception): pass buffer = [] class CM: async def __aenter__(self): buffer.append(1) await asyncio.sleep(0.01) buffer.append(2) return self async def __aexit__(self, exc_type, exc_val, exc_tb): await asyncio.sleep(0.01) buffer.append(exc_type.__name__) async def f(): async with CM() as c: await asyncio.sleep(0.01) raise MyException buffer.append('unreachable') loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) try: loop.run_until_complete(f()) except MyException: pass finally: loop.close() asyncio.set_event_loop(None) self.assertEqual(buffer, [1, 2, 'MyException']) class SysSetCoroWrapperTest(unittest.TestCase): def test_set_wrapper_1(self): async def foo(): return 'spam' wrapped = None def wrap(gen): nonlocal wrapped wrapped = gen return gen self.assertIsNone(sys.get_coroutine_wrapper()) sys.set_coroutine_wrapper(wrap) self.assertIs(sys.get_coroutine_wrapper(), wrap) try: f = foo() self.assertTrue(wrapped) self.assertEqual(run_async(f), ([], 'spam')) finally: sys.set_coroutine_wrapper(None) self.assertIsNone(sys.get_coroutine_wrapper()) wrapped = None with silence_coro_gc(): foo() self.assertFalse(wrapped) def test_set_wrapper_2(self): self.assertIsNone(sys.get_coroutine_wrapper()) with self.assertRaisesRegex(TypeError, "callable expected, got int"): sys.set_coroutine_wrapper(1) self.assertIsNone(sys.get_coroutine_wrapper()) def test_set_wrapper_3(self): async def foo(): return 'spam' def wrapper(coro): async def wrap(coro): return await coro return wrap(coro) sys.set_coroutine_wrapper(wrapper) try: with silence_coro_gc(), self.assertRaisesRegex( RuntimeError, r"coroutine wrapper.*\.wrapper at 0x.*attempted to " r"recursively wrap .* wrap .*"): foo() finally: sys.set_coroutine_wrapper(None) def test_set_wrapper_4(self): @types.coroutine def foo(): return 'spam' wrapped = None def wrap(gen): nonlocal wrapped wrapped = gen return gen sys.set_coroutine_wrapper(wrap) try: foo() self.assertIs( wrapped, None, "generator-based coroutine was wrapped via " "sys.set_coroutine_wrapper") finally: sys.set_coroutine_wrapper(None) @support.cpython_only class CAPITest(unittest.TestCase): def test_tp_await_1(self): from _testcapi import awaitType as at async def foo(): future = at(iter([1])) return (await future) self.assertEqual(foo().send(None), 1) def test_tp_await_2(self): # Test tp_await to __await__ mapping from _testcapi import awaitType as at future = at(iter([1])) self.assertEqual(next(future.__await__()), 1) def test_tp_await_3(self): from _testcapi import awaitType as at async def foo(): future = at(1) return (await future) with self.assertRaisesRegex( TypeError, "__await__.*returned non-iterator of type 'int'"): self.assertEqual(foo().send(None), 1) if __name__=="__main__": unittest.main()
59,518
2,233
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_capi.py
# Run the _testcapi module tests (tests for the Python/C API): by defn, # these are all functions _testcapi exports whose name begins with 'test_'. import cosmo import os import pickle import random import re import subprocess import sys import sysconfig import textwrap import time import unittest from test import support from test.support import MISSING_C_DOCSTRINGS from test.support.script_helper import assert_python_failure, assert_python_ok try: import _posixsubprocess except ImportError: _posixsubprocess = None try: import _thread import threading except ImportError: threading = None # Skip this test if the _testcapi module isn't available. _testcapi = support.import_module('_testcapi') # Were we compiled --with-pydebug or with #define Py_DEBUG? Py_DEBUG = hasattr(sys, 'gettotalrefcount') def testfunction(self): """some doc""" return self class InstanceMethod: id = _testcapi.instancemethod(id) testfunction = _testcapi.instancemethod(testfunction) class CAPITest(unittest.TestCase): def test_instancemethod(self): inst = InstanceMethod() self.assertEqual(id(inst), inst.id()) self.assertTrue(inst.testfunction() is inst) self.assertEqual(inst.testfunction.__doc__, testfunction.__doc__) self.assertEqual(InstanceMethod.testfunction.__doc__, testfunction.__doc__) InstanceMethod.testfunction.attribute = "test" self.assertEqual(testfunction.attribute, "test") self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test") @unittest.skipUnless(threading, 'Threading required for this test.') def test_no_FatalError_infinite_loop(self): with support.SuppressCrashReport(): p = subprocess.Popen([sys.executable, "-c", 'import _testcapi;' '_testcapi.crash_no_current_thread()'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() self.assertEqual(out, b'') # This used to cause an infinite loop. self.assertTrue(err.rstrip().startswith( b'Fatal Python error:' b' PyThreadState_Get: no current thread')) def test_memoryview_from_NULL_pointer(self): self.assertRaises(ValueError, _testcapi.make_memoryview_from_NULL_pointer) def test_exc_info(self): raised_exception = ValueError("5") new_exc = TypeError("TEST") try: raise raised_exception except ValueError as e: tb = e.__traceback__ orig_sys_exc_info = sys.exc_info() orig_exc_info = _testcapi.set_exc_info(new_exc.__class__, new_exc, None) new_sys_exc_info = sys.exc_info() new_exc_info = _testcapi.set_exc_info(*orig_exc_info) reset_sys_exc_info = sys.exc_info() self.assertEqual(orig_exc_info[1], e) self.assertSequenceEqual(orig_exc_info, (raised_exception.__class__, raised_exception, tb)) self.assertSequenceEqual(orig_sys_exc_info, orig_exc_info) self.assertSequenceEqual(reset_sys_exc_info, orig_exc_info) self.assertSequenceEqual(new_exc_info, (new_exc.__class__, new_exc, None)) self.assertSequenceEqual(new_sys_exc_info, new_exc_info) else: self.assertTrue(False) @unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.') def test_seq_bytes_to_charp_array(self): # Issue #15732: crash in _PySequence_BytesToCharpArray() class Z(object): def __len__(self): return 1 self.assertRaises(TypeError, _posixsubprocess.fork_exec, 1,Z(),3,(1, 2),5,6,7,8,9,10,11,12,13,14,15,16,17) # Issue #15736: overflow in _PySequence_BytesToCharpArray() class Z(object): def __len__(self): return sys.maxsize def __getitem__(self, i): return b'x' self.assertRaises(MemoryError, _posixsubprocess.fork_exec, 1,Z(),3,(1, 2),5,6,7,8,9,10,11,12,13,14,15,16,17) @unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.') def test_subprocess_fork_exec(self): class Z(object): def __len__(self): return 1 # Issue #15738: crash in subprocess_fork_exec() self.assertRaises(TypeError, _posixsubprocess.fork_exec, Z(),[b'1'],3,(1, 2),5,6,7,8,9,10,11,12,13,14,15,16,17) @unittest.skipIf(MISSING_C_DOCSTRINGS, "Signature information for builtins requires docstrings") def test_docstring_signature_parsing(self): self.assertEqual(_testcapi.no_docstring.__doc__, None) self.assertEqual(_testcapi.no_docstring.__text_signature__, None) self.assertEqual(_testcapi.docstring_empty.__doc__, None) self.assertEqual(_testcapi.docstring_empty.__text_signature__, None) self.assertEqual(_testcapi.docstring_no_signature.__doc__, "This docstring has no signature.") self.assertEqual(_testcapi.docstring_no_signature.__text_signature__, None) self.assertEqual(_testcapi.docstring_with_invalid_signature.__doc__, "docstring_with_invalid_signature($module, /, boo)\n" "\n" "This docstring has an invalid signature." ) self.assertEqual(_testcapi.docstring_with_invalid_signature.__text_signature__, None) self.assertEqual(_testcapi.docstring_with_invalid_signature2.__doc__, "docstring_with_invalid_signature2($module, /, boo)\n" "\n" "--\n" "\n" "This docstring also has an invalid signature." ) self.assertEqual(_testcapi.docstring_with_invalid_signature2.__text_signature__, None) self.assertEqual(_testcapi.docstring_with_signature.__doc__, "This docstring has a valid signature.") self.assertEqual(_testcapi.docstring_with_signature.__text_signature__, "($module, /, sig)") self.assertEqual(_testcapi.docstring_with_signature_but_no_doc.__doc__, None) self.assertEqual(_testcapi.docstring_with_signature_but_no_doc.__text_signature__, "($module, /, sig)") self.assertEqual(_testcapi.docstring_with_signature_and_extra_newlines.__doc__, "\nThis docstring has a valid signature and some extra newlines.") self.assertEqual(_testcapi.docstring_with_signature_and_extra_newlines.__text_signature__, "($module, /, parameter)") def test_c_type_with_matrix_multiplication(self): M = _testcapi.matmulType m1 = M() m2 = M() self.assertEqual(m1 @ m2, ("matmul", m1, m2)) self.assertEqual(m1 @ 42, ("matmul", m1, 42)) self.assertEqual(42 @ m1, ("matmul", 42, m1)) o = m1 o @= m2 self.assertEqual(o, ("imatmul", m1, m2)) o = m1 o @= 42 self.assertEqual(o, ("imatmul", m1, 42)) o = 42 o @= m1 self.assertEqual(o, ("matmul", 42, m1)) @unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion check") def test_return_null_without_error(self): # Issue #23571: A function must not return NULL without setting an # error if Py_DEBUG: code = textwrap.dedent(""" import _testcapi from test import support with support.SuppressCrashReport(): _testcapi.return_null_without_error() """) rc, out, err = assert_python_failure('-c', code) self.assertRegex(err.replace(b'\r', b''), br'Fatal Python error: a function returned NULL ' br'without setting an error\n' br'SystemError: <built-in function ' br'return_null_without_error> returned NULL ' br'without setting an error\n' br'\n' br'Current thread.*:\n' br' File .*", line 6 in <module>') else: with self.assertRaises(SystemError) as cm: _testcapi.return_null_without_error() self.assertRegex(str(cm.exception), 'return_null_without_error.* ' 'returned NULL without setting an error') @unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion check") def test_return_result_with_error(self): # Issue #23571: A function must not return a result with an error set if Py_DEBUG: code = textwrap.dedent(""" import _testcapi from test import support with support.SuppressCrashReport(): _testcapi.return_result_with_error() """) rc, out, err = assert_python_failure('-c', code) self.assertRegex(err.replace(b'\r', b''), br'Fatal Python error: a function returned a ' br'result with an error set\n' br'ValueError\n' br'\n' br'The above exception was the direct cause ' br'of the following exception:\n' br'\n' br'SystemError: <built-in ' br'function return_result_with_error> ' br'returned a result with an error set\n' br'\n' br'Current thread.*:\n' br' File .*, line 6 in <module>') else: with self.assertRaises(SystemError) as cm: _testcapi.return_result_with_error() self.assertRegex(str(cm.exception), 'return_result_with_error.* ' 'returned a result with an error set') def test_buildvalue_N(self): _testcapi.test_buildvalue_N() @unittest.skipUnless(cosmo.MODE == "dbg", "disabled memory hooks") def test_set_nomemory(self): code = """if 1: import _testcapi class C(): pass # The first loop tests both functions and that remove_mem_hooks() # can be called twice in a row. The second loop checks a call to # set_nomemory() after a call to remove_mem_hooks(). The third # loop checks the start and stop arguments of set_nomemory(). for outer_cnt in range(1, 4): start = 10 * outer_cnt for j in range(100): if j == 0: if outer_cnt != 3: _testcapi.set_nomemory(start) else: _testcapi.set_nomemory(start, start + 1) try: C() except MemoryError as e: if outer_cnt != 3: _testcapi.remove_mem_hooks() print('MemoryError', outer_cnt, j) _testcapi.remove_mem_hooks() break """ rc, out, err = assert_python_ok('-c', code) self.assertIn(b'MemoryError 1 10', out) self.assertIn(b'MemoryError 2 20', out) self.assertIn(b'MemoryError 3 30', out) @unittest.skipUnless(threading, 'Threading required for this test.') class TestPendingCalls(unittest.TestCase): def pendingcalls_submit(self, l, n): def callback(): #this function can be interrupted by thread switching so let's #use an atomic operation l.append(None) for i in range(n): time.sleep(random.random()*0.02) #0.01 secs on average #try submitting callback until successful. #rely on regular interrupt to flush queue if we are #unsuccessful. while True: if _testcapi._pending_threadfunc(callback): break; def pendingcalls_wait(self, l, n, context = None): #now, stick around until l[0] has grown to 10 count = 0; while len(l) != n: #this busy loop is where we expect to be interrupted to #run our callbacks. Note that callbacks are only run on the #main thread if False and support.verbose: print("(%i)"%(len(l),),) for i in range(1000): a = i*i if context and not context.event.is_set(): continue count += 1 self.assertTrue(count < 10000, "timeout waiting for %i callbacks, got %i"%(n, len(l))) if False and support.verbose: print("(%i)"%(len(l),)) def test_pendingcalls_threaded(self): #do every callback on a separate thread n = 32 #total callbacks threads = [] class foo(object):pass context = foo() context.l = [] context.n = 2 #submits per thread context.nThreads = n // context.n context.nFinished = 0 context.lock = threading.Lock() context.event = threading.Event() threads = [threading.Thread(target=self.pendingcalls_thread, args=(context,)) for i in range(context.nThreads)] with support.start_threads(threads): self.pendingcalls_wait(context.l, n, context) def pendingcalls_thread(self, context): try: self.pendingcalls_submit(context.l, context.n) finally: with context.lock: context.nFinished += 1 nFinished = context.nFinished if False and support.verbose: print("finished threads: ", nFinished) if nFinished == context.nThreads: context.event.set() def test_pendingcalls_non_threaded(self): #again, just using the main thread, likely they will all be dispatched at #once. It is ok to ask for too many, because we loop until we find a slot. #the loop can be interrupted to dispatch. #there are only 32 dispatch slots, so we go for twice that! l = [] n = 64 self.pendingcalls_submit(l, n) self.pendingcalls_wait(l, n) class SubinterpreterTest(unittest.TestCase): def test_subinterps(self): import builtins r, w = os.pipe() code = """if 1: import sys, builtins, pickle with open({:d}, "wb") as f: pickle.dump(id(sys.modules), f) pickle.dump(id(builtins), f) """.format(w) with open(r, "rb") as f: ret = support.run_in_subinterp(code) self.assertEqual(ret, 0) self.assertNotEqual(pickle.load(f), id(sys.modules)) self.assertNotEqual(pickle.load(f), id(builtins)) class EmbeddingTests(unittest.TestCase): def setUp(self): here = os.path.abspath(__file__) basepath = os.path.dirname(os.path.dirname(os.path.dirname(here))) exename = "_testembed" if sys.platform.startswith("win"): ext = ("_d" if "_d" in sys.executable else "") + ".exe" exename += ext exepath = os.path.dirname(sys.executable) else: exepath = os.path.join(basepath, "Programs") self.test_exe = exe = os.path.join(exepath, exename) if not os.path.exists(exe): self.skipTest("%r doesn't exist" % exe) # This is needed otherwise we get a fatal error: # "Py_Initialize: Unable to get the locale encoding # LookupError: no codec search functions registered: can't find encoding" self.oldcwd = os.getcwd() os.chdir(basepath) def tearDown(self): os.chdir(self.oldcwd) def run_embedded_interpreter(self, *args, env=None): """Runs a test in the embedded interpreter""" cmd = [self.test_exe] cmd.extend(args) if env is not None and sys.platform == 'win32': # Windows requires at least the SYSTEMROOT environment variable to # start Python. env = env.copy() env['SYSTEMROOT'] = os.environ['SYSTEMROOT'] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, env=env) (out, err) = p.communicate() self.assertEqual(p.returncode, 0, "bad returncode %d, stderr is %r" % (p.returncode, err)) return out, err def test_repeated_init_and_subinterpreters(self): # This is just a "don't crash" test out, err = self.run_embedded_interpreter('repeated_init_and_subinterpreters') if support.verbose: print() print(out) print(err) def test_forced_io_encoding(self): # Checks forced configuration of embedded interpreter IO streams env = dict(os.environ, PYTHONIOENCODING="utf-8:surrogateescape") out, err = self.run_embedded_interpreter("forced_io_encoding", env=env) if support.verbose: print() print(out) print(err) expected_stream_encoding = "utf-8" expected_errors = "surrogateescape" expected_output = '\n'.join([ "--- Use defaults ---", "Expected encoding: default", "Expected errors: default", "stdin: {in_encoding}:{errors}", "stdout: {out_encoding}:{errors}", "stderr: {out_encoding}:backslashreplace", "--- Set errors only ---", "Expected encoding: default", "Expected errors: ignore", "stdin: {in_encoding}:ignore", "stdout: {out_encoding}:ignore", "stderr: {out_encoding}:backslashreplace", "--- Set encoding only ---", "Expected encoding: latin-1", "Expected errors: default", "stdin: latin-1:{errors}", "stdout: latin-1:{errors}", "stderr: latin-1:backslashreplace", "--- Set encoding and errors ---", "Expected encoding: latin-1", "Expected errors: replace", "stdin: latin-1:replace", "stdout: latin-1:replace", "stderr: latin-1:backslashreplace"]) expected_output = expected_output.format( in_encoding=expected_stream_encoding, out_encoding=expected_stream_encoding, errors=expected_errors) # This is useful if we ever trip over odd platform behaviour self.maxDiff = None self.assertEqual(out.strip(), expected_output) def test_pre_initialization_api(self): """ Checks the few parts of the C-API that work before the runtine is initialized (via Py_Initialize()). """ env = dict(os.environ, PYTHONPATH=os.pathsep.join(sys.path)) out, err = self.run_embedded_interpreter("pre_initialization_api", env=env) self.assertEqual(out, '') self.assertEqual(err, '') @unittest.skipUnless(threading, 'Threading required for this test.') class TestThreadState(unittest.TestCase): @support.reap_threads def test_thread_state(self): # some extra thread-state tests driven via _testcapi def target(): idents = [] def callback(): idents.append(threading.get_ident()) _testcapi._test_thread_state(callback) a = b = callback time.sleep(1) # Check our main thread is in the list exactly 3 times. self.assertEqual(idents.count(threading.get_ident()), 3, "Couldn't find main thread correctly in the list") target() t = threading.Thread(target=target) t.start() t.join() class Test_testcapi(unittest.TestCase): locals().update((name, getattr(_testcapi, name)) for name in dir(_testcapi) if name.startswith('test_') and not name.endswith('_code')) @unittest.skipUnless(cosmo.MODE == "dbg", "disabled memory debugging") class PyMemDebugTests(unittest.TestCase): PYTHONMALLOC = 'debug' # '0x04c06e0' or '04C06E0' PTR_REGEX = r'(?:0x)?[0-9a-fA-F]+' def check(self, code): with support.SuppressCrashReport(): out = assert_python_failure('-c', code, PYTHONMALLOC=self.PYTHONMALLOC) stderr = out.err return stderr.decode('ascii', 'replace') def test_buffer_overflow(self): out = self.check('import _testcapi; _testcapi.pymem_buffer_overflow()') regex = (r"Debug memory block at address p={ptr}: API 'm'\n" r" 16 bytes originally requested\n" r" The [0-9] pad bytes at p-[0-9] are FORBIDDENBYTE, as expected.\n" r" The [0-9] pad bytes at tail={ptr} are not all FORBIDDENBYTE \(0x[0-9a-f]{{2}}\):\n" r" at tail\+0: 0x78 \*\*\* OUCH\n" r" at tail\+1: 0xfb\n" r" at tail\+2: 0xfb\n" r" .*\n" r" The block was made by call #[0-9]+ to debug malloc/realloc.\n" r" Data at p: cb cb cb .*\n" r"\n" r"Enable tracemalloc to get the memory block allocation traceback\n" r"\n" r"Fatal Python error: bad trailing pad byte") regex = regex.format(ptr=self.PTR_REGEX) regex = re.compile(regex, flags=re.DOTALL) self.assertRegex(out, regex) def test_api_misuse(self): out = self.check('import _testcapi; _testcapi.pymem_api_misuse()') regex = (r"Debug memory block at address p={ptr}: API 'm'\n" r" 16 bytes originally requested\n" r" The [0-9] pad bytes at p-[0-9] are FORBIDDENBYTE, as expected.\n" r" The [0-9] pad bytes at tail={ptr} are FORBIDDENBYTE, as expected.\n" r" The block was made by call #[0-9]+ to debug malloc/realloc.\n" r" Data at p: cb cb cb .*\n" r"\n" r"Enable tracemalloc to get the memory block allocation traceback\n" r"\n" r"Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r'\n") regex = regex.format(ptr=self.PTR_REGEX) self.assertRegex(out, regex) @unittest.skipUnless(threading, 'Test requires a GIL (multithreading)') def check_malloc_without_gil(self, code): out = self.check(code) expected = ('Fatal Python error: Python memory allocator called ' 'without holding the GIL') self.assertIn(expected, out) def test_pymem_malloc_without_gil(self): # Debug hooks must raise an error if PyMem_Malloc() is called # without holding the GIL code = 'import _testcapi; _testcapi.pymem_malloc_without_gil()' self.check_malloc_without_gil(code) def test_pyobject_malloc_without_gil(self): # Debug hooks must raise an error if PyObject_Malloc() is called # without holding the GIL code = 'import _testcapi; _testcapi.pyobject_malloc_without_gil()' self.check_malloc_without_gil(code) class PyMemMallocDebugTests(PyMemDebugTests): PYTHONMALLOC = 'malloc_debug' @unittest.skipUnless(sysconfig.get_config_var('WITH_PYMALLOC') == 1, 'need pymalloc') class PyMemPymallocDebugTests(PyMemDebugTests): PYTHONMALLOC = 'pymalloc_debug' @unittest.skipUnless(Py_DEBUG, 'need Py_DEBUG') class PyMemDefaultTests(PyMemDebugTests): # test default allocator of Python compiled in debug mode PYTHONMALLOC = '' if __name__ == "__main__": unittest.main()
24,459
603
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_ttk_guionly.py
import unittest from test import support # Skip this test if _tkinter wasn't built. support.import_module('_tkinter') # Skip test if tk cannot be initialized. support.requires('gui') import tkinter from _tkinter import TclError from tkinter import ttk from tkinter.test import runtktests root = None try: root = tkinter.Tk() button = ttk.Button(root) button.destroy() del button except TclError as msg: # assuming ttk is not available raise unittest.SkipTest("ttk not available: %s" % msg) finally: if root is not None: root.destroy() del root def test_main(): support.run_unittest( *runtktests.get_tests(text=False, packages=['test_ttk'])) if __name__ == '__main__': test_main()
746
35
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_signal.py
import unittest from test import support from contextlib import closing import enum import gc import os import pickle import random import select import signal import socket import statistics import subprocess import traceback import cosmo import sys, os, time, errno from test.support.script_helper import assert_python_ok, spawn_python try: import _thread import threading except ImportError: threading = None try: import _testcapi except ImportError: _testcapi = None class GenericTests(unittest.TestCase): @unittest.skipIf(threading is None, "test needs threading module") def test_enums(self): for name in dir(signal): sig = getattr(signal, name) if name in {'SIG_DFL', 'SIG_IGN'}: self.assertIsInstance(sig, signal.Handlers) elif name in {'SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK'}: self.assertIsInstance(sig, signal.Sigmasks) elif name.startswith('SIG') and not name.startswith('SIG_'): self.assertIsInstance(sig, signal.Signals) elif name.startswith('CTRL_'): self.assertIsInstance(sig, signal.Signals) self.assertEqual(sys.platform, "win32") @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class PosixTests(unittest.TestCase): def trivial_signal_handler(self, *args): pass def test_out_of_range_signal_number_raises_error(self): self.assertRaises(ValueError, signal.getsignal, 4242) self.assertRaises(ValueError, signal.signal, 4242, self.trivial_signal_handler) def test_setting_signal_handler_to_none_raises_error(self): self.assertRaises(TypeError, signal.signal, signal.SIGUSR1, None) def test_getsignal(self): hup = signal.signal(signal.SIGHUP, self.trivial_signal_handler) self.assertIsInstance(hup, signal.Handlers) self.assertEqual(signal.getsignal(signal.SIGHUP), self.trivial_signal_handler) signal.signal(signal.SIGHUP, hup) self.assertEqual(signal.getsignal(signal.SIGHUP), hup) # Issue 3864, unknown if this affects earlier versions of freebsd also @unittest.skipIf(sys.platform=='freebsd6', 'inter process signals not reliable (do not mix well with threading) ' 'on freebsd6') def test_interprocess_signal(self): dirname = os.path.dirname(__file__) script = os.path.join(dirname, 'signalinterproctester.pyc') assert_python_ok(script) @unittest.skipUnless(sys.platform == "win32", "Windows specific") class WindowsSignalTests(unittest.TestCase): def test_issue9324(self): # Updated for issue #10003, adding SIGBREAK handler = lambda x, y: None checked = set() for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE, signal.SIGILL, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM): # Set and then reset a handler for signals that work on windows. # Issue #18396, only for signals without a C-level handler. if signal.getsignal(sig) is not None: signal.signal(sig, signal.signal(sig, handler)) checked.add(sig) # Issue #18396: Ensure the above loop at least tested *something* self.assertTrue(checked) with self.assertRaises(ValueError): signal.signal(-1, handler) with self.assertRaises(ValueError): signal.signal(7, handler) class WakeupFDTests(unittest.TestCase): def test_invalid_fd(self): fd = support.make_bad_fd() self.assertRaises((ValueError, OSError), signal.set_wakeup_fd, fd) def test_invalid_socket(self): sock = socket.socket() fd = sock.fileno() sock.close() self.assertRaises((ValueError, OSError), signal.set_wakeup_fd, fd) def test_set_wakeup_fd_result(self): r1, w1 = os.pipe() self.addCleanup(os.close, r1) self.addCleanup(os.close, w1) r2, w2 = os.pipe() self.addCleanup(os.close, r2) self.addCleanup(os.close, w2) if hasattr(os, 'set_blocking'): os.set_blocking(w1, False) os.set_blocking(w2, False) signal.set_wakeup_fd(w1) self.assertEqual(signal.set_wakeup_fd(w2), w1) self.assertEqual(signal.set_wakeup_fd(-1), w2) self.assertEqual(signal.set_wakeup_fd(-1), -1) def test_set_wakeup_fd_socket_result(self): sock1 = socket.socket() self.addCleanup(sock1.close) sock1.setblocking(False) fd1 = sock1.fileno() sock2 = socket.socket() self.addCleanup(sock2.close) sock2.setblocking(False) fd2 = sock2.fileno() signal.set_wakeup_fd(fd1) self.assertEqual(signal.set_wakeup_fd(fd2), fd1) self.assertEqual(signal.set_wakeup_fd(-1), fd2) self.assertEqual(signal.set_wakeup_fd(-1), -1) # On Windows, files are always blocking and Windows does not provide a # function to test if a socket is in non-blocking mode. @unittest.skipIf(sys.platform == "win32", "tests specific to POSIX") def test_set_wakeup_fd_blocking(self): rfd, wfd = os.pipe() self.addCleanup(os.close, rfd) self.addCleanup(os.close, wfd) # fd must be non-blocking os.set_blocking(wfd, True) with self.assertRaises(ValueError) as cm: signal.set_wakeup_fd(wfd) self.assertEqual(str(cm.exception), "the fd %s must be in non-blocking mode" % wfd) # non-blocking is ok os.set_blocking(wfd, False) signal.set_wakeup_fd(wfd) signal.set_wakeup_fd(-1) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): @unittest.skipIf(_testcapi is None, 'need _testcapi') def check_wakeup(self, test_body, *signals, ordered=True): # use a subprocess to have only one thread code = """if 1: import _testcapi import os import signal import struct signals = {!r} def handler(signum, frame): pass def check_signum(signals): data = os.read(read, len(signals)+1) raised = struct.unpack('%uB' % len(data), data) if not {!r}: raised = set(raised) signals = set(signals) if raised != signals: raise Exception("%r != %r" % (raised, signals)) {} signal.signal(signal.SIGALRM, handler) read, write = os.pipe() os.set_blocking(write, False) signal.set_wakeup_fd(write) test() check_signum(signals) os.close(read) os.close(write) """.format(tuple(map(int, signals)), ordered, test_body) assert_python_ok('-c', code) @unittest.skipIf(_testcapi is None, 'need _testcapi') def test_wakeup_write_error(self): # Issue #16105: write() errors in the C signal handler should not # pass silently. # Use a subprocess to have only one thread. code = """if 1: import _testcapi import errno import os import signal import sys from test.support import captured_stderr def handler(signum, frame): 1/0 signal.signal(signal.SIGALRM, handler) r, w = os.pipe() os.set_blocking(r, False) # Set wakeup_fd a read-only file descriptor to trigger the error signal.set_wakeup_fd(r) try: with captured_stderr() as err: _testcapi.raise_signal(signal.SIGALRM) except ZeroDivisionError: # An ignored exception should have been printed out on stderr err = err.getvalue() if ('Exception ignored when trying to write to the signal wakeup fd' not in err): raise AssertionError(err) if ('OSError: [Errno %d]' % errno.EBADF) not in err: raise AssertionError(err) else: raise AssertionError("ZeroDivisionError not raised") os.close(r) os.close(w) """ r, w = os.pipe() try: os.write(r, b'x') except OSError: pass else: self.skipTest("OS doesn't report write() error on the read end of a pipe") finally: os.close(r) os.close(w) assert_python_ok('-c', code) def test_wakeup_fd_early(self): self.check_wakeup("""def test(): import select import time TIMEOUT_FULL = 10 TIMEOUT_HALF = 5 class InterruptSelect(Exception): pass def handler(signum, frame): raise InterruptSelect signal.signal(signal.SIGALRM, handler) # signal.alarm(1) signal.setitimer(signal.ITIMER_REAL, 0.001) # We attempt to get a signal during the sleep, # before select is called try: select.select([], [], [], TIMEOUT_FULL) except InterruptSelect: pass else: raise Exception("select() was not interrupted") before_time = time.monotonic() select.select([read], [], [], TIMEOUT_FULL) after_time = time.monotonic() dt = after_time - before_time if dt >= TIMEOUT_HALF: raise Exception("%s >= %s" % (dt, TIMEOUT_HALF)) """, signal.SIGALRM) def test_wakeup_fd_during(self): self.check_wakeup("""def test(): import select import time TIMEOUT_FULL = 10 TIMEOUT_HALF = 5 class InterruptSelect(Exception): pass def handler(signum, frame): raise InterruptSelect signal.signal(signal.SIGALRM, handler) # signal.alarm(1) signal.setitimer(signal.ITIMER_REAL, 0.001) before_time = time.monotonic() # We attempt to get a signal during the select call try: select.select([read], [], [], TIMEOUT_FULL) except InterruptSelect: pass else: raise Exception("select() was not interrupted") after_time = time.monotonic() dt = after_time - before_time if dt >= TIMEOUT_HALF: raise Exception("%s >= %s" % (dt, TIMEOUT_HALF)) """, signal.SIGALRM) def test_signum(self): self.check_wakeup("""def test(): import _testcapi signal.signal(signal.SIGUSR1, handler) _testcapi.raise_signal(signal.SIGUSR1) _testcapi.raise_signal(signal.SIGALRM) """, signal.SIGUSR1, signal.SIGALRM) @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()') def test_pending(self): self.check_wakeup("""def test(): signum1 = signal.SIGUSR1 signum2 = signal.SIGUSR2 signal.signal(signum1, handler) signal.signal(signum2, handler) signal.pthread_sigmask(signal.SIG_BLOCK, (signum1, signum2)) _testcapi.raise_signal(signum1) _testcapi.raise_signal(signum2) # Unblocking the 2 signals calls the C signal handler twice signal.pthread_sigmask(signal.SIG_UNBLOCK, (signum1, signum2)) """, signal.SIGUSR1, signal.SIGUSR2, ordered=False) @unittest.skipUnless(hasattr(socket, 'socketpair'), 'need socket.socketpair') class WakeupSocketSignalTests(unittest.TestCase): @unittest.skipIf(_testcapi is None, 'need _testcapi') def test_socket(self): # use a subprocess to have only one thread code = """if 1: import signal import socket import struct import _testcapi signum = signal.SIGINT signals = (signum,) def handler(signum, frame): pass signal.signal(signum, handler) read, write = socket.socketpair() write.setblocking(False) signal.set_wakeup_fd(write.fileno()) _testcapi.raise_signal(signum) data = read.recv(1) if not data: raise Exception("no signum written") raised = struct.unpack('B', data) if raised != signals: raise Exception("%r != %r" % (raised, signals)) read.close() write.close() """ assert_python_ok('-c', code) @unittest.skipIf(_testcapi is None, 'need _testcapi') def test_send_error(self): # Use a subprocess to have only one thread. if os.name == 'nt': action = 'send' else: action = 'write' code = """if 1: import errno import signal import socket import sys import time import _testcapi from test.support import captured_stderr signum = signal.SIGINT def handler(signum, frame): pass signal.signal(signum, handler) read, write = socket.socketpair() read.setblocking(False) write.setblocking(False) signal.set_wakeup_fd(write.fileno()) # Close sockets: send() will fail read.close() write.close() with captured_stderr() as err: _testcapi.raise_signal(signum) err = err.getvalue() if ('Exception ignored when trying to {action} to the signal wakeup fd' not in err): raise AssertionError(err) """.format(action=action) assert_python_ok('-c', code) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class SiginterruptTest(unittest.TestCase): def readpipe_interrupted(self, interrupt): """Perform a read during which a signal will arrive. Return True if the read is interrupted by the signal and raises an exception. Return False if it returns normally. """ # use a subprocess to have only one thread, to have a timeout on the # blocking read and to not touch signal handling in this process code = """if 1: import errno import os import signal import sys interrupt = %r r, w = os.pipe() def handler(signum, frame): 1 / 0 signal.signal(signal.SIGALRM, handler) if interrupt is not None: signal.siginterrupt(signal.SIGALRM, interrupt) print("ready") sys.stdout.flush() # run the test twice try: for loop in range(2): # send a SIGALRM in a second (during the read) # signal.alarm(1) signal.setitimer(signal.ITIMER_REAL, 0.001) try: # blocking call: read from a pipe without data os.read(r, 1) except ZeroDivisionError: pass else: sys.exit(2) sys.exit(3) finally: os.close(r) os.close(w) """ % (interrupt,) with spawn_python('-c', code) as process: try: # wait until the child process is loaded and has started first_line = process.stdout.readline() stdout, stderr = process.communicate(timeout=5.0) except subprocess.TimeoutExpired: process.kill() return False else: stdout = first_line + stdout exitcode = process.wait() if exitcode not in (2, 3): raise Exception("Child error (exit code %s): %r" % (exitcode, stdout)) return (exitcode == 3) def test_without_siginterrupt(self): # If a signal handler is installed and siginterrupt is not called # at all, when that signal arrives, it interrupts a syscall that's in # progress. interrupted = self.readpipe_interrupted(None) self.assertTrue(interrupted) def test_siginterrupt_on(self): # If a signal handler is installed and siginterrupt is called with # a true value for the second argument, when that signal arrives, it # interrupts a syscall that's in progress. interrupted = self.readpipe_interrupted(True) self.assertTrue(interrupted) # [jart]: lool a test that takes 5 seconds by design # def test_siginterrupt_off(self): # # If a signal handler is installed and siginterrupt is called with # # a false value for the second argument, when that signal arrives, it # # does not interrupt a syscall that's in progress. # interrupted = self.readpipe_interrupted(False) # self.assertFalse(interrupted) @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class ItimerTest(unittest.TestCase): def setUp(self): self.hndl_called = False self.hndl_count = 0 self.itimer = None self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm) def tearDown(self): signal.signal(signal.SIGALRM, self.old_alarm) if self.itimer is not None: # test_itimer_exc doesn't change this attr # just ensure that itimer is stopped signal.setitimer(self.itimer, 0) def sig_alrm(self, *args): self.hndl_called = True def sig_vtalrm(self, *args): self.hndl_called = True if self.hndl_count > 3: # it shouldn't be here, because it should have been disabled. raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL " "timer.") elif self.hndl_count == 3: # disable ITIMER_VIRTUAL, this function shouldn't be called anymore signal.setitimer(signal.ITIMER_VIRTUAL, 0) self.hndl_count += 1 def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) def test_itimer_exc(self): # XXX I'm assuming -1 is an invalid itimer, but maybe some platform # defines it ? self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0) # Negative times are treated as zero on some platforms. if 0: self.assertRaises(signal.ItimerError, signal.setitimer, signal.ITIMER_REAL, -1) def test_itimer_real(self): self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 0.01) signal.pause() self.assertEqual(self.hndl_called, True) # Issue 3864, unknown if this affects earlier versions of freebsd also @unittest.skipIf(sys.platform in ('freebsd6', 'netbsd5'), 'itimer not reliable (does not mix well with threading) on some BSDs.') def test_itimer_virtual(self): self.itimer = signal.ITIMER_VIRTUAL signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) start_time = time.monotonic() while time.monotonic() - start_time < 60.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # virtual itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) # Issue 3864, unknown if this affects earlier versions of freebsd also @unittest.skipIf(sys.platform=='freebsd6', 'itimer not reliable (does not mix well with threading) on freebsd6') def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.1, 0.1) start_time = time.monotonic() while time.monotonic() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True) def test_setitimer_tiny(self): # bpo-30807: C setitimer() takes a microsecond-resolution interval. # Check that float -> timeval conversion doesn't round # the interval down to zero, which would disable the timer. self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 1e-6) time.sleep(.11) self.assertEqual(self.hndl_called, True) class PendingSignalsTests(unittest.TestCase): """ Test pthread_sigmask(), pthread_kill(), sigpending() and sigwait() functions. """ @unittest.skipUnless(hasattr(signal, 'sigpending'), 'need signal.sigpending()') def test_sigpending_empty(self): self.assertEqual(signal.sigpending(), set()) @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()') @unittest.skipUnless(hasattr(signal, 'sigpending'), 'need signal.sigpending()') def test_sigpending(self): code = """if 1: import os import signal def handler(signum, frame): 1/0 signum = signal.SIGUSR1 signal.signal(signum, handler) signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) os.kill(os.getpid(), signum) pending = signal.sigpending() for sig in pending: assert isinstance(sig, signal.Signals), repr(pending) if pending != {signum}: raise Exception('%s != {%s}' % (pending, signum)) try: signal.pthread_sigmask(signal.SIG_UNBLOCK, [signum]) except ZeroDivisionError: pass else: raise Exception("ZeroDivisionError not raised") """ assert_python_ok('-c', code) @unittest.skipUnless(hasattr(signal, 'pthread_kill'), 'need signal.pthread_kill()') def test_pthread_kill(self): code = """if 1: import signal import threading import sys signum = signal.SIGUSR1 def handler(signum, frame): 1/0 signal.signal(signum, handler) if sys.platform == 'freebsd6': # Issue #12392 and #12469: send a signal to the main thread # doesn't work before the creation of the first thread on # FreeBSD 6 def noop(): pass thread = threading.Thread(target=noop) thread.start() thread.join() tid = threading.get_ident() try: signal.pthread_kill(tid, signum) except ZeroDivisionError: pass else: raise Exception("ZeroDivisionError not raised") """ assert_python_ok('-c', code) @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()') def wait_helper(self, blocked, test): """ test: body of the "def test(signum):" function. blocked: number of the blocked signal """ code = '''if 1: import signal import sys from signal import Signals def handler(signum, frame): 1/0 %s blocked = %s signum = signal.SIGALRM # child: block and wait the signal try: signal.signal(signum, handler) signal.pthread_sigmask(signal.SIG_BLOCK, [blocked]) # Do the tests test(signum) # The handler must not be called on unblock try: signal.pthread_sigmask(signal.SIG_UNBLOCK, [blocked]) except ZeroDivisionError: print("the signal handler has been called", file=sys.stderr) sys.exit(1) except BaseException as err: print("error: {}".format(err), file=sys.stderr) sys.stderr.flush() sys.exit(1) ''' % (test.strip(), blocked) # sig*wait* must be called with the signal blocked: since the current # process might have several threads running, use a subprocess to have # a single thread. assert_python_ok('-c', code) @unittest.skipUnless(hasattr(signal, 'sigwait'), 'need signal.sigwait()') def test_sigwait(self): self.wait_helper(signal.SIGALRM, ''' def test(signum): # signal.alarm(1) signal.setitimer(signal.ITIMER_REAL, 0.001) received = signal.sigwait([signum]) assert isinstance(received, signal.Signals), received if received != signum: raise Exception('received %s, not %s' % (received, signum)) ''') @unittest.skipUnless(hasattr(signal, 'sigwaitinfo'), 'need signal.sigwaitinfo()') def test_sigwaitinfo(self): self.wait_helper(signal.SIGALRM, ''' def test(signum): # signal.alarm(1) signal.setitimer(signal.ITIMER_REAL, 0.001) info = signal.sigwaitinfo([signum]) if info.si_signo != signum: raise Exception("info.si_signo != %s" % signum) ''') @unittest.skipUnless(hasattr(signal, 'sigtimedwait'), 'need signal.sigtimedwait()') def test_sigtimedwait(self): self.wait_helper(signal.SIGALRM, ''' def test(signum): # signal.alarm(1) signal.setitimer(signal.ITIMER_REAL, 0.001) info = signal.sigtimedwait([signum], 10.1000) if info.si_signo != signum: raise Exception('info.si_signo != %s' % signum) ''') @unittest.skipUnless(hasattr(signal, 'sigtimedwait'), 'need signal.sigtimedwait()') def test_sigtimedwait_poll(self): # check that polling with sigtimedwait works self.wait_helper(signal.SIGALRM, ''' def test(signum): import os os.kill(os.getpid(), signum) info = signal.sigtimedwait([signum], 0) if info.si_signo != signum: raise Exception('info.si_signo != %s' % signum) ''') @unittest.skipUnless(hasattr(signal, 'sigtimedwait'), 'need signal.sigtimedwait()') def test_sigtimedwait_timeout(self): self.wait_helper(signal.SIGALRM, ''' def test(signum): received = signal.sigtimedwait([signum], 1.0) if received is not None: raise Exception("received=%r" % (received,)) ''') @unittest.skipUnless(hasattr(signal, 'sigtimedwait'), 'need signal.sigtimedwait()') def test_sigtimedwait_negative_timeout(self): signum = signal.SIGALRM self.assertRaises(ValueError, signal.sigtimedwait, [signum], -1.0) @unittest.skipUnless(hasattr(signal, 'sigwait'), 'need signal.sigwait()') @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()') @unittest.skipIf(threading is None, "test needs threading module") def test_sigwait_thread(self): # Check that calling sigwait() from a thread doesn't suspend the whole # process. A new interpreter is spawned to avoid problems when mixing # threads and fork(): only async-safe functions are allowed between # fork() and exec(). assert_python_ok("-c", """if True: import os, threading, sys, time, signal # the default handler terminates the process signum = signal.SIGUSR1 def kill_later(): # wait until the main thread is waiting in sigwait() time.sleep(1) os.kill(os.getpid(), signum) # the signal must be blocked by all the threads signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) killer = threading.Thread(target=kill_later) killer.start() received = signal.sigwait([signum]) if received != signum: print("sigwait() received %s, not %s" % (received, signum), file=sys.stderr) sys.exit(1) killer.join() # unblock the signal, which should have been cleared by sigwait() signal.pthread_sigmask(signal.SIG_UNBLOCK, [signum]) """) @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()') def test_pthread_sigmask_arguments(self): self.assertRaises(TypeError, signal.pthread_sigmask) self.assertRaises(TypeError, signal.pthread_sigmask, 1) self.assertRaises(TypeError, signal.pthread_sigmask, 1, 2, 3) self.assertRaises(OSError, signal.pthread_sigmask, 1700, []) @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()') def test_pthread_sigmask(self): code = """if 1: import signal import os; import threading def handler(signum, frame): 1/0 def kill(signum): os.kill(os.getpid(), signum) def check_mask(mask): for sig in mask: assert isinstance(sig, signal.Signals), repr(sig) def read_sigmask(): sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, []) check_mask(sigmask) return sigmask signum = signal.SIGUSR1 # Install our signal handler old_handler = signal.signal(signum, handler) # Unblock SIGUSR1 (and copy the old mask) to test our signal handler old_mask = signal.pthread_sigmask(signal.SIG_UNBLOCK, [signum]) check_mask(old_mask) try: kill(signum) except ZeroDivisionError: pass else: raise Exception("ZeroDivisionError not raised") # Block and then raise SIGUSR1. The signal is blocked: the signal # handler is not called, and the signal is now pending mask = signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) check_mask(mask) kill(signum) # Check the new mask blocked = read_sigmask() check_mask(blocked) if signum not in blocked: raise Exception("%s not in %s" % (signum, blocked)) if old_mask ^ blocked != {signum}: raise Exception("%s ^ %s != {%s}" % (old_mask, blocked, signum)) # Unblock SIGUSR1 try: # unblock the pending signal calls immediately the signal handler signal.pthread_sigmask(signal.SIG_UNBLOCK, [signum]) except ZeroDivisionError: pass else: raise Exception("ZeroDivisionError not raised") try: kill(signum) except ZeroDivisionError: pass else: raise Exception("ZeroDivisionError not raised") # Check the new mask unblocked = read_sigmask() if signum in unblocked: raise Exception("%s in %s" % (signum, unblocked)) if blocked ^ unblocked != {signum}: raise Exception("%s ^ %s != {%s}" % (blocked, unblocked, signum)) if old_mask != unblocked: raise Exception("%s != %s" % (old_mask, unblocked)) """ assert_python_ok('-c', code) @unittest.skipIf(sys.platform == 'freebsd6', "issue #12392: send a signal to the main thread doesn't work " "before the creation of the first thread on FreeBSD 6") @unittest.skipUnless(hasattr(signal, 'pthread_kill'), 'need signal.pthread_kill()') def test_pthread_kill_main_thread(self): # Test that a signal can be sent to the main thread with pthread_kill() # before any other thread has been created (see issue #12392). code = """if True: import threading import signal import sys def handler(signum, frame): sys.exit(3) signal.signal(signal.SIGUSR1, handler) signal.pthread_kill(threading.get_ident(), signal.SIGUSR1) sys.exit(2) """ with spawn_python('-c', code) as process: stdout, stderr = process.communicate() exitcode = process.wait() if exitcode != 3: raise Exception("Child error (exit code %s): %s" % (exitcode, stdout)) class StressTest(unittest.TestCase): """ Stress signal delivery, especially when a signal arrives in the middle of recomputing the signal state or executing previously tripped signal handlers. """ def setsig(self, signum, handler): old_handler = signal.signal(signum, handler) self.addCleanup(signal.signal, signum, old_handler) def measure_itimer_resolution(self): N = 20 times = [] def handler(signum=None, frame=None): if len(times) < N: times.append(time.perf_counter()) # 1 µs is the smallest possible timer interval, # we want to measure what the concrete duration # will be on this platform signal.setitimer(signal.ITIMER_REAL, 1e-6) self.addCleanup(signal.setitimer, signal.ITIMER_REAL, 0) self.setsig(signal.SIGALRM, handler) handler() while len(times) < N: time.sleep(1e-3) durations = [times[i+1] - times[i] for i in range(len(times) - 1)] med = statistics.median(durations) if support.verbose: print("detected median itimer() resolution: %.6f s." % (med,)) return med def decide_itimer_count(self): # Some systems have poor setitimer() resolution (for example # measured around 20 ms. on FreeBSD 9), so decide on a reasonable # number of sequential timers based on that. reso = self.measure_itimer_resolution() if reso <= 1e-4: return 10000 elif reso <= 1e-2: return 100 else: self.skipTest("detected itimer resolution (%.3f s.) too high " "(> 10 ms.) on this platform (or system too busy)" % (reso,)) @unittest.skipUnless(hasattr(signal, "setitimer"), "test needs setitimer()") def test_stress_delivery_dependent(self): """ This test uses dependent signal handlers. """ N = self.decide_itimer_count() sigs = [] def first_handler(signum, frame): # 1e-6 is the minimum non-zero value for `setitimer()`. # Choose a random delay so as to improve chances of # triggering a race condition. Ideally the signal is received # when inside critical signal-handling routines such as # Py_MakePendingCalls(). signal.setitimer(signal.ITIMER_REAL, 1e-6 + random.random() * 1e-5) def second_handler(signum=None, frame=None): sigs.append(signum) # Here on Linux, SIGPROF > SIGALRM > SIGUSR1. By using both # ascending and descending sequences (SIGUSR1 then SIGALRM, # SIGPROF then SIGALRM), we maximize chances of hitting a bug. self.setsig(signal.SIGPROF, first_handler) self.setsig(signal.SIGUSR1, first_handler) self.setsig(signal.SIGALRM, second_handler) # for ITIMER_REAL expected_sigs = 0 deadline = time.time() + 15.0 while expected_sigs < N: os.kill(os.getpid(), signal.SIGPROF) expected_sigs += 1 # Wait for handlers to run to avoid signal coalescing while len(sigs) < expected_sigs and time.time() < deadline: time.sleep(1e-5) os.kill(os.getpid(), signal.SIGUSR1) expected_sigs += 1 while len(sigs) < expected_sigs and time.time() < deadline: time.sleep(1e-5) # All ITIMER_REAL signals should have been delivered to the # Python handler self.assertEqual(len(sigs), N, "Some signals were lost") @unittest.skipUnless(hasattr(signal, "setitimer"), "test needs setitimer()") def test_stress_delivery_simultaneous(self): """ This test uses simultaneous signal handlers. """ N = self.decide_itimer_count() sigs = [] def handler(signum, frame): sigs.append(signum) self.setsig(signal.SIGUSR1, handler) self.setsig(signal.SIGALRM, handler) # for ITIMER_REAL expected_sigs = 0 deadline = time.time() + 15.0 while expected_sigs < N: # Hopefully the SIGALRM will be received somewhere during # initial processing of SIGUSR1. signal.setitimer(signal.ITIMER_REAL, 1e-6 + random.random() * 1e-5) os.kill(os.getpid(), signal.SIGUSR1) expected_sigs += 2 # Wait for handlers to run to avoid signal coalescing while len(sigs) < expected_sigs and time.time() < deadline: time.sleep(1e-5) # All ITIMER_REAL signals should have been delivered to the # Python handler self.assertEqual(len(sigs), N, "Some signals were lost") def tearDownModule(): support.reap_children() if __name__ == "__main__": unittest.main()
38,867
1,095
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_codecencodings_hk.py
# # test_codecencodings_hk.py # Codec encoding tests for HongKong encodings. # from test import multibytecodec_support import unittest class Test_Big5HKSCS(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'big5hkscs' tstring = multibytecodec_support.load_teststring('big5hkscs') codectests = ( # invalid bytes (b"abc\x80\x80\xc1\xc4", "strict", None), (b"abc\xc8", "strict", None), (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\u8b10"), (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\u8b10\ufffd"), (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u8b10"), ) if __name__ == "__main__": unittest.main()
701
23
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_hash.py
# test the invariant that # iff a==b then hash(a)==hash(b) # # Also test that hash implementations are inherited as expected import datetime import os import sys import unittest from test.support.script_helper import assert_python_ok from collections.abc import Hashable IS_64BIT = sys.maxsize > 2**32 def lcg(x, length=16): """Linear congruential generator""" if x == 0: return bytes(length) out = bytearray(length) for i in range(length): x = (214013 * x + 2531011) & 0x7fffffff out[i] = (x >> 16) & 0xff return bytes(out) def pysiphash(uint64): """Convert SipHash24 output to Py_hash_t """ assert 0 <= uint64 < (1 << 64) # simple unsigned to signed int64 if uint64 > (1 << 63) - 1: int64 = uint64 - (1 << 64) else: int64 = uint64 # mangle uint64 to uint32 uint32 = (uint64 ^ uint64 >> 32) & 0xffffffff # simple unsigned to signed int32 if uint32 > (1 << 31) - 1: int32 = uint32 - (1 << 32) else: int32 = uint32 return int32, int64 def skip_unless_internalhash(test): """Skip decorator for tests that depend on SipHash24 or FNV""" ok = sys.hash_info.algorithm in {"fnv", "siphash24"} msg = "Requires SipHash24 or FNV" return test if ok else unittest.skip(msg)(test) class HashEqualityTestCase(unittest.TestCase): def same_hash(self, *objlist): # Hash each object given and fail if # the hash values are not all the same. hashed = list(map(hash, objlist)) for h in hashed[1:]: if h != hashed[0]: self.fail("hashed values differ: %r" % (objlist,)) def test_numeric_literals(self): self.same_hash(1, 1, 1.0, 1.0+0.0j) self.same_hash(0, 0.0, 0.0+0.0j) self.same_hash(-1, -1.0, -1.0+0.0j) self.same_hash(-2, -2.0, -2.0+0.0j) def test_coerced_integers(self): self.same_hash(int(1), int(1), float(1), complex(1), int('1'), float('1.0')) self.same_hash(int(-2**31), float(-2**31)) self.same_hash(int(1-2**31), float(1-2**31)) self.same_hash(int(2**31-1), float(2**31-1)) # for 64-bit platforms self.same_hash(int(2**31), float(2**31)) self.same_hash(int(-2**63), float(-2**63)) self.same_hash(int(2**63), float(2**63)) def test_coerced_floats(self): self.same_hash(int(1.23e300), float(1.23e300)) self.same_hash(float(0.5), complex(0.5, 0.0)) def test_unaligned_buffers(self): # The hash function for bytes-like objects shouldn't have # alignment-dependent results (example in issue #16427). b = b"123456789abcdefghijklmnopqrstuvwxyz" * 128 for i in range(16): for j in range(16): aligned = b[i:128+j] unaligned = memoryview(b)[i:128+j] self.assertEqual(hash(aligned), hash(unaligned)) _default_hash = object.__hash__ class DefaultHash(object): pass _FIXED_HASH_VALUE = 42 class FixedHash(object): def __hash__(self): return _FIXED_HASH_VALUE class OnlyEquality(object): def __eq__(self, other): return self is other class OnlyInequality(object): def __ne__(self, other): return self is not other class InheritedHashWithEquality(FixedHash, OnlyEquality): pass class InheritedHashWithInequality(FixedHash, OnlyInequality): pass class NoHash(object): __hash__ = None class HashInheritanceTestCase(unittest.TestCase): default_expected = [object(), DefaultHash(), OnlyInequality(), ] fixed_expected = [FixedHash(), InheritedHashWithEquality(), InheritedHashWithInequality(), ] error_expected = [NoHash(), OnlyEquality(), ] def test_default_hash(self): for obj in self.default_expected: self.assertEqual(hash(obj), _default_hash(obj)) def test_fixed_hash(self): for obj in self.fixed_expected: self.assertEqual(hash(obj), _FIXED_HASH_VALUE) def test_error_hash(self): for obj in self.error_expected: self.assertRaises(TypeError, hash, obj) def test_hashable(self): objects = (self.default_expected + self.fixed_expected) for obj in objects: self.assertIsInstance(obj, Hashable) def test_not_hashable(self): for obj in self.error_expected: self.assertNotIsInstance(obj, Hashable) # Issue #4701: Check that some builtin types are correctly hashable class DefaultIterSeq(object): seq = range(10) def __len__(self): return len(self.seq) def __getitem__(self, index): return self.seq[index] class HashBuiltinsTestCase(unittest.TestCase): hashes_to_check = [enumerate(range(10)), iter(DefaultIterSeq()), iter(lambda: 0, 0), ] def test_hashes(self): _default_hash = object.__hash__ for obj in self.hashes_to_check: self.assertEqual(hash(obj), _default_hash(obj)) class HashRandomizationTests: # Each subclass should define a field "repr_", containing the repr() of # an object to be tested def get_hash_command(self, repr_): return 'print(hash(eval(%a)))' % repr_ def get_hash(self, repr_, seed=None): env = os.environ.copy() env['__cleanenv'] = True # signal to assert_python not to do a copy # of os.environ on its own if seed is not None: env['PYTHONHASHSEED'] = str(seed) else: env.pop('PYTHONHASHSEED', None) out = assert_python_ok( '-c', self.get_hash_command(repr_), **env) stdout = out[1].strip() return int(stdout) def test_randomized_hash(self): # two runs should return different hashes run1 = self.get_hash(self.repr_, seed='random') run2 = self.get_hash(self.repr_, seed='random') self.assertNotEqual(run1, run2) class StringlikeHashRandomizationTests(HashRandomizationTests): repr_ = None repr_long = None # 32bit little, 64bit little, 32bit big, 64bit big known_hashes = { 'djba33x': [ # only used for small strings # seed 0, 'abc' [193485960, 193485960, 193485960, 193485960], # seed 42, 'abc' [-678966196, 573763426263223372, -820489388, -4282905804826039665], ], 'siphash24': [ # NOTE: PyUCS2 layout depends on endianess # seed 0, 'abc' [1198583518, 4596069200710135518, 1198583518, 4596069200710135518], # seed 42, 'abc' [273876886, -4501618152524544106, 273876886, -4501618152524544106], # seed 42, 'abcdefghijk' [-1745215313, 4436719588892876975, -1745215313, 4436719588892876975], # seed 0, 'äú∑ℇ' [493570806, 5749986484189612790, -1006381564, -5915111450199468540], # seed 42, 'äú∑ℇ' [-1677110816, -2947981342227738144, -1860207793, -4296699217652516017], ], 'fnv': [ # seed 0, 'abc' [-1600925533, 1453079729188098211, -1600925533, 1453079729188098211], # seed 42, 'abc' [-206076799, -4410911502303878509, -1024014457, -3570150969479994130], # seed 42, 'abcdefghijk' [811136751, -5046230049376118746, -77208053 , -4779029615281019666], # seed 0, 'äú∑ℇ' [44402817, 8998297579845987431, -1956240331, -782697888614047887], # seed 42, 'äú∑ℇ' [-283066365, -4576729883824601543, -271871407, -3927695501187247084], ] } def get_expected_hash(self, position, length): if length < sys.hash_info.cutoff: algorithm = "djba33x" else: algorithm = sys.hash_info.algorithm if sys.byteorder == 'little': platform = 1 if IS_64BIT else 0 else: assert(sys.byteorder == 'big') platform = 3 if IS_64BIT else 2 return self.known_hashes[algorithm][position][platform] def test_null_hash(self): # PYTHONHASHSEED=0 disables the randomized hash known_hash_of_obj = self.get_expected_hash(0, 3) # Randomization is enabled by default: self.assertNotEqual(self.get_hash(self.repr_), known_hash_of_obj) # It can also be disabled by setting the seed to 0: self.assertEqual(self.get_hash(self.repr_, seed=0), known_hash_of_obj) @skip_unless_internalhash def test_fixed_hash(self): # test a fixed seed for the randomized hash # Note that all types share the same values: h = self.get_expected_hash(1, 3) self.assertEqual(self.get_hash(self.repr_, seed=42), h) @skip_unless_internalhash def test_long_fixed_hash(self): if self.repr_long is None: return h = self.get_expected_hash(2, 11) self.assertEqual(self.get_hash(self.repr_long, seed=42), h) class StrHashRandomizationTests(StringlikeHashRandomizationTests, unittest.TestCase): repr_ = repr('abc') repr_long = repr('abcdefghijk') repr_ucs2 = repr('äú∑ℇ') @skip_unless_internalhash def test_empty_string(self): self.assertEqual(hash(""), 0) @skip_unless_internalhash def test_ucs2_string(self): h = self.get_expected_hash(3, 6) self.assertEqual(self.get_hash(self.repr_ucs2, seed=0), h) h = self.get_expected_hash(4, 6) self.assertEqual(self.get_hash(self.repr_ucs2, seed=42), h) class BytesHashRandomizationTests(StringlikeHashRandomizationTests, unittest.TestCase): repr_ = repr(b'abc') repr_long = repr(b'abcdefghijk') @skip_unless_internalhash def test_empty_string(self): self.assertEqual(hash(b""), 0) class MemoryviewHashRandomizationTests(StringlikeHashRandomizationTests, unittest.TestCase): repr_ = "memoryview(b'abc')" repr_long = "memoryview(b'abcdefghijk')" @skip_unless_internalhash def test_empty_string(self): self.assertEqual(hash(memoryview(b"")), 0) class DatetimeTests(HashRandomizationTests): def get_hash_command(self, repr_): return 'import datetime; print(hash(%s))' % repr_ class DatetimeDateTests(DatetimeTests, unittest.TestCase): repr_ = repr(datetime.date(1066, 10, 14)) class DatetimeDatetimeTests(DatetimeTests, unittest.TestCase): repr_ = repr(datetime.datetime(1, 2, 3, 4, 5, 6, 7)) class DatetimeTimeTests(DatetimeTests, unittest.TestCase): repr_ = repr(datetime.time(0)) class HashDistributionTestCase(unittest.TestCase): def test_hash_distribution(self): # check for hash collision base = "abcdefghabcdefg" for i in range(1, len(base)): prefix = base[:i] with self.subTest(prefix=prefix): s15 = set() s255 = set() for c in range(256): h = hash(prefix + chr(c)) s15.add(h & 0xf) s255.add(h & 0xff) # SipHash24 distribution depends on key, usually > 60% self.assertGreater(len(s15), 8, prefix) self.assertGreater(len(s255), 128, prefix) if __name__ == "__main__": unittest.main()
11,721
347
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/sortperf.py
"""Sort performance test. See main() for command line syntax. See tabulate() for output format. """ import sys import time import random import marshal import tempfile import os td = tempfile.gettempdir() def randfloats(n): """Return a list of n random floats in [0, 1).""" # Generating floats is expensive, so this writes them out to a file in # a temp directory. If the file already exists, it just reads them # back in and shuffles them a bit. fn = os.path.join(td, "rr%06d" % n) try: fp = open(fn, "rb") except OSError: r = random.random result = [r() for i in range(n)] try: try: fp = open(fn, "wb") marshal.dump(result, fp) fp.close() fp = None finally: if fp: try: os.unlink(fn) except OSError: pass except OSError as msg: print("can't write", fn, ":", msg) else: result = marshal.load(fp) fp.close() # Shuffle it a bit... for i in range(10): i = random.randrange(n) temp = result[:i] del result[:i] temp.reverse() result.extend(temp) del temp assert len(result) == n return result def flush(): sys.stdout.flush() def doit(L): t0 = time.perf_counter() L.sort() t1 = time.perf_counter() print("%6.2f" % (t1-t0), end=' ') flush() def tabulate(r): r"""Tabulate sort speed for lists of various sizes. The sizes are 2**i for i in r (the argument, a list). The output displays i, 2**i, and the time to sort arrays of 2**i floating point numbers with the following properties: *sort: random data \sort: descending data /sort: ascending data 3sort: ascending, then 3 random exchanges +sort: ascending, then 10 random at the end %sort: ascending, then randomly replace 1% of the elements w/ random values ~sort: many duplicates =sort: all equal !sort: worst case scenario """ cases = tuple([ch + "sort" for ch in r"*\/3+%~=!"]) fmt = ("%2s %7s" + " %6s"*len(cases)) print(fmt % (("i", "2**i") + cases)) for i in r: n = 1 << i L = randfloats(n) print("%2d %7d" % (i, n), end=' ') flush() doit(L) # *sort L.reverse() doit(L) # \sort doit(L) # /sort # Do 3 random exchanges. for dummy in range(3): i1 = random.randrange(n) i2 = random.randrange(n) L[i1], L[i2] = L[i2], L[i1] doit(L) # 3sort # Replace the last 10 with random floats. if n >= 10: L[-10:] = [random.random() for dummy in range(10)] doit(L) # +sort # Replace 1% of the elements at random. for dummy in range(n // 100): L[random.randrange(n)] = random.random() doit(L) # %sort # Arrange for lots of duplicates. if n > 4: del L[4:] L = L * (n // 4) # Force the elements to be distinct objects, else timings can be # artificially low. L = list(map(lambda x: --x, L)) doit(L) # ~sort del L # All equal. Again, force the elements to be distinct objects. L = list(map(abs, [-0.5] * n)) doit(L) # =sort del L # This one looks like [3, 2, 1, 0, 0, 1, 2, 3]. It was a bad case # for an older implementation of quicksort, which used the median # of the first, last and middle elements as the pivot. half = n // 2 L = list(range(half - 1, -1, -1)) L.extend(range(half)) # Force to float, so that the timings are comparable. This is # significantly faster if we leave tham as ints. L = list(map(float, L)) doit(L) # !sort print() def main(): """Main program when invoked as a script. One argument: tabulate a single row. Two arguments: tabulate a range (inclusive). Extra arguments are used to seed the random generator. """ # default range (inclusive) k1 = 15 k2 = 20 if sys.argv[1:]: # one argument: single point k1 = k2 = int(sys.argv[1]) if sys.argv[2:]: # two arguments: specify range k2 = int(sys.argv[2]) if sys.argv[3:]: # derive random seed from remaining arguments x = 1 for a in sys.argv[3:]: x = 69069 * x + hash(a) random.seed(x) r = range(k1, k2+1) # include the end point tabulate(r) if __name__ == '__main__': main()
4,806
170
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_heapq.py
"""Unittests for heapq.""" import heapq import random import unittest from test import support from unittest import TestCase, skipUnless from operator import itemgetter # heapq.nlargest/nsmallest are saved in heapq._nlargest/_smallest when # heapq is imported, so check them there func_names = ['heapify', 'heappop', 'heappush', 'heappushpop', 'heapreplace', '_heappop_max', '_heapreplace_max', '_heapify_max'] class TestHeap(TestCase): def test_push_pop(self): # 1) Push 256 random numbers and pop them off, verifying all's OK. heap = [] data = [] self.check_invariant(heap) for i in range(256): item = random.random() data.append(item) heapq.heappush(heap, item) self.check_invariant(heap) results = [] while heap: item = heapq.heappop(heap) self.check_invariant(heap) results.append(item) data_sorted = data[:] data_sorted.sort() self.assertEqual(data_sorted, results) # 2) Check that the invariant holds for a sorted array self.check_invariant(results) self.assertRaises(TypeError, heapq.heappush, []) try: self.assertRaises(TypeError, heapq.heappush, None, None) self.assertRaises(TypeError, heapq.heappop, None) except AttributeError: pass def check_invariant(self, heap): # Check the heap invariant. for pos, item in enumerate(heap): if pos: # pos 0 has no parent parentpos = (pos-1) >> 1 self.assertTrue(heap[parentpos] <= item) def test_heapify(self): for size in list(range(30)) + [20000]: heap = [random.random() for dummy in range(size)] heapq.heapify(heap) self.check_invariant(heap) self.assertRaises(TypeError, heapq.heapify, None) def test_naive_nbest(self): data = [random.randrange(2000) for i in range(1000)] heap = [] for item in data: heapq.heappush(heap, item) if len(heap) > 10: heapq.heappop(heap) heap.sort() self.assertEqual(heap, sorted(data)[-10:]) def heapiter(self, heap): # An iterator returning a heap's elements, smallest-first. try: while 1: yield heapq.heappop(heap) except IndexError: pass def test_nbest(self): # Less-naive "N-best" algorithm, much faster (if len(data) is big # enough <wink>) than sorting all of data. However, if we had a max # heap instead of a min heap, it could go faster still via # heapify'ing all of data (linear time), then doing 10 heappops # (10 log-time steps). data = [random.randrange(2000) for i in range(1000)] heap = data[:10] heapq.heapify(heap) for item in data[10:]: if item > heap[0]: # this gets rarer the longer we run heapq.heapreplace(heap, item) self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:]) self.assertRaises(TypeError, heapq.heapreplace, None) self.assertRaises(TypeError, heapq.heapreplace, None, None) self.assertRaises(IndexError, heapq.heapreplace, [], None) def test_nbest_with_pushpop(self): data = [random.randrange(2000) for i in range(1000)] heap = data[:10] heapq.heapify(heap) for item in data[10:]: heapq.heappushpop(heap, item) self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:]) self.assertEqual(heapq.heappushpop([], 'x'), 'x') def test_heappushpop(self): h = [] x = heapq.heappushpop(h, 10) self.assertEqual((h, x), ([], 10)) h = [10] x = heapq.heappushpop(h, 10.0) self.assertEqual((h, x), ([10], 10.0)) self.assertEqual(type(h[0]), int) self.assertEqual(type(x), float) h = [10]; x = heapq.heappushpop(h, 9) self.assertEqual((h, x), ([10], 9)) h = [10]; x = heapq.heappushpop(h, 11) self.assertEqual((h, x), ([11], 10)) def test_heapsort(self): # Exercise everything with repeated heapsort checks for trial in range(100): size = random.randrange(50) data = [random.randrange(25) for i in range(size)] if trial & 1: # Half of the time, use heapify heap = data[:] heapq.heapify(heap) else: # The rest of the time, use heappush heap = [] for item in data: heapq.heappush(heap, item) heap_sorted = [heapq.heappop(heap) for i in range(size)] self.assertEqual(heap_sorted, sorted(data)) def test_merge(self): inputs = [] for i in range(random.randrange(25)): row = [] for j in range(random.randrange(100)): tup = random.choice('ABC'), random.randrange(-500, 500) row.append(tup) inputs.append(row) for key in [None, itemgetter(0), itemgetter(1), itemgetter(1, 0)]: for reverse in [False, True]: seqs = [] for seq in inputs: seqs.append(sorted(seq, key=key, reverse=reverse)) self.assertEqual(sorted(chain(*inputs), key=key, reverse=reverse), list(heapq.merge(*seqs, key=key, reverse=reverse))) self.assertEqual(list(heapq.merge()), []) def test_merge_does_not_suppress_index_error(self): # Issue 19018: Heapq.merge suppresses IndexError from user generator def iterable(): s = list(range(10)) for i in range(20): yield s[i] # IndexError when i > 10 with self.assertRaises(IndexError): list(heapq.merge(iterable(), iterable())) def test_merge_stability(self): class Int(int): pass inputs = [[], [], [], []] for i in range(20000): stream = random.randrange(4) x = random.randrange(500) obj = Int(x) obj.pair = (x, stream) inputs[stream].append(obj) for stream in inputs: stream.sort() result = [i.pair for i in heapq.merge(*inputs)] self.assertEqual(result, sorted(result)) def test_nsmallest(self): data = [(random.randrange(2000), i) for i in range(1000)] for f in (None, lambda x: x[0] * 547 % 2000): for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100): self.assertEqual(list(heapq.nsmallest(n, data)), sorted(data)[:n]) self.assertEqual(list(heapq.nsmallest(n, data, key=f)), sorted(data, key=f)[:n]) def test_nlargest(self): data = [(random.randrange(2000), i) for i in range(1000)] for f in (None, lambda x: x[0] * 547 % 2000): for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100): self.assertEqual(list(heapq.nlargest(n, data)), sorted(data, reverse=True)[:n]) self.assertEqual(list(heapq.nlargest(n, data, key=f)), sorted(data, key=f, reverse=True)[:n]) def test_comparison_operator(self): # Issue 3051: Make sure heapq works with both __lt__ # For python 3.0, __le__ alone is not enough def hsort(data, comp): data = [comp(x) for x in data] heapq.heapify(data) return [heapq.heappop(data).x for i in range(len(data))] class LT: def __init__(self, x): self.x = x def __lt__(self, other): return self.x > other.x class LE: def __init__(self, x): self.x = x def __le__(self, other): return self.x >= other.x data = [random.random() for i in range(100)] target = sorted(data, reverse=True) self.assertEqual(hsort(data, LT), target) self.assertRaises(TypeError, data, LE) #============================================================================== class LenOnly: "Dummy sequence class defining __len__ but not __getitem__." def __len__(self): return 10 class GetOnly: "Dummy sequence class defining __getitem__ but not __len__." def __getitem__(self, ndx): return 10 class CmpErr: "Dummy element that always raises an error during comparison" def __eq__(self, other): raise ZeroDivisionError __ne__ = __lt__ = __le__ = __gt__ = __ge__ = __eq__ def R(seqn): 'Regular generator' for i in seqn: yield i class G: 'Sequence using __getitem__' def __init__(self, seqn): self.seqn = seqn def __getitem__(self, i): return self.seqn[i] class I: 'Sequence using iterator protocol' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 return v class Ig: 'Sequence using iterator protocol defined with a generator' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): for val in self.seqn: yield val class X: 'Missing __getitem__ and __iter__' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 return v class N: 'Iterator missing __next__()' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self class E: 'Test propagation of exceptions' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self def __next__(self): 3 // 0 class S: 'Test immediate stop' def __init__(self, seqn): pass def __iter__(self): return self def __next__(self): raise StopIteration from itertools import chain def L(seqn): 'Test multiple tiers of iterators' return chain(map(lambda x:x, R(Ig(G(seqn))))) class SideEffectLT: def __init__(self, value, heap): self.value = value self.heap = heap def __lt__(self, other): self.heap[:] = [] return self.value < other.value class TestErrorHandling(TestCase): def test_non_sequence(self): for f in (heapq.heapify, heapq.heappop): self.assertRaises((TypeError, AttributeError), f, 10) for f in (heapq.heappush, heapq.heapreplace, heapq.nlargest, heapq.nsmallest): self.assertRaises((TypeError, AttributeError), f, 10, 10) def test_len_only(self): for f in (heapq.heapify, heapq.heappop): self.assertRaises((TypeError, AttributeError), f, LenOnly()) for f in (heapq.heappush, heapq.heapreplace): self.assertRaises((TypeError, AttributeError), f, LenOnly(), 10) for f in (heapq.nlargest, heapq.nsmallest): self.assertRaises(TypeError, f, 2, LenOnly()) def test_get_only(self): for f in (heapq.heapify, heapq.heappop): self.assertRaises(TypeError, f, GetOnly()) for f in (heapq.heappush, heapq.heapreplace): self.assertRaises(TypeError, f, GetOnly(), 10) for f in (heapq.nlargest, heapq.nsmallest): self.assertRaises(TypeError, f, 2, GetOnly()) def test_get_only(self): seq = [CmpErr(), CmpErr(), CmpErr()] for f in (heapq.heapify, heapq.heappop): self.assertRaises(ZeroDivisionError, f, seq) for f in (heapq.heappush, heapq.heapreplace): self.assertRaises(ZeroDivisionError, f, seq, 10) for f in (heapq.nlargest, heapq.nsmallest): self.assertRaises(ZeroDivisionError, f, 2, seq) def test_arg_parsing(self): for f in (heapq.heapify, heapq.heappop, heapq.heappush, heapq.heapreplace, heapq.nlargest, heapq.nsmallest): self.assertRaises((TypeError, AttributeError), f, 10) def test_iterable_args(self): for f in (heapq.nlargest, heapq.nsmallest): for s in ("123", "", range(1000), (1, 1.2), range(2000,2200,5)): for g in (G, I, Ig, L, R): self.assertEqual(list(f(2, g(s))), list(f(2,s))) self.assertEqual(list(f(2, S(s))), []) self.assertRaises(TypeError, f, 2, X(s)) self.assertRaises(TypeError, f, 2, N(s)) self.assertRaises(ZeroDivisionError, f, 2, E(s)) # Issue #17278: the heap may change size while it's being walked. def test_heappush_mutating_heap(self): heap = [] heap.extend(SideEffectLT(i, heap) for i in range(200)) # Python version raises IndexError, C version RuntimeError with self.assertRaises((IndexError, RuntimeError)): heapq.heappush(heap, SideEffectLT(5, heap)) def test_heappop_mutating_heap(self): heap = [] heap.extend(SideEffectLT(i, heap) for i in range(200)) # Python version raises IndexError, C version RuntimeError with self.assertRaises((IndexError, RuntimeError)): heapq.heappop(heap) def test_comparison_operator_modifiying_heap(self): # See bpo-39421: Strong references need to be taken # when comparing objects as they can alter the heap class EvilClass(int): def __lt__(self, o): heap.clear() return NotImplemented heap = [] heapq.heappush(heap, EvilClass(0)) self.assertRaises(IndexError, heapq.heappushpop, heap, 1) def test_comparison_operator_modifiying_heap_two_heaps(self): class h(int): def __lt__(self, o): list2.clear() return NotImplemented class g(int): def __lt__(self, o): list1.clear() return NotImplemented list1, list2 = [], [] heapq.heappush(list1, h(0)) heapq.heappush(list2, g(0)) self.assertRaises((IndexError, RuntimeError), heapq.heappush, list1, g(1)) self.assertRaises((IndexError, RuntimeError), heapq.heappush, list2, h(1)) if __name__ == "__main__": unittest.main()
14,757
430
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_selectors.py
import errno import os import random import selectors import signal import socket import sys from test import support from time import sleep import unittest import unittest.mock import tempfile from time import monotonic as time try: import resource except ImportError: resource = None if __name__ == 'PYOBJ.COM': import resource if hasattr(socket, 'socketpair'): socketpair = socket.socketpair else: def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): with socket.socket(family, type, proto) as l: l.bind((support.HOST, 0)) l.listen() c = socket.socket(family, type, proto) try: c.connect(l.getsockname()) caddr = c.getsockname() while True: a, addr = l.accept() # check that we've got the correct client if addr == caddr: return c, a a.close() except OSError: c.close() raise def find_ready_matching(ready, flag): match = [] for key, events in ready: if events & flag: match.append(key.fileobj) return match class BaseSelectorTestCase(unittest.TestCase): def make_socketpair(self): rd, wr = socketpair() self.addCleanup(rd.close) self.addCleanup(wr.close) return rd, wr def test_register(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ, "data") self.assertIsInstance(key, selectors.SelectorKey) self.assertEqual(key.fileobj, rd) self.assertEqual(key.fd, rd.fileno()) self.assertEqual(key.events, selectors.EVENT_READ) self.assertEqual(key.data, "data") # register an unknown event self.assertRaises(ValueError, s.register, 0, 999999) # register an invalid FD self.assertRaises(ValueError, s.register, -10, selectors.EVENT_READ) # register twice self.assertRaises(KeyError, s.register, rd, selectors.EVENT_READ) # register the same FD, but with a different object self.assertRaises(KeyError, s.register, rd.fileno(), selectors.EVENT_READ) def test_unregister(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.unregister(rd) # unregister an unknown file obj self.assertRaises(KeyError, s.unregister, 999999) # unregister twice self.assertRaises(KeyError, s.unregister, rd) def test_unregister_after_fd_close(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() r, w = rd.fileno(), wr.fileno() s.register(r, selectors.EVENT_READ) s.register(w, selectors.EVENT_WRITE) rd.close() wr.close() s.unregister(r) s.unregister(w) @unittest.skipUnless(os.name == 'posix', "requires posix") def test_unregister_after_fd_close_and_reuse(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() r, w = rd.fileno(), wr.fileno() s.register(r, selectors.EVENT_READ) s.register(w, selectors.EVENT_WRITE) rd2, wr2 = self.make_socketpair() rd.close() wr.close() os.dup2(rd2.fileno(), r) os.dup2(wr2.fileno(), w) self.addCleanup(os.close, r) self.addCleanup(os.close, w) s.unregister(r) s.unregister(w) def test_unregister_after_socket_close(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) rd.close() wr.close() s.unregister(rd) s.unregister(wr) def test_modify(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ) # modify events key2 = s.modify(rd, selectors.EVENT_WRITE) self.assertNotEqual(key.events, key2.events) self.assertEqual(key2, s.get_key(rd)) s.unregister(rd) # modify data d1 = object() d2 = object() key = s.register(rd, selectors.EVENT_READ, d1) key2 = s.modify(rd, selectors.EVENT_READ, d2) self.assertEqual(key.events, key2.events) self.assertNotEqual(key.data, key2.data) self.assertEqual(key2, s.get_key(rd)) self.assertEqual(key2.data, d2) # modify unknown file obj self.assertRaises(KeyError, s.modify, 999999, selectors.EVENT_READ) # modify use a shortcut d3 = object() s.register = unittest.mock.Mock() s.unregister = unittest.mock.Mock() s.modify(rd, selectors.EVENT_READ, d3) self.assertFalse(s.register.called) self.assertFalse(s.unregister.called) def test_close(self): s = self.SELECTOR() self.addCleanup(s.close) mapping = s.get_map() rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) s.close() self.assertRaises(RuntimeError, s.get_key, rd) self.assertRaises(RuntimeError, s.get_key, wr) self.assertRaises(KeyError, mapping.__getitem__, rd) self.assertRaises(KeyError, mapping.__getitem__, wr) def test_get_key(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() key = s.register(rd, selectors.EVENT_READ, "data") self.assertEqual(key, s.get_key(rd)) # unknown file obj self.assertRaises(KeyError, s.get_key, 999999) def test_get_map(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() keys = s.get_map() self.assertFalse(keys) self.assertEqual(len(keys), 0) self.assertEqual(list(keys), []) key = s.register(rd, selectors.EVENT_READ, "data") self.assertIn(rd, keys) self.assertEqual(key, keys[rd]) self.assertEqual(len(keys), 1) self.assertEqual(list(keys), [rd.fileno()]) self.assertEqual(list(keys.values()), [key]) # unknown file obj with self.assertRaises(KeyError): keys[999999] # Read-only mapping with self.assertRaises(TypeError): del keys[rd] def test_select(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) wr_key = s.register(wr, selectors.EVENT_WRITE) result = s.select() for key, events in result: self.assertTrue(isinstance(key, selectors.SelectorKey)) self.assertTrue(events) self.assertFalse(events & ~(selectors.EVENT_READ | selectors.EVENT_WRITE)) self.assertEqual([(wr_key, selectors.EVENT_WRITE)], result) def test_context_manager(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() with s as sel: sel.register(rd, selectors.EVENT_READ) sel.register(wr, selectors.EVENT_WRITE) self.assertRaises(RuntimeError, s.get_key, rd) self.assertRaises(RuntimeError, s.get_key, wr) def test_fileno(self): s = self.SELECTOR() self.addCleanup(s.close) if hasattr(s, 'fileno'): fd = s.fileno() self.assertTrue(isinstance(fd, int)) self.assertGreaterEqual(fd, 0) def test_selector(self): s = self.SELECTOR() self.addCleanup(s.close) NUM_SOCKETS = 12 MSG = b" This is a test." MSG_LEN = len(MSG) readers = [] writers = [] r2w = {} w2r = {} for i in range(NUM_SOCKETS): rd, wr = self.make_socketpair() s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) readers.append(rd) writers.append(wr) r2w[rd] = wr w2r[wr] = rd bufs = [] while writers: ready = s.select() ready_writers = find_ready_matching(ready, selectors.EVENT_WRITE) if not ready_writers: self.fail("no sockets ready for writing") wr = random.choice(ready_writers) wr.send(MSG) for i in range(10): ready = s.select() ready_readers = find_ready_matching(ready, selectors.EVENT_READ) if ready_readers: break # there might be a delay between the write to the write end and # the read end is reported ready sleep(0.1) else: self.fail("no sockets ready for reading") self.assertEqual([w2r[wr]], ready_readers) rd = ready_readers[0] buf = rd.recv(MSG_LEN) self.assertEqual(len(buf), MSG_LEN) bufs.append(buf) s.unregister(r2w[rd]) s.unregister(rd) writers.remove(r2w[rd]) self.assertEqual(bufs, [MSG] * NUM_SOCKETS) @unittest.skipIf(sys.platform == 'win32', 'select.select() cannot be used with empty fd sets') def test_empty_select(self): # Issue #23009: Make sure EpollSelector.select() works when no FD is # registered. s = self.SELECTOR() self.addCleanup(s.close) self.assertEqual(s.select(timeout=0), []) @unittest.skip("[jart] unacceptable test") def test_timeout(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() s.register(wr, selectors.EVENT_WRITE) t = time() self.assertEqual(1, len(s.select(0))) self.assertEqual(1, len(s.select(-1))) self.assertLess(time() - t, 0.5) s.unregister(wr) s.register(rd, selectors.EVENT_READ) t = time() self.assertFalse(s.select(0)) self.assertFalse(s.select(-1)) self.assertLess(time() - t, 0.5) t0 = time() self.assertFalse(s.select(1)) t1 = time() dt = t1 - t0 # Tolerate 2.0 seconds for very slow buildbots self.assertTrue(0.8 <= dt <= 2.0, dt) @unittest.skipUnless(hasattr(signal, "alarm"), "signal.alarm() required for this test") def test_select_interrupt_exc(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() class InterruptSelect(Exception): pass def handler(*args): raise InterruptSelect orig_alrm_handler = signal.signal(signal.SIGALRM, handler) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) try: # [jart] sleep(1) isn't acceptable signal.setitimer(signal.ITIMER_REAL, 0.01) # signal.alarm(1) s.register(rd, selectors.EVENT_READ) t = time() # select() is interrupted by a signal which raises an exception with self.assertRaises(InterruptSelect): s.select(30) # select() was interrupted before the timeout of 30 seconds self.assertLess(time() - t, 5.0) finally: signal.alarm(0) @unittest.skip("[jart] unacceptable test") @unittest.skipUnless(hasattr(signal, "alarm"), "signal.alarm() required for this test") def test_select_interrupt_noraise(self): s = self.SELECTOR() self.addCleanup(s.close) rd, wr = self.make_socketpair() orig_alrm_handler = signal.signal(signal.SIGALRM, lambda *args: None) self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler) try: # [jart] sleep(1) isn't acceptable # signal.setitimer(signal.ITIMER_REAL, 0.01) # signal.alarm(1) s.register(rd, selectors.EVENT_READ) t = time() # select() is interrupted by a signal, but the signal handler doesn't # raise an exception, so select() should by retries with a recomputed # timeout self.assertFalse(s.select(1.5)) self.assertGreaterEqual(time() - t, 1.0) finally: signal.alarm(0) class ScalableSelectorMixIn: # see issue #18963 for why it's skipped on older OS X versions @support.requires_mac_ver(10, 5) @unittest.skipUnless(resource, "Test needs resource module") def test_above_fd_setsize(self): # A scalable implementation should have no problem with more than # FD_SETSIZE file descriptors. Since we don't know the value, we just # try to set the soft RLIMIT_NOFILE to the hard RLIMIT_NOFILE ceiling. soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) try: resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard)) self.addCleanup(resource.setrlimit, resource.RLIMIT_NOFILE, (soft, hard)) NUM_FDS = min(hard, 2**16) except (OSError, ValueError): NUM_FDS = soft # guard for already allocated FDs (stdin, stdout...) NUM_FDS -= 32 s = self.SELECTOR() self.addCleanup(s.close) for i in range(NUM_FDS // 2): try: rd, wr = self.make_socketpair() except OSError: # too many FDs, skip - note that we should only catch EMFILE # here, but apparently *BSD and Solaris can fail upon connect() # or bind() with EADDRNOTAVAIL, so let's be safe self.skipTest("FD limit reached") try: s.register(rd, selectors.EVENT_READ) s.register(wr, selectors.EVENT_WRITE) except OSError as e: if e.errno == errno.ENOSPC: # this can be raised by epoll if we go over # fs.epoll.max_user_watches sysctl self.skipTest("FD limit reached") raise try: fds = s.select() except OSError as e: if e.errno == errno.EINVAL and sys.platform == 'darwin': # unexplainable errors on macOS don't need to fail the test self.skipTest("Invalid argument error calling poll()") raise self.assertEqual(NUM_FDS // 2, len(fds)) class DefaultSelectorTestCase(BaseSelectorTestCase): SELECTOR = selectors.DefaultSelector class SelectSelectorTestCase(BaseSelectorTestCase): SELECTOR = selectors.SelectSelector @unittest.skipUnless(hasattr(selectors, 'PollSelector'), "Test needs selectors.PollSelector") class PollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'PollSelector', None) @unittest.skipUnless(hasattr(selectors, 'EpollSelector'), "Test needs selectors.EpollSelector") class EpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'EpollSelector', None) def test_register_file(self): # epoll(7) returns EPERM when given a file to watch s = self.SELECTOR() with tempfile.NamedTemporaryFile() as f: with self.assertRaises(IOError): s.register(f, selectors.EVENT_READ) # the SelectorKey has been removed with self.assertRaises(KeyError): s.get_key(f) @unittest.skipUnless(hasattr(selectors, 'KqueueSelector'), "Test needs selectors.KqueueSelector)") class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'KqueueSelector', None) def test_register_bad_fd(self): # a file descriptor that's been closed should raise an OSError # with EBADF s = self.SELECTOR() bad_f = support.make_bad_fd() with self.assertRaises(OSError) as cm: s.register(bad_f, selectors.EVENT_READ) self.assertEqual(cm.exception.errno, errno.EBADF) # the SelectorKey has been removed with self.assertRaises(KeyError): s.get_key(bad_f) @unittest.skipUnless(hasattr(selectors, 'DevpollSelector'), "Test needs selectors.DevpollSelector") class DevpollSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn): SELECTOR = getattr(selectors, 'DevpollSelector', None) def test_main(): tests = [DefaultSelectorTestCase, SelectSelectorTestCase, PollSelectorTestCase, EpollSelectorTestCase, KqueueSelectorTestCase, DevpollSelectorTestCase] support.run_unittest(*tests) support.reap_children() if __name__ == "__main__": test_main()
17,401
538
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_memoryio.py
"""Unit tests for memory-based file-like objects. StringIO -- for unicode strings BytesIO -- for bytes """ import unittest from test import support import io import _pyio as pyio import pickle import sys class MemorySeekTestMixin: def testInit(self): buf = self.buftype("1234567890") bytesIo = self.ioclass(buf) def testRead(self): buf = self.buftype("1234567890") bytesIo = self.ioclass(buf) self.assertEqual(buf[:1], bytesIo.read(1)) self.assertEqual(buf[1:5], bytesIo.read(4)) self.assertEqual(buf[5:], bytesIo.read(900)) self.assertEqual(self.EOF, bytesIo.read()) def testReadNoArgs(self): buf = self.buftype("1234567890") bytesIo = self.ioclass(buf) self.assertEqual(buf, bytesIo.read()) self.assertEqual(self.EOF, bytesIo.read()) def testSeek(self): buf = self.buftype("1234567890") bytesIo = self.ioclass(buf) bytesIo.read(5) bytesIo.seek(0) self.assertEqual(buf, bytesIo.read()) bytesIo.seek(3) self.assertEqual(buf[3:], bytesIo.read()) self.assertRaises(TypeError, bytesIo.seek, 0.0) def testTell(self): buf = self.buftype("1234567890") bytesIo = self.ioclass(buf) self.assertEqual(0, bytesIo.tell()) bytesIo.seek(5) self.assertEqual(5, bytesIo.tell()) bytesIo.seek(10000) self.assertEqual(10000, bytesIo.tell()) class MemoryTestMixin: def test_detach(self): buf = self.ioclass() self.assertRaises(self.UnsupportedOperation, buf.detach) def write_ops(self, f, t): self.assertEqual(f.write(t("blah.")), 5) self.assertEqual(f.seek(0), 0) self.assertEqual(f.write(t("Hello.")), 6) self.assertEqual(f.tell(), 6) self.assertEqual(f.seek(5), 5) self.assertEqual(f.tell(), 5) self.assertEqual(f.write(t(" world\n\n\n")), 9) self.assertEqual(f.seek(0), 0) self.assertEqual(f.write(t("h")), 1) self.assertEqual(f.truncate(12), 12) self.assertEqual(f.tell(), 1) def test_write(self): buf = self.buftype("hello world\n") memio = self.ioclass(buf) self.write_ops(memio, self.buftype) self.assertEqual(memio.getvalue(), buf) memio = self.ioclass() self.write_ops(memio, self.buftype) self.assertEqual(memio.getvalue(), buf) self.assertRaises(TypeError, memio.write, None) memio.close() self.assertRaises(ValueError, memio.write, self.buftype("")) def test_writelines(self): buf = self.buftype("1234567890") memio = self.ioclass() self.assertEqual(memio.writelines([buf] * 100), None) self.assertEqual(memio.getvalue(), buf * 100) memio.writelines([]) self.assertEqual(memio.getvalue(), buf * 100) memio = self.ioclass() self.assertRaises(TypeError, memio.writelines, [buf] + [1]) self.assertEqual(memio.getvalue(), buf) self.assertRaises(TypeError, memio.writelines, None) memio.close() self.assertRaises(ValueError, memio.writelines, []) def test_writelines_error(self): memio = self.ioclass() def error_gen(): yield self.buftype('spam') raise KeyboardInterrupt self.assertRaises(KeyboardInterrupt, memio.writelines, error_gen()) def test_truncate(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertRaises(ValueError, memio.truncate, -1) memio.seek(6) self.assertEqual(memio.truncate(), 6) self.assertEqual(memio.getvalue(), buf[:6]) self.assertEqual(memio.truncate(4), 4) self.assertEqual(memio.getvalue(), buf[:4]) self.assertEqual(memio.tell(), 6) memio.seek(0, 2) memio.write(buf) self.assertEqual(memio.getvalue(), buf[:4] + buf) pos = memio.tell() self.assertEqual(memio.truncate(None), pos) self.assertEqual(memio.tell(), pos) self.assertRaises(TypeError, memio.truncate, '0') memio.close() self.assertRaises(ValueError, memio.truncate, 0) def test_init(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.getvalue(), buf) memio = self.ioclass(None) self.assertEqual(memio.getvalue(), self.EOF) memio.__init__(buf * 2) self.assertEqual(memio.getvalue(), buf * 2) memio.__init__(buf) self.assertEqual(memio.getvalue(), buf) self.assertRaises(TypeError, memio.__init__, []) def test_read(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.read(0), self.EOF) self.assertEqual(memio.read(1), buf[:1]) self.assertEqual(memio.read(4), buf[1:5]) self.assertEqual(memio.read(900), buf[5:]) self.assertEqual(memio.read(), self.EOF) memio.seek(0) self.assertEqual(memio.read(), buf) self.assertEqual(memio.read(), self.EOF) self.assertEqual(memio.tell(), 10) memio.seek(0) self.assertEqual(memio.read(-1), buf) memio.seek(0) self.assertEqual(type(memio.read()), type(buf)) memio.seek(100) self.assertEqual(type(memio.read()), type(buf)) memio.seek(0) self.assertEqual(memio.read(None), buf) self.assertRaises(TypeError, memio.read, '') memio.seek(len(buf) + 1) self.assertEqual(memio.read(1), self.EOF) memio.seek(len(buf) + 1) self.assertEqual(memio.read(), self.EOF) memio.close() self.assertRaises(ValueError, memio.read) def test_readline(self): buf = self.buftype("1234567890\n") memio = self.ioclass(buf * 2) self.assertEqual(memio.readline(0), self.EOF) self.assertEqual(memio.readline(), buf) self.assertEqual(memio.readline(), buf) self.assertEqual(memio.readline(), self.EOF) memio.seek(0) self.assertEqual(memio.readline(5), buf[:5]) self.assertEqual(memio.readline(5), buf[5:10]) self.assertEqual(memio.readline(5), buf[10:15]) memio.seek(0) self.assertEqual(memio.readline(-1), buf) memio.seek(0) self.assertEqual(memio.readline(0), self.EOF) # Issue #24989: Buffer overread memio.seek(len(buf) * 2 + 1) self.assertEqual(memio.readline(), self.EOF) buf = self.buftype("1234567890\n") memio = self.ioclass((buf * 3)[:-1]) self.assertEqual(memio.readline(), buf) self.assertEqual(memio.readline(), buf) self.assertEqual(memio.readline(), buf[:-1]) self.assertEqual(memio.readline(), self.EOF) memio.seek(0) self.assertEqual(type(memio.readline()), type(buf)) self.assertEqual(memio.readline(), buf) self.assertRaises(TypeError, memio.readline, '') memio.close() self.assertRaises(ValueError, memio.readline) def test_readlines(self): buf = self.buftype("1234567890\n") memio = self.ioclass(buf * 10) self.assertEqual(memio.readlines(), [buf] * 10) memio.seek(5) self.assertEqual(memio.readlines(), [buf[5:]] + [buf] * 9) memio.seek(0) self.assertEqual(memio.readlines(15), [buf] * 2) memio.seek(0) self.assertEqual(memio.readlines(-1), [buf] * 10) memio.seek(0) self.assertEqual(memio.readlines(0), [buf] * 10) memio.seek(0) self.assertEqual(type(memio.readlines()[0]), type(buf)) memio.seek(0) self.assertEqual(memio.readlines(None), [buf] * 10) self.assertRaises(TypeError, memio.readlines, '') # Issue #24989: Buffer overread memio.seek(len(buf) * 10 + 1) self.assertEqual(memio.readlines(), []) memio.close() self.assertRaises(ValueError, memio.readlines) def test_iterator(self): buf = self.buftype("1234567890\n") memio = self.ioclass(buf * 10) self.assertEqual(iter(memio), memio) self.assertTrue(hasattr(memio, '__iter__')) self.assertTrue(hasattr(memio, '__next__')) i = 0 for line in memio: self.assertEqual(line, buf) i += 1 self.assertEqual(i, 10) memio.seek(0) i = 0 for line in memio: self.assertEqual(line, buf) i += 1 self.assertEqual(i, 10) # Issue #24989: Buffer overread memio.seek(len(buf) * 10 + 1) self.assertEqual(list(memio), []) memio = self.ioclass(buf * 2) memio.close() self.assertRaises(ValueError, memio.__next__) def test_getvalue(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.getvalue(), buf) memio.read() self.assertEqual(memio.getvalue(), buf) self.assertEqual(type(memio.getvalue()), type(buf)) memio = self.ioclass(buf * 1000) self.assertEqual(memio.getvalue()[-3:], self.buftype("890")) memio = self.ioclass(buf) memio.close() self.assertRaises(ValueError, memio.getvalue) def test_seek(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) memio.read(5) self.assertRaises(ValueError, memio.seek, -1) self.assertRaises(ValueError, memio.seek, 1, -1) self.assertRaises(ValueError, memio.seek, 1, 3) self.assertEqual(memio.seek(0), 0) self.assertEqual(memio.seek(0, 0), 0) self.assertEqual(memio.read(), buf) self.assertEqual(memio.seek(3), 3) self.assertEqual(memio.seek(0, 1), 3) self.assertEqual(memio.read(), buf[3:]) self.assertEqual(memio.seek(len(buf)), len(buf)) self.assertEqual(memio.read(), self.EOF) memio.seek(len(buf) + 1) self.assertEqual(memio.read(), self.EOF) self.assertEqual(memio.seek(0, 2), len(buf)) self.assertEqual(memio.read(), self.EOF) memio.close() self.assertRaises(ValueError, memio.seek, 0) def test_overseek(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.seek(len(buf) + 1), 11) self.assertEqual(memio.read(), self.EOF) self.assertEqual(memio.tell(), 11) self.assertEqual(memio.getvalue(), buf) memio.write(self.EOF) self.assertEqual(memio.getvalue(), buf) memio.write(buf) self.assertEqual(memio.getvalue(), buf + self.buftype('\0') + buf) def test_tell(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.tell(), 0) memio.seek(5) self.assertEqual(memio.tell(), 5) memio.seek(10000) self.assertEqual(memio.tell(), 10000) memio.close() self.assertRaises(ValueError, memio.tell) def test_flush(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.flush(), None) def test_flags(self): memio = self.ioclass() self.assertEqual(memio.writable(), True) self.assertEqual(memio.readable(), True) self.assertEqual(memio.seekable(), True) self.assertEqual(memio.isatty(), False) self.assertEqual(memio.closed, False) memio.close() self.assertRaises(ValueError, memio.writable) self.assertRaises(ValueError, memio.readable) self.assertRaises(ValueError, memio.seekable) self.assertRaises(ValueError, memio.isatty) self.assertEqual(memio.closed, True) def test_subclassing(self): buf = self.buftype("1234567890") def test1(): class MemIO(self.ioclass): pass m = MemIO(buf) return m.getvalue() def test2(): class MemIO(self.ioclass): def __init__(me, a, b): self.ioclass.__init__(me, a) m = MemIO(buf, None) return m.getvalue() self.assertEqual(test1(), buf) self.assertEqual(test2(), buf) def test_instance_dict_leak(self): # Test case for issue #6242. # This will be caught by regrtest.py -R if this leak. for _ in range(100): memio = self.ioclass() memio.foo = 1 def test_pickling(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) memio.foo = 42 memio.seek(2) class PickleTestMemIO(self.ioclass): def __init__(me, initvalue, foo): self.ioclass.__init__(me, initvalue) me.foo = foo # __getnewargs__ is undefined on purpose. This checks that PEP 307 # is used to provide pickling support. # Pickle expects the class to be on the module level. Here we use a # little hack to allow the PickleTestMemIO class to derive from # self.ioclass without having to define all combinations explicitly on # the module-level. import __main__ PickleTestMemIO.__module__ = '__main__' PickleTestMemIO.__qualname__ = PickleTestMemIO.__name__ __main__.PickleTestMemIO = PickleTestMemIO submemio = PickleTestMemIO(buf, 80) submemio.seek(2) # We only support pickle protocol 2 and onward since we use extended # __reduce__ API of PEP 307 to provide pickling support. for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): for obj in (memio, submemio): obj2 = pickle.loads(pickle.dumps(obj, protocol=proto)) self.assertEqual(obj.getvalue(), obj2.getvalue()) self.assertEqual(obj.__class__, obj2.__class__) self.assertEqual(obj.foo, obj2.foo) self.assertEqual(obj.tell(), obj2.tell()) obj2.close() self.assertRaises(ValueError, pickle.dumps, obj2, proto) del __main__.PickleTestMemIO class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase): # Test _pyio.BytesIO; class also inherited for testing C implementation UnsupportedOperation = pyio.UnsupportedOperation @staticmethod def buftype(s): return s.encode("ascii") ioclass = pyio.BytesIO EOF = b"" def test_getbuffer(self): memio = self.ioclass(b"1234567890") buf = memio.getbuffer() self.assertEqual(bytes(buf), b"1234567890") memio.seek(5) buf = memio.getbuffer() self.assertEqual(bytes(buf), b"1234567890") # Trying to change the size of the BytesIO while a buffer is exported # raises a BufferError. self.assertRaises(BufferError, memio.write, b'x' * 100) self.assertRaises(BufferError, memio.truncate) self.assertRaises(BufferError, memio.close) self.assertFalse(memio.closed) # Mutating the buffer updates the BytesIO buf[3:6] = b"abc" self.assertEqual(bytes(buf), b"123abc7890") self.assertEqual(memio.getvalue(), b"123abc7890") # After the buffer gets released, we can resize and close the BytesIO # again del buf support.gc_collect() memio.truncate() memio.close() self.assertRaises(ValueError, memio.getbuffer) def test_read1(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertRaises(TypeError, memio.read1) self.assertEqual(memio.read(), buf) def test_readinto(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) b = bytearray(b"hello") self.assertEqual(memio.readinto(b), 5) self.assertEqual(b, b"12345") self.assertEqual(memio.readinto(b), 5) self.assertEqual(b, b"67890") self.assertEqual(memio.readinto(b), 0) self.assertEqual(b, b"67890") b = bytearray(b"hello world") memio.seek(0) self.assertEqual(memio.readinto(b), 10) self.assertEqual(b, b"1234567890d") b = bytearray(b"") memio.seek(0) self.assertEqual(memio.readinto(b), 0) self.assertEqual(b, b"") self.assertRaises(TypeError, memio.readinto, '') import array a = array.array('b', b"hello world") memio = self.ioclass(buf) memio.readinto(a) self.assertEqual(a.tobytes(), b"1234567890d") memio.close() self.assertRaises(ValueError, memio.readinto, b) memio = self.ioclass(b"123") b = bytearray() memio.seek(42) memio.readinto(b) self.assertEqual(b, b"") def test_relative_seek(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) self.assertEqual(memio.seek(-1, 1), 0) self.assertEqual(memio.seek(3, 1), 3) self.assertEqual(memio.seek(-4, 1), 0) self.assertEqual(memio.seek(-1, 2), 9) self.assertEqual(memio.seek(1, 1), 10) self.assertEqual(memio.seek(1, 2), 11) memio.seek(-3, 2) self.assertEqual(memio.read(), buf[-3:]) memio.seek(0) memio.seek(1, 1) self.assertEqual(memio.read(), buf[1:]) def test_unicode(self): memio = self.ioclass() self.assertRaises(TypeError, self.ioclass, "1234567890") self.assertRaises(TypeError, memio.write, "1234567890") self.assertRaises(TypeError, memio.writelines, ["1234567890"]) def test_bytes_array(self): buf = b"1234567890" import array a = array.array('b', list(buf)) memio = self.ioclass(a) self.assertEqual(memio.getvalue(), buf) self.assertEqual(memio.write(a), 10) self.assertEqual(memio.getvalue(), buf) def test_issue5449(self): buf = self.buftype("1234567890") self.ioclass(initial_bytes=buf) self.assertRaises(TypeError, self.ioclass, buf, foo=None) class TextIOTestMixin: def test_newlines_property(self): memio = self.ioclass(newline=None) # The C StringIO decodes newlines in write() calls, but the Python # implementation only does when reading. This function forces them to # be decoded for testing. def force_decode(): memio.seek(0) memio.read() self.assertEqual(memio.newlines, None) memio.write("a\n") force_decode() self.assertEqual(memio.newlines, "\n") memio.write("b\r\n") force_decode() self.assertEqual(memio.newlines, ("\n", "\r\n")) memio.write("c\rd") force_decode() self.assertEqual(memio.newlines, ("\r", "\n", "\r\n")) def test_relative_seek(self): memio = self.ioclass() self.assertRaises(OSError, memio.seek, -1, 1) self.assertRaises(OSError, memio.seek, 3, 1) self.assertRaises(OSError, memio.seek, -3, 1) self.assertRaises(OSError, memio.seek, -1, 2) self.assertRaises(OSError, memio.seek, 1, 1) self.assertRaises(OSError, memio.seek, 1, 2) def test_textio_properties(self): memio = self.ioclass() # These are just dummy values but we nevertheless check them for fear # of unexpected breakage. self.assertIsNone(memio.encoding) self.assertIsNone(memio.errors) self.assertFalse(memio.line_buffering) def test_newline_default(self): memio = self.ioclass("a\nb\r\nc\rd") self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") memio = self.ioclass() self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) memio.seek(0) self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") def test_newline_none(self): # newline=None memio = self.ioclass("a\nb\r\nc\rd", newline=None) self.assertEqual(list(memio), ["a\n", "b\n", "c\n", "d"]) memio.seek(0) self.assertEqual(memio.read(1), "a") self.assertEqual(memio.read(2), "\nb") self.assertEqual(memio.read(2), "\nc") self.assertEqual(memio.read(1), "\n") self.assertEqual(memio.getvalue(), "a\nb\nc\nd") memio = self.ioclass(newline=None) self.assertEqual(2, memio.write("a\n")) self.assertEqual(3, memio.write("b\r\n")) self.assertEqual(3, memio.write("c\rd")) memio.seek(0) self.assertEqual(memio.read(), "a\nb\nc\nd") self.assertEqual(memio.getvalue(), "a\nb\nc\nd") memio = self.ioclass("a\r\nb", newline=None) self.assertEqual(memio.read(3), "a\nb") def test_newline_empty(self): # newline="" memio = self.ioclass("a\nb\r\nc\rd", newline="") self.assertEqual(list(memio), ["a\n", "b\r\n", "c\r", "d"]) memio.seek(0) self.assertEqual(memio.read(4), "a\nb\r") self.assertEqual(memio.read(2), "\nc") self.assertEqual(memio.read(1), "\r") self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") memio = self.ioclass(newline="") self.assertEqual(2, memio.write("a\n")) self.assertEqual(2, memio.write("b\r")) self.assertEqual(2, memio.write("\nc")) self.assertEqual(2, memio.write("\rd")) memio.seek(0) self.assertEqual(list(memio), ["a\n", "b\r\n", "c\r", "d"]) self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") def test_newline_lf(self): # newline="\n" memio = self.ioclass("a\nb\r\nc\rd", newline="\n") self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") memio = self.ioclass(newline="\n") self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) memio.seek(0) self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") def test_newline_cr(self): # newline="\r" memio = self.ioclass("a\nb\r\nc\rd", newline="\r") self.assertEqual(memio.read(), "a\rb\r\rc\rd") memio.seek(0) self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"]) self.assertEqual(memio.getvalue(), "a\rb\r\rc\rd") memio = self.ioclass(newline="\r") self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) memio.seek(0) self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"]) memio.seek(0) self.assertEqual(memio.readlines(), ["a\r", "b\r", "\r", "c\r", "d"]) self.assertEqual(memio.getvalue(), "a\rb\r\rc\rd") def test_newline_crlf(self): # newline="\r\n" memio = self.ioclass("a\nb\r\nc\rd", newline="\r\n") self.assertEqual(memio.read(), "a\r\nb\r\r\nc\rd") memio.seek(0) self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"]) memio.seek(0) self.assertEqual(memio.readlines(), ["a\r\n", "b\r\r\n", "c\rd"]) self.assertEqual(memio.getvalue(), "a\r\nb\r\r\nc\rd") memio = self.ioclass(newline="\r\n") self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) memio.seek(0) self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"]) self.assertEqual(memio.getvalue(), "a\r\nb\r\r\nc\rd") def test_issue5265(self): # StringIO can duplicate newlines in universal newlines mode memio = self.ioclass("a\r\nb\r\n", newline=None) self.assertEqual(memio.read(5), "a\nb\n") self.assertEqual(memio.getvalue(), "a\nb\n") def test_newline_argument(self): self.assertRaises(TypeError, self.ioclass, newline=b"\n") self.assertRaises(ValueError, self.ioclass, newline="error") # These should not raise an error for newline in (None, "", "\n", "\r", "\r\n"): self.ioclass(newline=newline) class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, TextIOTestMixin, unittest.TestCase): buftype = str ioclass = pyio.StringIO UnsupportedOperation = pyio.UnsupportedOperation EOF = "" def test_lone_surrogates(self): # Issue #20424 memio = self.ioclass('\ud800') self.assertEqual(memio.read(), '\ud800') memio = self.ioclass() memio.write('\ud800') self.assertEqual(memio.getvalue(), '\ud800') class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase): """Test if pickle restores properly the internal state of StringIO. """ buftype = str UnsupportedOperation = pyio.UnsupportedOperation EOF = "" class ioclass(pyio.StringIO): def __new__(cls, *args, **kwargs): return pickle.loads(pickle.dumps(pyio.StringIO(*args, **kwargs))) def __init__(self, *args, **kwargs): pass class CBytesIOTest(PyBytesIOTest): ioclass = io.BytesIO UnsupportedOperation = io.UnsupportedOperation def test_getstate(self): memio = self.ioclass() state = memio.__getstate__() self.assertEqual(len(state), 3) bytearray(state[0]) # Check if state[0] supports the buffer interface. self.assertIsInstance(state[1], int) if state[2] is not None: self.assertIsInstance(state[2], dict) memio.close() self.assertRaises(ValueError, memio.__getstate__) def test_setstate(self): # This checks whether __setstate__ does proper input validation. memio = self.ioclass() memio.__setstate__((b"no error", 0, None)) memio.__setstate__((bytearray(b"no error"), 0, None)) memio.__setstate__((b"no error", 0, {'spam': 3})) self.assertRaises(ValueError, memio.__setstate__, (b"", -1, None)) self.assertRaises(TypeError, memio.__setstate__, ("unicode", 0, None)) self.assertRaises(TypeError, memio.__setstate__, (b"", 0.0, None)) self.assertRaises(TypeError, memio.__setstate__, (b"", 0, 0)) self.assertRaises(TypeError, memio.__setstate__, (b"len-test", 0)) self.assertRaises(TypeError, memio.__setstate__) self.assertRaises(TypeError, memio.__setstate__, 0) memio.close() self.assertRaises(ValueError, memio.__setstate__, (b"closed", 0, None)) check_sizeof = support.check_sizeof @support.cpython_only def test_sizeof(self): basesize = support.calcobjsize('P2n2Pn') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) n = 1000 # use a variable to prevent constant folding check(io.BytesIO(b'a' * n), basesize + sys.getsizeof(b'a' * n)) # Various tests of copy-on-write behaviour for BytesIO. def _test_cow_mutation(self, mutation): # Common code for all BytesIO copy-on-write mutation tests. imm = b' ' * 1024 old_rc = sys.getrefcount(imm) memio = self.ioclass(imm) self.assertEqual(sys.getrefcount(imm), old_rc + 1) mutation(memio) self.assertEqual(sys.getrefcount(imm), old_rc) @support.cpython_only def test_cow_truncate(self): # Ensure truncate causes a copy. def mutation(memio): memio.truncate(1) self._test_cow_mutation(mutation) @support.cpython_only def test_cow_write(self): # Ensure write that would not cause a resize still results in a copy. def mutation(memio): memio.seek(0) memio.write(b'foo') self._test_cow_mutation(mutation) @support.cpython_only def test_cow_setstate(self): # __setstate__ should cause buffer to be released. memio = self.ioclass(b'foooooo') state = memio.__getstate__() def mutation(memio): memio.__setstate__(state) self._test_cow_mutation(mutation) @support.cpython_only def test_cow_mutable(self): # BytesIO should accept only Bytes for copy-on-write sharing, since # arbitrary buffer-exporting objects like bytearray() aren't guaranteed # to be immutable. ba = bytearray(1024) old_rc = sys.getrefcount(ba) memio = self.ioclass(ba) self.assertEqual(sys.getrefcount(ba), old_rc) class CStringIOTest(PyStringIOTest): ioclass = io.StringIO UnsupportedOperation = io.UnsupportedOperation # XXX: For the Python version of io.StringIO, this is highly # dependent on the encoding used for the underlying buffer. def test_widechar(self): buf = self.buftype("\U0002030a\U00020347") memio = self.ioclass(buf) self.assertEqual(memio.getvalue(), buf) self.assertEqual(memio.write(buf), len(buf)) self.assertEqual(memio.tell(), len(buf)) self.assertEqual(memio.getvalue(), buf) self.assertEqual(memio.write(buf), len(buf)) self.assertEqual(memio.tell(), len(buf) * 2) self.assertEqual(memio.getvalue(), buf + buf) def test_getstate(self): memio = self.ioclass() state = memio.__getstate__() self.assertEqual(len(state), 4) self.assertIsInstance(state[0], str) self.assertIsInstance(state[1], str) self.assertIsInstance(state[2], int) if state[3] is not None: self.assertIsInstance(state[3], dict) memio.close() self.assertRaises(ValueError, memio.__getstate__) def test_setstate(self): # This checks whether __setstate__ does proper input validation. memio = self.ioclass() memio.__setstate__(("no error", "\n", 0, None)) memio.__setstate__(("no error", "", 0, {'spam': 3})) self.assertRaises(ValueError, memio.__setstate__, ("", "f", 0, None)) self.assertRaises(ValueError, memio.__setstate__, ("", "", -1, None)) self.assertRaises(TypeError, memio.__setstate__, (b"", "", 0, None)) self.assertRaises(TypeError, memio.__setstate__, ("", b"", 0, None)) self.assertRaises(TypeError, memio.__setstate__, ("", "", 0.0, None)) self.assertRaises(TypeError, memio.__setstate__, ("", "", 0, 0)) self.assertRaises(TypeError, memio.__setstate__, ("len-test", 0)) self.assertRaises(TypeError, memio.__setstate__) self.assertRaises(TypeError, memio.__setstate__, 0) memio.close() self.assertRaises(ValueError, memio.__setstate__, ("closed", "", 0, None)) class CStringIOPickleTest(PyStringIOPickleTest): UnsupportedOperation = io.UnsupportedOperation class ioclass(io.StringIO): def __new__(cls, *args, **kwargs): return pickle.loads(pickle.dumps(io.StringIO(*args, **kwargs))) def __init__(self, *args, **kwargs): pass if __name__ == '__main__': unittest.main()
31,021
844
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_copyreg.py
import copyreg import unittest from test.pickletester import ExtensionSaver class C: pass class WithoutSlots(object): pass class WithWeakref(object): __slots__ = ('__weakref__',) class WithPrivate(object): __slots__ = ('__spam',) class _WithLeadingUnderscoreAndPrivate(object): __slots__ = ('__spam',) class ___(object): __slots__ = ('__spam',) class WithSingleString(object): __slots__ = 'spam' class WithInherited(WithSingleString): __slots__ = ('eggs',) class CopyRegTestCase(unittest.TestCase): def test_class(self): self.assertRaises(TypeError, copyreg.pickle, C, None, None) def test_noncallable_reduce(self): self.assertRaises(TypeError, copyreg.pickle, type(1), "not a callable") def test_noncallable_constructor(self): self.assertRaises(TypeError, copyreg.pickle, type(1), int, "not a callable") def test_bool(self): import copy self.assertEqual(True, copy.copy(True)) def test_extension_registry(self): mod, func, code = 'junk1 ', ' junk2', 0xabcd e = ExtensionSaver(code) try: # Shouldn't be in registry now. self.assertRaises(ValueError, copyreg.remove_extension, mod, func, code) copyreg.add_extension(mod, func, code) # Should be in the registry. self.assertTrue(copyreg._extension_registry[mod, func] == code) self.assertTrue(copyreg._inverted_registry[code] == (mod, func)) # Shouldn't be in the cache. self.assertNotIn(code, copyreg._extension_cache) # Redundant registration should be OK. copyreg.add_extension(mod, func, code) # shouldn't blow up # Conflicting code. self.assertRaises(ValueError, copyreg.add_extension, mod, func, code + 1) self.assertRaises(ValueError, copyreg.remove_extension, mod, func, code + 1) # Conflicting module name. self.assertRaises(ValueError, copyreg.add_extension, mod[1:], func, code ) self.assertRaises(ValueError, copyreg.remove_extension, mod[1:], func, code ) # Conflicting function name. self.assertRaises(ValueError, copyreg.add_extension, mod, func[1:], code) self.assertRaises(ValueError, copyreg.remove_extension, mod, func[1:], code) # Can't remove one that isn't registered at all. if code + 1 not in copyreg._inverted_registry: self.assertRaises(ValueError, copyreg.remove_extension, mod[1:], func[1:], code + 1) finally: e.restore() # Shouldn't be there anymore. self.assertNotIn((mod, func), copyreg._extension_registry) # The code *may* be in copyreg._extension_registry, though, if # we happened to pick on a registered code. So don't check for # that. # Check valid codes at the limits. for code in 1, 0x7fffffff: e = ExtensionSaver(code) try: copyreg.add_extension(mod, func, code) copyreg.remove_extension(mod, func, code) finally: e.restore() # Ensure invalid codes blow up. for code in -1, 0, 0x80000000: self.assertRaises(ValueError, copyreg.add_extension, mod, func, code) def test_slotnames(self): self.assertEqual(copyreg._slotnames(WithoutSlots), []) self.assertEqual(copyreg._slotnames(WithWeakref), []) expected = ['_WithPrivate__spam'] self.assertEqual(copyreg._slotnames(WithPrivate), expected) expected = ['_WithLeadingUnderscoreAndPrivate__spam'] self.assertEqual(copyreg._slotnames(_WithLeadingUnderscoreAndPrivate), expected) self.assertEqual(copyreg._slotnames(___), ['__spam']) self.assertEqual(copyreg._slotnames(WithSingleString), ['spam']) expected = ['eggs', 'spam'] expected.sort() result = copyreg._slotnames(WithInherited) result.sort() self.assertEqual(result, expected) if __name__ == "__main__": unittest.main()
4,498
127
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_enumerate.py
import unittest import operator import sys import pickle from test import support class G: 'Sequence using __getitem__' def __init__(self, seqn): self.seqn = seqn def __getitem__(self, i): return self.seqn[i] class I: 'Sequence using iterator protocol' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 return v class Ig: 'Sequence using iterator protocol defined with a generator' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): for val in self.seqn: yield val class X: 'Missing __getitem__ and __iter__' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 return v class E: 'Test propagation of exceptions' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self def __next__(self): 3 // 0 class N: 'Iterator missing __next__()' def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): return self class PickleTest: # Helper to check picklability def check_pickle(self, itorg, seq): for proto in range(pickle.HIGHEST_PROTOCOL + 1): d = pickle.dumps(itorg, proto) it = pickle.loads(d) self.assertEqual(type(itorg), type(it)) self.assertEqual(list(it), seq) it = pickle.loads(d) try: next(it) except StopIteration: self.assertFalse(seq[1:]) continue d = pickle.dumps(it, proto) it = pickle.loads(d) self.assertEqual(list(it), seq[1:]) class EnumerateTestCase(unittest.TestCase, PickleTest): enum = enumerate seq, res = 'abc', [(0,'a'), (1,'b'), (2,'c')] def test_basicfunction(self): self.assertEqual(type(self.enum(self.seq)), self.enum) e = self.enum(self.seq) self.assertEqual(iter(e), e) self.assertEqual(list(self.enum(self.seq)), self.res) self.enum.__doc__ def test_pickle(self): self.check_pickle(self.enum(self.seq), self.res) def test_getitemseqn(self): self.assertEqual(list(self.enum(G(self.seq))), self.res) e = self.enum(G('')) self.assertRaises(StopIteration, next, e) def test_iteratorseqn(self): self.assertEqual(list(self.enum(I(self.seq))), self.res) e = self.enum(I('')) self.assertRaises(StopIteration, next, e) def test_iteratorgenerator(self): self.assertEqual(list(self.enum(Ig(self.seq))), self.res) e = self.enum(Ig('')) self.assertRaises(StopIteration, next, e) def test_noniterable(self): self.assertRaises(TypeError, self.enum, X(self.seq)) def test_illformediterable(self): self.assertRaises(TypeError, self.enum, N(self.seq)) def test_exception_propagation(self): self.assertRaises(ZeroDivisionError, list, self.enum(E(self.seq))) def test_argumentcheck(self): self.assertRaises(TypeError, self.enum) # no arguments self.assertRaises(TypeError, self.enum, 1) # wrong type (not iterable) self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments @support.cpython_only def test_tuple_reuse(self): # Tests an implementation detail where tuple is reused # whenever nothing else holds a reference to it self.assertEqual(len(set(map(id, list(enumerate(self.seq))))), len(self.seq)) self.assertEqual(len(set(map(id, enumerate(self.seq)))), min(1,len(self.seq))) class MyEnum(enumerate): pass class SubclassTestCase(EnumerateTestCase): enum = MyEnum class TestEmpty(EnumerateTestCase): seq, res = '', [] class TestBig(EnumerateTestCase): seq = range(10,20000,2) res = list(zip(range(20000), seq)) class TestReversed(unittest.TestCase, PickleTest): def test_simple(self): class A: def __getitem__(self, i): if i < 5: return str(i) raise StopIteration def __len__(self): return 5 for data in 'abc', range(5), tuple(enumerate('abc')), A(), range(1,17,5): self.assertEqual(list(data)[::-1], list(reversed(data))) self.assertRaises(TypeError, reversed, {}) # don't allow keyword arguments self.assertRaises(TypeError, reversed, [], a=1) def test_range_optimization(self): x = range(1) self.assertEqual(type(reversed(x)), type(iter(x))) def test_len(self): for s in ('hello', tuple('hello'), list('hello'), range(5)): self.assertEqual(operator.length_hint(reversed(s)), len(s)) r = reversed(s) list(r) self.assertEqual(operator.length_hint(r), 0) class SeqWithWeirdLen: called = False def __len__(self): if not self.called: self.called = True return 10 raise ZeroDivisionError def __getitem__(self, index): return index r = reversed(SeqWithWeirdLen()) self.assertRaises(ZeroDivisionError, operator.length_hint, r) def test_gc(self): class Seq: def __len__(self): return 10 def __getitem__(self, index): return index s = Seq() r = reversed(s) s.r = r def test_args(self): self.assertRaises(TypeError, reversed) self.assertRaises(TypeError, reversed, [], 'extra') @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') def test_bug1229429(self): # this bug was never in reversed, it was in # PyObject_CallMethod, and reversed_new calls that sometimes. def f(): pass r = f.__reversed__ = object() rc = sys.getrefcount(r) for i in range(10): try: reversed(f) except TypeError: pass else: self.fail("non-callable __reversed__ didn't raise!") self.assertEqual(rc, sys.getrefcount(r)) def test_objmethods(self): # Objects must have __len__() and __getitem__() implemented. class NoLen(object): def __getitem__(self, i): return 1 nl = NoLen() self.assertRaises(TypeError, reversed, nl) class NoGetItem(object): def __len__(self): return 2 ngi = NoGetItem() self.assertRaises(TypeError, reversed, ngi) class Blocked(object): def __getitem__(self, i): return 1 def __len__(self): return 2 __reversed__ = None b = Blocked() self.assertRaises(TypeError, reversed, b) def test_pickle(self): for data in 'abc', range(5), tuple(enumerate('abc')), range(1,17,5): self.check_pickle(reversed(data), list(data)[::-1]) class EnumerateStartTestCase(EnumerateTestCase): def test_basicfunction(self): e = self.enum(self.seq) self.assertEqual(iter(e), e) self.assertEqual(list(self.enum(self.seq)), self.res) class TestStart(EnumerateStartTestCase): enum = lambda self, i: enumerate(i, start=11) seq, res = 'abc', [(11, 'a'), (12, 'b'), (13, 'c')] class TestLongStart(EnumerateStartTestCase): enum = lambda self, i: enumerate(i, start=sys.maxsize+1) seq, res = 'abc', [(sys.maxsize+1,'a'), (sys.maxsize+2,'b'), (sys.maxsize+3,'c')] if __name__ == "__main__": unittest.main()
8,087
270
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/sgml_input.html
<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <link rel="stylesheet" type="text/css" href="http://ogame182.de/epicblue/formate.css"> <script language="JavaScript" src="js/flotten.js"></script> </head> <body> <script language=JavaScript> if (parent.frames.length == 0) { top.location.href = "http://es.ogame.org/"; } </script> <script language="JavaScript"> function haha(z1) { eval("location='"+z1.options[z1.selectedIndex].value+"'"); } </script> <center> <table> <tr> <td></td> <td> <center> <table> <tr> <td><img src="http://ogame182.de/epicblue/planeten/small/s_dschjungelplanet04.jpg" width="50" height="50"></td> <td> <table border="1"> <select size="1" onchange="haha(this)"> <option value="/game/flotten1.php?session=8912ae912fec&cp=33875341&mode=Flotte&gid=&messageziel=&re=0" selected>Alien sex friend [2:250:6]</option> <option value="/game/flotten1.php?session=8912ae912fec&cp=33905100&mode=Flotte&gid=&messageziel=&re=0" >1989 [2:248:14]</option> <option value="/game/flotten1.php?session=8912ae912fec&cp=34570808&mode=Flotte&gid=&messageziel=&re=0" >1990 [2:248:6]</option> <option value="/game/flotten1.php?session=8912ae912fec&cp=34570858&mode=Flotte&gid=&messageziel=&re=0" >1991 [2:254:6]</option> <option value="/game/flotten1.php?session=8912ae912fec&cp=34572929&mode=Flotte&gid=&messageziel=&re=0" >Colonia [2:253:12]</option> </select> </table> </td> </tr> </table> </center> </td> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center"></td> <td align="center" width="85"> <img border="0" src="http://ogame182.de/epicblue/images/metall.gif" width="42" height="22"> </td> <td align="center" width="85"> <img border="0" src="http://ogame182.de/epicblue/images/kristall.gif" width="42" height="22"> </td> <td align="center" width="85"> <img border="0" src="http://ogame182.de/epicblue/images/deuterium.gif" width="42" height="22"> </td> <td align="center" width="85"> <img border="0" src="http://ogame182.de/epicblue/images/energie.gif" width="42" height="22"> </td> <td align="center"></td> </tr> <tr> <td align="center"><i><b>&nbsp;&nbsp;</b></i></td> <td align="center" width="85"><i><b><font color="#ffffff">Metal</font></b></i></td> <td align="center" width="85"><i><b><font color="#ffffff">Cristal</font></b></i></td> <td align="center" width="85"><i><b><font color="#ffffff">Deuterio</font></b></i></td> <td align="center" width="85"><i><b><font color="#ffffff">Energía</font></b></i></td> <td align="center"><i><b>&nbsp;&nbsp;</b></i></td> </tr> <tr> <td align="center"></td> <td align="center" width="85">160.636</td> <td align="center" width="85">3.406</td> <td align="center" width="85">39.230</td> <td align="center" width="85"><font color=#ff0000>-80</font>/3.965</td> <td align="center"></td> </tr> </table> </tr> </table> </center> <br /> <script language="JavaScript"> <!-- function link_to_gamepay() { self.location = "https://www.gamepay.de/?lang=es&serverID=8&userID=129360&gameID=ogame&gui=v2&chksum=a9751afa9e37e6b1b826356bcca45675"; } //--> </script> <center> <table width="519" border="0" cellpadding="0" cellspacing="1"> <tr height="20"> <td colspan="8" class="c">Flotas (max. 9)</td> </tr> <tr height="20"> <th>Num.</th> <th>Misión</th> <th>Cantidad</th> <th>Comienzo</th> <th>Salida</th> <th>Objetivo</th> <th>Llegada</th> <th>Orden</th> </tr> <tr height="20"> <th>1</th> <th> <a title="">Espionaje</a> <a title="Flota en el planeta">(F)</a> </th> <th> <a title="Sonda de espionaje: 3 ">3</a></th> <th>[2:250:6]</th> <th>Wed Aug 9 18:00:02</th> <th>[2:242:5]</th> <th>Wed Aug 9 18:01:02</th> <th> <form action="flotten1.php?session=8912ae912fec" method="POST"> <input type="hidden" name="order_return" value="25054490" /> <input type="submit" value="Enviar de regreso" /> </form> </th> </tr> <tr height="20"> <th>2</th> <th> <a title="">Espionaje</a> <a title="Volver al planeta">(V)</a> </th> <th> <a title="Sonda de espionaje: 3 ">3</a></th> <th>[2:250:6]</th> <th>Wed Aug 9 17:59:55</th> <th>[2:242:1]</th> <th>Wed Aug 9 18:01:55</th> <th> </th> </tr> </table> <form action="flotten2.php?session=8912ae912fec" method="POST"> <table width="519" border="0" cellpadding="0" cellspacing="1"> <tr height="20"> <td colspan="4" class="c">Nueva misión: elegir naves</td> </tr> <tr height="20"> <th>Naves</th> <th>Disponibles</th> <!-- <th>Gesch.</th> --> <th>-</th> <th>-</th> </tr> <tr height="20"> <th><a title="Velocidad: 8500">Nave pequeña de carga</a></th> <th>10<input type="hidden" name="maxship202" value="10"/></th> <!-- <th>8500 --> <input type="hidden" name="consumption202" value="10"/> <input type="hidden" name="speed202" value="8500" /></th> <input type="hidden" name="capacity202" value="5000" /></th> <th><a href="javascript:maxShip('ship202');" >máx</a> </th> <th><input name="ship202" size="10" value="0" alt="Nave pequeña de carga 10"/></th> </tr> <tr height="20"> <th><a title="Velocidad: 12750">Nave grande de carga</a></th> <th>19<input type="hidden" name="maxship203" value="19"/></th> <!-- <th>12750 --> <input type="hidden" name="consumption203" value="50"/> <input type="hidden" name="speed203" value="12750" /></th> <input type="hidden" name="capacity203" value="25000" /></th> <th><a href="javascript:maxShip('ship203');" >máx</a> </th> <th><input name="ship203" size="10" value="0" alt="Nave grande de carga 19"/></th> </tr> <tr height="20"> <th><a title="Velocidad: 27000">Crucero</a></th> <th>6<input type="hidden" name="maxship206" value="6"/></th> <!-- <th>27000 --> <input type="hidden" name="consumption206" value="300"/> <input type="hidden" name="speed206" value="27000" /></th> <input type="hidden" name="capacity206" value="800" /></th> <th><a href="javascript:maxShip('ship206');" >máx</a> </th> <th><input name="ship206" size="10" value="0" alt="Crucero 6"/></th> </tr> <tr height="20"> <th><a title="Velocidad: 3400">Reciclador</a></th> <th>1<input type="hidden" name="maxship209" value="1"/></th> <!-- <th>3400 --> <input type="hidden" name="consumption209" value="300"/> <input type="hidden" name="speed209" value="3400" /></th> <input type="hidden" name="capacity209" value="20000" /></th> <th><a href="javascript:maxShip('ship209');" >máx</a> </th> <th><input name="ship209" size="10" value="0" alt="Reciclador 1"/></th> </tr> <tr height="20"> <th><a title="Velocidad: 170000000">Sonda de espionaje</a></th> <th>139<input type="hidden" name="maxship210" value="139"/></th> <!-- <th>170000000 --> <input type="hidden" name="consumption210" value="1"/> <input type="hidden" name="speed210" value="170000000" /></th> <input type="hidden" name="capacity210" value="5" /></th> <th><a href="javascript:maxShip('ship210');" >máx</a> </th> <th><input name="ship210" size="10" value="0" alt="Sonda de espionaje 139"/></th> </tr> <tr height="20"> <th colspan="2"><a href="javascript:noShips();" >Ninguna nave</a></th> <th colspan="2"><a href="javascript:maxShips();" >Todas las naves</a></th> </tr> <tr height="20"> <th colspan="4"><input type="submit" value="Continuar" /></th> </tr> <tr><th colspan=4> <iframe id='a44fb522' name='a44fb522' src='http://ads.gameforgeads.de/adframe.php?n=a44fb522&amp;what=zone:578' framespacing='0' frameborder='no' scrolling='no' width='468' height='60'></iframe> <br><center></center></br> </th></tr> </form> </table> </body> </html>
8,294
213
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/JOHAB.TXT
# # Name: Johab to Unicode table # Unicode version: 2.0 # Table version: 1.1 # Table format: Format A # Date: 2011 October 14 # Authors: Jungshik Shin at [email protected] # # Copyright (c) 1999-2011 Unicode, Inc. All Rights reserved. # # This file is provided as-is by Unicode, Inc. (The Unicode Consortium). # No claims are made as to fitness for any particular purpose. No # warranties of any kind are expressed or implied. The recipient # agrees to determine applicability of information provided. If this # file has been provided on magnetic media by Unicode, Inc., the sole # remedy for any claim will be exchange of defective media within 90 # days of receipt. # # Unicode, Inc. hereby grants the right to freely use the information # supplied in this file in the creation of products supporting the # Unicode Standard, and to make copies of this file in any form for # internal or external distribution as long as this notice remains # attached. # # General notes: # # Johab encoding is specified in KS X 1001:1997(formerly # KS C 5601-1992) Annex 3 as a supplementary encoding. # # 1. Hangul # 1st byte : 0x84-0xd3 # 2nd byte : 0x41-0x7e, 0x81-0xfe # 2. Hanja & Symbol : # (can be arithmetically translated from KS X 1001 position) # 1st byte : 0xd8-0xde, 0xe0-0xf9 # 2nd byte : 0x31-0x7e, 0x91-0xfe # 0xd831-0xd87e and 0xd891-0xd8fe are user-defined area # # 3. KS X 1003(formely KS C 5636)/ISO 646-KR or US-ASCII (1byte) # : 0x21-0x7e # KS X 1003 is identical to US-ASCII except for WON SIGN, U20A9 # in place of BACK SLASH, U005C at 0x5C # NOTE : # # It's not clear JOHAB encoding should have BACK SLASH(U005C) # or WON SIGN(U20A9) at 0x5C in 1byte range. # This file Korean WON SIGN(U20A9) is used, # but using BACK SLASH(U005C) might be a better idea # # Format: # Column 1: JOHAB (specified as a supplementary encoding # in KS X 1001:1997, Annex 3) # Column 2: Unicode 2.0 # Column 3: Unicode name # # Revision History: # # [v1.1, 2011 October 14] # Updated terms of use to current wording. # Updated contact information. # No changes to the mapping data. # # [v1.0, 08/16/99] # First release. # # Use the Unicode reporting form <http://www.unicode.org/reporting.html> # for any questions or comments or to report errors in the data. # 20 0020 21 0021 22 0022 23 0023 24 0024 25 0025 26 0026 27 0027 28 0028 29 0029 2A 002A 2B 002B 2C 002C 2D 002D 2E 002E 2F 002F 30 0030 31 0031 32 0032 33 0033 34 0034 35 0035 36 0036 37 0037 38 0038 39 0039 3A 003A 3B 003B 3C 003C 3D 003D 3E 003E 3F 003F 40 0040 41 0041 42 0042 43 0043 44 0044 45 0045 46 0046 47 0047 48 0048 49 0049 4A 004A 4B 004B 4C 004C 4D 004D 4E 004E 4F 004F 50 0050 51 0051 52 0052 53 0053 54 0054 55 0055 56 0056 57 0057 58 0058 59 0059 5A 005A 5B 005B 5C 20A9 5D 005D 5E 005E 5F 005F 60 0060 61 0061 62 0062 63 0063 64 0064 65 0065 66 0066 67 0067 68 0068 69 0069 6A 006A 6B 006B 6C 006C 6D 006D 6E 006E 6F 006F 70 0070 71 0071 72 0072 73 0073 74 0074 75 0075 76 0076 77 0077 78 0078 79 0079 7A 007A 7B 007B 7C 007C 7D 007D 7E 007E 8444 3133 8446 3135 8447 3136 844A 313A 844B 313B 844C 313C 844D 313D 844E 313E 844F 313F 8450 3140 8454 3144 8461 314F 8481 3150 84A1 3151 84C1 3152 84E1 3153 8541 3154 8561 3155 8581 3156 85A1 3157 85C1 3158 85E1 3159 8641 315A 8661 315B 8681 315C 86A1 315D 86C1 315E 86E1 315F 8741 3160 8761 3161 8781 3162 87A1 3163 8841 3131 8861 AC00 8862 AC01 8863 AC02 8864 AC03 8865 AC04 8866 AC05 8867 AC06 8868 AC07 8869 AC08 886A AC09 886B AC0A 886C AC0B 886D AC0C 886E AC0D 886F AC0E 8870 AC0F 8871 AC10 8873 AC11 8874 AC12 8875 AC13 8876 AC14 8877 AC15 8878 AC16 8879 AC17 887A AC18 887B AC19 887C AC1A 887D AC1B 8881 AC1C 8882 AC1D 8883 AC1E 8884 AC1F 8885 AC20 8886 AC21 8887 AC22 8888 AC23 8889 AC24 888A AC25 888B AC26 888C AC27 888D AC28 888E AC29 888F AC2A 8890 AC2B 8891 AC2C 8893 AC2D 8894 AC2E 8895 AC2F 8896 AC30 8897 AC31 8898 AC32 8899 AC33 889A AC34 889B AC35 889C AC36 889D AC37 88A1 AC38 88A2 AC39 88A3 AC3A 88A4 AC3B 88A5 AC3C 88A6 AC3D 88A7 AC3E 88A8 AC3F 88A9 AC40 88AA AC41 88AB AC42 88AC AC43 88AD AC44 88AE AC45 88AF AC46 88B0 AC47 88B1 AC48 88B3 AC49 88B4 AC4A 88B5 AC4B 88B6 AC4C 88B7 AC4D 88B8 AC4E 88B9 AC4F 88BA AC50 88BB AC51 88BC AC52 88BD AC53 88C1 AC54 88C2 AC55 88C3 AC56 88C4 AC57 88C5 AC58 88C6 AC59 88C7 AC5A 88C8 AC5B 88C9 AC5C 88CA AC5D 88CB AC5E 88CC AC5F 88CD AC60 88CE AC61 88CF AC62 88D0 AC63 88D1 AC64 88D3 AC65 88D4 AC66 88D5 AC67 88D6 AC68 88D7 AC69 88D8 AC6A 88D9 AC6B 88DA AC6C 88DB AC6D 88DC AC6E 88DD AC6F 88E1 AC70 88E2 AC71 88E3 AC72 88E4 AC73 88E5 AC74 88E6 AC75 88E7 AC76 88E8 AC77 88E9 AC78 88EA AC79 88EB AC7A 88EC AC7B 88ED AC7C 88EE AC7D 88EF AC7E 88F0 AC7F 88F1 AC80 88F3 AC81 88F4 AC82 88F5 AC83 88F6 AC84 88F7 AC85 88F8 AC86 88F9 AC87 88FA AC88 88FB AC89 88FC AC8A 88FD AC8B 8941 AC8C 8942 AC8D 8943 AC8E 8944 AC8F 8945 AC90 8946 AC91 8947 AC92 8948 AC93 8949 AC94 894A AC95 894B AC96 894C AC97 894D AC98 894E AC99 894F AC9A 8950 AC9B 8951 AC9C 8953 AC9D 8954 AC9E 8955 AC9F 8956 ACA0 8957 ACA1 8958 ACA2 8959 ACA3 895A ACA4 895B ACA5 895C ACA6 895D ACA7 8961 ACA8 8962 ACA9 8963 ACAA 8964 ACAB 8965 ACAC 8966 ACAD 8967 ACAE 8968 ACAF 8969 ACB0 896A ACB1 896B ACB2 896C ACB3 896D ACB4 896E ACB5 896F ACB6 8970 ACB7 8971 ACB8 8973 ACB9 8974 ACBA 8975 ACBB 8976 ACBC 8977 ACBD 8978 ACBE 8979 ACBF 897A ACC0 897B ACC1 897C ACC2 897D ACC3 8981 ACC4 8982 ACC5 8983 ACC6 8984 ACC7 8985 ACC8 8986 ACC9 8987 ACCA 8988 ACCB 8989 ACCC 898A ACCD 898B ACCE 898C ACCF 898D ACD0 898E ACD1 898F ACD2 8990 ACD3 8991 ACD4 8993 ACD5 8994 ACD6 8995 ACD7 8996 ACD8 8997 ACD9 8998 ACDA 8999 ACDB 899A ACDC 899B ACDD 899C ACDE 899D ACDF 89A1 ACE0 89A2 ACE1 89A3 ACE2 89A4 ACE3 89A5 ACE4 89A6 ACE5 89A7 ACE6 89A8 ACE7 89A9 ACE8 89AA ACE9 89AB ACEA 89AC ACEB 89AD ACEC 89AE ACED 89AF ACEE 89B0 ACEF 89B1 ACF0 89B3 ACF1 89B4 ACF2 89B5 ACF3 89B6 ACF4 89B7 ACF5 89B8 ACF6 89B9 ACF7 89BA ACF8 89BB ACF9 89BC ACFA 89BD ACFB 89C1 ACFC 89C2 ACFD 89C3 ACFE 89C4 ACFF 89C5 AD00 89C6 AD01 89C7 AD02 89C8 AD03 89C9 AD04 89CA AD05 89CB AD06 89CC AD07 89CD AD08 89CE AD09 89CF AD0A 89D0 AD0B 89D1 AD0C 89D3 AD0D 89D4 AD0E 89D5 AD0F 89D6 AD10 89D7 AD11 89D8 AD12 89D9 AD13 89DA AD14 89DB AD15 89DC AD16 89DD AD17 89E1 AD18 89E2 AD19 89E3 AD1A 89E4 AD1B 89E5 AD1C 89E6 AD1D 89E7 AD1E 89E8 AD1F 89E9 AD20 89EA AD21 89EB AD22 89EC AD23 89ED AD24 89EE AD25 89EF AD26 89F0 AD27 89F1 AD28 89F3 AD29 89F4 AD2A 89F5 AD2B 89F6 AD2C 89F7 AD2D 89F8 AD2E 89F9 AD2F 89FA AD30 89FB AD31 89FC AD32 89FD AD33 8A41 AD34 8A42 AD35 8A43 AD36 8A44 AD37 8A45 AD38 8A46 AD39 8A47 AD3A 8A48 AD3B 8A49 AD3C 8A4A AD3D 8A4B AD3E 8A4C AD3F 8A4D AD40 8A4E AD41 8A4F AD42 8A50 AD43 8A51 AD44 8A53 AD45 8A54 AD46 8A55 AD47 8A56 AD48 8A57 AD49 8A58 AD4A 8A59 AD4B 8A5A AD4C 8A5B AD4D 8A5C AD4E 8A5D AD4F 8A61 AD50 8A62 AD51 8A63 AD52 8A64 AD53 8A65 AD54 8A66 AD55 8A67 AD56 8A68 AD57 8A69 AD58 8A6A AD59 8A6B AD5A 8A6C AD5B 8A6D AD5C 8A6E AD5D 8A6F AD5E 8A70 AD5F 8A71 AD60 8A73 AD61 8A74 AD62 8A75 AD63 8A76 AD64 8A77 AD65 8A78 AD66 8A79 AD67 8A7A AD68 8A7B AD69 8A7C AD6A 8A7D AD6B 8A81 AD6C 8A82 AD6D 8A83 AD6E 8A84 AD6F 8A85 AD70 8A86 AD71 8A87 AD72 8A88 AD73 8A89 AD74 8A8A AD75 8A8B AD76 8A8C AD77 8A8D AD78 8A8E AD79 8A8F AD7A 8A90 AD7B 8A91 AD7C 8A93 AD7D 8A94 AD7E 8A95 AD7F 8A96 AD80 8A97 AD81 8A98 AD82 8A99 AD83 8A9A AD84 8A9B AD85 8A9C AD86 8A9D AD87 8AA1 AD88 8AA2 AD89 8AA3 AD8A 8AA4 AD8B 8AA5 AD8C 8AA6 AD8D 8AA7 AD8E 8AA8 AD8F 8AA9 AD90 8AAA AD91 8AAB AD92 8AAC AD93 8AAD AD94 8AAE AD95 8AAF AD96 8AB0 AD97 8AB1 AD98 8AB3 AD99 8AB4 AD9A 8AB5 AD9B 8AB6 AD9C 8AB7 AD9D 8AB8 AD9E 8AB9 AD9F 8ABA ADA0 8ABB ADA1 8ABC ADA2 8ABD ADA3 8AC1 ADA4 8AC2 ADA5 8AC3 ADA6 8AC4 ADA7 8AC5 ADA8 8AC6 ADA9 8AC7 ADAA 8AC8 ADAB 8AC9 ADAC 8ACA ADAD 8ACB ADAE 8ACC ADAF 8ACD ADB0 8ACE ADB1 8ACF ADB2 8AD0 ADB3 8AD1 ADB4 8AD3 ADB5 8AD4 ADB6 8AD5 ADB7 8AD6 ADB8 8AD7 ADB9 8AD8 ADBA 8AD9 ADBB 8ADA ADBC 8ADB ADBD 8ADC ADBE 8ADD ADBF 8AE1 ADC0 8AE2 ADC1 8AE3 ADC2 8AE4 ADC3 8AE5 ADC4 8AE6 ADC5 8AE7 ADC6 8AE8 ADC7 8AE9 ADC8 8AEA ADC9 8AEB ADCA 8AEC ADCB 8AED ADCC 8AEE ADCD 8AEF ADCE 8AF0 ADCF 8AF1 ADD0 8AF3 ADD1 8AF4 ADD2 8AF5 ADD3 8AF6 ADD4 8AF7 ADD5 8AF8 ADD6 8AF9 ADD7 8AFA ADD8 8AFB ADD9 8AFC ADDA 8AFD ADDB 8B41 ADDC 8B42 ADDD 8B43 ADDE 8B44 ADDF 8B45 ADE0 8B46 ADE1 8B47 ADE2 8B48 ADE3 8B49 ADE4 8B4A ADE5 8B4B ADE6 8B4C ADE7 8B4D ADE8 8B4E ADE9 8B4F ADEA 8B50 ADEB 8B51 ADEC 8B53 ADED 8B54 ADEE 8B55 ADEF 8B56 ADF0 8B57 ADF1 8B58 ADF2 8B59 ADF3 8B5A ADF4 8B5B ADF5 8B5C ADF6 8B5D ADF7 8B61 ADF8 8B62 ADF9 8B63 ADFA 8B64 ADFB 8B65 ADFC 8B66 ADFD 8B67 ADFE 8B68 ADFF 8B69 AE00 8B6A AE01 8B6B AE02 8B6C AE03 8B6D AE04 8B6E AE05 8B6F AE06 8B70 AE07 8B71 AE08 8B73 AE09 8B74 AE0A 8B75 AE0B 8B76 AE0C 8B77 AE0D 8B78 AE0E 8B79 AE0F 8B7A AE10 8B7B AE11 8B7C AE12 8B7D AE13 8B81 AE14 8B82 AE15 8B83 AE16 8B84 AE17 8B85 AE18 8B86 AE19 8B87 AE1A 8B88 AE1B 8B89 AE1C 8B8A AE1D 8B8B AE1E 8B8C AE1F 8B8D AE20 8B8E AE21 8B8F AE22 8B90 AE23 8B91 AE24 8B93 AE25 8B94 AE26 8B95 AE27 8B96 AE28 8B97 AE29 8B98 AE2A 8B99 AE2B 8B9A AE2C 8B9B AE2D 8B9C AE2E 8B9D AE2F 8BA1 AE30 8BA2 AE31 8BA3 AE32 8BA4 AE33 8BA5 AE34 8BA6 AE35 8BA7 AE36 8BA8 AE37 8BA9 AE38 8BAA AE39 8BAB AE3A 8BAC AE3B 8BAD AE3C 8BAE AE3D 8BAF AE3E 8BB0 AE3F 8BB1 AE40 8BB3 AE41 8BB4 AE42 8BB5 AE43 8BB6 AE44 8BB7 AE45 8BB8 AE46 8BB9 AE47 8BBA AE48 8BBB AE49 8BBC AE4A 8BBD AE4B 8C41 3132 8C61 AE4C 8C62 AE4D 8C63 AE4E 8C64 AE4F 8C65 AE50 8C66 AE51 8C67 AE52 8C68 AE53 8C69 AE54 8C6A AE55 8C6B AE56 8C6C AE57 8C6D AE58 8C6E AE59 8C6F AE5A 8C70 AE5B 8C71 AE5C 8C73 AE5D 8C74 AE5E 8C75 AE5F 8C76 AE60 8C77 AE61 8C78 AE62 8C79 AE63 8C7A AE64 8C7B AE65 8C7C AE66 8C7D AE67 8C81 AE68 8C82 AE69 8C83 AE6A 8C84 AE6B 8C85 AE6C 8C86 AE6D 8C87 AE6E 8C88 AE6F 8C89 AE70 8C8A AE71 8C8B AE72 8C8C AE73 8C8D AE74 8C8E AE75 8C8F AE76 8C90 AE77 8C91 AE78 8C93 AE79 8C94 AE7A 8C95 AE7B 8C96 AE7C 8C97 AE7D 8C98 AE7E 8C99 AE7F 8C9A AE80 8C9B AE81 8C9C AE82 8C9D AE83 8CA1 AE84 8CA2 AE85 8CA3 AE86 8CA4 AE87 8CA5 AE88 8CA6 AE89 8CA7 AE8A 8CA8 AE8B 8CA9 AE8C 8CAA AE8D 8CAB AE8E 8CAC AE8F 8CAD AE90 8CAE AE91 8CAF AE92 8CB0 AE93 8CB1 AE94 8CB3 AE95 8CB4 AE96 8CB5 AE97 8CB6 AE98 8CB7 AE99 8CB8 AE9A 8CB9 AE9B 8CBA AE9C 8CBB AE9D 8CBC AE9E 8CBD AE9F 8CC1 AEA0 8CC2 AEA1 8CC3 AEA2 8CC4 AEA3 8CC5 AEA4 8CC6 AEA5 8CC7 AEA6 8CC8 AEA7 8CC9 AEA8 8CCA AEA9 8CCB AEAA 8CCC AEAB 8CCD AEAC 8CCE AEAD 8CCF AEAE 8CD0 AEAF 8CD1 AEB0 8CD3 AEB1 8CD4 AEB2 8CD5 AEB3 8CD6 AEB4 8CD7 AEB5 8CD8 AEB6 8CD9 AEB7 8CDA AEB8 8CDB AEB9 8CDC AEBA 8CDD AEBB 8CE1 AEBC 8CE2 AEBD 8CE3 AEBE 8CE4 AEBF 8CE5 AEC0 8CE6 AEC1 8CE7 AEC2 8CE8 AEC3 8CE9 AEC4 8CEA AEC5 8CEB AEC6 8CEC AEC7 8CED AEC8 8CEE AEC9 8CEF AECA 8CF0 AECB 8CF1 AECC 8CF3 AECD 8CF4 AECE 8CF5 AECF 8CF6 AED0 8CF7 AED1 8CF8 AED2 8CF9 AED3 8CFA AED4 8CFB AED5 8CFC AED6 8CFD AED7 8D41 AED8 8D42 AED9 8D43 AEDA 8D44 AEDB 8D45 AEDC 8D46 AEDD 8D47 AEDE 8D48 AEDF 8D49 AEE0 8D4A AEE1 8D4B AEE2 8D4C AEE3 8D4D AEE4 8D4E AEE5 8D4F AEE6 8D50 AEE7 8D51 AEE8 8D53 AEE9 8D54 AEEA 8D55 AEEB 8D56 AEEC 8D57 AEED 8D58 AEEE 8D59 AEEF 8D5A AEF0 8D5B AEF1 8D5C AEF2 8D5D AEF3 8D61 AEF4 8D62 AEF5 8D63 AEF6 8D64 AEF7 8D65 AEF8 8D66 AEF9 8D67 AEFA 8D68 AEFB 8D69 AEFC 8D6A AEFD 8D6B AEFE 8D6C AEFF 8D6D AF00 8D6E AF01 8D6F AF02 8D70 AF03 8D71 AF04 8D73 AF05 8D74 AF06 8D75 AF07 8D76 AF08 8D77 AF09 8D78 AF0A 8D79 AF0B 8D7A AF0C 8D7B AF0D 8D7C AF0E 8D7D AF0F 8D81 AF10 8D82 AF11 8D83 AF12 8D84 AF13 8D85 AF14 8D86 AF15 8D87 AF16 8D88 AF17 8D89 AF18 8D8A AF19 8D8B AF1A 8D8C AF1B 8D8D AF1C 8D8E AF1D 8D8F AF1E 8D90 AF1F 8D91 AF20 8D93 AF21 8D94 AF22 8D95 AF23 8D96 AF24 8D97 AF25 8D98 AF26 8D99 AF27 8D9A AF28 8D9B AF29 8D9C AF2A 8D9D AF2B 8DA1 AF2C 8DA2 AF2D 8DA3 AF2E 8DA4 AF2F 8DA5 AF30 8DA6 AF31 8DA7 AF32 8DA8 AF33 8DA9 AF34 8DAA AF35 8DAB AF36 8DAC AF37 8DAD AF38 8DAE AF39 8DAF AF3A 8DB0 AF3B 8DB1 AF3C 8DB3 AF3D 8DB4 AF3E 8DB5 AF3F 8DB6 AF40 8DB7 AF41 8DB8 AF42 8DB9 AF43 8DBA AF44 8DBB AF45 8DBC AF46 8DBD AF47 8DC1 AF48 8DC2 AF49 8DC3 AF4A 8DC4 AF4B 8DC5 AF4C 8DC6 AF4D 8DC7 AF4E 8DC8 AF4F 8DC9 AF50 8DCA AF51 8DCB AF52 8DCC AF53 8DCD AF54 8DCE AF55 8DCF AF56 8DD0 AF57 8DD1 AF58 8DD3 AF59 8DD4 AF5A 8DD5 AF5B 8DD6 AF5C 8DD7 AF5D 8DD8 AF5E 8DD9 AF5F 8DDA AF60 8DDB AF61 8DDC AF62 8DDD AF63 8DE1 AF64 8DE2 AF65 8DE3 AF66 8DE4 AF67 8DE5 AF68 8DE6 AF69 8DE7 AF6A 8DE8 AF6B 8DE9 AF6C 8DEA AF6D 8DEB AF6E 8DEC AF6F 8DED AF70 8DEE AF71 8DEF AF72 8DF0 AF73 8DF1 AF74 8DF3 AF75 8DF4 AF76 8DF5 AF77 8DF6 AF78 8DF7 AF79 8DF8 AF7A 8DF9 AF7B 8DFA AF7C 8DFB AF7D 8DFC AF7E 8DFD AF7F 8E41 AF80 8E42 AF81 8E43 AF82 8E44 AF83 8E45 AF84 8E46 AF85 8E47 AF86 8E48 AF87 8E49 AF88 8E4A AF89 8E4B AF8A 8E4C AF8B 8E4D AF8C 8E4E AF8D 8E4F AF8E 8E50 AF8F 8E51 AF90 8E53 AF91 8E54 AF92 8E55 AF93 8E56 AF94 8E57 AF95 8E58 AF96 8E59 AF97 8E5A AF98 8E5B AF99 8E5C AF9A 8E5D AF9B 8E61 AF9C 8E62 AF9D 8E63 AF9E 8E64 AF9F 8E65 AFA0 8E66 AFA1 8E67 AFA2 8E68 AFA3 8E69 AFA4 8E6A AFA5 8E6B AFA6 8E6C AFA7 8E6D AFA8 8E6E AFA9 8E6F AFAA 8E70 AFAB 8E71 AFAC 8E73 AFAD 8E74 AFAE 8E75 AFAF 8E76 AFB0 8E77 AFB1 8E78 AFB2 8E79 AFB3 8E7A AFB4 8E7B AFB5 8E7C AFB6 8E7D AFB7 8E81 AFB8 8E82 AFB9 8E83 AFBA 8E84 AFBB 8E85 AFBC 8E86 AFBD 8E87 AFBE 8E88 AFBF 8E89 AFC0 8E8A AFC1 8E8B AFC2 8E8C AFC3 8E8D AFC4 8E8E AFC5 8E8F AFC6 8E90 AFC7 8E91 AFC8 8E93 AFC9 8E94 AFCA 8E95 AFCB 8E96 AFCC 8E97 AFCD 8E98 AFCE 8E99 AFCF 8E9A AFD0 8E9B AFD1 8E9C AFD2 8E9D AFD3 8EA1 AFD4 8EA2 AFD5 8EA3 AFD6 8EA4 AFD7 8EA5 AFD8 8EA6 AFD9 8EA7 AFDA 8EA8 AFDB 8EA9 AFDC 8EAA AFDD 8EAB AFDE 8EAC AFDF 8EAD AFE0 8EAE AFE1 8EAF AFE2 8EB0 AFE3 8EB1 AFE4 8EB3 AFE5 8EB4 AFE6 8EB5 AFE7 8EB6 AFE8 8EB7 AFE9 8EB8 AFEA 8EB9 AFEB 8EBA AFEC 8EBB AFED 8EBC AFEE 8EBD AFEF 8EC1 AFF0 8EC2 AFF1 8EC3 AFF2 8EC4 AFF3 8EC5 AFF4 8EC6 AFF5 8EC7 AFF6 8EC8 AFF7 8EC9 AFF8 8ECA AFF9 8ECB AFFA 8ECC AFFB 8ECD AFFC 8ECE AFFD 8ECF AFFE 8ED0 AFFF 8ED1 B000 8ED3 B001 8ED4 B002 8ED5 B003 8ED6 B004 8ED7 B005 8ED8 B006 8ED9 B007 8EDA B008 8EDB B009 8EDC B00A 8EDD B00B 8EE1 B00C 8EE2 B00D 8EE3 B00E 8EE4 B00F 8EE5 B010 8EE6 B011 8EE7 B012 8EE8 B013 8EE9 B014 8EEA B015 8EEB B016 8EEC B017 8EED B018 8EEE B019 8EEF B01A 8EF0 B01B 8EF1 B01C 8EF3 B01D 8EF4 B01E 8EF5 B01F 8EF6 B020 8EF7 B021 8EF8 B022 8EF9 B023 8EFA B024 8EFB B025 8EFC B026 8EFD B027 8F41 B028 8F42 B029 8F43 B02A 8F44 B02B 8F45 B02C 8F46 B02D 8F47 B02E 8F48 B02F 8F49 B030 8F4A B031 8F4B B032 8F4C B033 8F4D B034 8F4E B035 8F4F B036 8F50 B037 8F51 B038 8F53 B039 8F54 B03A 8F55 B03B 8F56 B03C 8F57 B03D 8F58 B03E 8F59 B03F 8F5A B040 8F5B B041 8F5C B042 8F5D B043 8F61 B044 8F62 B045 8F63 B046 8F64 B047 8F65 B048 8F66 B049 8F67 B04A 8F68 B04B 8F69 B04C 8F6A B04D 8F6B B04E 8F6C B04F 8F6D B050 8F6E B051 8F6F B052 8F70 B053 8F71 B054 8F73 B055 8F74 B056 8F75 B057 8F76 B058 8F77 B059 8F78 B05A 8F79 B05B 8F7A B05C 8F7B B05D 8F7C B05E 8F7D B05F 8F81 B060 8F82 B061 8F83 B062 8F84 B063 8F85 B064 8F86 B065 8F87 B066 8F88 B067 8F89 B068 8F8A B069 8F8B B06A 8F8C B06B 8F8D B06C 8F8E B06D 8F8F B06E 8F90 B06F 8F91 B070 8F93 B071 8F94 B072 8F95 B073 8F96 B074 8F97 B075 8F98 B076 8F99 B077 8F9A B078 8F9B B079 8F9C B07A 8F9D B07B 8FA1 B07C 8FA2 B07D 8FA3 B07E 8FA4 B07F 8FA5 B080 8FA6 B081 8FA7 B082 8FA8 B083 8FA9 B084 8FAA B085 8FAB B086 8FAC B087 8FAD B088 8FAE B089 8FAF B08A 8FB0 B08B 8FB1 B08C 8FB3 B08D 8FB4 B08E 8FB5 B08F 8FB6 B090 8FB7 B091 8FB8 B092 8FB9 B093 8FBA B094 8FBB B095 8FBC B096 8FBD B097 9041 3134 9061 B098 9062 B099 9063 B09A 9064 B09B 9065 B09C 9066 B09D 9067 B09E 9068 B09F 9069 B0A0 906A B0A1 906B B0A2 906C B0A3 906D B0A4 906E B0A5 906F B0A6 9070 B0A7 9071 B0A8 9073 B0A9 9074 B0AA 9075 B0AB 9076 B0AC 9077 B0AD 9078 B0AE 9079 B0AF 907A B0B0 907B B0B1 907C B0B2 907D B0B3 9081 B0B4 9082 B0B5 9083 B0B6 9084 B0B7 9085 B0B8 9086 B0B9 9087 B0BA 9088 B0BB 9089 B0BC 908A B0BD 908B B0BE 908C B0BF 908D B0C0 908E B0C1 908F B0C2 9090 B0C3 9091 B0C4 9093 B0C5 9094 B0C6 9095 B0C7 9096 B0C8 9097 B0C9 9098 B0CA 9099 B0CB 909A B0CC 909B B0CD 909C B0CE 909D B0CF 90A1 B0D0 90A2 B0D1 90A3 B0D2 90A4 B0D3 90A5 B0D4 90A6 B0D5 90A7 B0D6 90A8 B0D7 90A9 B0D8 90AA B0D9 90AB B0DA 90AC B0DB 90AD B0DC 90AE B0DD 90AF B0DE 90B0 B0DF 90B1 B0E0 90B3 B0E1 90B4 B0E2 90B5 B0E3 90B6 B0E4 90B7 B0E5 90B8 B0E6 90B9 B0E7 90BA B0E8 90BB B0E9 90BC B0EA 90BD B0EB 90C1 B0EC 90C2 B0ED 90C3 B0EE 90C4 B0EF 90C5 B0F0 90C6 B0F1 90C7 B0F2 90C8 B0F3 90C9 B0F4 90CA B0F5 90CB B0F6 90CC B0F7 90CD B0F8 90CE B0F9 90CF B0FA 90D0 B0FB 90D1 B0FC 90D3 B0FD 90D4 B0FE 90D5 B0FF 90D6 B100 90D7 B101 90D8 B102 90D9 B103 90DA B104 90DB B105 90DC B106 90DD B107 90E1 B108 90E2 B109 90E3 B10A 90E4 B10B 90E5 B10C 90E6 B10D 90E7 B10E 90E8 B10F 90E9 B110 90EA B111 90EB B112 90EC B113 90ED B114 90EE B115 90EF B116 90F0 B117 90F1 B118 90F3 B119 90F4 B11A 90F5 B11B 90F6 B11C 90F7 B11D 90F8 B11E 90F9 B11F 90FA B120 90FB B121 90FC B122 90FD B123 9141 B124 9142 B125 9143 B126 9144 B127 9145 B128 9146 B129 9147 B12A 9148 B12B 9149 B12C 914A B12D 914B B12E 914C B12F 914D B130 914E B131 914F B132 9150 B133 9151 B134 9153 B135 9154 B136 9155 B137 9156 B138 9157 B139 9158 B13A 9159 B13B 915A B13C 915B B13D 915C B13E 915D B13F 9161 B140 9162 B141 9163 B142 9164 B143 9165 B144 9166 B145 9167 B146 9168 B147 9169 B148 916A B149 916B B14A 916C B14B 916D B14C 916E B14D 916F B14E 9170 B14F 9171 B150 9173 B151 9174 B152 9175 B153 9176 B154 9177 B155 9178 B156 9179 B157 917A B158 917B B159 917C B15A 917D B15B 9181 B15C 9182 B15D 9183 B15E 9184 B15F 9185 B160 9186 B161 9187 B162 9188 B163 9189 B164 918A B165 918B B166 918C B167 918D B168 918E B169 918F B16A 9190 B16B 9191 B16C 9193 B16D 9194 B16E 9195 B16F 9196 B170 9197 B171 9198 B172 9199 B173 919A B174 919B B175 919C B176 919D B177 91A1 B178 91A2 B179 91A3 B17A 91A4 B17B 91A5 B17C 91A6 B17D 91A7 B17E 91A8 B17F 91A9 B180 91AA B181 91AB B182 91AC B183 91AD B184 91AE B185 91AF B186 91B0 B187 91B1 B188 91B3 B189 91B4 B18A 91B5 B18B 91B6 B18C 91B7 B18D 91B8 B18E 91B9 B18F 91BA B190 91BB B191 91BC B192 91BD B193 91C1 B194 91C2 B195 91C3 B196 91C4 B197 91C5 B198 91C6 B199 91C7 B19A 91C8 B19B 91C9 B19C 91CA B19D 91CB B19E 91CC B19F 91CD B1A0 91CE B1A1 91CF B1A2 91D0 B1A3 91D1 B1A4 91D3 B1A5 91D4 B1A6 91D5 B1A7 91D6 B1A8 91D7 B1A9 91D8 B1AA 91D9 B1AB 91DA B1AC 91DB B1AD 91DC B1AE 91DD B1AF 91E1 B1B0 91E2 B1B1 91E3 B1B2 91E4 B1B3 91E5 B1B4 91E6 B1B5 91E7 B1B6 91E8 B1B7 91E9 B1B8 91EA B1B9 91EB B1BA 91EC B1BB 91ED B1BC 91EE B1BD 91EF B1BE 91F0 B1BF 91F1 B1C0 91F3 B1C1 91F4 B1C2 91F5 B1C3 91F6 B1C4 91F7 B1C5 91F8 B1C6 91F9 B1C7 91FA B1C8 91FB B1C9 91FC B1CA 91FD B1CB 9241 B1CC 9242 B1CD 9243 B1CE 9244 B1CF 9245 B1D0 9246 B1D1 9247 B1D2 9248 B1D3 9249 B1D4 924A B1D5 924B B1D6 924C B1D7 924D B1D8 924E B1D9 924F B1DA 9250 B1DB 9251 B1DC 9253 B1DD 9254 B1DE 9255 B1DF 9256 B1E0 9257 B1E1 9258 B1E2 9259 B1E3 925A B1E4 925B B1E5 925C B1E6 925D B1E7 9261 B1E8 9262 B1E9 9263 B1EA 9264 B1EB 9265 B1EC 9266 B1ED 9267 B1EE 9268 B1EF 9269 B1F0 926A B1F1 926B B1F2 926C B1F3 926D B1F4 926E B1F5 926F B1F6 9270 B1F7 9271 B1F8 9273 B1F9 9274 B1FA 9275 B1FB 9276 B1FC 9277 B1FD 9278 B1FE 9279 B1FF 927A B200 927B B201 927C B202 927D B203 9281 B204 9282 B205 9283 B206 9284 B207 9285 B208 9286 B209 9287 B20A 9288 B20B 9289 B20C 928A B20D 928B B20E 928C B20F 928D B210 928E B211 928F B212 9290 B213 9291 B214 9293 B215 9294 B216 9295 B217 9296 B218 9297 B219 9298 B21A 9299 B21B 929A B21C 929B B21D 929C B21E 929D B21F 92A1 B220 92A2 B221 92A3 B222 92A4 B223 92A5 B224 92A6 B225 92A7 B226 92A8 B227 92A9 B228 92AA B229 92AB B22A 92AC B22B 92AD B22C 92AE B22D 92AF B22E 92B0 B22F 92B1 B230 92B3 B231 92B4 B232 92B5 B233 92B6 B234 92B7 B235 92B8 B236 92B9 B237 92BA B238 92BB B239 92BC B23A 92BD B23B 92C1 B23C 92C2 B23D 92C3 B23E 92C4 B23F 92C5 B240 92C6 B241 92C7 B242 92C8 B243 92C9 B244 92CA B245 92CB B246 92CC B247 92CD B248 92CE B249 92CF B24A 92D0 B24B 92D1 B24C 92D3 B24D 92D4 B24E 92D5 B24F 92D6 B250 92D7 B251 92D8 B252 92D9 B253 92DA B254 92DB B255 92DC B256 92DD B257 92E1 B258 92E2 B259 92E3 B25A 92E4 B25B 92E5 B25C 92E6 B25D 92E7 B25E 92E8 B25F 92E9 B260 92EA B261 92EB B262 92EC B263 92ED B264 92EE B265 92EF B266 92F0 B267 92F1 B268 92F3 B269 92F4 B26A 92F5 B26B 92F6 B26C 92F7 B26D 92F8 B26E 92F9 B26F 92FA B270 92FB B271 92FC B272 92FD B273 9341 B274 9342 B275 9343 B276 9344 B277 9345 B278 9346 B279 9347 B27A 9348 B27B 9349 B27C 934A B27D 934B B27E 934C B27F 934D B280 934E B281 934F B282 9350 B283 9351 B284 9353 B285 9354 B286 9355 B287 9356 B288 9357 B289 9358 B28A 9359 B28B 935A B28C 935B B28D 935C B28E 935D B28F 9361 B290 9362 B291 9363 B292 9364 B293 9365 B294 9366 B295 9367 B296 9368 B297 9369 B298 936A B299 936B B29A 936C B29B 936D B29C 936E B29D 936F B29E 9370 B29F 9371 B2A0 9373 B2A1 9374 B2A2 9375 B2A3 9376 B2A4 9377 B2A5 9378 B2A6 9379 B2A7 937A B2A8 937B B2A9 937C B2AA 937D B2AB 9381 B2AC 9382 B2AD 9383 B2AE 9384 B2AF 9385 B2B0 9386 B2B1 9387 B2B2 9388 B2B3 9389 B2B4 938A B2B5 938B B2B6 938C B2B7 938D B2B8 938E B2B9 938F B2BA 9390 B2BB 9391 B2BC 9393 B2BD 9394 B2BE 9395 B2BF 9396 B2C0 9397 B2C1 9398 B2C2 9399 B2C3 939A B2C4 939B B2C5 939C B2C6 939D B2C7 93A1 B2C8 93A2 B2C9 93A3 B2CA 93A4 B2CB 93A5 B2CC 93A6 B2CD 93A7 B2CE 93A8 B2CF 93A9 B2D0 93AA B2D1 93AB B2D2 93AC B2D3 93AD B2D4 93AE B2D5 93AF B2D6 93B0 B2D7 93B1 B2D8 93B3 B2D9 93B4 B2DA 93B5 B2DB 93B6 B2DC 93B7 B2DD 93B8 B2DE 93B9 B2DF 93BA B2E0 93BB B2E1 93BC B2E2 93BD B2E3 9441 3137 9461 B2E4 9462 B2E5 9463 B2E6 9464 B2E7 9465 B2E8 9466 B2E9 9467 B2EA 9468 B2EB 9469 B2EC 946A B2ED 946B B2EE 946C B2EF 946D B2F0 946E B2F1 946F B2F2 9470 B2F3 9471 B2F4 9473 B2F5 9474 B2F6 9475 B2F7 9476 B2F8 9477 B2F9 9478 B2FA 9479 B2FB 947A B2FC 947B B2FD 947C B2FE 947D B2FF 9481 B300 9482 B301 9483 B302 9484 B303 9485 B304 9486 B305 9487 B306 9488 B307 9489 B308 948A B309 948B B30A 948C B30B 948D B30C 948E B30D 948F B30E 9490 B30F 9491 B310 9493 B311 9494 B312 9495 B313 9496 B314 9497 B315 9498 B316 9499 B317 949A B318 949B B319 949C B31A 949D B31B 94A1 B31C 94A2 B31D 94A3 B31E 94A4 B31F 94A5 B320 94A6 B321 94A7 B322 94A8 B323 94A9 B324 94AA B325 94AB B326 94AC B327 94AD B328 94AE B329 94AF B32A 94B0 B32B 94B1 B32C 94B3 B32D 94B4 B32E 94B5 B32F 94B6 B330 94B7 B331 94B8 B332 94B9 B333 94BA B334 94BB B335 94BC B336 94BD B337 94C1 B338 94C2 B339 94C3 B33A 94C4 B33B 94C5 B33C 94C6 B33D 94C7 B33E 94C8 B33F 94C9 B340 94CA B341 94CB B342 94CC B343 94CD B344 94CE B345 94CF B346 94D0 B347 94D1 B348 94D3 B349 94D4 B34A 94D5 B34B 94D6 B34C 94D7 B34D 94D8 B34E 94D9 B34F 94DA B350 94DB B351 94DC B352 94DD B353 94E1 B354 94E2 B355 94E3 B356 94E4 B357 94E5 B358 94E6 B359 94E7 B35A 94E8 B35B 94E9 B35C 94EA B35D 94EB B35E 94EC B35F 94ED B360 94EE B361 94EF B362 94F0 B363 94F1 B364 94F3 B365 94F4 B366 94F5 B367 94F6 B368 94F7 B369 94F8 B36A 94F9 B36B 94FA B36C 94FB B36D 94FC B36E 94FD B36F 9541 B370 9542 B371 9543 B372 9544 B373 9545 B374 9546 B375 9547 B376 9548 B377 9549 B378 954A B379 954B B37A 954C B37B 954D B37C 954E B37D 954F B37E 9550 B37F 9551 B380 9553 B381 9554 B382 9555 B383 9556 B384 9557 B385 9558 B386 9559 B387 955A B388 955B B389 955C B38A 955D B38B 9561 B38C 9562 B38D 9563 B38E 9564 B38F 9565 B390 9566 B391 9567 B392 9568 B393 9569 B394 956A B395 956B B396 956C B397 956D B398 956E B399 956F B39A 9570 B39B 9571 B39C 9573 B39D 9574 B39E 9575 B39F 9576 B3A0 9577 B3A1 9578 B3A2 9579 B3A3 957A B3A4 957B B3A5 957C B3A6 957D B3A7 9581 B3A8 9582 B3A9 9583 B3AA 9584 B3AB 9585 B3AC 9586 B3AD 9587 B3AE 9588 B3AF 9589 B3B0 958A B3B1 958B B3B2 958C B3B3 958D B3B4 958E B3B5 958F B3B6 9590 B3B7 9591 B3B8 9593 B3B9 9594 B3BA 9595 B3BB 9596 B3BC 9597 B3BD 9598 B3BE 9599 B3BF 959A B3C0 959B B3C1 959C B3C2 959D B3C3 95A1 B3C4 95A2 B3C5 95A3 B3C6 95A4 B3C7 95A5 B3C8 95A6 B3C9 95A7 B3CA 95A8 B3CB 95A9 B3CC 95AA B3CD 95AB B3CE 95AC B3CF 95AD B3D0 95AE B3D1 95AF B3D2 95B0 B3D3 95B1 B3D4 95B3 B3D5 95B4 B3D6 95B5 B3D7 95B6 B3D8 95B7 B3D9 95B8 B3DA 95B9 B3DB 95BA B3DC 95BB B3DD 95BC B3DE 95BD B3DF 95C1 B3E0 95C2 B3E1 95C3 B3E2 95C4 B3E3 95C5 B3E4 95C6 B3E5 95C7 B3E6 95C8 B3E7 95C9 B3E8 95CA B3E9 95CB B3EA 95CC B3EB 95CD B3EC 95CE B3ED 95CF B3EE 95D0 B3EF 95D1 B3F0 95D3 B3F1 95D4 B3F2 95D5 B3F3 95D6 B3F4 95D7 B3F5 95D8 B3F6 95D9 B3F7 95DA B3F8 95DB B3F9 95DC B3FA 95DD B3FB 95E1 B3FC 95E2 B3FD 95E3 B3FE 95E4 B3FF 95E5 B400 95E6 B401 95E7 B402 95E8 B403 95E9 B404 95EA B405 95EB B406 95EC B407 95ED B408 95EE B409 95EF B40A 95F0 B40B 95F1 B40C 95F3 B40D 95F4 B40E 95F5 B40F 95F6 B410 95F7 B411 95F8 B412 95F9 B413 95FA B414 95FB B415 95FC B416 95FD B417 9641 B418 9642 B419 9643 B41A 9644 B41B 9645 B41C 9646 B41D 9647 B41E 9648 B41F 9649 B420 964A B421 964B B422 964C B423 964D B424 964E B425 964F B426 9650 B427 9651 B428 9653 B429 9654 B42A 9655 B42B 9656 B42C 9657 B42D 9658 B42E 9659 B42F 965A B430 965B B431 965C B432 965D B433 9661 B434 9662 B435 9663 B436 9664 B437 9665 B438 9666 B439 9667 B43A 9668 B43B 9669 B43C 966A B43D 966B B43E 966C B43F 966D B440 966E B441 966F B442 9670 B443 9671 B444 9673 B445 9674 B446 9675 B447 9676 B448 9677 B449 9678 B44A 9679 B44B 967A B44C 967B B44D 967C B44E 967D B44F 9681 B450 9682 B451 9683 B452 9684 B453 9685 B454 9686 B455 9687 B456 9688 B457 9689 B458 968A B459 968B B45A 968C B45B 968D B45C 968E B45D 968F B45E 9690 B45F 9691 B460 9693 B461 9694 B462 9695 B463 9696 B464 9697 B465 9698 B466 9699 B467 969A B468 969B B469 969C B46A 969D B46B 96A1 B46C 96A2 B46D 96A3 B46E 96A4 B46F 96A5 B470 96A6 B471 96A7 B472 96A8 B473 96A9 B474 96AA B475 96AB B476 96AC B477 96AD B478 96AE B479 96AF B47A 96B0 B47B 96B1 B47C 96B3 B47D 96B4 B47E 96B5 B47F 96B6 B480 96B7 B481 96B8 B482 96B9 B483 96BA B484 96BB B485 96BC B486 96BD B487 96C1 B488 96C2 B489 96C3 B48A 96C4 B48B 96C5 B48C 96C6 B48D 96C7 B48E 96C8 B48F 96C9 B490 96CA B491 96CB B492 96CC B493 96CD B494 96CE B495 96CF B496 96D0 B497 96D1 B498 96D3 B499 96D4 B49A 96D5 B49B 96D6 B49C 96D7 B49D 96D8 B49E 96D9 B49F 96DA B4A0 96DB B4A1 96DC B4A2 96DD B4A3 96E1 B4A4 96E2 B4A5 96E3 B4A6 96E4 B4A7 96E5 B4A8 96E6 B4A9 96E7 B4AA 96E8 B4AB 96E9 B4AC 96EA B4AD 96EB B4AE 96EC B4AF 96ED B4B0 96EE B4B1 96EF B4B2 96F0 B4B3 96F1 B4B4 96F3 B4B5 96F4 B4B6 96F5 B4B7 96F6 B4B8 96F7 B4B9 96F8 B4BA 96F9 B4BB 96FA B4BC 96FB B4BD 96FC B4BE 96FD B4BF 9741 B4C0 9742 B4C1 9743 B4C2 9744 B4C3 9745 B4C4 9746 B4C5 9747 B4C6 9748 B4C7 9749 B4C8 974A B4C9 974B B4CA 974C B4CB 974D B4CC 974E B4CD 974F B4CE 9750 B4CF 9751 B4D0 9753 B4D1 9754 B4D2 9755 B4D3 9756 B4D4 9757 B4D5 9758 B4D6 9759 B4D7 975A B4D8 975B B4D9 975C B4DA 975D B4DB 9761 B4DC 9762 B4DD 9763 B4DE 9764 B4DF 9765 B4E0 9766 B4E1 9767 B4E2 9768 B4E3 9769 B4E4 976A B4E5 976B B4E6 976C B4E7 976D B4E8 976E B4E9 976F B4EA 9770 B4EB 9771 B4EC 9773 B4ED 9774 B4EE 9775 B4EF 9776 B4F0 9777 B4F1 9778 B4F2 9779 B4F3 977A B4F4 977B B4F5 977C B4F6 977D B4F7 9781 B4F8 9782 B4F9 9783 B4FA 9784 B4FB 9785 B4FC 9786 B4FD 9787 B4FE 9788 B4FF 9789 B500 978A B501 978B B502 978C B503 978D B504 978E B505 978F B506 9790 B507 9791 B508 9793 B509 9794 B50A 9795 B50B 9796 B50C 9797 B50D 9798 B50E 9799 B50F 979A B510 979B B511 979C B512 979D B513 97A1 B514 97A2 B515 97A3 B516 97A4 B517 97A5 B518 97A6 B519 97A7 B51A 97A8 B51B 97A9 B51C 97AA B51D 97AB B51E 97AC B51F 97AD B520 97AE B521 97AF B522 97B0 B523 97B1 B524 97B3 B525 97B4 B526 97B5 B527 97B6 B528 97B7 B529 97B8 B52A 97B9 B52B 97BA B52C 97BB B52D 97BC B52E 97BD B52F 9841 3138 9861 B530 9862 B531 9863 B532 9864 B533 9865 B534 9866 B535 9867 B536 9868 B537 9869 B538 986A B539 986B B53A 986C B53B 986D B53C 986E B53D 986F B53E 9870 B53F 9871 B540 9873 B541 9874 B542 9875 B543 9876 B544 9877 B545 9878 B546 9879 B547 987A B548 987B B549 987C B54A 987D B54B 9881 B54C 9882 B54D 9883 B54E 9884 B54F 9885 B550 9886 B551 9887 B552 9888 B553 9889 B554 988A B555 988B B556 988C B557 988D B558 988E B559 988F B55A 9890 B55B 9891 B55C 9893 B55D 9894 B55E 9895 B55F 9896 B560 9897 B561 9898 B562 9899 B563 989A B564 989B B565 989C B566 989D B567 98A1 B568 98A2 B569 98A3 B56A 98A4 B56B 98A5 B56C 98A6 B56D 98A7 B56E 98A8 B56F 98A9 B570 98AA B571 98AB B572 98AC B573 98AD B574 98AE B575 98AF B576 98B0 B577 98B1 B578 98B3 B579 98B4 B57A 98B5 B57B 98B6 B57C 98B7 B57D 98B8 B57E 98B9 B57F 98BA B580 98BB B581 98BC B582 98BD B583 98C1 B584 98C2 B585 98C3 B586 98C4 B587 98C5 B588 98C6 B589 98C7 B58A 98C8 B58B 98C9 B58C 98CA B58D 98CB B58E 98CC B58F 98CD B590 98CE B591 98CF B592 98D0 B593 98D1 B594 98D3 B595 98D4 B596 98D5 B597 98D6 B598 98D7 B599 98D8 B59A 98D9 B59B 98DA B59C 98DB B59D 98DC B59E 98DD B59F 98E1 B5A0 98E2 B5A1 98E3 B5A2 98E4 B5A3 98E5 B5A4 98E6 B5A5 98E7 B5A6 98E8 B5A7 98E9 B5A8 98EA B5A9 98EB B5AA 98EC B5AB 98ED B5AC 98EE B5AD 98EF B5AE 98F0 B5AF 98F1 B5B0 98F3 B5B1 98F4 B5B2 98F5 B5B3 98F6 B5B4 98F7 B5B5 98F8 B5B6 98F9 B5B7 98FA B5B8 98FB B5B9 98FC B5BA 98FD B5BB 9941 B5BC 9942 B5BD 9943 B5BE 9944 B5BF 9945 B5C0 9946 B5C1 9947 B5C2 9948 B5C3 9949 B5C4 994A B5C5 994B B5C6 994C B5C7 994D B5C8 994E B5C9 994F B5CA 9950 B5CB 9951 B5CC 9953 B5CD 9954 B5CE 9955 B5CF 9956 B5D0 9957 B5D1 9958 B5D2 9959 B5D3 995A B5D4 995B B5D5 995C B5D6 995D B5D7 9961 B5D8 9962 B5D9 9963 B5DA 9964 B5DB 9965 B5DC 9966 B5DD 9967 B5DE 9968 B5DF 9969 B5E0 996A B5E1 996B B5E2 996C B5E3 996D B5E4 996E B5E5 996F B5E6 9970 B5E7 9971 B5E8 9973 B5E9 9974 B5EA 9975 B5EB 9976 B5EC 9977 B5ED 9978 B5EE 9979 B5EF 997A B5F0 997B B5F1 997C B5F2 997D B5F3 9981 B5F4 9982 B5F5 9983 B5F6 9984 B5F7 9985 B5F8 9986 B5F9 9987 B5FA 9988 B5FB 9989 B5FC 998A B5FD 998B B5FE 998C B5FF 998D B600 998E B601 998F B602 9990 B603 9991 B604 9993 B605 9994 B606 9995 B607 9996 B608 9997 B609 9998 B60A 9999 B60B 999A B60C 999B B60D 999C B60E 999D B60F 99A1 B610 99A2 B611 99A3 B612 99A4 B613 99A5 B614 99A6 B615 99A7 B616 99A8 B617 99A9 B618 99AA B619 99AB B61A 99AC B61B 99AD B61C 99AE B61D 99AF B61E 99B0 B61F 99B1 B620 99B3 B621 99B4 B622 99B5 B623 99B6 B624 99B7 B625 99B8 B626 99B9 B627 99BA B628 99BB B629 99BC B62A 99BD B62B 99C1 B62C 99C2 B62D 99C3 B62E 99C4 B62F 99C5 B630 99C6 B631 99C7 B632 99C8 B633 99C9 B634 99CA B635 99CB B636 99CC B637 99CD B638 99CE B639 99CF B63A 99D0 B63B 99D1 B63C 99D3 B63D 99D4 B63E 99D5 B63F 99D6 B640 99D7 B641 99D8 B642 99D9 B643 99DA B644 99DB B645 99DC B646 99DD B647 99E1 B648 99E2 B649 99E3 B64A 99E4 B64B 99E5 B64C 99E6 B64D 99E7 B64E 99E8 B64F 99E9 B650 99EA B651 99EB B652 99EC B653 99ED B654 99EE B655 99EF B656 99F0 B657 99F1 B658 99F3 B659 99F4 B65A 99F5 B65B 99F6 B65C 99F7 B65D 99F8 B65E 99F9 B65F 99FA B660 99FB B661 99FC B662 99FD B663 9A41 B664 9A42 B665 9A43 B666 9A44 B667 9A45 B668 9A46 B669 9A47 B66A 9A48 B66B 9A49 B66C 9A4A B66D 9A4B B66E 9A4C B66F 9A4D B670 9A4E B671 9A4F B672 9A50 B673 9A51 B674 9A53 B675 9A54 B676 9A55 B677 9A56 B678 9A57 B679 9A58 B67A 9A59 B67B 9A5A B67C 9A5B B67D 9A5C B67E 9A5D B67F 9A61 B680 9A62 B681 9A63 B682 9A64 B683 9A65 B684 9A66 B685 9A67 B686 9A68 B687 9A69 B688 9A6A B689 9A6B B68A 9A6C B68B 9A6D B68C 9A6E B68D 9A6F B68E 9A70 B68F 9A71 B690 9A73 B691 9A74 B692 9A75 B693 9A76 B694 9A77 B695 9A78 B696 9A79 B697 9A7A B698 9A7B B699 9A7C B69A 9A7D B69B 9A81 B69C 9A82 B69D 9A83 B69E 9A84 B69F 9A85 B6A0 9A86 B6A1 9A87 B6A2 9A88 B6A3 9A89 B6A4 9A8A B6A5 9A8B B6A6 9A8C B6A7 9A8D B6A8 9A8E B6A9 9A8F B6AA 9A90 B6AB 9A91 B6AC 9A93 B6AD 9A94 B6AE 9A95 B6AF 9A96 B6B0 9A97 B6B1 9A98 B6B2 9A99 B6B3 9A9A B6B4 9A9B B6B5 9A9C B6B6 9A9D B6B7 9AA1 B6B8 9AA2 B6B9 9AA3 B6BA 9AA4 B6BB 9AA5 B6BC 9AA6 B6BD 9AA7 B6BE 9AA8 B6BF 9AA9 B6C0 9AAA B6C1 9AAB B6C2 9AAC B6C3 9AAD B6C4 9AAE B6C5 9AAF B6C6 9AB0 B6C7 9AB1 B6C8 9AB3 B6C9 9AB4 B6CA 9AB5 B6CB 9AB6 B6CC 9AB7 B6CD 9AB8 B6CE 9AB9 B6CF 9ABA B6D0 9ABB B6D1 9ABC B6D2 9ABD B6D3 9AC1 B6D4 9AC2 B6D5 9AC3 B6D6 9AC4 B6D7 9AC5 B6D8 9AC6 B6D9 9AC7 B6DA 9AC8 B6DB 9AC9 B6DC 9ACA B6DD 9ACB B6DE 9ACC B6DF 9ACD B6E0 9ACE B6E1 9ACF B6E2 9AD0 B6E3 9AD1 B6E4 9AD3 B6E5 9AD4 B6E6 9AD5 B6E7 9AD6 B6E8 9AD7 B6E9 9AD8 B6EA 9AD9 B6EB 9ADA B6EC 9ADB B6ED 9ADC B6EE 9ADD B6EF 9AE1 B6F0 9AE2 B6F1 9AE3 B6F2 9AE4 B6F3 9AE5 B6F4 9AE6 B6F5 9AE7 B6F6 9AE8 B6F7 9AE9 B6F8 9AEA B6F9 9AEB B6FA 9AEC B6FB 9AED B6FC 9AEE B6FD 9AEF B6FE 9AF0 B6FF 9AF1 B700 9AF3 B701 9AF4 B702 9AF5 B703 9AF6 B704 9AF7 B705 9AF8 B706 9AF9 B707 9AFA B708 9AFB B709 9AFC B70A 9AFD B70B 9B41 B70C 9B42 B70D 9B43 B70E 9B44 B70F 9B45 B710 9B46 B711 9B47 B712 9B48 B713 9B49 B714 9B4A B715 9B4B B716 9B4C B717 9B4D B718 9B4E B719 9B4F B71A 9B50 B71B 9B51 B71C 9B53 B71D 9B54 B71E 9B55 B71F 9B56 B720 9B57 B721 9B58 B722 9B59 B723 9B5A B724 9B5B B725 9B5C B726 9B5D B727 9B61 B728 9B62 B729 9B63 B72A 9B64 B72B 9B65 B72C 9B66 B72D 9B67 B72E 9B68 B72F 9B69 B730 9B6A B731 9B6B B732 9B6C B733 9B6D B734 9B6E B735 9B6F B736 9B70 B737 9B71 B738 9B73 B739 9B74 B73A 9B75 B73B 9B76 B73C 9B77 B73D 9B78 B73E 9B79 B73F 9B7A B740 9B7B B741 9B7C B742 9B7D B743 9B81 B744 9B82 B745 9B83 B746 9B84 B747 9B85 B748 9B86 B749 9B87 B74A 9B88 B74B 9B89 B74C 9B8A B74D 9B8B B74E 9B8C B74F 9B8D B750 9B8E B751 9B8F B752 9B90 B753 9B91 B754 9B93 B755 9B94 B756 9B95 B757 9B96 B758 9B97 B759 9B98 B75A 9B99 B75B 9B9A B75C 9B9B B75D 9B9C B75E 9B9D B75F 9BA1 B760 9BA2 B761 9BA3 B762 9BA4 B763 9BA5 B764 9BA6 B765 9BA7 B766 9BA8 B767 9BA9 B768 9BAA B769 9BAB B76A 9BAC B76B 9BAD B76C 9BAE B76D 9BAF B76E 9BB0 B76F 9BB1 B770 9BB3 B771 9BB4 B772 9BB5 B773 9BB6 B774 9BB7 B775 9BB8 B776 9BB9 B777 9BBA B778 9BBB B779 9BBC B77A 9BBD B77B 9C41 3139 9C61 B77C 9C62 B77D 9C63 B77E 9C64 B77F 9C65 B780 9C66 B781 9C67 B782 9C68 B783 9C69 B784 9C6A B785 9C6B B786 9C6C B787 9C6D B788 9C6E B789 9C6F B78A 9C70 B78B 9C71 B78C 9C73 B78D 9C74 B78E 9C75 B78F 9C76 B790 9C77 B791 9C78 B792 9C79 B793 9C7A B794 9C7B B795 9C7C B796 9C7D B797 9C81 B798 9C82 B799 9C83 B79A 9C84 B79B 9C85 B79C 9C86 B79D 9C87 B79E 9C88 B79F 9C89 B7A0 9C8A B7A1 9C8B B7A2 9C8C B7A3 9C8D B7A4 9C8E B7A5 9C8F B7A6 9C90 B7A7 9C91 B7A8 9C93 B7A9 9C94 B7AA 9C95 B7AB 9C96 B7AC 9C97 B7AD 9C98 B7AE 9C99 B7AF 9C9A B7B0 9C9B B7B1 9C9C B7B2 9C9D B7B3 9CA1 B7B4 9CA2 B7B5 9CA3 B7B6 9CA4 B7B7 9CA5 B7B8 9CA6 B7B9 9CA7 B7BA 9CA8 B7BB 9CA9 B7BC 9CAA B7BD 9CAB B7BE 9CAC B7BF 9CAD B7C0 9CAE B7C1 9CAF B7C2 9CB0 B7C3 9CB1 B7C4 9CB3 B7C5 9CB4 B7C6 9CB5 B7C7 9CB6 B7C8 9CB7 B7C9 9CB8 B7CA 9CB9 B7CB 9CBA B7CC 9CBB B7CD 9CBC B7CE 9CBD B7CF 9CC1 B7D0 9CC2 B7D1 9CC3 B7D2 9CC4 B7D3 9CC5 B7D4 9CC6 B7D5 9CC7 B7D6 9CC8 B7D7 9CC9 B7D8 9CCA B7D9 9CCB B7DA 9CCC B7DB 9CCD B7DC 9CCE B7DD 9CCF B7DE 9CD0 B7DF 9CD1 B7E0 9CD3 B7E1 9CD4 B7E2 9CD5 B7E3 9CD6 B7E4 9CD7 B7E5 9CD8 B7E6 9CD9 B7E7 9CDA B7E8 9CDB B7E9 9CDC B7EA 9CDD B7EB 9CE1 B7EC 9CE2 B7ED 9CE3 B7EE 9CE4 B7EF 9CE5 B7F0 9CE6 B7F1 9CE7 B7F2 9CE8 B7F3 9CE9 B7F4 9CEA B7F5 9CEB B7F6 9CEC B7F7 9CED B7F8 9CEE B7F9 9CEF B7FA 9CF0 B7FB 9CF1 B7FC 9CF3 B7FD 9CF4 B7FE 9CF5 B7FF 9CF6 B800 9CF7 B801 9CF8 B802 9CF9 B803 9CFA B804 9CFB B805 9CFC B806 9CFD B807 9D41 B808 9D42 B809 9D43 B80A 9D44 B80B 9D45 B80C 9D46 B80D 9D47 B80E 9D48 B80F 9D49 B810 9D4A B811 9D4B B812 9D4C B813 9D4D B814 9D4E B815 9D4F B816 9D50 B817 9D51 B818 9D53 B819 9D54 B81A 9D55 B81B 9D56 B81C 9D57 B81D 9D58 B81E 9D59 B81F 9D5A B820 9D5B B821 9D5C B822 9D5D B823 9D61 B824 9D62 B825 9D63 B826 9D64 B827 9D65 B828 9D66 B829 9D67 B82A 9D68 B82B 9D69 B82C 9D6A B82D 9D6B B82E 9D6C B82F 9D6D B830 9D6E B831 9D6F B832 9D70 B833 9D71 B834 9D73 B835 9D74 B836 9D75 B837 9D76 B838 9D77 B839 9D78 B83A 9D79 B83B 9D7A B83C 9D7B B83D 9D7C B83E 9D7D B83F 9D81 B840 9D82 B841 9D83 B842 9D84 B843 9D85 B844 9D86 B845 9D87 B846 9D88 B847 9D89 B848 9D8A B849 9D8B B84A 9D8C B84B 9D8D B84C 9D8E B84D 9D8F B84E 9D90 B84F 9D91 B850 9D93 B851 9D94 B852 9D95 B853 9D96 B854 9D97 B855 9D98 B856 9D99 B857 9D9A B858 9D9B B859 9D9C B85A 9D9D B85B 9DA1 B85C 9DA2 B85D 9DA3 B85E 9DA4 B85F 9DA5 B860 9DA6 B861 9DA7 B862 9DA8 B863 9DA9 B864 9DAA B865 9DAB B866 9DAC B867 9DAD B868 9DAE B869 9DAF B86A 9DB0 B86B 9DB1 B86C 9DB3 B86D 9DB4 B86E 9DB5 B86F 9DB6 B870 9DB7 B871 9DB8 B872 9DB9 B873 9DBA B874 9DBB B875 9DBC B876 9DBD B877 9DC1 B878 9DC2 B879 9DC3 B87A 9DC4 B87B 9DC5 B87C 9DC6 B87D 9DC7 B87E 9DC8 B87F 9DC9 B880 9DCA B881 9DCB B882 9DCC B883 9DCD B884 9DCE B885 9DCF B886 9DD0 B887 9DD1 B888 9DD3 B889 9DD4 B88A 9DD5 B88B 9DD6 B88C 9DD7 B88D 9DD8 B88E 9DD9 B88F 9DDA B890 9DDB B891 9DDC B892 9DDD B893 9DE1 B894 9DE2 B895 9DE3 B896 9DE4 B897 9DE5 B898 9DE6 B899 9DE7 B89A 9DE8 B89B 9DE9 B89C 9DEA B89D 9DEB B89E 9DEC B89F 9DED B8A0 9DEE B8A1 9DEF B8A2 9DF0 B8A3 9DF1 B8A4 9DF3 B8A5 9DF4 B8A6 9DF5 B8A7 9DF6 B8A8 9DF7 B8A9 9DF8 B8AA 9DF9 B8AB 9DFA B8AC 9DFB B8AD 9DFC B8AE 9DFD B8AF 9E41 B8B0 9E42 B8B1 9E43 B8B2 9E44 B8B3 9E45 B8B4 9E46 B8B5 9E47 B8B6 9E48 B8B7 9E49 B8B8 9E4A B8B9 9E4B B8BA 9E4C B8BB 9E4D B8BC 9E4E B8BD 9E4F B8BE 9E50 B8BF 9E51 B8C0 9E53 B8C1 9E54 B8C2 9E55 B8C3 9E56 B8C4 9E57 B8C5 9E58 B8C6 9E59 B8C7 9E5A B8C8 9E5B B8C9 9E5C B8CA 9E5D B8CB 9E61 B8CC 9E62 B8CD 9E63 B8CE 9E64 B8CF 9E65 B8D0 9E66 B8D1 9E67 B8D2 9E68 B8D3 9E69 B8D4 9E6A B8D5 9E6B B8D6 9E6C B8D7 9E6D B8D8 9E6E B8D9 9E6F B8DA 9E70 B8DB 9E71 B8DC 9E73 B8DD 9E74 B8DE 9E75 B8DF 9E76 B8E0 9E77 B8E1 9E78 B8E2 9E79 B8E3 9E7A B8E4 9E7B B8E5 9E7C B8E6 9E7D B8E7 9E81 B8E8 9E82 B8E9 9E83 B8EA 9E84 B8EB 9E85 B8EC 9E86 B8ED 9E87 B8EE 9E88 B8EF 9E89 B8F0 9E8A B8F1 9E8B B8F2 9E8C B8F3 9E8D B8F4 9E8E B8F5 9E8F B8F6 9E90 B8F7 9E91 B8F8 9E93 B8F9 9E94 B8FA 9E95 B8FB 9E96 B8FC 9E97 B8FD 9E98 B8FE 9E99 B8FF 9E9A B900 9E9B B901 9E9C B902 9E9D B903 9EA1 B904 9EA2 B905 9EA3 B906 9EA4 B907 9EA5 B908 9EA6 B909 9EA7 B90A 9EA8 B90B 9EA9 B90C 9EAA B90D 9EAB B90E 9EAC B90F 9EAD B910 9EAE B911 9EAF B912 9EB0 B913 9EB1 B914 9EB3 B915 9EB4 B916 9EB5 B917 9EB6 B918 9EB7 B919 9EB8 B91A 9EB9 B91B 9EBA B91C 9EBB B91D 9EBC B91E 9EBD B91F 9EC1 B920 9EC2 B921 9EC3 B922 9EC4 B923 9EC5 B924 9EC6 B925 9EC7 B926 9EC8 B927 9EC9 B928 9ECA B929 9ECB B92A 9ECC B92B 9ECD B92C 9ECE B92D 9ECF B92E 9ED0 B92F 9ED1 B930 9ED3 B931 9ED4 B932 9ED5 B933 9ED6 B934 9ED7 B935 9ED8 B936 9ED9 B937 9EDA B938 9EDB B939 9EDC B93A 9EDD B93B 9EE1 B93C 9EE2 B93D 9EE3 B93E 9EE4 B93F 9EE5 B940 9EE6 B941 9EE7 B942 9EE8 B943 9EE9 B944 9EEA B945 9EEB B946 9EEC B947 9EED B948 9EEE B949 9EEF B94A 9EF0 B94B 9EF1 B94C 9EF3 B94D 9EF4 B94E 9EF5 B94F 9EF6 B950 9EF7 B951 9EF8 B952 9EF9 B953 9EFA B954 9EFB B955 9EFC B956 9EFD B957 9F41 B958 9F42 B959 9F43 B95A 9F44 B95B 9F45 B95C 9F46 B95D 9F47 B95E 9F48 B95F 9F49 B960 9F4A B961 9F4B B962 9F4C B963 9F4D B964 9F4E B965 9F4F B966 9F50 B967 9F51 B968 9F53 B969 9F54 B96A 9F55 B96B 9F56 B96C 9F57 B96D 9F58 B96E 9F59 B96F 9F5A B970 9F5B B971 9F5C B972 9F5D B973 9F61 B974 9F62 B975 9F63 B976 9F64 B977 9F65 B978 9F66 B979 9F67 B97A 9F68 B97B 9F69 B97C 9F6A B97D 9F6B B97E 9F6C B97F 9F6D B980 9F6E B981 9F6F B982 9F70 B983 9F71 B984 9F73 B985 9F74 B986 9F75 B987 9F76 B988 9F77 B989 9F78 B98A 9F79 B98B 9F7A B98C 9F7B B98D 9F7C B98E 9F7D B98F 9F81 B990 9F82 B991 9F83 B992 9F84 B993 9F85 B994 9F86 B995 9F87 B996 9F88 B997 9F89 B998 9F8A B999 9F8B B99A 9F8C B99B 9F8D B99C 9F8E B99D 9F8F B99E 9F90 B99F 9F91 B9A0 9F93 B9A1 9F94 B9A2 9F95 B9A3 9F96 B9A4 9F97 B9A5 9F98 B9A6 9F99 B9A7 9F9A B9A8 9F9B B9A9 9F9C B9AA 9F9D B9AB 9FA1 B9AC 9FA2 B9AD 9FA3 B9AE 9FA4 B9AF 9FA5 B9B0 9FA6 B9B1 9FA7 B9B2 9FA8 B9B3 9FA9 B9B4 9FAA B9B5 9FAB B9B6 9FAC B9B7 9FAD B9B8 9FAE B9B9 9FAF B9BA 9FB0 B9BB 9FB1 B9BC 9FB3 B9BD 9FB4 B9BE 9FB5 B9BF 9FB6 B9C0 9FB7 B9C1 9FB8 B9C2 9FB9 B9C3 9FBA B9C4 9FBB B9C5 9FBC B9C6 9FBD B9C7 A041 3141 A061 B9C8 A062 B9C9 A063 B9CA A064 B9CB A065 B9CC A066 B9CD A067 B9CE A068 B9CF A069 B9D0 A06A B9D1 A06B B9D2 A06C B9D3 A06D B9D4 A06E B9D5 A06F B9D6 A070 B9D7 A071 B9D8 A073 B9D9 A074 B9DA A075 B9DB A076 B9DC A077 B9DD A078 B9DE A079 B9DF A07A B9E0 A07B B9E1 A07C B9E2 A07D B9E3 A081 B9E4 A082 B9E5 A083 B9E6 A084 B9E7 A085 B9E8 A086 B9E9 A087 B9EA A088 B9EB A089 B9EC A08A B9ED A08B B9EE A08C B9EF A08D B9F0 A08E B9F1 A08F B9F2 A090 B9F3 A091 B9F4 A093 B9F5 A094 B9F6 A095 B9F7 A096 B9F8 A097 B9F9 A098 B9FA A099 B9FB A09A B9FC A09B B9FD A09C B9FE A09D B9FF A0A1 BA00 A0A2 BA01 A0A3 BA02 A0A4 BA03 A0A5 BA04 A0A6 BA05 A0A7 BA06 A0A8 BA07 A0A9 BA08 A0AA BA09 A0AB BA0A A0AC BA0B A0AD BA0C A0AE BA0D A0AF BA0E A0B0 BA0F A0B1 BA10 A0B3 BA11 A0B4 BA12 A0B5 BA13 A0B6 BA14 A0B7 BA15 A0B8 BA16 A0B9 BA17 A0BA BA18 A0BB BA19 A0BC BA1A A0BD BA1B A0C1 BA1C A0C2 BA1D A0C3 BA1E A0C4 BA1F A0C5 BA20 A0C6 BA21 A0C7 BA22 A0C8 BA23 A0C9 BA24 A0CA BA25 A0CB BA26 A0CC BA27 A0CD BA28 A0CE BA29 A0CF BA2A A0D0 BA2B A0D1 BA2C A0D3 BA2D A0D4 BA2E A0D5 BA2F A0D6 BA30 A0D7 BA31 A0D8 BA32 A0D9 BA33 A0DA BA34 A0DB BA35 A0DC BA36 A0DD BA37 A0E1 BA38 A0E2 BA39 A0E3 BA3A A0E4 BA3B A0E5 BA3C A0E6 BA3D A0E7 BA3E A0E8 BA3F A0E9 BA40 A0EA BA41 A0EB BA42 A0EC BA43 A0ED BA44 A0EE BA45 A0EF BA46 A0F0 BA47 A0F1 BA48 A0F3 BA49 A0F4 BA4A A0F5 BA4B A0F6 BA4C A0F7 BA4D A0F8 BA4E A0F9 BA4F A0FA BA50 A0FB BA51 A0FC BA52 A0FD BA53 A141 BA54 A142 BA55 A143 BA56 A144 BA57 A145 BA58 A146 BA59 A147 BA5A A148 BA5B A149 BA5C A14A BA5D A14B BA5E A14C BA5F A14D BA60 A14E BA61 A14F BA62 A150 BA63 A151 BA64 A153 BA65 A154 BA66 A155 BA67 A156 BA68 A157 BA69 A158 BA6A A159 BA6B A15A BA6C A15B BA6D A15C BA6E A15D BA6F A161 BA70 A162 BA71 A163 BA72 A164 BA73 A165 BA74 A166 BA75 A167 BA76 A168 BA77 A169 BA78 A16A BA79 A16B BA7A A16C BA7B A16D BA7C A16E BA7D A16F BA7E A170 BA7F A171 BA80 A173 BA81 A174 BA82 A175 BA83 A176 BA84 A177 BA85 A178 BA86 A179 BA87 A17A BA88 A17B BA89 A17C BA8A A17D BA8B A181 BA8C A182 BA8D A183 BA8E A184 BA8F A185 BA90 A186 BA91 A187 BA92 A188 BA93 A189 BA94 A18A BA95 A18B BA96 A18C BA97 A18D BA98 A18E BA99 A18F BA9A A190 BA9B A191 BA9C A193 BA9D A194 BA9E A195 BA9F A196 BAA0 A197 BAA1 A198 BAA2 A199 BAA3 A19A BAA4 A19B BAA5 A19C BAA6 A19D BAA7 A1A1 BAA8 A1A2 BAA9 A1A3 BAAA A1A4 BAAB A1A5 BAAC A1A6 BAAD A1A7 BAAE A1A8 BAAF A1A9 BAB0 A1AA BAB1 A1AB BAB2 A1AC BAB3 A1AD BAB4 A1AE BAB5 A1AF BAB6 A1B0 BAB7 A1B1 BAB8 A1B3 BAB9 A1B4 BABA A1B5 BABB A1B6 BABC A1B7 BABD A1B8 BABE A1B9 BABF A1BA BAC0 A1BB BAC1 A1BC BAC2 A1BD BAC3 A1C1 BAC4 A1C2 BAC5 A1C3 BAC6 A1C4 BAC7 A1C5 BAC8 A1C6 BAC9 A1C7 BACA A1C8 BACB A1C9 BACC A1CA BACD A1CB BACE A1CC BACF A1CD BAD0 A1CE BAD1 A1CF BAD2 A1D0 BAD3 A1D1 BAD4 A1D3 BAD5 A1D4 BAD6 A1D5 BAD7 A1D6 BAD8 A1D7 BAD9 A1D8 BADA A1D9 BADB A1DA BADC A1DB BADD A1DC BADE A1DD BADF A1E1 BAE0 A1E2 BAE1 A1E3 BAE2 A1E4 BAE3 A1E5 BAE4 A1E6 BAE5 A1E7 BAE6 A1E8 BAE7 A1E9 BAE8 A1EA BAE9 A1EB BAEA A1EC BAEB A1ED BAEC A1EE BAED A1EF BAEE A1F0 BAEF A1F1 BAF0 A1F3 BAF1 A1F4 BAF2 A1F5 BAF3 A1F6 BAF4 A1F7 BAF5 A1F8 BAF6 A1F9 BAF7 A1FA BAF8 A1FB BAF9 A1FC BAFA A1FD BAFB A241 BAFC A242 BAFD A243 BAFE A244 BAFF A245 BB00 A246 BB01 A247 BB02 A248 BB03 A249 BB04 A24A BB05 A24B BB06 A24C BB07 A24D BB08 A24E BB09 A24F BB0A A250 BB0B A251 BB0C A253 BB0D A254 BB0E A255 BB0F A256 BB10 A257 BB11 A258 BB12 A259 BB13 A25A BB14 A25B BB15 A25C BB16 A25D BB17 A261 BB18 A262 BB19 A263 BB1A A264 BB1B A265 BB1C A266 BB1D A267 BB1E A268 BB1F A269 BB20 A26A BB21 A26B BB22 A26C BB23 A26D BB24 A26E BB25 A26F BB26 A270 BB27 A271 BB28 A273 BB29 A274 BB2A A275 BB2B A276 BB2C A277 BB2D A278 BB2E A279 BB2F A27A BB30 A27B BB31 A27C BB32 A27D BB33 A281 BB34 A282 BB35 A283 BB36 A284 BB37 A285 BB38 A286 BB39 A287 BB3A A288 BB3B A289 BB3C A28A BB3D A28B BB3E A28C BB3F A28D BB40 A28E BB41 A28F BB42 A290 BB43 A291 BB44 A293 BB45 A294 BB46 A295 BB47 A296 BB48 A297 BB49 A298 BB4A A299 BB4B A29A BB4C A29B BB4D A29C BB4E A29D BB4F A2A1 BB50 A2A2 BB51 A2A3 BB52 A2A4 BB53 A2A5 BB54 A2A6 BB55 A2A7 BB56 A2A8 BB57 A2A9 BB58 A2AA BB59 A2AB BB5A A2AC BB5B A2AD BB5C A2AE BB5D A2AF BB5E A2B0 BB5F A2B1 BB60 A2B3 BB61 A2B4 BB62 A2B5 BB63 A2B6 BB64 A2B7 BB65 A2B8 BB66 A2B9 BB67 A2BA BB68 A2BB BB69 A2BC BB6A A2BD BB6B A2C1 BB6C A2C2 BB6D A2C3 BB6E A2C4 BB6F A2C5 BB70 A2C6 BB71 A2C7 BB72 A2C8 BB73 A2C9 BB74 A2CA BB75 A2CB BB76 A2CC BB77 A2CD BB78 A2CE BB79 A2CF BB7A A2D0 BB7B A2D1 BB7C A2D3 BB7D A2D4 BB7E A2D5 BB7F A2D6 BB80 A2D7 BB81 A2D8 BB82 A2D9 BB83 A2DA BB84 A2DB BB85 A2DC BB86 A2DD BB87 A2E1 BB88 A2E2 BB89 A2E3 BB8A A2E4 BB8B A2E5 BB8C A2E6 BB8D A2E7 BB8E A2E8 BB8F A2E9 BB90 A2EA BB91 A2EB BB92 A2EC BB93 A2ED BB94 A2EE BB95 A2EF BB96 A2F0 BB97 A2F1 BB98 A2F3 BB99 A2F4 BB9A A2F5 BB9B A2F6 BB9C A2F7 BB9D A2F8 BB9E A2F9 BB9F A2FA BBA0 A2FB BBA1 A2FC BBA2 A2FD BBA3 A341 BBA4 A342 BBA5 A343 BBA6 A344 BBA7 A345 BBA8 A346 BBA9 A347 BBAA A348 BBAB A349 BBAC A34A BBAD A34B BBAE A34C BBAF A34D BBB0 A34E BBB1 A34F BBB2 A350 BBB3 A351 BBB4 A353 BBB5 A354 BBB6 A355 BBB7 A356 BBB8 A357 BBB9 A358 BBBA A359 BBBB A35A BBBC A35B BBBD A35C BBBE A35D BBBF A361 BBC0 A362 BBC1 A363 BBC2 A364 BBC3 A365 BBC4 A366 BBC5 A367 BBC6 A368 BBC7 A369 BBC8 A36A BBC9 A36B BBCA A36C BBCB A36D BBCC A36E BBCD A36F BBCE A370 BBCF A371 BBD0 A373 BBD1 A374 BBD2 A375 BBD3 A376 BBD4 A377 BBD5 A378 BBD6 A379 BBD7 A37A BBD8 A37B BBD9 A37C BBDA A37D BBDB A381 BBDC A382 BBDD A383 BBDE A384 BBDF A385 BBE0 A386 BBE1 A387 BBE2 A388 BBE3 A389 BBE4 A38A BBE5 A38B BBE6 A38C BBE7 A38D BBE8 A38E BBE9 A38F BBEA A390 BBEB A391 BBEC A393 BBED A394 BBEE A395 BBEF A396 BBF0 A397 BBF1 A398 BBF2 A399 BBF3 A39A BBF4 A39B BBF5 A39C BBF6 A39D BBF7 A3A1 BBF8 A3A2 BBF9 A3A3 BBFA A3A4 BBFB A3A5 BBFC A3A6 BBFD A3A7 BBFE A3A8 BBFF A3A9 BC00 A3AA BC01 A3AB BC02 A3AC BC03 A3AD BC04 A3AE BC05 A3AF BC06 A3B0 BC07 A3B1 BC08 A3B3 BC09 A3B4 BC0A A3B5 BC0B A3B6 BC0C A3B7 BC0D A3B8 BC0E A3B9 BC0F A3BA BC10 A3BB BC11 A3BC BC12 A3BD BC13 A441 3142 A461 BC14 A462 BC15 A463 BC16 A464 BC17 A465 BC18 A466 BC19 A467 BC1A A468 BC1B A469 BC1C A46A BC1D A46B BC1E A46C BC1F A46D BC20 A46E BC21 A46F BC22 A470 BC23 A471 BC24 A473 BC25 A474 BC26 A475 BC27 A476 BC28 A477 BC29 A478 BC2A A479 BC2B A47A BC2C A47B BC2D A47C BC2E A47D BC2F A481 BC30 A482 BC31 A483 BC32 A484 BC33 A485 BC34 A486 BC35 A487 BC36 A488 BC37 A489 BC38 A48A BC39 A48B BC3A A48C BC3B A48D BC3C A48E BC3D A48F BC3E A490 BC3F A491 BC40 A493 BC41 A494 BC42 A495 BC43 A496 BC44 A497 BC45 A498 BC46 A499 BC47 A49A BC48 A49B BC49 A49C BC4A A49D BC4B A4A1 BC4C A4A2 BC4D A4A3 BC4E A4A4 BC4F A4A5 BC50 A4A6 BC51 A4A7 BC52 A4A8 BC53 A4A9 BC54 A4AA BC55 A4AB BC56 A4AC BC57 A4AD BC58 A4AE BC59 A4AF BC5A A4B0 BC5B A4B1 BC5C A4B3 BC5D A4B4 BC5E A4B5 BC5F A4B6 BC60 A4B7 BC61 A4B8 BC62 A4B9 BC63 A4BA BC64 A4BB BC65 A4BC BC66 A4BD BC67 A4C1 BC68 A4C2 BC69 A4C3 BC6A A4C4 BC6B A4C5 BC6C A4C6 BC6D A4C7 BC6E A4C8 BC6F A4C9 BC70 A4CA BC71 A4CB BC72 A4CC BC73 A4CD BC74 A4CE BC75 A4CF BC76 A4D0 BC77 A4D1 BC78 A4D3 BC79 A4D4 BC7A A4D5 BC7B A4D6 BC7C A4D7 BC7D A4D8 BC7E A4D9 BC7F A4DA BC80 A4DB BC81 A4DC BC82 A4DD BC83 A4E1 BC84 A4E2 BC85 A4E3 BC86 A4E4 BC87 A4E5 BC88 A4E6 BC89 A4E7 BC8A A4E8 BC8B A4E9 BC8C A4EA BC8D A4EB BC8E A4EC BC8F A4ED BC90 A4EE BC91 A4EF BC92 A4F0 BC93 A4F1 BC94 A4F3 BC95 A4F4 BC96 A4F5 BC97 A4F6 BC98 A4F7 BC99 A4F8 BC9A A4F9 BC9B A4FA BC9C A4FB BC9D A4FC BC9E A4FD BC9F A541 BCA0 A542 BCA1 A543 BCA2 A544 BCA3 A545 BCA4 A546 BCA5 A547 BCA6 A548 BCA7 A549 BCA8 A54A BCA9 A54B BCAA A54C BCAB A54D BCAC A54E BCAD A54F BCAE A550 BCAF A551 BCB0 A553 BCB1 A554 BCB2 A555 BCB3 A556 BCB4 A557 BCB5 A558 BCB6 A559 BCB7 A55A BCB8 A55B BCB9 A55C BCBA A55D BCBB A561 BCBC A562 BCBD A563 BCBE A564 BCBF A565 BCC0 A566 BCC1 A567 BCC2 A568 BCC3 A569 BCC4 A56A BCC5 A56B BCC6 A56C BCC7 A56D BCC8 A56E BCC9 A56F BCCA A570 BCCB A571 BCCC A573 BCCD A574 BCCE A575 BCCF A576 BCD0 A577 BCD1 A578 BCD2 A579 BCD3 A57A BCD4 A57B BCD5 A57C BCD6 A57D BCD7 A581 BCD8 A582 BCD9 A583 BCDA A584 BCDB A585 BCDC A586 BCDD A587 BCDE A588 BCDF A589 BCE0 A58A BCE1 A58B BCE2 A58C BCE3 A58D BCE4 A58E BCE5 A58F BCE6 A590 BCE7 A591 BCE8 A593 BCE9 A594 BCEA A595 BCEB A596 BCEC A597 BCED A598 BCEE A599 BCEF A59A BCF0 A59B BCF1 A59C BCF2 A59D BCF3 A5A1 BCF4 A5A2 BCF5 A5A3 BCF6 A5A4 BCF7 A5A5 BCF8 A5A6 BCF9 A5A7 BCFA A5A8 BCFB A5A9 BCFC A5AA BCFD A5AB BCFE A5AC BCFF A5AD BD00 A5AE BD01 A5AF BD02 A5B0 BD03 A5B1 BD04 A5B3 BD05 A5B4 BD06 A5B5 BD07 A5B6 BD08 A5B7 BD09 A5B8 BD0A A5B9 BD0B A5BA BD0C A5BB BD0D A5BC BD0E A5BD BD0F A5C1 BD10 A5C2 BD11 A5C3 BD12 A5C4 BD13 A5C5 BD14 A5C6 BD15 A5C7 BD16 A5C8 BD17 A5C9 BD18 A5CA BD19 A5CB BD1A A5CC BD1B A5CD BD1C A5CE BD1D A5CF BD1E A5D0 BD1F A5D1 BD20 A5D3 BD21 A5D4 BD22 A5D5 BD23 A5D6 BD24 A5D7 BD25 A5D8 BD26 A5D9 BD27 A5DA BD28 A5DB BD29 A5DC BD2A A5DD BD2B A5E1 BD2C A5E2 BD2D A5E3 BD2E A5E4 BD2F A5E5 BD30 A5E6 BD31 A5E7 BD32 A5E8 BD33 A5E9 BD34 A5EA BD35 A5EB BD36 A5EC BD37 A5ED BD38 A5EE BD39 A5EF BD3A A5F0 BD3B A5F1 BD3C A5F3 BD3D A5F4 BD3E A5F5 BD3F A5F6 BD40 A5F7 BD41 A5F8 BD42 A5F9 BD43 A5FA BD44 A5FB BD45 A5FC BD46 A5FD BD47 A641 BD48 A642 BD49 A643 BD4A A644 BD4B A645 BD4C A646 BD4D A647 BD4E A648 BD4F A649 BD50 A64A BD51 A64B BD52 A64C BD53 A64D BD54 A64E BD55 A64F BD56 A650 BD57 A651 BD58 A653 BD59 A654 BD5A A655 BD5B A656 BD5C A657 BD5D A658 BD5E A659 BD5F A65A BD60 A65B BD61 A65C BD62 A65D BD63 A661 BD64 A662 BD65 A663 BD66 A664 BD67 A665 BD68 A666 BD69 A667 BD6A A668 BD6B A669 BD6C A66A BD6D A66B BD6E A66C BD6F A66D BD70 A66E BD71 A66F BD72 A670 BD73 A671 BD74 A673 BD75 A674 BD76 A675 BD77 A676 BD78 A677 BD79 A678 BD7A A679 BD7B A67A BD7C A67B BD7D A67C BD7E A67D BD7F A681 BD80 A682 BD81 A683 BD82 A684 BD83 A685 BD84 A686 BD85 A687 BD86 A688 BD87 A689 BD88 A68A BD89 A68B BD8A A68C BD8B A68D BD8C A68E BD8D A68F BD8E A690 BD8F A691 BD90 A693 BD91 A694 BD92 A695 BD93 A696 BD94 A697 BD95 A698 BD96 A699 BD97 A69A BD98 A69B BD99 A69C BD9A A69D BD9B A6A1 BD9C A6A2 BD9D A6A3 BD9E A6A4 BD9F A6A5 BDA0 A6A6 BDA1 A6A7 BDA2 A6A8 BDA3 A6A9 BDA4 A6AA BDA5 A6AB BDA6 A6AC BDA7 A6AD BDA8 A6AE BDA9 A6AF BDAA A6B0 BDAB A6B1 BDAC A6B3 BDAD A6B4 BDAE A6B5 BDAF A6B6 BDB0 A6B7 BDB1 A6B8 BDB2 A6B9 BDB3 A6BA BDB4 A6BB BDB5 A6BC BDB6 A6BD BDB7 A6C1 BDB8 A6C2 BDB9 A6C3 BDBA A6C4 BDBB A6C5 BDBC A6C6 BDBD A6C7 BDBE A6C8 BDBF A6C9 BDC0 A6CA BDC1 A6CB BDC2 A6CC BDC3 A6CD BDC4 A6CE BDC5 A6CF BDC6 A6D0 BDC7 A6D1 BDC8 A6D3 BDC9 A6D4 BDCA A6D5 BDCB A6D6 BDCC A6D7 BDCD A6D8 BDCE A6D9 BDCF A6DA BDD0 A6DB BDD1 A6DC BDD2 A6DD BDD3 A6E1 BDD4 A6E2 BDD5 A6E3 BDD6 A6E4 BDD7 A6E5 BDD8 A6E6 BDD9 A6E7 BDDA A6E8 BDDB A6E9 BDDC A6EA BDDD A6EB BDDE A6EC BDDF A6ED BDE0 A6EE BDE1 A6EF BDE2 A6F0 BDE3 A6F1 BDE4 A6F3 BDE5 A6F4 BDE6 A6F5 BDE7 A6F6 BDE8 A6F7 BDE9 A6F8 BDEA A6F9 BDEB A6FA BDEC A6FB BDED A6FC BDEE A6FD BDEF A741 BDF0 A742 BDF1 A743 BDF2 A744 BDF3 A745 BDF4 A746 BDF5 A747 BDF6 A748 BDF7 A749 BDF8 A74A BDF9 A74B BDFA A74C BDFB A74D BDFC A74E BDFD A74F BDFE A750 BDFF A751 BE00 A753 BE01 A754 BE02 A755 BE03 A756 BE04 A757 BE05 A758 BE06 A759 BE07 A75A BE08 A75B BE09 A75C BE0A A75D BE0B A761 BE0C A762 BE0D A763 BE0E A764 BE0F A765 BE10 A766 BE11 A767 BE12 A768 BE13 A769 BE14 A76A BE15 A76B BE16 A76C BE17 A76D BE18 A76E BE19 A76F BE1A A770 BE1B A771 BE1C A773 BE1D A774 BE1E A775 BE1F A776 BE20 A777 BE21 A778 BE22 A779 BE23 A77A BE24 A77B BE25 A77C BE26 A77D BE27 A781 BE28 A782 BE29 A783 BE2A A784 BE2B A785 BE2C A786 BE2D A787 BE2E A788 BE2F A789 BE30 A78A BE31 A78B BE32 A78C BE33 A78D BE34 A78E BE35 A78F BE36 A790 BE37 A791 BE38 A793 BE39 A794 BE3A A795 BE3B A796 BE3C A797 BE3D A798 BE3E A799 BE3F A79A BE40 A79B BE41 A79C BE42 A79D BE43 A7A1 BE44 A7A2 BE45 A7A3 BE46 A7A4 BE47 A7A5 BE48 A7A6 BE49 A7A7 BE4A A7A8 BE4B A7A9 BE4C A7AA BE4D A7AB BE4E A7AC BE4F A7AD BE50 A7AE BE51 A7AF BE52 A7B0 BE53 A7B1 BE54 A7B3 BE55 A7B4 BE56 A7B5 BE57 A7B6 BE58 A7B7 BE59 A7B8 BE5A A7B9 BE5B A7BA BE5C A7BB BE5D A7BC BE5E A7BD BE5F A841 3143 A861 BE60 A862 BE61 A863 BE62 A864 BE63 A865 BE64 A866 BE65 A867 BE66 A868 BE67 A869 BE68 A86A BE69 A86B BE6A A86C BE6B A86D BE6C A86E BE6D A86F BE6E A870 BE6F A871 BE70 A873 BE71 A874 BE72 A875 BE73 A876 BE74 A877 BE75 A878 BE76 A879 BE77 A87A BE78 A87B BE79 A87C BE7A A87D BE7B A881 BE7C A882 BE7D A883 BE7E A884 BE7F A885 BE80 A886 BE81 A887 BE82 A888 BE83 A889 BE84 A88A BE85 A88B BE86 A88C BE87 A88D BE88 A88E BE89 A88F BE8A A890 BE8B A891 BE8C A893 BE8D A894 BE8E A895 BE8F A896 BE90 A897 BE91 A898 BE92 A899 BE93 A89A BE94 A89B BE95 A89C BE96 A89D BE97 A8A1 BE98 A8A2 BE99 A8A3 BE9A A8A4 BE9B A8A5 BE9C A8A6 BE9D A8A7 BE9E A8A8 BE9F A8A9 BEA0 A8AA BEA1 A8AB BEA2 A8AC BEA3 A8AD BEA4 A8AE BEA5 A8AF BEA6 A8B0 BEA7 A8B1 BEA8 A8B3 BEA9 A8B4 BEAA A8B5 BEAB A8B6 BEAC A8B7 BEAD A8B8 BEAE A8B9 BEAF A8BA BEB0 A8BB BEB1 A8BC BEB2 A8BD BEB3 A8C1 BEB4 A8C2 BEB5 A8C3 BEB6 A8C4 BEB7 A8C5 BEB8 A8C6 BEB9 A8C7 BEBA A8C8 BEBB A8C9 BEBC A8CA BEBD A8CB BEBE A8CC BEBF A8CD BEC0 A8CE BEC1 A8CF BEC2 A8D0 BEC3 A8D1 BEC4 A8D3 BEC5 A8D4 BEC6 A8D5 BEC7 A8D6 BEC8 A8D7 BEC9 A8D8 BECA A8D9 BECB A8DA BECC A8DB BECD A8DC BECE A8DD BECF A8E1 BED0 A8E2 BED1 A8E3 BED2 A8E4 BED3 A8E5 BED4 A8E6 BED5 A8E7 BED6 A8E8 BED7 A8E9 BED8 A8EA BED9 A8EB BEDA A8EC BEDB A8ED BEDC A8EE BEDD A8EF BEDE A8F0 BEDF A8F1 BEE0 A8F3 BEE1 A8F4 BEE2 A8F5 BEE3 A8F6 BEE4 A8F7 BEE5 A8F8 BEE6 A8F9 BEE7 A8FA BEE8 A8FB BEE9 A8FC BEEA A8FD BEEB A941 BEEC A942 BEED A943 BEEE A944 BEEF A945 BEF0 A946 BEF1 A947 BEF2 A948 BEF3 A949 BEF4 A94A BEF5 A94B BEF6 A94C BEF7 A94D BEF8 A94E BEF9 A94F BEFA A950 BEFB A951 BEFC A953 BEFD A954 BEFE A955 BEFF A956 BF00 A957 BF01 A958 BF02 A959 BF03 A95A BF04 A95B BF05 A95C BF06 A95D BF07 A961 BF08 A962 BF09 A963 BF0A A964 BF0B A965 BF0C A966 BF0D A967 BF0E A968 BF0F A969 BF10 A96A BF11 A96B BF12 A96C BF13 A96D BF14 A96E BF15 A96F BF16 A970 BF17 A971 BF18 A973 BF19 A974 BF1A A975 BF1B A976 BF1C A977 BF1D A978 BF1E A979 BF1F A97A BF20 A97B BF21 A97C BF22 A97D BF23 A981 BF24 A982 BF25 A983 BF26 A984 BF27 A985 BF28 A986 BF29 A987 BF2A A988 BF2B A989 BF2C A98A BF2D A98B BF2E A98C BF2F A98D BF30 A98E BF31 A98F BF32 A990 BF33 A991 BF34 A993 BF35 A994 BF36 A995 BF37 A996 BF38 A997 BF39 A998 BF3A A999 BF3B A99A BF3C A99B BF3D A99C BF3E A99D BF3F A9A1 BF40 A9A2 BF41 A9A3 BF42 A9A4 BF43 A9A5 BF44 A9A6 BF45 A9A7 BF46 A9A8 BF47 A9A9 BF48 A9AA BF49 A9AB BF4A A9AC BF4B A9AD BF4C A9AE BF4D A9AF BF4E A9B0 BF4F A9B1 BF50 A9B3 BF51 A9B4 BF52 A9B5 BF53 A9B6 BF54 A9B7 BF55 A9B8 BF56 A9B9 BF57 A9BA BF58 A9BB BF59 A9BC BF5A A9BD BF5B A9C1 BF5C A9C2 BF5D A9C3 BF5E A9C4 BF5F A9C5 BF60 A9C6 BF61 A9C7 BF62 A9C8 BF63 A9C9 BF64 A9CA BF65 A9CB BF66 A9CC BF67 A9CD BF68 A9CE BF69 A9CF BF6A A9D0 BF6B A9D1 BF6C A9D3 BF6D A9D4 BF6E A9D5 BF6F A9D6 BF70 A9D7 BF71 A9D8 BF72 A9D9 BF73 A9DA BF74 A9DB BF75 A9DC BF76 A9DD BF77 A9E1 BF78 A9E2 BF79 A9E3 BF7A A9E4 BF7B A9E5 BF7C A9E6 BF7D A9E7 BF7E A9E8 BF7F A9E9 BF80 A9EA BF81 A9EB BF82 A9EC BF83 A9ED BF84 A9EE BF85 A9EF BF86 A9F0 BF87 A9F1 BF88 A9F3 BF89 A9F4 BF8A A9F5 BF8B A9F6 BF8C A9F7 BF8D A9F8 BF8E A9F9 BF8F A9FA BF90 A9FB BF91 A9FC BF92 A9FD BF93 AA41 BF94 AA42 BF95 AA43 BF96 AA44 BF97 AA45 BF98 AA46 BF99 AA47 BF9A AA48 BF9B AA49 BF9C AA4A BF9D AA4B BF9E AA4C BF9F AA4D BFA0 AA4E BFA1 AA4F BFA2 AA50 BFA3 AA51 BFA4 AA53 BFA5 AA54 BFA6 AA55 BFA7 AA56 BFA8 AA57 BFA9 AA58 BFAA AA59 BFAB AA5A BFAC AA5B BFAD AA5C BFAE AA5D BFAF AA61 BFB0 AA62 BFB1 AA63 BFB2 AA64 BFB3 AA65 BFB4 AA66 BFB5 AA67 BFB6 AA68 BFB7 AA69 BFB8 AA6A BFB9 AA6B BFBA AA6C BFBB AA6D BFBC AA6E BFBD AA6F BFBE AA70 BFBF AA71 BFC0 AA73 BFC1 AA74 BFC2 AA75 BFC3 AA76 BFC4 AA77 BFC5 AA78 BFC6 AA79 BFC7 AA7A BFC8 AA7B BFC9 AA7C BFCA AA7D BFCB AA81 BFCC AA82 BFCD AA83 BFCE AA84 BFCF AA85 BFD0 AA86 BFD1 AA87 BFD2 AA88 BFD3 AA89 BFD4 AA8A BFD5 AA8B BFD6 AA8C BFD7 AA8D BFD8 AA8E BFD9 AA8F BFDA AA90 BFDB AA91 BFDC AA93 BFDD AA94 BFDE AA95 BFDF AA96 BFE0 AA97 BFE1 AA98 BFE2 AA99 BFE3 AA9A BFE4 AA9B BFE5 AA9C BFE6 AA9D BFE7 AAA1 BFE8 AAA2 BFE9 AAA3 BFEA AAA4 BFEB AAA5 BFEC AAA6 BFED AAA7 BFEE AAA8 BFEF AAA9 BFF0 AAAA BFF1 AAAB BFF2 AAAC BFF3 AAAD BFF4 AAAE BFF5 AAAF BFF6 AAB0 BFF7 AAB1 BFF8 AAB3 BFF9 AAB4 BFFA AAB5 BFFB AAB6 BFFC AAB7 BFFD AAB8 BFFE AAB9 BFFF AABA C000 AABB C001 AABC C002 AABD C003 AAC1 C004 AAC2 C005 AAC3 C006 AAC4 C007 AAC5 C008 AAC6 C009 AAC7 C00A AAC8 C00B AAC9 C00C AACA C00D AACB C00E AACC C00F AACD C010 AACE C011 AACF C012 AAD0 C013 AAD1 C014 AAD3 C015 AAD4 C016 AAD5 C017 AAD6 C018 AAD7 C019 AAD8 C01A AAD9 C01B AADA C01C AADB C01D AADC C01E AADD C01F AAE1 C020 AAE2 C021 AAE3 C022 AAE4 C023 AAE5 C024 AAE6 C025 AAE7 C026 AAE8 C027 AAE9 C028 AAEA C029 AAEB C02A AAEC C02B AAED C02C AAEE C02D AAEF C02E AAF0 C02F AAF1 C030 AAF3 C031 AAF4 C032 AAF5 C033 AAF6 C034 AAF7 C035 AAF8 C036 AAF9 C037 AAFA C038 AAFB C039 AAFC C03A AAFD C03B AB41 C03C AB42 C03D AB43 C03E AB44 C03F AB45 C040 AB46 C041 AB47 C042 AB48 C043 AB49 C044 AB4A C045 AB4B C046 AB4C C047 AB4D C048 AB4E C049 AB4F C04A AB50 C04B AB51 C04C AB53 C04D AB54 C04E AB55 C04F AB56 C050 AB57 C051 AB58 C052 AB59 C053 AB5A C054 AB5B C055 AB5C C056 AB5D C057 AB61 C058 AB62 C059 AB63 C05A AB64 C05B AB65 C05C AB66 C05D AB67 C05E AB68 C05F AB69 C060 AB6A C061 AB6B C062 AB6C C063 AB6D C064 AB6E C065 AB6F C066 AB70 C067 AB71 C068 AB73 C069 AB74 C06A AB75 C06B AB76 C06C AB77 C06D AB78 C06E AB79 C06F AB7A C070 AB7B C071 AB7C C072 AB7D C073 AB81 C074 AB82 C075 AB83 C076 AB84 C077 AB85 C078 AB86 C079 AB87 C07A AB88 C07B AB89 C07C AB8A C07D AB8B C07E AB8C C07F AB8D C080 AB8E C081 AB8F C082 AB90 C083 AB91 C084 AB93 C085 AB94 C086 AB95 C087 AB96 C088 AB97 C089 AB98 C08A AB99 C08B AB9A C08C AB9B C08D AB9C C08E AB9D C08F ABA1 C090 ABA2 C091 ABA3 C092 ABA4 C093 ABA5 C094 ABA6 C095 ABA7 C096 ABA8 C097 ABA9 C098 ABAA C099 ABAB C09A ABAC C09B ABAD C09C ABAE C09D ABAF C09E ABB0 C09F ABB1 C0A0 ABB3 C0A1 ABB4 C0A2 ABB5 C0A3 ABB6 C0A4 ABB7 C0A5 ABB8 C0A6 ABB9 C0A7 ABBA C0A8 ABBB C0A9 ABBC C0AA ABBD C0AB AC41 3145 AC61 C0AC AC62 C0AD AC63 C0AE AC64 C0AF AC65 C0B0 AC66 C0B1 AC67 C0B2 AC68 C0B3 AC69 C0B4 AC6A C0B5 AC6B C0B6 AC6C C0B7 AC6D C0B8 AC6E C0B9 AC6F C0BA AC70 C0BB AC71 C0BC AC73 C0BD AC74 C0BE AC75 C0BF AC76 C0C0 AC77 C0C1 AC78 C0C2 AC79 C0C3 AC7A C0C4 AC7B C0C5 AC7C C0C6 AC7D C0C7 AC81 C0C8 AC82 C0C9 AC83 C0CA AC84 C0CB AC85 C0CC AC86 C0CD AC87 C0CE AC88 C0CF AC89 C0D0 AC8A C0D1 AC8B C0D2 AC8C C0D3 AC8D C0D4 AC8E C0D5 AC8F C0D6 AC90 C0D7 AC91 C0D8 AC93 C0D9 AC94 C0DA AC95 C0DB AC96 C0DC AC97 C0DD AC98 C0DE AC99 C0DF AC9A C0E0 AC9B C0E1 AC9C C0E2 AC9D C0E3 ACA1 C0E4 ACA2 C0E5 ACA3 C0E6 ACA4 C0E7 ACA5 C0E8 ACA6 C0E9 ACA7 C0EA ACA8 C0EB ACA9 C0EC ACAA C0ED ACAB C0EE ACAC C0EF ACAD C0F0 ACAE C0F1 ACAF C0F2 ACB0 C0F3 ACB1 C0F4 ACB3 C0F5 ACB4 C0F6 ACB5 C0F7 ACB6 C0F8 ACB7 C0F9 ACB8 C0FA ACB9 C0FB ACBA C0FC ACBB C0FD ACBC C0FE ACBD C0FF ACC1 C100 ACC2 C101 ACC3 C102 ACC4 C103 ACC5 C104 ACC6 C105 ACC7 C106 ACC8 C107 ACC9 C108 ACCA C109 ACCB C10A ACCC C10B ACCD C10C ACCE C10D ACCF C10E ACD0 C10F ACD1 C110 ACD3 C111 ACD4 C112 ACD5 C113 ACD6 C114 ACD7 C115 ACD8 C116 ACD9 C117 ACDA C118 ACDB C119 ACDC C11A ACDD C11B ACE1 C11C ACE2 C11D ACE3 C11E ACE4 C11F ACE5 C120 ACE6 C121 ACE7 C122 ACE8 C123 ACE9 C124 ACEA C125 ACEB C126 ACEC C127 ACED C128 ACEE C129 ACEF C12A ACF0 C12B ACF1 C12C ACF3 C12D ACF4 C12E ACF5 C12F ACF6 C130 ACF7 C131 ACF8 C132 ACF9 C133 ACFA C134 ACFB C135 ACFC C136 ACFD C137 AD41 C138 AD42 C139 AD43 C13A AD44 C13B AD45 C13C AD46 C13D AD47 C13E AD48 C13F AD49 C140 AD4A C141 AD4B C142 AD4C C143 AD4D C144 AD4E C145 AD4F C146 AD50 C147 AD51 C148 AD53 C149 AD54 C14A AD55 C14B AD56 C14C AD57 C14D AD58 C14E AD59 C14F AD5A C150 AD5B C151 AD5C C152 AD5D C153 AD61 C154 AD62 C155 AD63 C156 AD64 C157 AD65 C158 AD66 C159 AD67 C15A AD68 C15B AD69 C15C AD6A C15D AD6B C15E AD6C C15F AD6D C160 AD6E C161 AD6F C162 AD70 C163 AD71 C164 AD73 C165 AD74 C166 AD75 C167 AD76 C168 AD77 C169 AD78 C16A AD79 C16B AD7A C16C AD7B C16D AD7C C16E AD7D C16F AD81 C170 AD82 C171 AD83 C172 AD84 C173 AD85 C174 AD86 C175 AD87 C176 AD88 C177 AD89 C178 AD8A C179 AD8B C17A AD8C C17B AD8D C17C AD8E C17D AD8F C17E AD90 C17F AD91 C180 AD93 C181 AD94 C182 AD95 C183 AD96 C184 AD97 C185 AD98 C186 AD99 C187 AD9A C188 AD9B C189 AD9C C18A AD9D C18B ADA1 C18C ADA2 C18D ADA3 C18E ADA4 C18F ADA5 C190 ADA6 C191 ADA7 C192 ADA8 C193 ADA9 C194 ADAA C195 ADAB C196 ADAC C197 ADAD C198 ADAE C199 ADAF C19A ADB0 C19B ADB1 C19C ADB3 C19D ADB4 C19E ADB5 C19F ADB6 C1A0 ADB7 C1A1 ADB8 C1A2 ADB9 C1A3 ADBA C1A4 ADBB C1A5 ADBC C1A6 ADBD C1A7 ADC1 C1A8 ADC2 C1A9 ADC3 C1AA ADC4 C1AB ADC5 C1AC ADC6 C1AD ADC7 C1AE ADC8 C1AF ADC9 C1B0 ADCA C1B1 ADCB C1B2 ADCC C1B3 ADCD C1B4 ADCE C1B5 ADCF C1B6 ADD0 C1B7 ADD1 C1B8 ADD3 C1B9 ADD4 C1BA ADD5 C1BB ADD6 C1BC ADD7 C1BD ADD8 C1BE ADD9 C1BF ADDA C1C0 ADDB C1C1 ADDC C1C2 ADDD C1C3 ADE1 C1C4 ADE2 C1C5 ADE3 C1C6 ADE4 C1C7 ADE5 C1C8 ADE6 C1C9 ADE7 C1CA ADE8 C1CB ADE9 C1CC ADEA C1CD ADEB C1CE ADEC C1CF ADED C1D0 ADEE C1D1 ADEF C1D2 ADF0 C1D3 ADF1 C1D4 ADF3 C1D5 ADF4 C1D6 ADF5 C1D7 ADF6 C1D8 ADF7 C1D9 ADF8 C1DA ADF9 C1DB ADFA C1DC ADFB C1DD ADFC C1DE ADFD C1DF AE41 C1E0 AE42 C1E1 AE43 C1E2 AE44 C1E3 AE45 C1E4 AE46 C1E5 AE47 C1E6 AE48 C1E7 AE49 C1E8 AE4A C1E9 AE4B C1EA AE4C C1EB AE4D C1EC AE4E C1ED AE4F C1EE AE50 C1EF AE51 C1F0 AE53 C1F1 AE54 C1F2 AE55 C1F3 AE56 C1F4 AE57 C1F5 AE58 C1F6 AE59 C1F7 AE5A C1F8 AE5B C1F9 AE5C C1FA AE5D C1FB AE61 C1FC AE62 C1FD AE63 C1FE AE64 C1FF AE65 C200 AE66 C201 AE67 C202 AE68 C203 AE69 C204 AE6A C205 AE6B C206 AE6C C207 AE6D C208 AE6E C209 AE6F C20A AE70 C20B AE71 C20C AE73 C20D AE74 C20E AE75 C20F AE76 C210 AE77 C211 AE78 C212 AE79 C213 AE7A C214 AE7B C215 AE7C C216 AE7D C217 AE81 C218 AE82 C219 AE83 C21A AE84 C21B AE85 C21C AE86 C21D AE87 C21E AE88 C21F AE89 C220 AE8A C221 AE8B C222 AE8C C223 AE8D C224 AE8E C225 AE8F C226 AE90 C227 AE91 C228 AE93 C229 AE94 C22A AE95 C22B AE96 C22C AE97 C22D AE98 C22E AE99 C22F AE9A C230 AE9B C231 AE9C C232 AE9D C233 AEA1 C234 AEA2 C235 AEA3 C236 AEA4 C237 AEA5 C238 AEA6 C239 AEA7 C23A AEA8 C23B AEA9 C23C AEAA C23D AEAB C23E AEAC C23F AEAD C240 AEAE C241 AEAF C242 AEB0 C243 AEB1 C244 AEB3 C245 AEB4 C246 AEB5 C247 AEB6 C248 AEB7 C249 AEB8 C24A AEB9 C24B AEBA C24C AEBB C24D AEBC C24E AEBD C24F AEC1 C250 AEC2 C251 AEC3 C252 AEC4 C253 AEC5 C254 AEC6 C255 AEC7 C256 AEC8 C257 AEC9 C258 AECA C259 AECB C25A AECC C25B AECD C25C AECE C25D AECF C25E AED0 C25F AED1 C260 AED3 C261 AED4 C262 AED5 C263 AED6 C264 AED7 C265 AED8 C266 AED9 C267 AEDA C268 AEDB C269 AEDC C26A AEDD C26B AEE1 C26C AEE2 C26D AEE3 C26E AEE4 C26F AEE5 C270 AEE6 C271 AEE7 C272 AEE8 C273 AEE9 C274 AEEA C275 AEEB C276 AEEC C277 AEED C278 AEEE C279 AEEF C27A AEF0 C27B AEF1 C27C AEF3 C27D AEF4 C27E AEF5 C27F AEF6 C280 AEF7 C281 AEF8 C282 AEF9 C283 AEFA C284 AEFB C285 AEFC C286 AEFD C287 AF41 C288 AF42 C289 AF43 C28A AF44 C28B AF45 C28C AF46 C28D AF47 C28E AF48 C28F AF49 C290 AF4A C291 AF4B C292 AF4C C293 AF4D C294 AF4E C295 AF4F C296 AF50 C297 AF51 C298 AF53 C299 AF54 C29A AF55 C29B AF56 C29C AF57 C29D AF58 C29E AF59 C29F AF5A C2A0 AF5B C2A1 AF5C C2A2 AF5D C2A3 AF61 C2A4 AF62 C2A5 AF63 C2A6 AF64 C2A7 AF65 C2A8 AF66 C2A9 AF67 C2AA AF68 C2AB AF69 C2AC AF6A C2AD AF6B C2AE AF6C C2AF AF6D C2B0 AF6E C2B1 AF6F C2B2 AF70 C2B3 AF71 C2B4 AF73 C2B5 AF74 C2B6 AF75 C2B7 AF76 C2B8 AF77 C2B9 AF78 C2BA AF79 C2BB AF7A C2BC AF7B C2BD AF7C C2BE AF7D C2BF AF81 C2C0 AF82 C2C1 AF83 C2C2 AF84 C2C3 AF85 C2C4 AF86 C2C5 AF87 C2C6 AF88 C2C7 AF89 C2C8 AF8A C2C9 AF8B C2CA AF8C C2CB AF8D C2CC AF8E C2CD AF8F C2CE AF90 C2CF AF91 C2D0 AF93 C2D1 AF94 C2D2 AF95 C2D3 AF96 C2D4 AF97 C2D5 AF98 C2D6 AF99 C2D7 AF9A C2D8 AF9B C2D9 AF9C C2DA AF9D C2DB AFA1 C2DC AFA2 C2DD AFA3 C2DE AFA4 C2DF AFA5 C2E0 AFA6 C2E1 AFA7 C2E2 AFA8 C2E3 AFA9 C2E4 AFAA C2E5 AFAB C2E6 AFAC C2E7 AFAD C2E8 AFAE C2E9 AFAF C2EA AFB0 C2EB AFB1 C2EC AFB3 C2ED AFB4 C2EE AFB5 C2EF AFB6 C2F0 AFB7 C2F1 AFB8 C2F2 AFB9 C2F3 AFBA C2F4 AFBB C2F5 AFBC C2F6 AFBD C2F7 B041 3146 B061 C2F8 B062 C2F9 B063 C2FA B064 C2FB B065 C2FC B066 C2FD B067 C2FE B068 C2FF B069 C300 B06A C301 B06B C302 B06C C303 B06D C304 B06E C305 B06F C306 B070 C307 B071 C308 B073 C309 B074 C30A B075 C30B B076 C30C B077 C30D B078 C30E B079 C30F B07A C310 B07B C311 B07C C312 B07D C313 B081 C314 B082 C315 B083 C316 B084 C317 B085 C318 B086 C319 B087 C31A B088 C31B B089 C31C B08A C31D B08B C31E B08C C31F B08D C320 B08E C321 B08F C322 B090 C323 B091 C324 B093 C325 B094 C326 B095 C327 B096 C328 B097 C329 B098 C32A B099 C32B B09A C32C B09B C32D B09C C32E B09D C32F B0A1 C330 B0A2 C331 B0A3 C332 B0A4 C333 B0A5 C334 B0A6 C335 B0A7 C336 B0A8 C337 B0A9 C338 B0AA C339 B0AB C33A B0AC C33B B0AD C33C B0AE C33D B0AF C33E B0B0 C33F B0B1 C340 B0B3 C341 B0B4 C342 B0B5 C343 B0B6 C344 B0B7 C345 B0B8 C346 B0B9 C347 B0BA C348 B0BB C349 B0BC C34A B0BD C34B B0C1 C34C B0C2 C34D B0C3 C34E B0C4 C34F B0C5 C350 B0C6 C351 B0C7 C352 B0C8 C353 B0C9 C354 B0CA C355 B0CB C356 B0CC C357 B0CD C358 B0CE C359 B0CF C35A B0D0 C35B B0D1 C35C B0D3 C35D B0D4 C35E B0D5 C35F B0D6 C360 B0D7 C361 B0D8 C362 B0D9 C363 B0DA C364 B0DB C365 B0DC C366 B0DD C367 B0E1 C368 B0E2 C369 B0E3 C36A B0E4 C36B B0E5 C36C B0E6 C36D B0E7 C36E B0E8 C36F B0E9 C370 B0EA C371 B0EB C372 B0EC C373 B0ED C374 B0EE C375 B0EF C376 B0F0 C377 B0F1 C378 B0F3 C379 B0F4 C37A B0F5 C37B B0F6 C37C B0F7 C37D B0F8 C37E B0F9 C37F B0FA C380 B0FB C381 B0FC C382 B0FD C383 B141 C384 B142 C385 B143 C386 B144 C387 B145 C388 B146 C389 B147 C38A B148 C38B B149 C38C B14A C38D B14B C38E B14C C38F B14D C390 B14E C391 B14F C392 B150 C393 B151 C394 B153 C395 B154 C396 B155 C397 B156 C398 B157 C399 B158 C39A B159 C39B B15A C39C B15B C39D B15C C39E B15D C39F B161 C3A0 B162 C3A1 B163 C3A2 B164 C3A3 B165 C3A4 B166 C3A5 B167 C3A6 B168 C3A7 B169 C3A8 B16A C3A9 B16B C3AA B16C C3AB B16D C3AC B16E C3AD B16F C3AE B170 C3AF B171 C3B0 B173 C3B1 B174 C3B2 B175 C3B3 B176 C3B4 B177 C3B5 B178 C3B6 B179 C3B7 B17A C3B8 B17B C3B9 B17C C3BA B17D C3BB B181 C3BC B182 C3BD B183 C3BE B184 C3BF B185 C3C0 B186 C3C1 B187 C3C2 B188 C3C3 B189 C3C4 B18A C3C5 B18B C3C6 B18C C3C7 B18D C3C8 B18E C3C9 B18F C3CA B190 C3CB B191 C3CC B193 C3CD B194 C3CE B195 C3CF B196 C3D0 B197 C3D1 B198 C3D2 B199 C3D3 B19A C3D4 B19B C3D5 B19C C3D6 B19D C3D7 B1A1 C3D8 B1A2 C3D9 B1A3 C3DA B1A4 C3DB B1A5 C3DC B1A6 C3DD B1A7 C3DE B1A8 C3DF B1A9 C3E0 B1AA C3E1 B1AB C3E2 B1AC C3E3 B1AD C3E4 B1AE C3E5 B1AF C3E6 B1B0 C3E7 B1B1 C3E8 B1B3 C3E9 B1B4 C3EA B1B5 C3EB B1B6 C3EC B1B7 C3ED B1B8 C3EE B1B9 C3EF B1BA C3F0 B1BB C3F1 B1BC C3F2 B1BD C3F3 B1C1 C3F4 B1C2 C3F5 B1C3 C3F6 B1C4 C3F7 B1C5 C3F8 B1C6 C3F9 B1C7 C3FA B1C8 C3FB B1C9 C3FC B1CA C3FD B1CB C3FE B1CC C3FF B1CD C400 B1CE C401 B1CF C402 B1D0 C403 B1D1 C404 B1D3 C405 B1D4 C406 B1D5 C407 B1D6 C408 B1D7 C409 B1D8 C40A B1D9 C40B B1DA C40C B1DB C40D B1DC C40E B1DD C40F B1E1 C410 B1E2 C411 B1E3 C412 B1E4 C413 B1E5 C414 B1E6 C415 B1E7 C416 B1E8 C417 B1E9 C418 B1EA C419 B1EB C41A B1EC C41B B1ED C41C B1EE C41D B1EF C41E B1F0 C41F B1F1 C420 B1F3 C421 B1F4 C422 B1F5 C423 B1F6 C424 B1F7 C425 B1F8 C426 B1F9 C427 B1FA C428 B1FB C429 B1FC C42A B1FD C42B B241 C42C B242 C42D B243 C42E B244 C42F B245 C430 B246 C431 B247 C432 B248 C433 B249 C434 B24A C435 B24B C436 B24C C437 B24D C438 B24E C439 B24F C43A B250 C43B B251 C43C B253 C43D B254 C43E B255 C43F B256 C440 B257 C441 B258 C442 B259 C443 B25A C444 B25B C445 B25C C446 B25D C447 B261 C448 B262 C449 B263 C44A B264 C44B B265 C44C B266 C44D B267 C44E B268 C44F B269 C450 B26A C451 B26B C452 B26C C453 B26D C454 B26E C455 B26F C456 B270 C457 B271 C458 B273 C459 B274 C45A B275 C45B B276 C45C B277 C45D B278 C45E B279 C45F B27A C460 B27B C461 B27C C462 B27D C463 B281 C464 B282 C465 B283 C466 B284 C467 B285 C468 B286 C469 B287 C46A B288 C46B B289 C46C B28A C46D B28B C46E B28C C46F B28D C470 B28E C471 B28F C472 B290 C473 B291 C474 B293 C475 B294 C476 B295 C477 B296 C478 B297 C479 B298 C47A B299 C47B B29A C47C B29B C47D B29C C47E B29D C47F B2A1 C480 B2A2 C481 B2A3 C482 B2A4 C483 B2A5 C484 B2A6 C485 B2A7 C486 B2A8 C487 B2A9 C488 B2AA C489 B2AB C48A B2AC C48B B2AD C48C B2AE C48D B2AF C48E B2B0 C48F B2B1 C490 B2B3 C491 B2B4 C492 B2B5 C493 B2B6 C494 B2B7 C495 B2B8 C496 B2B9 C497 B2BA C498 B2BB C499 B2BC C49A B2BD C49B B2C1 C49C B2C2 C49D B2C3 C49E B2C4 C49F B2C5 C4A0 B2C6 C4A1 B2C7 C4A2 B2C8 C4A3 B2C9 C4A4 B2CA C4A5 B2CB C4A6 B2CC C4A7 B2CD C4A8 B2CE C4A9 B2CF C4AA B2D0 C4AB B2D1 C4AC B2D3 C4AD B2D4 C4AE B2D5 C4AF B2D6 C4B0 B2D7 C4B1 B2D8 C4B2 B2D9 C4B3 B2DA C4B4 B2DB C4B5 B2DC C4B6 B2DD C4B7 B2E1 C4B8 B2E2 C4B9 B2E3 C4BA B2E4 C4BB B2E5 C4BC B2E6 C4BD B2E7 C4BE B2E8 C4BF B2E9 C4C0 B2EA C4C1 B2EB C4C2 B2EC C4C3 B2ED C4C4 B2EE C4C5 B2EF C4C6 B2F0 C4C7 B2F1 C4C8 B2F3 C4C9 B2F4 C4CA B2F5 C4CB B2F6 C4CC B2F7 C4CD B2F8 C4CE B2F9 C4CF B2FA C4D0 B2FB C4D1 B2FC C4D2 B2FD C4D3 B341 C4D4 B342 C4D5 B343 C4D6 B344 C4D7 B345 C4D8 B346 C4D9 B347 C4DA B348 C4DB B349 C4DC B34A C4DD B34B C4DE B34C C4DF B34D C4E0 B34E C4E1 B34F C4E2 B350 C4E3 B351 C4E4 B353 C4E5 B354 C4E6 B355 C4E7 B356 C4E8 B357 C4E9 B358 C4EA B359 C4EB B35A C4EC B35B C4ED B35C C4EE B35D C4EF B361 C4F0 B362 C4F1 B363 C4F2 B364 C4F3 B365 C4F4 B366 C4F5 B367 C4F6 B368 C4F7 B369 C4F8 B36A C4F9 B36B C4FA B36C C4FB B36D C4FC B36E C4FD B36F C4FE B370 C4FF B371 C500 B373 C501 B374 C502 B375 C503 B376 C504 B377 C505 B378 C506 B379 C507 B37A C508 B37B C509 B37C C50A B37D C50B B381 C50C B382 C50D B383 C50E B384 C50F B385 C510 B386 C511 B387 C512 B388 C513 B389 C514 B38A C515 B38B C516 B38C C517 B38D C518 B38E C519 B38F C51A B390 C51B B391 C51C B393 C51D B394 C51E B395 C51F B396 C520 B397 C521 B398 C522 B399 C523 B39A C524 B39B C525 B39C C526 B39D C527 B3A1 C528 B3A2 C529 B3A3 C52A B3A4 C52B B3A5 C52C B3A6 C52D B3A7 C52E B3A8 C52F B3A9 C530 B3AA C531 B3AB C532 B3AC C533 B3AD C534 B3AE C535 B3AF C536 B3B0 C537 B3B1 C538 B3B3 C539 B3B4 C53A B3B5 C53B B3B6 C53C B3B7 C53D B3B8 C53E B3B9 C53F B3BA C540 B3BB C541 B3BC C542 B3BD C543 B441 3147 B461 C544 B462 C545 B463 C546 B464 C547 B465 C548 B466 C549 B467 C54A B468 C54B B469 C54C B46A C54D B46B C54E B46C C54F B46D C550 B46E C551 B46F C552 B470 C553 B471 C554 B473 C555 B474 C556 B475 C557 B476 C558 B477 C559 B478 C55A B479 C55B B47A C55C B47B C55D B47C C55E B47D C55F B481 C560 B482 C561 B483 C562 B484 C563 B485 C564 B486 C565 B487 C566 B488 C567 B489 C568 B48A C569 B48B C56A B48C C56B B48D C56C B48E C56D B48F C56E B490 C56F B491 C570 B493 C571 B494 C572 B495 C573 B496 C574 B497 C575 B498 C576 B499 C577 B49A C578 B49B C579 B49C C57A B49D C57B B4A1 C57C B4A2 C57D B4A3 C57E B4A4 C57F B4A5 C580 B4A6 C581 B4A7 C582 B4A8 C583 B4A9 C584 B4AA C585 B4AB C586 B4AC C587 B4AD C588 B4AE C589 B4AF C58A B4B0 C58B B4B1 C58C B4B3 C58D B4B4 C58E B4B5 C58F B4B6 C590 B4B7 C591 B4B8 C592 B4B9 C593 B4BA C594 B4BB C595 B4BC C596 B4BD C597 B4C1 C598 B4C2 C599 B4C3 C59A B4C4 C59B B4C5 C59C B4C6 C59D B4C7 C59E B4C8 C59F B4C9 C5A0 B4CA C5A1 B4CB C5A2 B4CC C5A3 B4CD C5A4 B4CE C5A5 B4CF C5A6 B4D0 C5A7 B4D1 C5A8 B4D3 C5A9 B4D4 C5AA B4D5 C5AB B4D6 C5AC B4D7 C5AD B4D8 C5AE B4D9 C5AF B4DA C5B0 B4DB C5B1 B4DC C5B2 B4DD C5B3 B4E1 C5B4 B4E2 C5B5 B4E3 C5B6 B4E4 C5B7 B4E5 C5B8 B4E6 C5B9 B4E7 C5BA B4E8 C5BB B4E9 C5BC B4EA C5BD B4EB C5BE B4EC C5BF B4ED C5C0 B4EE C5C1 B4EF C5C2 B4F0 C5C3 B4F1 C5C4 B4F3 C5C5 B4F4 C5C6 B4F5 C5C7 B4F6 C5C8 B4F7 C5C9 B4F8 C5CA B4F9 C5CB B4FA C5CC B4FB C5CD B4FC C5CE B4FD C5CF B541 C5D0 B542 C5D1 B543 C5D2 B544 C5D3 B545 C5D4 B546 C5D5 B547 C5D6 B548 C5D7 B549 C5D8 B54A C5D9 B54B C5DA B54C C5DB B54D C5DC B54E C5DD B54F C5DE B550 C5DF B551 C5E0 B553 C5E1 B554 C5E2 B555 C5E3 B556 C5E4 B557 C5E5 B558 C5E6 B559 C5E7 B55A C5E8 B55B C5E9 B55C C5EA B55D C5EB B561 C5EC B562 C5ED B563 C5EE B564 C5EF B565 C5F0 B566 C5F1 B567 C5F2 B568 C5F3 B569 C5F4 B56A C5F5 B56B C5F6 B56C C5F7 B56D C5F8 B56E C5F9 B56F C5FA B570 C5FB B571 C5FC B573 C5FD B574 C5FE B575 C5FF B576 C600 B577 C601 B578 C602 B579 C603 B57A C604 B57B C605 B57C C606 B57D C607 B581 C608 B582 C609 B583 C60A B584 C60B B585 C60C B586 C60D B587 C60E B588 C60F B589 C610 B58A C611 B58B C612 B58C C613 B58D C614 B58E C615 B58F C616 B590 C617 B591 C618 B593 C619 B594 C61A B595 C61B B596 C61C B597 C61D B598 C61E B599 C61F B59A C620 B59B C621 B59C C622 B59D C623 B5A1 C624 B5A2 C625 B5A3 C626 B5A4 C627 B5A5 C628 B5A6 C629 B5A7 C62A B5A8 C62B B5A9 C62C B5AA C62D B5AB C62E B5AC C62F B5AD C630 B5AE C631 B5AF C632 B5B0 C633 B5B1 C634 B5B3 C635 B5B4 C636 B5B5 C637 B5B6 C638 B5B7 C639 B5B8 C63A B5B9 C63B B5BA C63C B5BB C63D B5BC C63E B5BD C63F B5C1 C640 B5C2 C641 B5C3 C642 B5C4 C643 B5C5 C644 B5C6 C645 B5C7 C646 B5C8 C647 B5C9 C648 B5CA C649 B5CB C64A B5CC C64B B5CD C64C B5CE C64D B5CF C64E B5D0 C64F B5D1 C650 B5D3 C651 B5D4 C652 B5D5 C653 B5D6 C654 B5D7 C655 B5D8 C656 B5D9 C657 B5DA C658 B5DB C659 B5DC C65A B5DD C65B B5E1 C65C B5E2 C65D B5E3 C65E B5E4 C65F B5E5 C660 B5E6 C661 B5E7 C662 B5E8 C663 B5E9 C664 B5EA C665 B5EB C666 B5EC C667 B5ED C668 B5EE C669 B5EF C66A B5F0 C66B B5F1 C66C B5F3 C66D B5F4 C66E B5F5 C66F B5F6 C670 B5F7 C671 B5F8 C672 B5F9 C673 B5FA C674 B5FB C675 B5FC C676 B5FD C677 B641 C678 B642 C679 B643 C67A B644 C67B B645 C67C B646 C67D B647 C67E B648 C67F B649 C680 B64A C681 B64B C682 B64C C683 B64D C684 B64E C685 B64F C686 B650 C687 B651 C688 B653 C689 B654 C68A B655 C68B B656 C68C B657 C68D B658 C68E B659 C68F B65A C690 B65B C691 B65C C692 B65D C693 B661 C694 B662 C695 B663 C696 B664 C697 B665 C698 B666 C699 B667 C69A B668 C69B B669 C69C B66A C69D B66B C69E B66C C69F B66D C6A0 B66E C6A1 B66F C6A2 B670 C6A3 B671 C6A4 B673 C6A5 B674 C6A6 B675 C6A7 B676 C6A8 B677 C6A9 B678 C6AA B679 C6AB B67A C6AC B67B C6AD B67C C6AE B67D C6AF B681 C6B0 B682 C6B1 B683 C6B2 B684 C6B3 B685 C6B4 B686 C6B5 B687 C6B6 B688 C6B7 B689 C6B8 B68A C6B9 B68B C6BA B68C C6BB B68D C6BC B68E C6BD B68F C6BE B690 C6BF B691 C6C0 B693 C6C1 B694 C6C2 B695 C6C3 B696 C6C4 B697 C6C5 B698 C6C6 B699 C6C7 B69A C6C8 B69B C6C9 B69C C6CA B69D C6CB B6A1 C6CC B6A2 C6CD B6A3 C6CE B6A4 C6CF B6A5 C6D0 B6A6 C6D1 B6A7 C6D2 B6A8 C6D3 B6A9 C6D4 B6AA C6D5 B6AB C6D6 B6AC C6D7 B6AD C6D8 B6AE C6D9 B6AF C6DA B6B0 C6DB B6B1 C6DC B6B3 C6DD B6B4 C6DE B6B5 C6DF B6B6 C6E0 B6B7 C6E1 B6B8 C6E2 B6B9 C6E3 B6BA C6E4 B6BB C6E5 B6BC C6E6 B6BD C6E7 B6C1 C6E8 B6C2 C6E9 B6C3 C6EA B6C4 C6EB B6C5 C6EC B6C6 C6ED B6C7 C6EE B6C8 C6EF B6C9 C6F0 B6CA C6F1 B6CB C6F2 B6CC C6F3 B6CD C6F4 B6CE C6F5 B6CF C6F6 B6D0 C6F7 B6D1 C6F8 B6D3 C6F9 B6D4 C6FA B6D5 C6FB B6D6 C6FC B6D7 C6FD B6D8 C6FE B6D9 C6FF B6DA C700 B6DB C701 B6DC C702 B6DD C703 B6E1 C704 B6E2 C705 B6E3 C706 B6E4 C707 B6E5 C708 B6E6 C709 B6E7 C70A B6E8 C70B B6E9 C70C B6EA C70D B6EB C70E B6EC C70F B6ED C710 B6EE C711 B6EF C712 B6F0 C713 B6F1 C714 B6F3 C715 B6F4 C716 B6F5 C717 B6F6 C718 B6F7 C719 B6F8 C71A B6F9 C71B B6FA C71C B6FB C71D B6FC C71E B6FD C71F B741 C720 B742 C721 B743 C722 B744 C723 B745 C724 B746 C725 B747 C726 B748 C727 B749 C728 B74A C729 B74B C72A B74C C72B B74D C72C B74E C72D B74F C72E B750 C72F B751 C730 B753 C731 B754 C732 B755 C733 B756 C734 B757 C735 B758 C736 B759 C737 B75A C738 B75B C739 B75C C73A B75D C73B B761 C73C B762 C73D B763 C73E B764 C73F B765 C740 B766 C741 B767 C742 B768 C743 B769 C744 B76A C745 B76B C746 B76C C747 B76D C748 B76E C749 B76F C74A B770 C74B B771 C74C B773 C74D B774 C74E B775 C74F B776 C750 B777 C751 B778 C752 B779 C753 B77A C754 B77B C755 B77C C756 B77D C757 B781 C758 B782 C759 B783 C75A B784 C75B B785 C75C B786 C75D B787 C75E B788 C75F B789 C760 B78A C761 B78B C762 B78C C763 B78D C764 B78E C765 B78F C766 B790 C767 B791 C768 B793 C769 B794 C76A B795 C76B B796 C76C B797 C76D B798 C76E B799 C76F B79A C770 B79B C771 B79C C772 B79D C773 B7A1 C774 B7A2 C775 B7A3 C776 B7A4 C777 B7A5 C778 B7A6 C779 B7A7 C77A B7A8 C77B B7A9 C77C B7AA C77D B7AB C77E B7AC C77F B7AD C780 B7AE C781 B7AF C782 B7B0 C783 B7B1 C784 B7B3 C785 B7B4 C786 B7B5 C787 B7B6 C788 B7B7 C789 B7B8 C78A B7B9 C78B B7BA C78C B7BB C78D B7BC C78E B7BD C78F B841 3148 B861 C790 B862 C791 B863 C792 B864 C793 B865 C794 B866 C795 B867 C796 B868 C797 B869 C798 B86A C799 B86B C79A B86C C79B B86D C79C B86E C79D B86F C79E B870 C79F B871 C7A0 B873 C7A1 B874 C7A2 B875 C7A3 B876 C7A4 B877 C7A5 B878 C7A6 B879 C7A7 B87A C7A8 B87B C7A9 B87C C7AA B87D C7AB B881 C7AC B882 C7AD B883 C7AE B884 C7AF B885 C7B0 B886 C7B1 B887 C7B2 B888 C7B3 B889 C7B4 B88A C7B5 B88B C7B6 B88C C7B7 B88D C7B8 B88E C7B9 B88F C7BA B890 C7BB B891 C7BC B893 C7BD B894 C7BE B895 C7BF B896 C7C0 B897 C7C1 B898 C7C2 B899 C7C3 B89A C7C4 B89B C7C5 B89C C7C6 B89D C7C7 B8A1 C7C8 B8A2 C7C9 B8A3 C7CA B8A4 C7CB B8A5 C7CC B8A6 C7CD B8A7 C7CE B8A8 C7CF B8A9 C7D0 B8AA C7D1 B8AB C7D2 B8AC C7D3 B8AD C7D4 B8AE C7D5 B8AF C7D6 B8B0 C7D7 B8B1 C7D8 B8B3 C7D9 B8B4 C7DA B8B5 C7DB B8B6 C7DC B8B7 C7DD B8B8 C7DE B8B9 C7DF B8BA C7E0 B8BB C7E1 B8BC C7E2 B8BD C7E3 B8C1 C7E4 B8C2 C7E5 B8C3 C7E6 B8C4 C7E7 B8C5 C7E8 B8C6 C7E9 B8C7 C7EA B8C8 C7EB B8C9 C7EC B8CA C7ED B8CB C7EE B8CC C7EF B8CD C7F0 B8CE C7F1 B8CF C7F2 B8D0 C7F3 B8D1 C7F4 B8D3 C7F5 B8D4 C7F6 B8D5 C7F7 B8D6 C7F8 B8D7 C7F9 B8D8 C7FA B8D9 C7FB B8DA C7FC B8DB C7FD B8DC C7FE B8DD C7FF B8E1 C800 B8E2 C801 B8E3 C802 B8E4 C803 B8E5 C804 B8E6 C805 B8E7 C806 B8E8 C807 B8E9 C808 B8EA C809 B8EB C80A B8EC C80B B8ED C80C B8EE C80D B8EF C80E B8F0 C80F B8F1 C810 B8F3 C811 B8F4 C812 B8F5 C813 B8F6 C814 B8F7 C815 B8F8 C816 B8F9 C817 B8FA C818 B8FB C819 B8FC C81A B8FD C81B B941 C81C B942 C81D B943 C81E B944 C81F B945 C820 B946 C821 B947 C822 B948 C823 B949 C824 B94A C825 B94B C826 B94C C827 B94D C828 B94E C829 B94F C82A B950 C82B B951 C82C B953 C82D B954 C82E B955 C82F B956 C830 B957 C831 B958 C832 B959 C833 B95A C834 B95B C835 B95C C836 B95D C837 B961 C838 B962 C839 B963 C83A B964 C83B B965 C83C B966 C83D B967 C83E B968 C83F B969 C840 B96A C841 B96B C842 B96C C843 B96D C844 B96E C845 B96F C846 B970 C847 B971 C848 B973 C849 B974 C84A B975 C84B B976 C84C B977 C84D B978 C84E B979 C84F B97A C850 B97B C851 B97C C852 B97D C853 B981 C854 B982 C855 B983 C856 B984 C857 B985 C858 B986 C859 B987 C85A B988 C85B B989 C85C B98A C85D B98B C85E B98C C85F B98D C860 B98E C861 B98F C862 B990 C863 B991 C864 B993 C865 B994 C866 B995 C867 B996 C868 B997 C869 B998 C86A B999 C86B B99A C86C B99B C86D B99C C86E B99D C86F B9A1 C870 B9A2 C871 B9A3 C872 B9A4 C873 B9A5 C874 B9A6 C875 B9A7 C876 B9A8 C877 B9A9 C878 B9AA C879 B9AB C87A B9AC C87B B9AD C87C B9AE C87D B9AF C87E B9B0 C87F B9B1 C880 B9B3 C881 B9B4 C882 B9B5 C883 B9B6 C884 B9B7 C885 B9B8 C886 B9B9 C887 B9BA C888 B9BB C889 B9BC C88A B9BD C88B B9C1 C88C B9C2 C88D B9C3 C88E B9C4 C88F B9C5 C890 B9C6 C891 B9C7 C892 B9C8 C893 B9C9 C894 B9CA C895 B9CB C896 B9CC C897 B9CD C898 B9CE C899 B9CF C89A B9D0 C89B B9D1 C89C B9D3 C89D B9D4 C89E B9D5 C89F B9D6 C8A0 B9D7 C8A1 B9D8 C8A2 B9D9 C8A3 B9DA C8A4 B9DB C8A5 B9DC C8A6 B9DD C8A7 B9E1 C8A8 B9E2 C8A9 B9E3 C8AA B9E4 C8AB B9E5 C8AC B9E6 C8AD B9E7 C8AE B9E8 C8AF B9E9 C8B0 B9EA C8B1 B9EB C8B2 B9EC C8B3 B9ED C8B4 B9EE C8B5 B9EF C8B6 B9F0 C8B7 B9F1 C8B8 B9F3 C8B9 B9F4 C8BA B9F5 C8BB B9F6 C8BC B9F7 C8BD B9F8 C8BE B9F9 C8BF B9FA C8C0 B9FB C8C1 B9FC C8C2 B9FD C8C3 BA41 C8C4 BA42 C8C5 BA43 C8C6 BA44 C8C7 BA45 C8C8 BA46 C8C9 BA47 C8CA BA48 C8CB BA49 C8CC BA4A C8CD BA4B C8CE BA4C C8CF BA4D C8D0 BA4E C8D1 BA4F C8D2 BA50 C8D3 BA51 C8D4 BA53 C8D5 BA54 C8D6 BA55 C8D7 BA56 C8D8 BA57 C8D9 BA58 C8DA BA59 C8DB BA5A C8DC BA5B C8DD BA5C C8DE BA5D C8DF BA61 C8E0 BA62 C8E1 BA63 C8E2 BA64 C8E3 BA65 C8E4 BA66 C8E5 BA67 C8E6 BA68 C8E7 BA69 C8E8 BA6A C8E9 BA6B C8EA BA6C C8EB BA6D C8EC BA6E C8ED BA6F C8EE BA70 C8EF BA71 C8F0 BA73 C8F1 BA74 C8F2 BA75 C8F3 BA76 C8F4 BA77 C8F5 BA78 C8F6 BA79 C8F7 BA7A C8F8 BA7B C8F9 BA7C C8FA BA7D C8FB BA81 C8FC BA82 C8FD BA83 C8FE BA84 C8FF BA85 C900 BA86 C901 BA87 C902 BA88 C903 BA89 C904 BA8A C905 BA8B C906 BA8C C907 BA8D C908 BA8E C909 BA8F C90A BA90 C90B BA91 C90C BA93 C90D BA94 C90E BA95 C90F BA96 C910 BA97 C911 BA98 C912 BA99 C913 BA9A C914 BA9B C915 BA9C C916 BA9D C917 BAA1 C918 BAA2 C919 BAA3 C91A BAA4 C91B BAA5 C91C BAA6 C91D BAA7 C91E BAA8 C91F BAA9 C920 BAAA C921 BAAB C922 BAAC C923 BAAD C924 BAAE C925 BAAF C926 BAB0 C927 BAB1 C928 BAB3 C929 BAB4 C92A BAB5 C92B BAB6 C92C BAB7 C92D BAB8 C92E BAB9 C92F BABA C930 BABB C931 BABC C932 BABD C933 BAC1 C934 BAC2 C935 BAC3 C936 BAC4 C937 BAC5 C938 BAC6 C939 BAC7 C93A BAC8 C93B BAC9 C93C BACA C93D BACB C93E BACC C93F BACD C940 BACE C941 BACF C942 BAD0 C943 BAD1 C944 BAD3 C945 BAD4 C946 BAD5 C947 BAD6 C948 BAD7 C949 BAD8 C94A BAD9 C94B BADA C94C BADB C94D BADC C94E BADD C94F BAE1 C950 BAE2 C951 BAE3 C952 BAE4 C953 BAE5 C954 BAE6 C955 BAE7 C956 BAE8 C957 BAE9 C958 BAEA C959 BAEB C95A BAEC C95B BAED C95C BAEE C95D BAEF C95E BAF0 C95F BAF1 C960 BAF3 C961 BAF4 C962 BAF5 C963 BAF6 C964 BAF7 C965 BAF8 C966 BAF9 C967 BAFA C968 BAFB C969 BAFC C96A BAFD C96B BB41 C96C BB42 C96D BB43 C96E BB44 C96F BB45 C970 BB46 C971 BB47 C972 BB48 C973 BB49 C974 BB4A C975 BB4B C976 BB4C C977 BB4D C978 BB4E C979 BB4F C97A BB50 C97B BB51 C97C BB53 C97D BB54 C97E BB55 C97F BB56 C980 BB57 C981 BB58 C982 BB59 C983 BB5A C984 BB5B C985 BB5C C986 BB5D C987 BB61 C988 BB62 C989 BB63 C98A BB64 C98B BB65 C98C BB66 C98D BB67 C98E BB68 C98F BB69 C990 BB6A C991 BB6B C992 BB6C C993 BB6D C994 BB6E C995 BB6F C996 BB70 C997 BB71 C998 BB73 C999 BB74 C99A BB75 C99B BB76 C99C BB77 C99D BB78 C99E BB79 C99F BB7A C9A0 BB7B C9A1 BB7C C9A2 BB7D C9A3 BB81 C9A4 BB82 C9A5 BB83 C9A6 BB84 C9A7 BB85 C9A8 BB86 C9A9 BB87 C9AA BB88 C9AB BB89 C9AC BB8A C9AD BB8B C9AE BB8C C9AF BB8D C9B0 BB8E C9B1 BB8F C9B2 BB90 C9B3 BB91 C9B4 BB93 C9B5 BB94 C9B6 BB95 C9B7 BB96 C9B8 BB97 C9B9 BB98 C9BA BB99 C9BB BB9A C9BC BB9B C9BD BB9C C9BE BB9D C9BF BBA1 C9C0 BBA2 C9C1 BBA3 C9C2 BBA4 C9C3 BBA5 C9C4 BBA6 C9C5 BBA7 C9C6 BBA8 C9C7 BBA9 C9C8 BBAA C9C9 BBAB C9CA BBAC C9CB BBAD C9CC BBAE C9CD BBAF C9CE BBB0 C9CF BBB1 C9D0 BBB3 C9D1 BBB4 C9D2 BBB5 C9D3 BBB6 C9D4 BBB7 C9D5 BBB8 C9D6 BBB9 C9D7 BBBA C9D8 BBBB C9D9 BBBC C9DA BBBD C9DB BC41 3149 BC61 C9DC BC62 C9DD BC63 C9DE BC64 C9DF BC65 C9E0 BC66 C9E1 BC67 C9E2 BC68 C9E3 BC69 C9E4 BC6A C9E5 BC6B C9E6 BC6C C9E7 BC6D C9E8 BC6E C9E9 BC6F C9EA BC70 C9EB BC71 C9EC BC73 C9ED BC74 C9EE BC75 C9EF BC76 C9F0 BC77 C9F1 BC78 C9F2 BC79 C9F3 BC7A C9F4 BC7B C9F5 BC7C C9F6 BC7D C9F7 BC81 C9F8 BC82 C9F9 BC83 C9FA BC84 C9FB BC85 C9FC BC86 C9FD BC87 C9FE BC88 C9FF BC89 CA00 BC8A CA01 BC8B CA02 BC8C CA03 BC8D CA04 BC8E CA05 BC8F CA06 BC90 CA07 BC91 CA08 BC93 CA09 BC94 CA0A BC95 CA0B BC96 CA0C BC97 CA0D BC98 CA0E BC99 CA0F BC9A CA10 BC9B CA11 BC9C CA12 BC9D CA13 BCA1 CA14 BCA2 CA15 BCA3 CA16 BCA4 CA17 BCA5 CA18 BCA6 CA19 BCA7 CA1A BCA8 CA1B BCA9 CA1C BCAA CA1D BCAB CA1E BCAC CA1F BCAD CA20 BCAE CA21 BCAF CA22 BCB0 CA23 BCB1 CA24 BCB3 CA25 BCB4 CA26 BCB5 CA27 BCB6 CA28 BCB7 CA29 BCB8 CA2A BCB9 CA2B BCBA CA2C BCBB CA2D BCBC CA2E BCBD CA2F BCC1 CA30 BCC2 CA31 BCC3 CA32 BCC4 CA33 BCC5 CA34 BCC6 CA35 BCC7 CA36 BCC8 CA37 BCC9 CA38 BCCA CA39 BCCB CA3A BCCC CA3B BCCD CA3C BCCE CA3D BCCF CA3E BCD0 CA3F BCD1 CA40 BCD3 CA41 BCD4 CA42 BCD5 CA43 BCD6 CA44 BCD7 CA45 BCD8 CA46 BCD9 CA47 BCDA CA48 BCDB CA49 BCDC CA4A BCDD CA4B BCE1 CA4C BCE2 CA4D BCE3 CA4E BCE4 CA4F BCE5 CA50 BCE6 CA51 BCE7 CA52 BCE8 CA53 BCE9 CA54 BCEA CA55 BCEB CA56 BCEC CA57 BCED CA58 BCEE CA59 BCEF CA5A BCF0 CA5B BCF1 CA5C BCF3 CA5D BCF4 CA5E BCF5 CA5F BCF6 CA60 BCF7 CA61 BCF8 CA62 BCF9 CA63 BCFA CA64 BCFB CA65 BCFC CA66 BCFD CA67 BD41 CA68 BD42 CA69 BD43 CA6A BD44 CA6B BD45 CA6C BD46 CA6D BD47 CA6E BD48 CA6F BD49 CA70 BD4A CA71 BD4B CA72 BD4C CA73 BD4D CA74 BD4E CA75 BD4F CA76 BD50 CA77 BD51 CA78 BD53 CA79 BD54 CA7A BD55 CA7B BD56 CA7C BD57 CA7D BD58 CA7E BD59 CA7F BD5A CA80 BD5B CA81 BD5C CA82 BD5D CA83 BD61 CA84 BD62 CA85 BD63 CA86 BD64 CA87 BD65 CA88 BD66 CA89 BD67 CA8A BD68 CA8B BD69 CA8C BD6A CA8D BD6B CA8E BD6C CA8F BD6D CA90 BD6E CA91 BD6F CA92 BD70 CA93 BD71 CA94 BD73 CA95 BD74 CA96 BD75 CA97 BD76 CA98 BD77 CA99 BD78 CA9A BD79 CA9B BD7A CA9C BD7B CA9D BD7C CA9E BD7D CA9F BD81 CAA0 BD82 CAA1 BD83 CAA2 BD84 CAA3 BD85 CAA4 BD86 CAA5 BD87 CAA6 BD88 CAA7 BD89 CAA8 BD8A CAA9 BD8B CAAA BD8C CAAB BD8D CAAC BD8E CAAD BD8F CAAE BD90 CAAF BD91 CAB0 BD93 CAB1 BD94 CAB2 BD95 CAB3 BD96 CAB4 BD97 CAB5 BD98 CAB6 BD99 CAB7 BD9A CAB8 BD9B CAB9 BD9C CABA BD9D CABB BDA1 CABC BDA2 CABD BDA3 CABE BDA4 CABF BDA5 CAC0 BDA6 CAC1 BDA7 CAC2 BDA8 CAC3 BDA9 CAC4 BDAA CAC5 BDAB CAC6 BDAC CAC7 BDAD CAC8 BDAE CAC9 BDAF CACA BDB0 CACB BDB1 CACC BDB3 CACD BDB4 CACE BDB5 CACF BDB6 CAD0 BDB7 CAD1 BDB8 CAD2 BDB9 CAD3 BDBA CAD4 BDBB CAD5 BDBC CAD6 BDBD CAD7 BDC1 CAD8 BDC2 CAD9 BDC3 CADA BDC4 CADB BDC5 CADC BDC6 CADD BDC7 CADE BDC8 CADF BDC9 CAE0 BDCA CAE1 BDCB CAE2 BDCC CAE3 BDCD CAE4 BDCE CAE5 BDCF CAE6 BDD0 CAE7 BDD1 CAE8 BDD3 CAE9 BDD4 CAEA BDD5 CAEB BDD6 CAEC BDD7 CAED BDD8 CAEE BDD9 CAEF BDDA CAF0 BDDB CAF1 BDDC CAF2 BDDD CAF3 BDE1 CAF4 BDE2 CAF5 BDE3 CAF6 BDE4 CAF7 BDE5 CAF8 BDE6 CAF9 BDE7 CAFA BDE8 CAFB BDE9 CAFC BDEA CAFD BDEB CAFE BDEC CAFF BDED CB00 BDEE CB01 BDEF CB02 BDF0 CB03 BDF1 CB04 BDF3 CB05 BDF4 CB06 BDF5 CB07 BDF6 CB08 BDF7 CB09 BDF8 CB0A BDF9 CB0B BDFA CB0C BDFB CB0D BDFC CB0E BDFD CB0F BE41 CB10 BE42 CB11 BE43 CB12 BE44 CB13 BE45 CB14 BE46 CB15 BE47 CB16 BE48 CB17 BE49 CB18 BE4A CB19 BE4B CB1A BE4C CB1B BE4D CB1C BE4E CB1D BE4F CB1E BE50 CB1F BE51 CB20 BE53 CB21 BE54 CB22 BE55 CB23 BE56 CB24 BE57 CB25 BE58 CB26 BE59 CB27 BE5A CB28 BE5B CB29 BE5C CB2A BE5D CB2B BE61 CB2C BE62 CB2D BE63 CB2E BE64 CB2F BE65 CB30 BE66 CB31 BE67 CB32 BE68 CB33 BE69 CB34 BE6A CB35 BE6B CB36 BE6C CB37 BE6D CB38 BE6E CB39 BE6F CB3A BE70 CB3B BE71 CB3C BE73 CB3D BE74 CB3E BE75 CB3F BE76 CB40 BE77 CB41 BE78 CB42 BE79 CB43 BE7A CB44 BE7B CB45 BE7C CB46 BE7D CB47 BE81 CB48 BE82 CB49 BE83 CB4A BE84 CB4B BE85 CB4C BE86 CB4D BE87 CB4E BE88 CB4F BE89 CB50 BE8A CB51 BE8B CB52 BE8C CB53 BE8D CB54 BE8E CB55 BE8F CB56 BE90 CB57 BE91 CB58 BE93 CB59 BE94 CB5A BE95 CB5B BE96 CB5C BE97 CB5D BE98 CB5E BE99 CB5F BE9A CB60 BE9B CB61 BE9C CB62 BE9D CB63 BEA1 CB64 BEA2 CB65 BEA3 CB66 BEA4 CB67 BEA5 CB68 BEA6 CB69 BEA7 CB6A BEA8 CB6B BEA9 CB6C BEAA CB6D BEAB CB6E BEAC CB6F BEAD CB70 BEAE CB71 BEAF CB72 BEB0 CB73 BEB1 CB74 BEB3 CB75 BEB4 CB76 BEB5 CB77 BEB6 CB78 BEB7 CB79 BEB8 CB7A BEB9 CB7B BEBA CB7C BEBB CB7D BEBC CB7E BEBD CB7F BEC1 CB80 BEC2 CB81 BEC3 CB82 BEC4 CB83 BEC5 CB84 BEC6 CB85 BEC7 CB86 BEC8 CB87 BEC9 CB88 BECA CB89 BECB CB8A BECC CB8B BECD CB8C BECE CB8D BECF CB8E BED0 CB8F BED1 CB90 BED3 CB91 BED4 CB92 BED5 CB93 BED6 CB94 BED7 CB95 BED8 CB96 BED9 CB97 BEDA CB98 BEDB CB99 BEDC CB9A BEDD CB9B BEE1 CB9C BEE2 CB9D BEE3 CB9E BEE4 CB9F BEE5 CBA0 BEE6 CBA1 BEE7 CBA2 BEE8 CBA3 BEE9 CBA4 BEEA CBA5 BEEB CBA6 BEEC CBA7 BEED CBA8 BEEE CBA9 BEEF CBAA BEF0 CBAB BEF1 CBAC BEF3 CBAD BEF4 CBAE BEF5 CBAF BEF6 CBB0 BEF7 CBB1 BEF8 CBB2 BEF9 CBB3 BEFA CBB4 BEFB CBB5 BEFC CBB6 BEFD CBB7 BF41 CBB8 BF42 CBB9 BF43 CBBA BF44 CBBB BF45 CBBC BF46 CBBD BF47 CBBE BF48 CBBF BF49 CBC0 BF4A CBC1 BF4B CBC2 BF4C CBC3 BF4D CBC4 BF4E CBC5 BF4F CBC6 BF50 CBC7 BF51 CBC8 BF53 CBC9 BF54 CBCA BF55 CBCB BF56 CBCC BF57 CBCD BF58 CBCE BF59 CBCF BF5A CBD0 BF5B CBD1 BF5C CBD2 BF5D CBD3 BF61 CBD4 BF62 CBD5 BF63 CBD6 BF64 CBD7 BF65 CBD8 BF66 CBD9 BF67 CBDA BF68 CBDB BF69 CBDC BF6A CBDD BF6B CBDE BF6C CBDF BF6D CBE0 BF6E CBE1 BF6F CBE2 BF70 CBE3 BF71 CBE4 BF73 CBE5 BF74 CBE6 BF75 CBE7 BF76 CBE8 BF77 CBE9 BF78 CBEA BF79 CBEB BF7A CBEC BF7B CBED BF7C CBEE BF7D CBEF BF81 CBF0 BF82 CBF1 BF83 CBF2 BF84 CBF3 BF85 CBF4 BF86 CBF5 BF87 CBF6 BF88 CBF7 BF89 CBF8 BF8A CBF9 BF8B CBFA BF8C CBFB BF8D CBFC BF8E CBFD BF8F CBFE BF90 CBFF BF91 CC00 BF93 CC01 BF94 CC02 BF95 CC03 BF96 CC04 BF97 CC05 BF98 CC06 BF99 CC07 BF9A CC08 BF9B CC09 BF9C CC0A BF9D CC0B BFA1 CC0C BFA2 CC0D BFA3 CC0E BFA4 CC0F BFA5 CC10 BFA6 CC11 BFA7 CC12 BFA8 CC13 BFA9 CC14 BFAA CC15 BFAB CC16 BFAC CC17 BFAD CC18 BFAE CC19 BFAF CC1A BFB0 CC1B BFB1 CC1C BFB3 CC1D BFB4 CC1E BFB5 CC1F BFB6 CC20 BFB7 CC21 BFB8 CC22 BFB9 CC23 BFBA CC24 BFBB CC25 BFBC CC26 BFBD CC27 C041 314A C061 CC28 C062 CC29 C063 CC2A C064 CC2B C065 CC2C C066 CC2D C067 CC2E C068 CC2F C069 CC30 C06A CC31 C06B CC32 C06C CC33 C06D CC34 C06E CC35 C06F CC36 C070 CC37 C071 CC38 C073 CC39 C074 CC3A C075 CC3B C076 CC3C C077 CC3D C078 CC3E C079 CC3F C07A CC40 C07B CC41 C07C CC42 C07D CC43 C081 CC44 C082 CC45 C083 CC46 C084 CC47 C085 CC48 C086 CC49 C087 CC4A C088 CC4B C089 CC4C C08A CC4D C08B CC4E C08C CC4F C08D CC50 C08E CC51 C08F CC52 C090 CC53 C091 CC54 C093 CC55 C094 CC56 C095 CC57 C096 CC58 C097 CC59 C098 CC5A C099 CC5B C09A CC5C C09B CC5D C09C CC5E C09D CC5F C0A1 CC60 C0A2 CC61 C0A3 CC62 C0A4 CC63 C0A5 CC64 C0A6 CC65 C0A7 CC66 C0A8 CC67 C0A9 CC68 C0AA CC69 C0AB CC6A C0AC CC6B C0AD CC6C C0AE CC6D C0AF CC6E C0B0 CC6F C0B1 CC70 C0B3 CC71 C0B4 CC72 C0B5 CC73 C0B6 CC74 C0B7 CC75 C0B8 CC76 C0B9 CC77 C0BA CC78 C0BB CC79 C0BC CC7A C0BD CC7B C0C1 CC7C C0C2 CC7D C0C3 CC7E C0C4 CC7F C0C5 CC80 C0C6 CC81 C0C7 CC82 C0C8 CC83 C0C9 CC84 C0CA CC85 C0CB CC86 C0CC CC87 C0CD CC88 C0CE CC89 C0CF CC8A C0D0 CC8B C0D1 CC8C C0D3 CC8D C0D4 CC8E C0D5 CC8F C0D6 CC90 C0D7 CC91 C0D8 CC92 C0D9 CC93 C0DA CC94 C0DB CC95 C0DC CC96 C0DD CC97 C0E1 CC98 C0E2 CC99 C0E3 CC9A C0E4 CC9B C0E5 CC9C C0E6 CC9D C0E7 CC9E C0E8 CC9F C0E9 CCA0 C0EA CCA1 C0EB CCA2 C0EC CCA3 C0ED CCA4 C0EE CCA5 C0EF CCA6 C0F0 CCA7 C0F1 CCA8 C0F3 CCA9 C0F4 CCAA C0F5 CCAB C0F6 CCAC C0F7 CCAD C0F8 CCAE C0F9 CCAF C0FA CCB0 C0FB CCB1 C0FC CCB2 C0FD CCB3 C141 CCB4 C142 CCB5 C143 CCB6 C144 CCB7 C145 CCB8 C146 CCB9 C147 CCBA C148 CCBB C149 CCBC C14A CCBD C14B CCBE C14C CCBF C14D CCC0 C14E CCC1 C14F CCC2 C150 CCC3 C151 CCC4 C153 CCC5 C154 CCC6 C155 CCC7 C156 CCC8 C157 CCC9 C158 CCCA C159 CCCB C15A CCCC C15B CCCD C15C CCCE C15D CCCF C161 CCD0 C162 CCD1 C163 CCD2 C164 CCD3 C165 CCD4 C166 CCD5 C167 CCD6 C168 CCD7 C169 CCD8 C16A CCD9 C16B CCDA C16C CCDB C16D CCDC C16E CCDD C16F CCDE C170 CCDF C171 CCE0 C173 CCE1 C174 CCE2 C175 CCE3 C176 CCE4 C177 CCE5 C178 CCE6 C179 CCE7 C17A CCE8 C17B CCE9 C17C CCEA C17D CCEB C181 CCEC C182 CCED C183 CCEE C184 CCEF C185 CCF0 C186 CCF1 C187 CCF2 C188 CCF3 C189 CCF4 C18A CCF5 C18B CCF6 C18C CCF7 C18D CCF8 C18E CCF9 C18F CCFA C190 CCFB C191 CCFC C193 CCFD C194 CCFE C195 CCFF C196 CD00 C197 CD01 C198 CD02 C199 CD03 C19A CD04 C19B CD05 C19C CD06 C19D CD07 C1A1 CD08 C1A2 CD09 C1A3 CD0A C1A4 CD0B C1A5 CD0C C1A6 CD0D C1A7 CD0E C1A8 CD0F C1A9 CD10 C1AA CD11 C1AB CD12 C1AC CD13 C1AD CD14 C1AE CD15 C1AF CD16 C1B0 CD17 C1B1 CD18 C1B3 CD19 C1B4 CD1A C1B5 CD1B C1B6 CD1C C1B7 CD1D C1B8 CD1E C1B9 CD1F C1BA CD20 C1BB CD21 C1BC CD22 C1BD CD23 C1C1 CD24 C1C2 CD25 C1C3 CD26 C1C4 CD27 C1C5 CD28 C1C6 CD29 C1C7 CD2A C1C8 CD2B C1C9 CD2C C1CA CD2D C1CB CD2E C1CC CD2F C1CD CD30 C1CE CD31 C1CF CD32 C1D0 CD33 C1D1 CD34 C1D3 CD35 C1D4 CD36 C1D5 CD37 C1D6 CD38 C1D7 CD39 C1D8 CD3A C1D9 CD3B C1DA CD3C C1DB CD3D C1DC CD3E C1DD CD3F C1E1 CD40 C1E2 CD41 C1E3 CD42 C1E4 CD43 C1E5 CD44 C1E6 CD45 C1E7 CD46 C1E8 CD47 C1E9 CD48 C1EA CD49 C1EB CD4A C1EC CD4B C1ED CD4C C1EE CD4D C1EF CD4E C1F0 CD4F C1F1 CD50 C1F3 CD51 C1F4 CD52 C1F5 CD53 C1F6 CD54 C1F7 CD55 C1F8 CD56 C1F9 CD57 C1FA CD58 C1FB CD59 C1FC CD5A C1FD CD5B C241 CD5C C242 CD5D C243 CD5E C244 CD5F C245 CD60 C246 CD61 C247 CD62 C248 CD63 C249 CD64 C24A CD65 C24B CD66 C24C CD67 C24D CD68 C24E CD69 C24F CD6A C250 CD6B C251 CD6C C253 CD6D C254 CD6E C255 CD6F C256 CD70 C257 CD71 C258 CD72 C259 CD73 C25A CD74 C25B CD75 C25C CD76 C25D CD77 C261 CD78 C262 CD79 C263 CD7A C264 CD7B C265 CD7C C266 CD7D C267 CD7E C268 CD7F C269 CD80 C26A CD81 C26B CD82 C26C CD83 C26D CD84 C26E CD85 C26F CD86 C270 CD87 C271 CD88 C273 CD89 C274 CD8A C275 CD8B C276 CD8C C277 CD8D C278 CD8E C279 CD8F C27A CD90 C27B CD91 C27C CD92 C27D CD93 C281 CD94 C282 CD95 C283 CD96 C284 CD97 C285 CD98 C286 CD99 C287 CD9A C288 CD9B C289 CD9C C28A CD9D C28B CD9E C28C CD9F C28D CDA0 C28E CDA1 C28F CDA2 C290 CDA3 C291 CDA4 C293 CDA5 C294 CDA6 C295 CDA7 C296 CDA8 C297 CDA9 C298 CDAA C299 CDAB C29A CDAC C29B CDAD C29C CDAE C29D CDAF C2A1 CDB0 C2A2 CDB1 C2A3 CDB2 C2A4 CDB3 C2A5 CDB4 C2A6 CDB5 C2A7 CDB6 C2A8 CDB7 C2A9 CDB8 C2AA CDB9 C2AB CDBA C2AC CDBB C2AD CDBC C2AE CDBD C2AF CDBE C2B0 CDBF C2B1 CDC0 C2B3 CDC1 C2B4 CDC2 C2B5 CDC3 C2B6 CDC4 C2B7 CDC5 C2B8 CDC6 C2B9 CDC7 C2BA CDC8 C2BB CDC9 C2BC CDCA C2BD CDCB C2C1 CDCC C2C2 CDCD C2C3 CDCE C2C4 CDCF C2C5 CDD0 C2C6 CDD1 C2C7 CDD2 C2C8 CDD3 C2C9 CDD4 C2CA CDD5 C2CB CDD6 C2CC CDD7 C2CD CDD8 C2CE CDD9 C2CF CDDA C2D0 CDDB C2D1 CDDC C2D3 CDDD C2D4 CDDE C2D5 CDDF C2D6 CDE0 C2D7 CDE1 C2D8 CDE2 C2D9 CDE3 C2DA CDE4 C2DB CDE5 C2DC CDE6 C2DD CDE7 C2E1 CDE8 C2E2 CDE9 C2E3 CDEA C2E4 CDEB C2E5 CDEC C2E6 CDED C2E7 CDEE C2E8 CDEF C2E9 CDF0 C2EA CDF1 C2EB CDF2 C2EC CDF3 C2ED CDF4 C2EE CDF5 C2EF CDF6 C2F0 CDF7 C2F1 CDF8 C2F3 CDF9 C2F4 CDFA C2F5 CDFB C2F6 CDFC C2F7 CDFD C2F8 CDFE C2F9 CDFF C2FA CE00 C2FB CE01 C2FC CE02 C2FD CE03 C341 CE04 C342 CE05 C343 CE06 C344 CE07 C345 CE08 C346 CE09 C347 CE0A C348 CE0B C349 CE0C C34A CE0D C34B CE0E C34C CE0F C34D CE10 C34E CE11 C34F CE12 C350 CE13 C351 CE14 C353 CE15 C354 CE16 C355 CE17 C356 CE18 C357 CE19 C358 CE1A C359 CE1B C35A CE1C C35B CE1D C35C CE1E C35D CE1F C361 CE20 C362 CE21 C363 CE22 C364 CE23 C365 CE24 C366 CE25 C367 CE26 C368 CE27 C369 CE28 C36A CE29 C36B CE2A C36C CE2B C36D CE2C C36E CE2D C36F CE2E C370 CE2F C371 CE30 C373 CE31 C374 CE32 C375 CE33 C376 CE34 C377 CE35 C378 CE36 C379 CE37 C37A CE38 C37B CE39 C37C CE3A C37D CE3B C381 CE3C C382 CE3D C383 CE3E C384 CE3F C385 CE40 C386 CE41 C387 CE42 C388 CE43 C389 CE44 C38A CE45 C38B CE46 C38C CE47 C38D CE48 C38E CE49 C38F CE4A C390 CE4B C391 CE4C C393 CE4D C394 CE4E C395 CE4F C396 CE50 C397 CE51 C398 CE52 C399 CE53 C39A CE54 C39B CE55 C39C CE56 C39D CE57 C3A1 CE58 C3A2 CE59 C3A3 CE5A C3A4 CE5B C3A5 CE5C C3A6 CE5D C3A7 CE5E C3A8 CE5F C3A9 CE60 C3AA CE61 C3AB CE62 C3AC CE63 C3AD CE64 C3AE CE65 C3AF CE66 C3B0 CE67 C3B1 CE68 C3B3 CE69 C3B4 CE6A C3B5 CE6B C3B6 CE6C C3B7 CE6D C3B8 CE6E C3B9 CE6F C3BA CE70 C3BB CE71 C3BC CE72 C3BD CE73 C441 314B C461 CE74 C462 CE75 C463 CE76 C464 CE77 C465 CE78 C466 CE79 C467 CE7A C468 CE7B C469 CE7C C46A CE7D C46B CE7E C46C CE7F C46D CE80 C46E CE81 C46F CE82 C470 CE83 C471 CE84 C473 CE85 C474 CE86 C475 CE87 C476 CE88 C477 CE89 C478 CE8A C479 CE8B C47A CE8C C47B CE8D C47C CE8E C47D CE8F C481 CE90 C482 CE91 C483 CE92 C484 CE93 C485 CE94 C486 CE95 C487 CE96 C488 CE97 C489 CE98 C48A CE99 C48B CE9A C48C CE9B C48D CE9C C48E CE9D C48F CE9E C490 CE9F C491 CEA0 C493 CEA1 C494 CEA2 C495 CEA3 C496 CEA4 C497 CEA5 C498 CEA6 C499 CEA7 C49A CEA8 C49B CEA9 C49C CEAA C49D CEAB C4A1 CEAC C4A2 CEAD C4A3 CEAE C4A4 CEAF C4A5 CEB0 C4A6 CEB1 C4A7 CEB2 C4A8 CEB3 C4A9 CEB4 C4AA CEB5 C4AB CEB6 C4AC CEB7 C4AD CEB8 C4AE CEB9 C4AF CEBA C4B0 CEBB C4B1 CEBC C4B3 CEBD C4B4 CEBE C4B5 CEBF C4B6 CEC0 C4B7 CEC1 C4B8 CEC2 C4B9 CEC3 C4BA CEC4 C4BB CEC5 C4BC CEC6 C4BD CEC7 C4C1 CEC8 C4C2 CEC9 C4C3 CECA C4C4 CECB C4C5 CECC C4C6 CECD C4C7 CECE C4C8 CECF C4C9 CED0 C4CA CED1 C4CB CED2 C4CC CED3 C4CD CED4 C4CE CED5 C4CF CED6 C4D0 CED7 C4D1 CED8 C4D3 CED9 C4D4 CEDA C4D5 CEDB C4D6 CEDC C4D7 CEDD C4D8 CEDE C4D9 CEDF C4DA CEE0 C4DB CEE1 C4DC CEE2 C4DD CEE3 C4E1 CEE4 C4E2 CEE5 C4E3 CEE6 C4E4 CEE7 C4E5 CEE8 C4E6 CEE9 C4E7 CEEA C4E8 CEEB C4E9 CEEC C4EA CEED C4EB CEEE C4EC CEEF C4ED CEF0 C4EE CEF1 C4EF CEF2 C4F0 CEF3 C4F1 CEF4 C4F3 CEF5 C4F4 CEF6 C4F5 CEF7 C4F6 CEF8 C4F7 CEF9 C4F8 CEFA C4F9 CEFB C4FA CEFC C4FB CEFD C4FC CEFE C4FD CEFF C541 CF00 C542 CF01 C543 CF02 C544 CF03 C545 CF04 C546 CF05 C547 CF06 C548 CF07 C549 CF08 C54A CF09 C54B CF0A C54C CF0B C54D CF0C C54E CF0D C54F CF0E C550 CF0F C551 CF10 C553 CF11 C554 CF12 C555 CF13 C556 CF14 C557 CF15 C558 CF16 C559 CF17 C55A CF18 C55B CF19 C55C CF1A C55D CF1B C561 CF1C C562 CF1D C563 CF1E C564 CF1F C565 CF20 C566 CF21 C567 CF22 C568 CF23 C569 CF24 C56A CF25 C56B CF26 C56C CF27 C56D CF28 C56E CF29 C56F CF2A C570 CF2B C571 CF2C C573 CF2D C574 CF2E C575 CF2F C576 CF30 C577 CF31 C578 CF32 C579 CF33 C57A CF34 C57B CF35 C57C CF36 C57D CF37 C581 CF38 C582 CF39 C583 CF3A C584 CF3B C585 CF3C C586 CF3D C587 CF3E C588 CF3F C589 CF40 C58A CF41 C58B CF42 C58C CF43 C58D CF44 C58E CF45 C58F CF46 C590 CF47 C591 CF48 C593 CF49 C594 CF4A C595 CF4B C596 CF4C C597 CF4D C598 CF4E C599 CF4F C59A CF50 C59B CF51 C59C CF52 C59D CF53 C5A1 CF54 C5A2 CF55 C5A3 CF56 C5A4 CF57 C5A5 CF58 C5A6 CF59 C5A7 CF5A C5A8 CF5B C5A9 CF5C C5AA CF5D C5AB CF5E C5AC CF5F C5AD CF60 C5AE CF61 C5AF CF62 C5B0 CF63 C5B1 CF64 C5B3 CF65 C5B4 CF66 C5B5 CF67 C5B6 CF68 C5B7 CF69 C5B8 CF6A C5B9 CF6B C5BA CF6C C5BB CF6D C5BC CF6E C5BD CF6F C5C1 CF70 C5C2 CF71 C5C3 CF72 C5C4 CF73 C5C5 CF74 C5C6 CF75 C5C7 CF76 C5C8 CF77 C5C9 CF78 C5CA CF79 C5CB CF7A C5CC CF7B C5CD CF7C C5CE CF7D C5CF CF7E C5D0 CF7F C5D1 CF80 C5D3 CF81 C5D4 CF82 C5D5 CF83 C5D6 CF84 C5D7 CF85 C5D8 CF86 C5D9 CF87 C5DA CF88 C5DB CF89 C5DC CF8A C5DD CF8B C5E1 CF8C C5E2 CF8D C5E3 CF8E C5E4 CF8F C5E5 CF90 C5E6 CF91 C5E7 CF92 C5E8 CF93 C5E9 CF94 C5EA CF95 C5EB CF96 C5EC CF97 C5ED CF98 C5EE CF99 C5EF CF9A C5F0 CF9B C5F1 CF9C C5F3 CF9D C5F4 CF9E C5F5 CF9F C5F6 CFA0 C5F7 CFA1 C5F8 CFA2 C5F9 CFA3 C5FA CFA4 C5FB CFA5 C5FC CFA6 C5FD CFA7 C641 CFA8 C642 CFA9 C643 CFAA C644 CFAB C645 CFAC C646 CFAD C647 CFAE C648 CFAF C649 CFB0 C64A CFB1 C64B CFB2 C64C CFB3 C64D CFB4 C64E CFB5 C64F CFB6 C650 CFB7 C651 CFB8 C653 CFB9 C654 CFBA C655 CFBB C656 CFBC C657 CFBD C658 CFBE C659 CFBF C65A CFC0 C65B CFC1 C65C CFC2 C65D CFC3 C661 CFC4 C662 CFC5 C663 CFC6 C664 CFC7 C665 CFC8 C666 CFC9 C667 CFCA C668 CFCB C669 CFCC C66A CFCD C66B CFCE C66C CFCF C66D CFD0 C66E CFD1 C66F CFD2 C670 CFD3 C671 CFD4 C673 CFD5 C674 CFD6 C675 CFD7 C676 CFD8 C677 CFD9 C678 CFDA C679 CFDB C67A CFDC C67B CFDD C67C CFDE C67D CFDF C681 CFE0 C682 CFE1 C683 CFE2 C684 CFE3 C685 CFE4 C686 CFE5 C687 CFE6 C688 CFE7 C689 CFE8 C68A CFE9 C68B CFEA C68C CFEB C68D CFEC C68E CFED C68F CFEE C690 CFEF C691 CFF0 C693 CFF1 C694 CFF2 C695 CFF3 C696 CFF4 C697 CFF5 C698 CFF6 C699 CFF7 C69A CFF8 C69B CFF9 C69C CFFA C69D CFFB C6A1 CFFC C6A2 CFFD C6A3 CFFE C6A4 CFFF C6A5 D000 C6A6 D001 C6A7 D002 C6A8 D003 C6A9 D004 C6AA D005 C6AB D006 C6AC D007 C6AD D008 C6AE D009 C6AF D00A C6B0 D00B C6B1 D00C C6B3 D00D C6B4 D00E C6B5 D00F C6B6 D010 C6B7 D011 C6B8 D012 C6B9 D013 C6BA D014 C6BB D015 C6BC D016 C6BD D017 C6C1 D018 C6C2 D019 C6C3 D01A C6C4 D01B C6C5 D01C C6C6 D01D C6C7 D01E C6C8 D01F C6C9 D020 C6CA D021 C6CB D022 C6CC D023 C6CD D024 C6CE D025 C6CF D026 C6D0 D027 C6D1 D028 C6D3 D029 C6D4 D02A C6D5 D02B C6D6 D02C C6D7 D02D C6D8 D02E C6D9 D02F C6DA D030 C6DB D031 C6DC D032 C6DD D033 C6E1 D034 C6E2 D035 C6E3 D036 C6E4 D037 C6E5 D038 C6E6 D039 C6E7 D03A C6E8 D03B C6E9 D03C C6EA D03D C6EB D03E C6EC D03F C6ED D040 C6EE D041 C6EF D042 C6F0 D043 C6F1 D044 C6F3 D045 C6F4 D046 C6F5 D047 C6F6 D048 C6F7 D049 C6F8 D04A C6F9 D04B C6FA D04C C6FB D04D C6FC D04E C6FD D04F C741 D050 C742 D051 C743 D052 C744 D053 C745 D054 C746 D055 C747 D056 C748 D057 C749 D058 C74A D059 C74B D05A C74C D05B C74D D05C C74E D05D C74F D05E C750 D05F C751 D060 C753 D061 C754 D062 C755 D063 C756 D064 C757 D065 C758 D066 C759 D067 C75A D068 C75B D069 C75C D06A C75D D06B C761 D06C C762 D06D C763 D06E C764 D06F C765 D070 C766 D071 C767 D072 C768 D073 C769 D074 C76A D075 C76B D076 C76C D077 C76D D078 C76E D079 C76F D07A C770 D07B C771 D07C C773 D07D C774 D07E C775 D07F C776 D080 C777 D081 C778 D082 C779 D083 C77A D084 C77B D085 C77C D086 C77D D087 C781 D088 C782 D089 C783 D08A C784 D08B C785 D08C C786 D08D C787 D08E C788 D08F C789 D090 C78A D091 C78B D092 C78C D093 C78D D094 C78E D095 C78F D096 C790 D097 C791 D098 C793 D099 C794 D09A C795 D09B C796 D09C C797 D09D C798 D09E C799 D09F C79A D0A0 C79B D0A1 C79C D0A2 C79D D0A3 C7A1 D0A4 C7A2 D0A5 C7A3 D0A6 C7A4 D0A7 C7A5 D0A8 C7A6 D0A9 C7A7 D0AA C7A8 D0AB C7A9 D0AC C7AA D0AD C7AB D0AE C7AC D0AF C7AD D0B0 C7AE D0B1 C7AF D0B2 C7B0 D0B3 C7B1 D0B4 C7B3 D0B5 C7B4 D0B6 C7B5 D0B7 C7B6 D0B8 C7B7 D0B9 C7B8 D0BA C7B9 D0BB C7BA D0BC C7BB D0BD C7BC D0BE C7BD D0BF C841 314C C861 D0C0 C862 D0C1 C863 D0C2 C864 D0C3 C865 D0C4 C866 D0C5 C867 D0C6 C868 D0C7 C869 D0C8 C86A D0C9 C86B D0CA C86C D0CB C86D D0CC C86E D0CD C86F D0CE C870 D0CF C871 D0D0 C873 D0D1 C874 D0D2 C875 D0D3 C876 D0D4 C877 D0D5 C878 D0D6 C879 D0D7 C87A D0D8 C87B D0D9 C87C D0DA C87D D0DB C881 D0DC C882 D0DD C883 D0DE C884 D0DF C885 D0E0 C886 D0E1 C887 D0E2 C888 D0E3 C889 D0E4 C88A D0E5 C88B D0E6 C88C D0E7 C88D D0E8 C88E D0E9 C88F D0EA C890 D0EB C891 D0EC C893 D0ED C894 D0EE C895 D0EF C896 D0F0 C897 D0F1 C898 D0F2 C899 D0F3 C89A D0F4 C89B D0F5 C89C D0F6 C89D D0F7 C8A1 D0F8 C8A2 D0F9 C8A3 D0FA C8A4 D0FB C8A5 D0FC C8A6 D0FD C8A7 D0FE C8A8 D0FF C8A9 D100 C8AA D101 C8AB D102 C8AC D103 C8AD D104 C8AE D105 C8AF D106 C8B0 D107 C8B1 D108 C8B3 D109 C8B4 D10A C8B5 D10B C8B6 D10C C8B7 D10D C8B8 D10E C8B9 D10F C8BA D110 C8BB D111 C8BC D112 C8BD D113 C8C1 D114 C8C2 D115 C8C3 D116 C8C4 D117 C8C5 D118 C8C6 D119 C8C7 D11A C8C8 D11B C8C9 D11C C8CA D11D C8CB D11E C8CC D11F C8CD D120 C8CE D121 C8CF D122 C8D0 D123 C8D1 D124 C8D3 D125 C8D4 D126 C8D5 D127 C8D6 D128 C8D7 D129 C8D8 D12A C8D9 D12B C8DA D12C C8DB D12D C8DC D12E C8DD D12F C8E1 D130 C8E2 D131 C8E3 D132 C8E4 D133 C8E5 D134 C8E6 D135 C8E7 D136 C8E8 D137 C8E9 D138 C8EA D139 C8EB D13A C8EC D13B C8ED D13C C8EE D13D C8EF D13E C8F0 D13F C8F1 D140 C8F3 D141 C8F4 D142 C8F5 D143 C8F6 D144 C8F7 D145 C8F8 D146 C8F9 D147 C8FA D148 C8FB D149 C8FC D14A C8FD D14B C941 D14C C942 D14D C943 D14E C944 D14F C945 D150 C946 D151 C947 D152 C948 D153 C949 D154 C94A D155 C94B D156 C94C D157 C94D D158 C94E D159 C94F D15A C950 D15B C951 D15C C953 D15D C954 D15E C955 D15F C956 D160 C957 D161 C958 D162 C959 D163 C95A D164 C95B D165 C95C D166 C95D D167 C961 D168 C962 D169 C963 D16A C964 D16B C965 D16C C966 D16D C967 D16E C968 D16F C969 D170 C96A D171 C96B D172 C96C D173 C96D D174 C96E D175 C96F D176 C970 D177 C971 D178 C973 D179 C974 D17A C975 D17B C976 D17C C977 D17D C978 D17E C979 D17F C97A D180 C97B D181 C97C D182 C97D D183 C981 D184 C982 D185 C983 D186 C984 D187 C985 D188 C986 D189 C987 D18A C988 D18B C989 D18C C98A D18D C98B D18E C98C D18F C98D D190 C98E D191 C98F D192 C990 D193 C991 D194 C993 D195 C994 D196 C995 D197 C996 D198 C997 D199 C998 D19A C999 D19B C99A D19C C99B D19D C99C D19E C99D D19F C9A1 D1A0 C9A2 D1A1 C9A3 D1A2 C9A4 D1A3 C9A5 D1A4 C9A6 D1A5 C9A7 D1A6 C9A8 D1A7 C9A9 D1A8 C9AA D1A9 C9AB D1AA C9AC D1AB C9AD D1AC C9AE D1AD C9AF D1AE C9B0 D1AF C9B1 D1B0 C9B3 D1B1 C9B4 D1B2 C9B5 D1B3 C9B6 D1B4 C9B7 D1B5 C9B8 D1B6 C9B9 D1B7 C9BA D1B8 C9BB D1B9 C9BC D1BA C9BD D1BB C9C1 D1BC C9C2 D1BD C9C3 D1BE C9C4 D1BF C9C5 D1C0 C9C6 D1C1 C9C7 D1C2 C9C8 D1C3 C9C9 D1C4 C9CA D1C5 C9CB D1C6 C9CC D1C7 C9CD D1C8 C9CE D1C9 C9CF D1CA C9D0 D1CB C9D1 D1CC C9D3 D1CD C9D4 D1CE C9D5 D1CF C9D6 D1D0 C9D7 D1D1 C9D8 D1D2 C9D9 D1D3 C9DA D1D4 C9DB D1D5 C9DC D1D6 C9DD D1D7 C9E1 D1D8 C9E2 D1D9 C9E3 D1DA C9E4 D1DB C9E5 D1DC C9E6 D1DD C9E7 D1DE C9E8 D1DF C9E9 D1E0 C9EA D1E1 C9EB D1E2 C9EC D1E3 C9ED D1E4 C9EE D1E5 C9EF D1E6 C9F0 D1E7 C9F1 D1E8 C9F3 D1E9 C9F4 D1EA C9F5 D1EB C9F6 D1EC C9F7 D1ED C9F8 D1EE C9F9 D1EF C9FA D1F0 C9FB D1F1 C9FC D1F2 C9FD D1F3 CA41 D1F4 CA42 D1F5 CA43 D1F6 CA44 D1F7 CA45 D1F8 CA46 D1F9 CA47 D1FA CA48 D1FB CA49 D1FC CA4A D1FD CA4B D1FE CA4C D1FF CA4D D200 CA4E D201 CA4F D202 CA50 D203 CA51 D204 CA53 D205 CA54 D206 CA55 D207 CA56 D208 CA57 D209 CA58 D20A CA59 D20B CA5A D20C CA5B D20D CA5C D20E CA5D D20F CA61 D210 CA62 D211 CA63 D212 CA64 D213 CA65 D214 CA66 D215 CA67 D216 CA68 D217 CA69 D218 CA6A D219 CA6B D21A CA6C D21B CA6D D21C CA6E D21D CA6F D21E CA70 D21F CA71 D220 CA73 D221 CA74 D222 CA75 D223 CA76 D224 CA77 D225 CA78 D226 CA79 D227 CA7A D228 CA7B D229 CA7C D22A CA7D D22B CA81 D22C CA82 D22D CA83 D22E CA84 D22F CA85 D230 CA86 D231 CA87 D232 CA88 D233 CA89 D234 CA8A D235 CA8B D236 CA8C D237 CA8D D238 CA8E D239 CA8F D23A CA90 D23B CA91 D23C CA93 D23D CA94 D23E CA95 D23F CA96 D240 CA97 D241 CA98 D242 CA99 D243 CA9A D244 CA9B D245 CA9C D246 CA9D D247 CAA1 D248 CAA2 D249 CAA3 D24A CAA4 D24B CAA5 D24C CAA6 D24D CAA7 D24E CAA8 D24F CAA9 D250 CAAA D251 CAAB D252 CAAC D253 CAAD D254 CAAE D255 CAAF D256 CAB0 D257 CAB1 D258 CAB3 D259 CAB4 D25A CAB5 D25B CAB6 D25C CAB7 D25D CAB8 D25E CAB9 D25F CABA D260 CABB D261 CABC D262 CABD D263 CAC1 D264 CAC2 D265 CAC3 D266 CAC4 D267 CAC5 D268 CAC6 D269 CAC7 D26A CAC8 D26B CAC9 D26C CACA D26D CACB D26E CACC D26F CACD D270 CACE D271 CACF D272 CAD0 D273 CAD1 D274 CAD3 D275 CAD4 D276 CAD5 D277 CAD6 D278 CAD7 D279 CAD8 D27A CAD9 D27B CADA D27C CADB D27D CADC D27E CADD D27F CAE1 D280 CAE2 D281 CAE3 D282 CAE4 D283 CAE5 D284 CAE6 D285 CAE7 D286 CAE8 D287 CAE9 D288 CAEA D289 CAEB D28A CAEC D28B CAED D28C CAEE D28D CAEF D28E CAF0 D28F CAF1 D290 CAF3 D291 CAF4 D292 CAF5 D293 CAF6 D294 CAF7 D295 CAF8 D296 CAF9 D297 CAFA D298 CAFB D299 CAFC D29A CAFD D29B CB41 D29C CB42 D29D CB43 D29E CB44 D29F CB45 D2A0 CB46 D2A1 CB47 D2A2 CB48 D2A3 CB49 D2A4 CB4A D2A5 CB4B D2A6 CB4C D2A7 CB4D D2A8 CB4E D2A9 CB4F D2AA CB50 D2AB CB51 D2AC CB53 D2AD CB54 D2AE CB55 D2AF CB56 D2B0 CB57 D2B1 CB58 D2B2 CB59 D2B3 CB5A D2B4 CB5B D2B5 CB5C D2B6 CB5D D2B7 CB61 D2B8 CB62 D2B9 CB63 D2BA CB64 D2BB CB65 D2BC CB66 D2BD CB67 D2BE CB68 D2BF CB69 D2C0 CB6A D2C1 CB6B D2C2 CB6C D2C3 CB6D D2C4 CB6E D2C5 CB6F D2C6 CB70 D2C7 CB71 D2C8 CB73 D2C9 CB74 D2CA CB75 D2CB CB76 D2CC CB77 D2CD CB78 D2CE CB79 D2CF CB7A D2D0 CB7B D2D1 CB7C D2D2 CB7D D2D3 CB81 D2D4 CB82 D2D5 CB83 D2D6 CB84 D2D7 CB85 D2D8 CB86 D2D9 CB87 D2DA CB88 D2DB CB89 D2DC CB8A D2DD CB8B D2DE CB8C D2DF CB8D D2E0 CB8E D2E1 CB8F D2E2 CB90 D2E3 CB91 D2E4 CB93 D2E5 CB94 D2E6 CB95 D2E7 CB96 D2E8 CB97 D2E9 CB98 D2EA CB99 D2EB CB9A D2EC CB9B D2ED CB9C D2EE CB9D D2EF CBA1 D2F0 CBA2 D2F1 CBA3 D2F2 CBA4 D2F3 CBA5 D2F4 CBA6 D2F5 CBA7 D2F6 CBA8 D2F7 CBA9 D2F8 CBAA D2F9 CBAB D2FA CBAC D2FB CBAD D2FC CBAE D2FD CBAF D2FE CBB0 D2FF CBB1 D300 CBB3 D301 CBB4 D302 CBB5 D303 CBB6 D304 CBB7 D305 CBB8 D306 CBB9 D307 CBBA D308 CBBB D309 CBBC D30A CBBD D30B CC41 314D CC61 D30C CC62 D30D CC63 D30E CC64 D30F CC65 D310 CC66 D311 CC67 D312 CC68 D313 CC69 D314 CC6A D315 CC6B D316 CC6C D317 CC6D D318 CC6E D319 CC6F D31A CC70 D31B CC71 D31C CC73 D31D CC74 D31E CC75 D31F CC76 D320 CC77 D321 CC78 D322 CC79 D323 CC7A D324 CC7B D325 CC7C D326 CC7D D327 CC81 D328 CC82 D329 CC83 D32A CC84 D32B CC85 D32C CC86 D32D CC87 D32E CC88 D32F CC89 D330 CC8A D331 CC8B D332 CC8C D333 CC8D D334 CC8E D335 CC8F D336 CC90 D337 CC91 D338 CC93 D339 CC94 D33A CC95 D33B CC96 D33C CC97 D33D CC98 D33E CC99 D33F CC9A D340 CC9B D341 CC9C D342 CC9D D343 CCA1 D344 CCA2 D345 CCA3 D346 CCA4 D347 CCA5 D348 CCA6 D349 CCA7 D34A CCA8 D34B CCA9 D34C CCAA D34D CCAB D34E CCAC D34F CCAD D350 CCAE D351 CCAF D352 CCB0 D353 CCB1 D354 CCB3 D355 CCB4 D356 CCB5 D357 CCB6 D358 CCB7 D359 CCB8 D35A CCB9 D35B CCBA D35C CCBB D35D CCBC D35E CCBD D35F CCC1 D360 CCC2 D361 CCC3 D362 CCC4 D363 CCC5 D364 CCC6 D365 CCC7 D366 CCC8 D367 CCC9 D368 CCCA D369 CCCB D36A CCCC D36B CCCD D36C CCCE D36D CCCF D36E CCD0 D36F CCD1 D370 CCD3 D371 CCD4 D372 CCD5 D373 CCD6 D374 CCD7 D375 CCD8 D376 CCD9 D377 CCDA D378 CCDB D379 CCDC D37A CCDD D37B CCE1 D37C CCE2 D37D CCE3 D37E CCE4 D37F CCE5 D380 CCE6 D381 CCE7 D382 CCE8 D383 CCE9 D384 CCEA D385 CCEB D386 CCEC D387 CCED D388 CCEE D389 CCEF D38A CCF0 D38B CCF1 D38C CCF3 D38D CCF4 D38E CCF5 D38F CCF6 D390 CCF7 D391 CCF8 D392 CCF9 D393 CCFA D394 CCFB D395 CCFC D396 CCFD D397 CD41 D398 CD42 D399 CD43 D39A CD44 D39B CD45 D39C CD46 D39D CD47 D39E CD48 D39F CD49 D3A0 CD4A D3A1 CD4B D3A2 CD4C D3A3 CD4D D3A4 CD4E D3A5 CD4F D3A6 CD50 D3A7 CD51 D3A8 CD53 D3A9 CD54 D3AA CD55 D3AB CD56 D3AC CD57 D3AD CD58 D3AE CD59 D3AF CD5A D3B0 CD5B D3B1 CD5C D3B2 CD5D D3B3 CD61 D3B4 CD62 D3B5 CD63 D3B6 CD64 D3B7 CD65 D3B8 CD66 D3B9 CD67 D3BA CD68 D3BB CD69 D3BC CD6A D3BD CD6B D3BE CD6C D3BF CD6D D3C0 CD6E D3C1 CD6F D3C2 CD70 D3C3 CD71 D3C4 CD73 D3C5 CD74 D3C6 CD75 D3C7 CD76 D3C8 CD77 D3C9 CD78 D3CA CD79 D3CB CD7A D3CC CD7B D3CD CD7C D3CE CD7D D3CF CD81 D3D0 CD82 D3D1 CD83 D3D2 CD84 D3D3 CD85 D3D4 CD86 D3D5 CD87 D3D6 CD88 D3D7 CD89 D3D8 CD8A D3D9 CD8B D3DA CD8C D3DB CD8D D3DC CD8E D3DD CD8F D3DE CD90 D3DF CD91 D3E0 CD93 D3E1 CD94 D3E2 CD95 D3E3 CD96 D3E4 CD97 D3E5 CD98 D3E6 CD99 D3E7 CD9A D3E8 CD9B D3E9 CD9C D3EA CD9D D3EB CDA1 D3EC CDA2 D3ED CDA3 D3EE CDA4 D3EF CDA5 D3F0 CDA6 D3F1 CDA7 D3F2 CDA8 D3F3 CDA9 D3F4 CDAA D3F5 CDAB D3F6 CDAC D3F7 CDAD D3F8 CDAE D3F9 CDAF D3FA CDB0 D3FB CDB1 D3FC CDB3 D3FD CDB4 D3FE CDB5 D3FF CDB6 D400 CDB7 D401 CDB8 D402 CDB9 D403 CDBA D404 CDBB D405 CDBC D406 CDBD D407 CDC1 D408 CDC2 D409 CDC3 D40A CDC4 D40B CDC5 D40C CDC6 D40D CDC7 D40E CDC8 D40F CDC9 D410 CDCA D411 CDCB D412 CDCC D413 CDCD D414 CDCE D415 CDCF D416 CDD0 D417 CDD1 D418 CDD3 D419 CDD4 D41A CDD5 D41B CDD6 D41C CDD7 D41D CDD8 D41E CDD9 D41F CDDA D420 CDDB D421 CDDC D422 CDDD D423 CDE1 D424 CDE2 D425 CDE3 D426 CDE4 D427 CDE5 D428 CDE6 D429 CDE7 D42A CDE8 D42B CDE9 D42C CDEA D42D CDEB D42E CDEC D42F CDED D430 CDEE D431 CDEF D432 CDF0 D433 CDF1 D434 CDF3 D435 CDF4 D436 CDF5 D437 CDF6 D438 CDF7 D439 CDF8 D43A CDF9 D43B CDFA D43C CDFB D43D CDFC D43E CDFD D43F CE41 D440 CE42 D441 CE43 D442 CE44 D443 CE45 D444 CE46 D445 CE47 D446 CE48 D447 CE49 D448 CE4A D449 CE4B D44A CE4C D44B CE4D D44C CE4E D44D CE4F D44E CE50 D44F CE51 D450 CE53 D451 CE54 D452 CE55 D453 CE56 D454 CE57 D455 CE58 D456 CE59 D457 CE5A D458 CE5B D459 CE5C D45A CE5D D45B CE61 D45C CE62 D45D CE63 D45E CE64 D45F CE65 D460 CE66 D461 CE67 D462 CE68 D463 CE69 D464 CE6A D465 CE6B D466 CE6C D467 CE6D D468 CE6E D469 CE6F D46A CE70 D46B CE71 D46C CE73 D46D CE74 D46E CE75 D46F CE76 D470 CE77 D471 CE78 D472 CE79 D473 CE7A D474 CE7B D475 CE7C D476 CE7D D477 CE81 D478 CE82 D479 CE83 D47A CE84 D47B CE85 D47C CE86 D47D CE87 D47E CE88 D47F CE89 D480 CE8A D481 CE8B D482 CE8C D483 CE8D D484 CE8E D485 CE8F D486 CE90 D487 CE91 D488 CE93 D489 CE94 D48A CE95 D48B CE96 D48C CE97 D48D CE98 D48E CE99 D48F CE9A D490 CE9B D491 CE9C D492 CE9D D493 CEA1 D494 CEA2 D495 CEA3 D496 CEA4 D497 CEA5 D498 CEA6 D499 CEA7 D49A CEA8 D49B CEA9 D49C CEAA D49D CEAB D49E CEAC D49F CEAD D4A0 CEAE D4A1 CEAF D4A2 CEB0 D4A3 CEB1 D4A4 CEB3 D4A5 CEB4 D4A6 CEB5 D4A7 CEB6 D4A8 CEB7 D4A9 CEB8 D4AA CEB9 D4AB CEBA D4AC CEBB D4AD CEBC D4AE CEBD D4AF CEC1 D4B0 CEC2 D4B1 CEC3 D4B2 CEC4 D4B3 CEC5 D4B4 CEC6 D4B5 CEC7 D4B6 CEC8 D4B7 CEC9 D4B8 CECA D4B9 CECB D4BA CECC D4BB CECD D4BC CECE D4BD CECF D4BE CED0 D4BF CED1 D4C0 CED3 D4C1 CED4 D4C2 CED5 D4C3 CED6 D4C4 CED7 D4C5 CED8 D4C6 CED9 D4C7 CEDA D4C8 CEDB D4C9 CEDC D4CA CEDD D4CB CEE1 D4CC CEE2 D4CD CEE3 D4CE CEE4 D4CF CEE5 D4D0 CEE6 D4D1 CEE7 D4D2 CEE8 D4D3 CEE9 D4D4 CEEA D4D5 CEEB D4D6 CEEC D4D7 CEED D4D8 CEEE D4D9 CEEF D4DA CEF0 D4DB CEF1 D4DC CEF3 D4DD CEF4 D4DE CEF5 D4DF CEF6 D4E0 CEF7 D4E1 CEF8 D4E2 CEF9 D4E3 CEFA D4E4 CEFB D4E5 CEFC D4E6 CEFD D4E7 CF41 D4E8 CF42 D4E9 CF43 D4EA CF44 D4EB CF45 D4EC CF46 D4ED CF47 D4EE CF48 D4EF CF49 D4F0 CF4A D4F1 CF4B D4F2 CF4C D4F3 CF4D D4F4 CF4E D4F5 CF4F D4F6 CF50 D4F7 CF51 D4F8 CF53 D4F9 CF54 D4FA CF55 D4FB CF56 D4FC CF57 D4FD CF58 D4FE CF59 D4FF CF5A D500 CF5B D501 CF5C D502 CF5D D503 CF61 D504 CF62 D505 CF63 D506 CF64 D507 CF65 D508 CF66 D509 CF67 D50A CF68 D50B CF69 D50C CF6A D50D CF6B D50E CF6C D50F CF6D D510 CF6E D511 CF6F D512 CF70 D513 CF71 D514 CF73 D515 CF74 D516 CF75 D517 CF76 D518 CF77 D519 CF78 D51A CF79 D51B CF7A D51C CF7B D51D CF7C D51E CF7D D51F CF81 D520 CF82 D521 CF83 D522 CF84 D523 CF85 D524 CF86 D525 CF87 D526 CF88 D527 CF89 D528 CF8A D529 CF8B D52A CF8C D52B CF8D D52C CF8E D52D CF8F D52E CF90 D52F CF91 D530 CF93 D531 CF94 D532 CF95 D533 CF96 D534 CF97 D535 CF98 D536 CF99 D537 CF9A D538 CF9B D539 CF9C D53A CF9D D53B CFA1 D53C CFA2 D53D CFA3 D53E CFA4 D53F CFA5 D540 CFA6 D541 CFA7 D542 CFA8 D543 CFA9 D544 CFAA D545 CFAB D546 CFAC D547 CFAD D548 CFAE D549 CFAF D54A CFB0 D54B CFB1 D54C CFB3 D54D CFB4 D54E CFB5 D54F CFB6 D550 CFB7 D551 CFB8 D552 CFB9 D553 CFBA D554 CFBB D555 CFBC D556 CFBD D557 D041 314E D061 D558 D062 D559 D063 D55A D064 D55B D065 D55C D066 D55D D067 D55E D068 D55F D069 D560 D06A D561 D06B D562 D06C D563 D06D D564 D06E D565 D06F D566 D070 D567 D071 D568 D073 D569 D074 D56A D075 D56B D076 D56C D077 D56D D078 D56E D079 D56F D07A D570 D07B D571 D07C D572 D07D D573 D081 D574 D082 D575 D083 D576 D084 D577 D085 D578 D086 D579 D087 D57A D088 D57B D089 D57C D08A D57D D08B D57E D08C D57F D08D D580 D08E D581 D08F D582 D090 D583 D091 D584 D093 D585 D094 D586 D095 D587 D096 D588 D097 D589 D098 D58A D099 D58B D09A D58C D09B D58D D09C D58E D09D D58F D0A1 D590 D0A2 D591 D0A3 D592 D0A4 D593 D0A5 D594 D0A6 D595 D0A7 D596 D0A8 D597 D0A9 D598 D0AA D599 D0AB D59A D0AC D59B D0AD D59C D0AE D59D D0AF D59E D0B0 D59F D0B1 D5A0 D0B3 D5A1 D0B4 D5A2 D0B5 D5A3 D0B6 D5A4 D0B7 D5A5 D0B8 D5A6 D0B9 D5A7 D0BA D5A8 D0BB D5A9 D0BC D5AA D0BD D5AB D0C1 D5AC D0C2 D5AD D0C3 D5AE D0C4 D5AF D0C5 D5B0 D0C6 D5B1 D0C7 D5B2 D0C8 D5B3 D0C9 D5B4 D0CA D5B5 D0CB D5B6 D0CC D5B7 D0CD D5B8 D0CE D5B9 D0CF D5BA D0D0 D5BB D0D1 D5BC D0D3 D5BD D0D4 D5BE D0D5 D5BF D0D6 D5C0 D0D7 D5C1 D0D8 D5C2 D0D9 D5C3 D0DA D5C4 D0DB D5C5 D0DC D5C6 D0DD D5C7 D0E1 D5C8 D0E2 D5C9 D0E3 D5CA D0E4 D5CB D0E5 D5CC D0E6 D5CD D0E7 D5CE D0E8 D5CF D0E9 D5D0 D0EA D5D1 D0EB D5D2 D0EC D5D3 D0ED D5D4 D0EE D5D5 D0EF D5D6 D0F0 D5D7 D0F1 D5D8 D0F3 D5D9 D0F4 D5DA D0F5 D5DB D0F6 D5DC D0F7 D5DD D0F8 D5DE D0F9 D5DF D0FA D5E0 D0FB D5E1 D0FC D5E2 D0FD D5E3 D141 D5E4 D142 D5E5 D143 D5E6 D144 D5E7 D145 D5E8 D146 D5E9 D147 D5EA D148 D5EB D149 D5EC D14A D5ED D14B D5EE D14C D5EF D14D D5F0 D14E D5F1 D14F D5F2 D150 D5F3 D151 D5F4 D153 D5F5 D154 D5F6 D155 D5F7 D156 D5F8 D157 D5F9 D158 D5FA D159 D5FB D15A D5FC D15B D5FD D15C D5FE D15D D5FF D161 D600 D162 D601 D163 D602 D164 D603 D165 D604 D166 D605 D167 D606 D168 D607 D169 D608 D16A D609 D16B D60A D16C D60B D16D D60C D16E D60D D16F D60E D170 D60F D171 D610 D173 D611 D174 D612 D175 D613 D176 D614 D177 D615 D178 D616 D179 D617 D17A D618 D17B D619 D17C D61A D17D D61B D181 D61C D182 D61D D183 D61E D184 D61F D185 D620 D186 D621 D187 D622 D188 D623 D189 D624 D18A D625 D18B D626 D18C D627 D18D D628 D18E D629 D18F D62A D190 D62B D191 D62C D193 D62D D194 D62E D195 D62F D196 D630 D197 D631 D198 D632 D199 D633 D19A D634 D19B D635 D19C D636 D19D D637 D1A1 D638 D1A2 D639 D1A3 D63A D1A4 D63B D1A5 D63C D1A6 D63D D1A7 D63E D1A8 D63F D1A9 D640 D1AA D641 D1AB D642 D1AC D643 D1AD D644 D1AE D645 D1AF D646 D1B0 D647 D1B1 D648 D1B3 D649 D1B4 D64A D1B5 D64B D1B6 D64C D1B7 D64D D1B8 D64E D1B9 D64F D1BA D650 D1BB D651 D1BC D652 D1BD D653 D1C1 D654 D1C2 D655 D1C3 D656 D1C4 D657 D1C5 D658 D1C6 D659 D1C7 D65A D1C8 D65B D1C9 D65C D1CA D65D D1CB D65E D1CC D65F D1CD D660 D1CE D661 D1CF D662 D1D0 D663 D1D1 D664 D1D3 D665 D1D4 D666 D1D5 D667 D1D6 D668 D1D7 D669 D1D8 D66A D1D9 D66B D1DA D66C D1DB D66D D1DC D66E D1DD D66F D1E1 D670 D1E2 D671 D1E3 D672 D1E4 D673 D1E5 D674 D1E6 D675 D1E7 D676 D1E8 D677 D1E9 D678 D1EA D679 D1EB D67A D1EC D67B D1ED D67C D1EE D67D D1EF D67E D1F0 D67F D1F1 D680 D1F3 D681 D1F4 D682 D1F5 D683 D1F6 D684 D1F7 D685 D1F8 D686 D1F9 D687 D1FA D688 D1FB D689 D1FC D68A D1FD D68B D241 D68C D242 D68D D243 D68E D244 D68F D245 D690 D246 D691 D247 D692 D248 D693 D249 D694 D24A D695 D24B D696 D24C D697 D24D D698 D24E D699 D24F D69A D250 D69B D251 D69C D253 D69D D254 D69E D255 D69F D256 D6A0 D257 D6A1 D258 D6A2 D259 D6A3 D25A D6A4 D25B D6A5 D25C D6A6 D25D D6A7 D261 D6A8 D262 D6A9 D263 D6AA D264 D6AB D265 D6AC D266 D6AD D267 D6AE D268 D6AF D269 D6B0 D26A D6B1 D26B D6B2 D26C D6B3 D26D D6B4 D26E D6B5 D26F D6B6 D270 D6B7 D271 D6B8 D273 D6B9 D274 D6BA D275 D6BB D276 D6BC D277 D6BD D278 D6BE D279 D6BF D27A D6C0 D27B D6C1 D27C D6C2 D27D D6C3 D281 D6C4 D282 D6C5 D283 D6C6 D284 D6C7 D285 D6C8 D286 D6C9 D287 D6CA D288 D6CB D289 D6CC D28A D6CD D28B D6CE D28C D6CF D28D D6D0 D28E D6D1 D28F D6D2 D290 D6D3 D291 D6D4 D293 D6D5 D294 D6D6 D295 D6D7 D296 D6D8 D297 D6D9 D298 D6DA D299 D6DB D29A D6DC D29B D6DD D29C D6DE D29D D6DF D2A1 D6E0 D2A2 D6E1 D2A3 D6E2 D2A4 D6E3 D2A5 D6E4 D2A6 D6E5 D2A7 D6E6 D2A8 D6E7 D2A9 D6E8 D2AA D6E9 D2AB D6EA D2AC D6EB D2AD D6EC D2AE D6ED D2AF D6EE D2B0 D6EF D2B1 D6F0 D2B3 D6F1 D2B4 D6F2 D2B5 D6F3 D2B6 D6F4 D2B7 D6F5 D2B8 D6F6 D2B9 D6F7 D2BA D6F8 D2BB D6F9 D2BC D6FA D2BD D6FB D2C1 D6FC D2C2 D6FD D2C3 D6FE D2C4 D6FF D2C5 D700 D2C6 D701 D2C7 D702 D2C8 D703 D2C9 D704 D2CA D705 D2CB D706 D2CC D707 D2CD D708 D2CE D709 D2CF D70A D2D0 D70B D2D1 D70C D2D3 D70D D2D4 D70E D2D5 D70F D2D6 D710 D2D7 D711 D2D8 D712 D2D9 D713 D2DA D714 D2DB D715 D2DC D716 D2DD D717 D2E1 D718 D2E2 D719 D2E3 D71A D2E4 D71B D2E5 D71C D2E6 D71D D2E7 D71E D2E8 D71F D2E9 D720 D2EA D721 D2EB D722 D2EC D723 D2ED D724 D2EE D725 D2EF D726 D2F0 D727 D2F1 D728 D2F3 D729 D2F4 D72A D2F5 D72B D2F6 D72C D2F7 D72D D2F8 D72E D2F9 D72F D2FA D730 D2FB D731 D2FC D732 D2FD D733 D341 D734 D342 D735 D343 D736 D344 D737 D345 D738 D346 D739 D347 D73A D348 D73B D349 D73C D34A D73D D34B D73E D34C D73F D34D D740 D34E D741 D34F D742 D350 D743 D351 D744 D353 D745 D354 D746 D355 D747 D356 D748 D357 D749 D358 D74A D359 D74B D35A D74C D35B D74D D35C D74E D35D D74F D361 D750 D362 D751 D363 D752 D364 D753 D365 D754 D366 D755 D367 D756 D368 D757 D369 D758 D36A D759 D36B D75A D36C D75B D36D D75C D36E D75D D36F D75E D370 D75F D371 D760 D373 D761 D374 D762 D375 D763 D376 D764 D377 D765 D378 D766 D379 D767 D37A D768 D37B D769 D37C D76A D37D D76B D381 D76C D382 D76D D383 D76E D384 D76F D385 D770 D386 D771 D387 D772 D388 D773 D389 D774 D38A D775 D38B D776 D38C D777 D38D D778 D38E D779 D38F D77A D390 D77B D391 D77C D393 D77D D394 D77E D395 D77F D396 D780 D397 D781 D398 D782 D399 D783 D39A D784 D39B D785 D39C D786 D39D D787 D3A1 D788 D3A2 D789 D3A3 D78A D3A4 D78B D3A5 D78C D3A6 D78D D3A7 D78E D3A8 D78F D3A9 D790 D3AA D791 D3AB D792 D3AC D793 D3AD D794 D3AE D795 D3AF D796 D3B0 D797 D3B1 D798 D3B3 D799 D3B4 D79A D3B5 D79B D3B6 D79C D3B7 D79D D3B8 D79E D3B9 D79F D3BA D7A0 D3BB D7A1 D3BC D7A2 D3BD D7A3 D931 3000 D932 3001 D933 3002 D934 00B7 D935 2025 D936 2026 D937 00A8 D938 3003 D939 00AD D93A 2015 D93B 2225 D93C FF3C D93D 223C D93E 2018 D93F 2019 D940 201C D941 201D D942 3014 D943 3015 D944 3008 D945 3009 D946 300A D947 300B D948 300C D949 300D D94A 300E D94B 300F D94C 3010 D94D 3011 D94E 00B1 D94F 00D7 D950 00F7 D951 2260 D952 2264 D953 2265 D954 221E D955 2234 D956 00B0 D957 2032 D958 2033 D959 2103 D95A 212B D95B FFE0 D95C FFE1 D95D FFE5 D95E 2642 D95F 2640 D960 2220 D961 22A5 D962 2312 D963 2202 D964 2207 D965 2261 D966 2252 D967 00A7 D968 203B D969 2606 D96A 2605 D96B 25CB D96C 25CF D96D 25CE D96E 25C7 D96F 25C6 D970 25A1 D971 25A0 D972 25B3 D973 25B2 D974 25BD D975 25BC D976 2192 D977 2190 D978 2191 D979 2193 D97A 2194 D97B 3013 D97C 226A D97D 226B D97E 221A D991 223D D992 221D D993 2235 D994 222B D995 222C D996 2208 D997 220B D998 2286 D999 2287 D99A 2282 D99B 2283 D99C 222A D99D 2229 D99E 2227 D99F 2228 D9A0 FFE2 D9A1 21D2 D9A2 21D4 D9A3 2200 D9A4 2203 D9A5 00B4 D9A6 FF5E D9A7 02C7 D9A8 02D8 D9A9 02DD D9AA 02DA D9AB 02D9 D9AC 00B8 D9AD 02DB D9AE 00A1 D9AF 00BF D9B0 02D0 D9B1 222E D9B2 2211 D9B3 220F D9B4 00A4 D9B5 2109 D9B6 2030 D9B7 25C1 D9B8 25C0 D9B9 25B7 D9BA 25B6 D9BB 2664 D9BC 2660 D9BD 2661 D9BE 2665 D9BF 2667 D9C0 2663 D9C1 2299 D9C2 25C8 D9C3 25A3 D9C4 25D0 D9C5 25D1 D9C6 2592 D9C7 25A4 D9C8 25A5 D9C9 25A8 D9CA 25A7 D9CB 25A6 D9CC 25A9 D9CD 2668 D9CE 260F D9CF 260E D9D0 261C D9D1 261E D9D2 00B6 D9D3 2020 D9D4 2021 D9D5 2195 D9D6 2197 D9D7 2199 D9D8 2196 D9D9 2198 D9DA 266D D9DB 2669 D9DC 266A D9DD 266C D9DE 327F D9DF 321C D9E0 2116 D9E1 33C7 D9E2 2122 D9E3 33C2 D9E4 33D8 D9E5 2121 DA31 FF01 DA32 FF02 DA33 FF03 DA34 FF04 DA35 FF05 DA36 FF06 DA37 FF07 DA38 FF08 DA39 FF09 DA3A FF0A DA3B FF0B DA3C FF0C DA3D FF0D DA3E FF0E DA3F FF0F DA40 FF10 DA41 FF11 DA42 FF12 DA43 FF13 DA44 FF14 DA45 FF15 DA46 FF16 DA47 FF17 DA48 FF18 DA49 FF19 DA4A FF1A DA4B FF1B DA4C FF1C DA4D FF1D DA4E FF1E DA4F FF1F DA50 FF20 DA51 FF21 DA52 FF22 DA53 FF23 DA54 FF24 DA55 FF25 DA56 FF26 DA57 FF27 DA58 FF28 DA59 FF29 DA5A FF2A DA5B FF2B DA5C FF2C DA5D FF2D DA5E FF2E DA5F FF2F DA60 FF30 DA61 FF31 DA62 FF32 DA63 FF33 DA64 FF34 DA65 FF35 DA66 FF36 DA67 FF37 DA68 FF38 DA69 FF39 DA6A FF3A DA6B FF3B DA6C FFE6 DA6D FF3D DA6E FF3E DA6F FF3F DA70 FF40 DA71 FF41 DA72 FF42 DA73 FF43 DA74 FF44 DA75 FF45 DA76 FF46 DA77 FF47 DA78 FF48 DA79 FF49 DA7A FF4A DA7B FF4B DA7C FF4C DA7D FF4D DA7E FF4E DA91 FF4F DA92 FF50 DA93 FF51 DA94 FF52 DA95 FF53 DA96 FF54 DA97 FF55 DA98 FF56 DA99 FF57 DA9A FF58 DA9B FF59 DA9C FF5A DA9D FF5B DA9E FF5C DA9F FF5D DAA0 FFE3 DAD4 3164 DAD5 3165 DAD6 3166 DAD7 3167 DAD8 3168 DAD9 3169 DADA 316A DADB 316B DADC 316C DADD 316D DADE 316E DADF 316F DAE0 3170 DAE1 3171 DAE2 3172 DAE3 3173 DAE4 3174 DAE5 3175 DAE6 3176 DAE7 3177 DAE8 3178 DAE9 3179 DAEA 317A DAEB 317B DAEC 317C DAED 317D DAEE 317E DAEF 317F DAF0 3180 DAF1 3181 DAF2 3182 DAF3 3183 DAF4 3184 DAF5 3185 DAF6 3186 DAF7 3187 DAF8 3188 DAF9 3189 DAFA 318A DAFB 318B DAFC 318C DAFD 318D DAFE 318E DB31 2170 DB32 2171 DB33 2172 DB34 2173 DB35 2174 DB36 2175 DB37 2176 DB38 2177 DB39 2178 DB3A 2179 DB40 2160 DB41 2161 DB42 2162 DB43 2163 DB44 2164 DB45 2165 DB46 2166 DB47 2167 DB48 2168 DB49 2169 DB51 0391 DB52 0392 DB53 0393 DB54 0394 DB55 0395 DB56 0396 DB57 0397 DB58 0398 DB59 0399 DB5A 039A DB5B 039B DB5C 039C DB5D 039D DB5E 039E DB5F 039F DB60 03A0 DB61 03A1 DB62 03A3 DB63 03A4 DB64 03A5 DB65 03A6 DB66 03A7 DB67 03A8 DB68 03A9 DB71 03B1 DB72 03B2 DB73 03B3 DB74 03B4 DB75 03B5 DB76 03B6 DB77 03B7 DB78 03B8 DB79 03B9 DB7A 03BA DB7B 03BB DB7C 03BC DB7D 03BD DB7E 03BE DB91 03BF DB92 03C0 DB93 03C1 DB94 03C3 DB95 03C4 DB96 03C5 DB97 03C6 DB98 03C7 DB99 03C8 DB9A 03C9 DBA1 2500 DBA2 2502 DBA3 250C DBA4 2510 DBA5 2518 DBA6 2514 DBA7 251C DBA8 252C DBA9 2524 DBAA 2534 DBAB 253C DBAC 2501 DBAD 2503 DBAE 250F DBAF 2513 DBB0 251B DBB1 2517 DBB2 2523 DBB3 2533 DBB4 252B DBB5 253B DBB6 254B DBB7 2520 DBB8 252F DBB9 2528 DBBA 2537 DBBB 253F DBBC 251D DBBD 2530 DBBE 2525 DBBF 2538 DBC0 2542 DBC1 2512 DBC2 2511 DBC3 251A DBC4 2519 DBC5 2516 DBC6 2515 DBC7 250E DBC8 250D DBC9 251E DBCA 251F DBCB 2521 DBCC 2522 DBCD 2526 DBCE 2527 DBCF 2529 DBD0 252A DBD1 252D DBD2 252E DBD3 2531 DBD4 2532 DBD5 2535 DBD6 2536 DBD7 2539 DBD8 253A DBD9 253D DBDA 253E DBDB 2540 DBDC 2541 DBDD 2543 DBDE 2544 DBDF 2545 DBE0 2546 DBE1 2547 DBE2 2548 DBE3 2549 DBE4 254A DC31 3395 DC32 3396 DC33 3397 DC34 2113 DC35 3398 DC36 33C4 DC37 33A3 DC38 33A4 DC39 33A5 DC3A 33A6 DC3B 3399 DC3C 339A DC3D 339B DC3E 339C DC3F 339D DC40 339E DC41 339F DC42 33A0 DC43 33A1 DC44 33A2 DC45 33CA DC46 338D DC47 338E DC48 338F DC49 33CF DC4A 3388 DC4B 3389 DC4C 33C8 DC4D 33A7 DC4E 33A8 DC4F 33B0 DC50 33B1 DC51 33B2 DC52 33B3 DC53 33B4 DC54 33B5 DC55 33B6 DC56 33B7 DC57 33B8 DC58 33B9 DC59 3380 DC5A 3381 DC5B 3382 DC5C 3383 DC5D 3384 DC5E 33BA DC5F 33BB DC60 33BC DC61 33BD DC62 33BE DC63 33BF DC64 3390 DC65 3391 DC66 3392 DC67 3393 DC68 3394 DC69 2126 DC6A 33C0 DC6B 33C1 DC6C 338A DC6D 338B DC6E 338C DC6F 33D6 DC70 33C5 DC71 33AD DC72 33AE DC73 33AF DC74 33DB DC75 33A9 DC76 33AA DC77 33AB DC78 33AC DC79 33DD DC7A 33D0 DC7B 33D3 DC7C 33C3 DC7D 33C9 DC7E 33DC DC91 33C6 DCA1 00C6 DCA2 00D0 DCA3 00AA DCA4 0126 DCA6 0132 DCA8 013F DCA9 0141 DCAA 00D8 DCAB 0152 DCAC 00BA DCAD 00DE DCAE 0166 DCAF 014A DCB1 3260 DCB2 3261 DCB3 3262 DCB4 3263 DCB5 3264 DCB6 3265 DCB7 3266 DCB8 3267 DCB9 3268 DCBA 3269 DCBB 326A DCBC 326B DCBD 326C DCBE 326D DCBF 326E DCC0 326F DCC1 3270 DCC2 3271 DCC3 3272 DCC4 3273 DCC5 3274 DCC6 3275 DCC7 3276 DCC8 3277 DCC9 3278 DCCA 3279 DCCB 327A DCCC 327B DCCD 24D0 DCCE 24D1 DCCF 24D2 DCD0 24D3 DCD1 24D4 DCD2 24D5 DCD3 24D6 DCD4 24D7 DCD5 24D8 DCD6 24D9 DCD7 24DA DCD8 24DB DCD9 24DC DCDA 24DD DCDB 24DE DCDC 24DF DCDD 24E0 DCDE 24E1 DCDF 24E2 DCE0 24E3 DCE1 24E4 DCE2 24E5 DCE3 24E6 DCE4 24E7 DCE5 24E8 DCE6 24E9 DCE7 2460 DCE8 2461 DCE9 2462 DCEA 2463 DCEB 2464 DCEC 2465 DCED 2466 DCEE 2467 DCEF 2468 DCF0 2469 DCF1 246A DCF2 246B DCF3 246C DCF4 246D DCF5 246E DCF6 00BD DCF7 2153 DCF8 2154 DCF9 00BC DCFA 00BE DCFB 215B DCFC 215C DCFD 215D DCFE 215E DD31 00E6 DD32 0111 DD33 00F0 DD34 0127 DD35 0131 DD36 0133 DD37 0138 DD38 0140 DD39 0142 DD3A 00F8 DD3B 0153 DD3C 00DF DD3D 00FE DD3E 0167 DD3F 014B DD40 0149 DD41 3200 DD42 3201 DD43 3202 DD44 3203 DD45 3204 DD46 3205 DD47 3206 DD48 3207 DD49 3208 DD4A 3209 DD4B 320A DD4C 320B DD4D 320C DD4E 320D DD4F 320E DD50 320F DD51 3210 DD52 3211 DD53 3212 DD54 3213 DD55 3214 DD56 3215 DD57 3216 DD58 3217 DD59 3218 DD5A 3219 DD5B 321A DD5C 321B DD5D 249C DD5E 249D DD5F 249E DD60 249F DD61 24A0 DD62 24A1 DD63 24A2 DD64 24A3 DD65 24A4 DD66 24A5 DD67 24A6 DD68 24A7 DD69 24A8 DD6A 24A9 DD6B 24AA DD6C 24AB DD6D 24AC DD6E 24AD DD6F 24AE DD70 24AF DD71 24B0 DD72 24B1 DD73 24B2 DD74 24B3 DD75 24B4 DD76 24B5 DD77 2474 DD78 2475 DD79 2476 DD7A 2477 DD7B 2478 DD7C 2479 DD7D 247A DD7E 247B DD91 247C DD92 247D DD93 247E DD94 247F DD95 2480 DD96 2481 DD97 2482 DD98 00B9 DD99 00B2 DD9A 00B3 DD9B 2074 DD9C 207F DD9D 2081 DD9E 2082 DD9F 2083 DDA0 2084 DDA1 3041 DDA2 3042 DDA3 3043 DDA4 3044 DDA5 3045 DDA6 3046 DDA7 3047 DDA8 3048 DDA9 3049 DDAA 304A DDAB 304B DDAC 304C DDAD 304D DDAE 304E DDAF 304F DDB0 3050 DDB1 3051 DDB2 3052 DDB3 3053 DDB4 3054 DDB5 3055 DDB6 3056 DDB7 3057 DDB8 3058 DDB9 3059 DDBA 305A DDBB 305B DDBC 305C DDBD 305D DDBE 305E DDBF 305F DDC0 3060 DDC1 3061 DDC2 3062 DDC3 3063 DDC4 3064 DDC5 3065 DDC6 3066 DDC7 3067 DDC8 3068 DDC9 3069 DDCA 306A DDCB 306B DDCC 306C DDCD 306D DDCE 306E DDCF 306F DDD0 3070 DDD1 3071 DDD2 3072 DDD3 3073 DDD4 3074 DDD5 3075 DDD6 3076 DDD7 3077 DDD8 3078 DDD9 3079 DDDA 307A DDDB 307B DDDC 307C DDDD 307D DDDE 307E DDDF 307F DDE0 3080 DDE1 3081 DDE2 3082 DDE3 3083 DDE4 3084 DDE5 3085 DDE6 3086 DDE7 3087 DDE8 3088 DDE9 3089 DDEA 308A DDEB 308B DDEC 308C DDED 308D DDEE 308E DDEF 308F DDF0 3090 DDF1 3091 DDF2 3092 DDF3 3093 DE31 30A1 DE32 30A2 DE33 30A3 DE34 30A4 DE35 30A5 DE36 30A6 DE37 30A7 DE38 30A8 DE39 30A9 DE3A 30AA DE3B 30AB DE3C 30AC DE3D 30AD DE3E 30AE DE3F 30AF DE40 30B0 DE41 30B1 DE42 30B2 DE43 30B3 DE44 30B4 DE45 30B5 DE46 30B6 DE47 30B7 DE48 30B8 DE49 30B9 DE4A 30BA DE4B 30BB DE4C 30BC DE4D 30BD DE4E 30BE DE4F 30BF DE50 30C0 DE51 30C1 DE52 30C2 DE53 30C3 DE54 30C4 DE55 30C5 DE56 30C6 DE57 30C7 DE58 30C8 DE59 30C9 DE5A 30CA DE5B 30CB DE5C 30CC DE5D 30CD DE5E 30CE DE5F 30CF DE60 30D0 DE61 30D1 DE62 30D2 DE63 30D3 DE64 30D4 DE65 30D5 DE66 30D6 DE67 30D7 DE68 30D8 DE69 30D9 DE6A 30DA DE6B 30DB DE6C 30DC DE6D 30DD DE6E 30DE DE6F 30DF DE70 30E0 DE71 30E1 DE72 30E2 DE73 30E3 DE74 30E4 DE75 30E5 DE76 30E6 DE77 30E7 DE78 30E8 DE79 30E9 DE7A 30EA DE7B 30EB DE7C 30EC DE7D 30ED DE7E 30EE DE91 30EF DE92 30F0 DE93 30F1 DE94 30F2 DE95 30F3 DE96 30F4 DE97 30F5 DE98 30F6 DEA1 0410 DEA2 0411 DEA3 0412 DEA4 0413 DEA5 0414 DEA6 0415 DEA7 0401 DEA8 0416 DEA9 0417 DEAA 0418 DEAB 0419 DEAC 041A DEAD 041B DEAE 041C DEAF 041D DEB0 041E DEB1 041F DEB2 0420 DEB3 0421 DEB4 0422 DEB5 0423 DEB6 0424 DEB7 0425 DEB8 0426 DEB9 0427 DEBA 0428 DEBB 0429 DEBC 042A DEBD 042B DEBE 042C DEBF 042D DEC0 042E DEC1 042F DED1 0430 DED2 0431 DED3 0432 DED4 0433 DED5 0434 DED6 0435 DED7 0451 DED8 0436 DED9 0437 DEDA 0438 DEDB 0439 DEDC 043A DEDD 043B DEDE 043C DEDF 043D DEE0 043E DEE1 043F DEE2 0440 DEE3 0441 DEE4 0442 DEE5 0443 DEE6 0444 DEE7 0445 DEE8 0446 DEE9 0447 DEEA 0448 DEEB 0449 DEEC 044A DEED 044B DEEE 044C DEEF 044D DEF0 044E DEF1 044F E031 4F3D E032 4F73 E033 5047 E034 50F9 E035 52A0 E036 53EF E037 5475 E038 54E5 E039 5609 E03A 5AC1 E03B 5BB6 E03C 6687 E03D 67B6 E03E 67B7 E03F 67EF E040 6B4C E041 73C2 E042 75C2 E043 7A3C E044 82DB E045 8304 E046 8857 E047 8888 E048 8A36 E049 8CC8 E04A 8DCF E04B 8EFB E04C 8FE6 E04D 99D5 E04E 523B E04F 5374 E050 5404 E051 606A E052 6164 E053 6BBC E054 73CF E055 811A E056 89BA E057 89D2 E058 95A3 E059 4F83 E05A 520A E05B 58BE E05C 5978 E05D 59E6 E05E 5E72 E05F 5E79 E060 61C7 E061 63C0 E062 6746 E063 67EC E064 687F E065 6F97 E066 764E E067 770B E068 78F5 E069 7A08 E06A 7AFF E06B 7C21 E06C 809D E06D 826E E06E 8271 E06F 8AEB E070 9593 E071 4E6B E072 559D E073 66F7 E074 6E34 E075 78A3 E076 7AED E077 845B E078 8910 E079 874E E07A 97A8 E07B 52D8 E07C 574E E07D 582A E07E 5D4C E091 611F E092 61BE E093 6221 E094 6562 E095 67D1 E096 6A44 E097 6E1B E098 7518 E099 75B3 E09A 76E3 E09B 77B0 E09C 7D3A E09D 90AF E09E 9451 E09F 9452 E0A0 9F95 E0A1 5323 E0A2 5CAC E0A3 7532 E0A4 80DB E0A5 9240 E0A6 9598 E0A7 525B E0A8 5808 E0A9 59DC E0AA 5CA1 E0AB 5D17 E0AC 5EB7 E0AD 5F3A E0AE 5F4A E0AF 6177 E0B0 6C5F E0B1 757A E0B2 7586 E0B3 7CE0 E0B4 7D73 E0B5 7DB1 E0B6 7F8C E0B7 8154 E0B8 8221 E0B9 8591 E0BA 8941 E0BB 8B1B E0BC 92FC E0BD 964D E0BE 9C47 E0BF 4ECB E0C0 4EF7 E0C1 500B E0C2 51F1 E0C3 584F E0C4 6137 E0C5 613E E0C6 6168 E0C7 6539 E0C8 69EA E0C9 6F11 E0CA 75A5 E0CB 7686 E0CC 76D6 E0CD 7B87 E0CE 82A5 E0CF 84CB E0D0 F900 E0D1 93A7 E0D2 958B E0D3 5580 E0D4 5BA2 E0D5 5751 E0D6 F901 E0D7 7CB3 E0D8 7FB9 E0D9 91B5 E0DA 5028 E0DB 53BB E0DC 5C45 E0DD 5DE8 E0DE 62D2 E0DF 636E E0E0 64DA E0E1 64E7 E0E2 6E20 E0E3 70AC E0E4 795B E0E5 8DDD E0E6 8E1E E0E7 F902 E0E8 907D E0E9 9245 E0EA 92F8 E0EB 4E7E E0EC 4EF6 E0ED 5065 E0EE 5DFE E0EF 5EFA E0F0 6106 E0F1 6957 E0F2 8171 E0F3 8654 E0F4 8E47 E0F5 9375 E0F6 9A2B E0F7 4E5E E0F8 5091 E0F9 6770 E0FA 6840 E0FB 5109 E0FC 528D E0FD 5292 E0FE 6AA2 E131 77BC E132 9210 E133 9ED4 E134 52AB E135 602F E136 8FF2 E137 5048 E138 61A9 E139 63ED E13A 64CA E13B 683C E13C 6A84 E13D 6FC0 E13E 8188 E13F 89A1 E140 9694 E141 5805 E142 727D E143 72AC E144 7504 E145 7D79 E146 7E6D E147 80A9 E148 898B E149 8B74 E14A 9063 E14B 9D51 E14C 6289 E14D 6C7A E14E 6F54 E14F 7D50 E150 7F3A E151 8A23 E152 517C E153 614A E154 7B9D E155 8B19 E156 9257 E157 938C E158 4EAC E159 4FD3 E15A 501E E15B 50BE E15C 5106 E15D 52C1 E15E 52CD E15F 537F E160 5770 E161 5883 E162 5E9A E163 5F91 E164 6176 E165 61AC E166 64CE E167 656C E168 666F E169 66BB E16A 66F4 E16B 6897 E16C 6D87 E16D 7085 E16E 70F1 E16F 749F E170 74A5 E171 74CA E172 75D9 E173 786C E174 78EC E175 7ADF E176 7AF6 E177 7D45 E178 7D93 E179 8015 E17A 803F E17B 811B E17C 8396 E17D 8B66 E17E 8F15 E191 9015 E192 93E1 E193 9803 E194 9838 E195 9A5A E196 9BE8 E197 4FC2 E198 5553 E199 583A E19A 5951 E19B 5B63 E19C 5C46 E19D 60B8 E19E 6212 E19F 6842 E1A0 68B0 E1A1 68E8 E1A2 6EAA E1A3 754C E1A4 7678 E1A5 78CE E1A6 7A3D E1A7 7CFB E1A8 7E6B E1A9 7E7C E1AA 8A08 E1AB 8AA1 E1AC 8C3F E1AD 968E E1AE 9DC4 E1AF 53E4 E1B0 53E9 E1B1 544A E1B2 5471 E1B3 56FA E1B4 59D1 E1B5 5B64 E1B6 5C3B E1B7 5EAB E1B8 62F7 E1B9 6537 E1BA 6545 E1BB 6572 E1BC 66A0 E1BD 67AF E1BE 69C1 E1BF 6CBD E1C0 75FC E1C1 7690 E1C2 777E E1C3 7A3F E1C4 7F94 E1C5 8003 E1C6 80A1 E1C7 818F E1C8 82E6 E1C9 82FD E1CA 83F0 E1CB 85C1 E1CC 8831 E1CD 88B4 E1CE 8AA5 E1CF F903 E1D0 8F9C E1D1 932E E1D2 96C7 E1D3 9867 E1D4 9AD8 E1D5 9F13 E1D6 54ED E1D7 659B E1D8 66F2 E1D9 688F E1DA 7A40 E1DB 8C37 E1DC 9D60 E1DD 56F0 E1DE 5764 E1DF 5D11 E1E0 6606 E1E1 68B1 E1E2 68CD E1E3 6EFE E1E4 7428 E1E5 889E E1E6 9BE4 E1E7 6C68 E1E8 F904 E1E9 9AA8 E1EA 4F9B E1EB 516C E1EC 5171 E1ED 529F E1EE 5B54 E1EF 5DE5 E1F0 6050 E1F1 606D E1F2 62F1 E1F3 63A7 E1F4 653B E1F5 73D9 E1F6 7A7A E1F7 86A3 E1F8 8CA2 E1F9 978F E1FA 4E32 E1FB 5BE1 E1FC 6208 E1FD 679C E1FE 74DC E231 79D1 E232 83D3 E233 8A87 E234 8AB2 E235 8DE8 E236 904E E237 934B E238 9846 E239 5ED3 E23A 69E8 E23B 85FF E23C 90ED E23D F905 E23E 51A0 E23F 5B98 E240 5BEC E241 6163 E242 68FA E243 6B3E E244 704C E245 742F E246 74D8 E247 7BA1 E248 7F50 E249 83C5 E24A 89C0 E24B 8CAB E24C 95DC E24D 9928 E24E 522E E24F 605D E250 62EC E251 9002 E252 4F8A E253 5149 E254 5321 E255 58D9 E256 5EE3 E257 66E0 E258 6D38 E259 709A E25A 72C2 E25B 73D6 E25C 7B50 E25D 80F1 E25E 945B E25F 5366 E260 639B E261 7F6B E262 4E56 E263 5080 E264 584A E265 58DE E266 602A E267 6127 E268 62D0 E269 69D0 E26A 9B41 E26B 5B8F E26C 7D18 E26D 80B1 E26E 8F5F E26F 4EA4 E270 50D1 E271 54AC E272 55AC E273 5B0C E274 5DA0 E275 5DE7 E276 652A E277 654E E278 6821 E279 6A4B E27A 72E1 E27B 768E E27C 77EF E27D 7D5E E27E 7FF9 E291 81A0 E292 854E E293 86DF E294 8F03 E295 8F4E E296 90CA E297 9903 E298 9A55 E299 9BAB E29A 4E18 E29B 4E45 E29C 4E5D E29D 4EC7 E29E 4FF1 E29F 5177 E2A0 52FE E2A1 5340 E2A2 53E3 E2A3 53E5 E2A4 548E E2A5 5614 E2A6 5775 E2A7 57A2 E2A8 5BC7 E2A9 5D87 E2AA 5ED0 E2AB 61FC E2AC 62D8 E2AD 6551 E2AE 67B8 E2AF 67E9 E2B0 69CB E2B1 6B50 E2B2 6BC6 E2B3 6BEC E2B4 6C42 E2B5 6E9D E2B6 7078 E2B7 72D7 E2B8 7396 E2B9 7403 E2BA 77BF E2BB 77E9 E2BC 7A76 E2BD 7D7F E2BE 8009 E2BF 81FC E2C0 8205 E2C1 820A E2C2 82DF E2C3 8862 E2C4 8B33 E2C5 8CFC E2C6 8EC0 E2C7 9011 E2C8 90B1 E2C9 9264 E2CA 92B6 E2CB 99D2 E2CC 9A45 E2CD 9CE9 E2CE 9DD7 E2CF 9F9C E2D0 570B E2D1 5C40 E2D2 83CA E2D3 97A0 E2D4 97AB E2D5 9EB4 E2D6 541B E2D7 7A98 E2D8 7FA4 E2D9 88D9 E2DA 8ECD E2DB 90E1 E2DC 5800 E2DD 5C48 E2DE 6398 E2DF 7A9F E2E0 5BAE E2E1 5F13 E2E2 7A79 E2E3 7AAE E2E4 828E E2E5 8EAC E2E6 5026 E2E7 5238 E2E8 52F8 E2E9 5377 E2EA 5708 E2EB 62F3 E2EC 6372 E2ED 6B0A E2EE 6DC3 E2EF 7737 E2F0 53A5 E2F1 7357 E2F2 8568 E2F3 8E76 E2F4 95D5 E2F5 673A E2F6 6AC3 E2F7 6F70 E2F8 8A6D E2F9 8ECC E2FA 994B E2FB F906 E2FC 6677 E2FD 6B78 E2FE 8CB4 E331 9B3C E332 F907 E333 53EB E334 572D E335 594E E336 63C6 E337 69FB E338 73EA E339 7845 E33A 7ABA E33B 7AC5 E33C 7CFE E33D 8475 E33E 898F E33F 8D73 E340 9035 E341 95A8 E342 52FB E343 5747 E344 7547 E345 7B60 E346 83CC E347 921E E348 F908 E349 6A58 E34A 514B E34B 524B E34C 5287 E34D 621F E34E 68D8 E34F 6975 E350 9699 E351 50C5 E352 52A4 E353 52E4 E354 61C3 E355 65A4 E356 6839 E357 69FF E358 747E E359 7B4B E35A 82B9 E35B 83EB E35C 89B2 E35D 8B39 E35E 8FD1 E35F 9949 E360 F909 E361 4ECA E362 5997 E363 64D2 E364 6611 E365 6A8E E366 7434 E367 7981 E368 79BD E369 82A9 E36A 887E E36B 887F E36C 895F E36D F90A E36E 9326 E36F 4F0B E370 53CA E371 6025 E372 6271 E373 6C72 E374 7D1A E375 7D66 E376 4E98 E377 5162 E378 77DC E379 80AF E37A 4F01 E37B 4F0E E37C 5176 E37D 5180 E37E 55DC E391 5668 E392 573B E393 57FA E394 57FC E395 5914 E396 5947 E397 5993 E398 5BC4 E399 5C90 E39A 5D0E E39B 5DF1 E39C 5E7E E39D 5FCC E39E 6280 E39F 65D7 E3A0 65E3 E3A1 671E E3A2 671F E3A3 675E E3A4 68CB E3A5 68C4 E3A6 6A5F E3A7 6B3A E3A8 6C23 E3A9 6C7D E3AA 6C82 E3AB 6DC7 E3AC 7398 E3AD 7426 E3AE 742A E3AF 7482 E3B0 74A3 E3B1 7578 E3B2 757F E3B3 7881 E3B4 78EF E3B5 7941 E3B6 7947 E3B7 7948 E3B8 797A E3B9 7B95 E3BA 7D00 E3BB 7DBA E3BC 7F88 E3BD 8006 E3BE 802D E3BF 808C E3C0 8A18 E3C1 8B4F E3C2 8C48 E3C3 8D77 E3C4 9321 E3C5 9324 E3C6 98E2 E3C7 9951 E3C8 9A0E E3C9 9A0F E3CA 9A65 E3CB 9E92 E3CC 7DCA E3CD 4F76 E3CE 5409 E3CF 62EE E3D0 6854 E3D1 91D1 E3D2 55AB E3D3 513A E3D4 F90B E3D5 F90C E3D6 5A1C E3D7 61E6 E3D8 F90D E3D9 62CF E3DA 62FF E3DB F90E E3DC F90F E3DD F910 E3DE F911 E3DF F912 E3E0 F913 E3E1 90A3 E3E2 F914 E3E3 F915 E3E4 F916 E3E5 F917 E3E6 F918 E3E7 8AFE E3E8 F919 E3E9 F91A E3EA F91B E3EB F91C E3EC 6696 E3ED F91D E3EE 7156 E3EF F91E E3F0 F91F E3F1 96E3 E3F2 F920 E3F3 634F E3F4 637A E3F5 5357 E3F6 F921 E3F7 678F E3F8 6960 E3F9 6E73 E3FA F922 E3FB 7537 E3FC F923 E3FD F924 E3FE F925 E431 7D0D E432 F926 E433 F927 E434 8872 E435 56CA E436 5A18 E437 F928 E438 F929 E439 F92A E43A F92B E43B F92C E43C 4E43 E43D F92D E43E 5167 E43F 5948 E440 67F0 E441 8010 E442 F92E E443 5973 E444 5E74 E445 649A E446 79CA E447 5FF5 E448 606C E449 62C8 E44A 637B E44B 5BE7 E44C 5BD7 E44D 52AA E44E F92F E44F 5974 E450 5F29 E451 6012 E452 F930 E453 F931 E454 F932 E455 7459 E456 F933 E457 F934 E458 F935 E459 F936 E45A F937 E45B F938 E45C 99D1 E45D F939 E45E F93A E45F F93B E460 F93C E461 F93D E462 F93E E463 F93F E464 F940 E465 F941 E466 F942 E467 F943 E468 6FC3 E469 F944 E46A F945 E46B 81BF E46C 8FB2 E46D 60F1 E46E F946 E46F F947 E470 8166 E471 F948 E472 F949 E473 5C3F E474 F94A E475 F94B E476 F94C E477 F94D E478 F94E E479 F94F E47A F950 E47B F951 E47C 5AE9 E47D 8A25 E47E 677B E491 7D10 E492 F952 E493 F953 E494 F954 E495 F955 E496 F956 E497 F957 E498 80FD E499 F958 E49A F959 E49B 5C3C E49C 6CE5 E49D 533F E49E 6EBA E49F 591A E4A0 8336 E4A1 4E39 E4A2 4EB6 E4A3 4F46 E4A4 55AE E4A5 5718 E4A6 58C7 E4A7 5F56 E4A8 65B7 E4A9 65E6 E4AA 6A80 E4AB 6BB5 E4AC 6E4D E4AD 77ED E4AE 7AEF E4AF 7C1E E4B0 7DDE E4B1 86CB E4B2 8892 E4B3 9132 E4B4 935B E4B5 64BB E4B6 6FBE E4B7 737A E4B8 75B8 E4B9 9054 E4BA 5556 E4BB 574D E4BC 61BA E4BD 64D4 E4BE 66C7 E4BF 6DE1 E4C0 6E5B E4C1 6F6D E4C2 6FB9 E4C3 75F0 E4C4 8043 E4C5 81BD E4C6 8541 E4C7 8983 E4C8 8AC7 E4C9 8B5A E4CA 931F E4CB 6C93 E4CC 7553 E4CD 7B54 E4CE 8E0F E4CF 905D E4D0 5510 E4D1 5802 E4D2 5858 E4D3 5E62 E4D4 6207 E4D5 649E E4D6 68E0 E4D7 7576 E4D8 7CD6 E4D9 87B3 E4DA 9EE8 E4DB 4EE3 E4DC 5788 E4DD 576E E4DE 5927 E4DF 5C0D E4E0 5CB1 E4E1 5E36 E4E2 5F85 E4E3 6234 E4E4 64E1 E4E5 73B3 E4E6 81FA E4E7 888B E4E8 8CB8 E4E9 968A E4EA 9EDB E4EB 5B85 E4EC 5FB7 E4ED 60B3 E4EE 5012 E4EF 5200 E4F0 5230 E4F1 5716 E4F2 5835 E4F3 5857 E4F4 5C0E E4F5 5C60 E4F6 5CF6 E4F7 5D8B E4F8 5EA6 E4F9 5F92 E4FA 60BC E4FB 6311 E4FC 6389 E4FD 6417 E4FE 6843 E531 68F9 E532 6AC2 E533 6DD8 E534 6E21 E535 6ED4 E536 6FE4 E537 71FE E538 76DC E539 7779 E53A 79B1 E53B 7A3B E53C 8404 E53D 89A9 E53E 8CED E53F 8DF3 E540 8E48 E541 9003 E542 9014 E543 9053 E544 90FD E545 934D E546 9676 E547 97DC E548 6BD2 E549 7006 E54A 7258 E54B 72A2 E54C 7368 E54D 7763 E54E 79BF E54F 7BE4 E550 7E9B E551 8B80 E552 58A9 E553 60C7 E554 6566 E555 65FD E556 66BE E557 6C8C E558 711E E559 71C9 E55A 8C5A E55B 9813 E55C 4E6D E55D 7A81 E55E 4EDD E55F 51AC E560 51CD E561 52D5 E562 540C E563 61A7 E564 6771 E565 6850 E566 68DF E567 6D1E E568 6F7C E569 75BC E56A 77B3 E56B 7AE5 E56C 80F4 E56D 8463 E56E 9285 E56F 515C E570 6597 E571 675C E572 6793 E573 75D8 E574 7AC7 E575 8373 E576 F95A E577 8C46 E578 9017 E579 982D E57A 5C6F E57B 81C0 E57C 829A E57D 9041 E57E 906F E591 920D E592 5F97 E593 5D9D E594 6A59 E595 71C8 E596 767B E597 7B49 E598 85E4 E599 8B04 E59A 9127 E59B 9A30 E59C 5587 E59D 61F6 E59E F95B E59F 7669 E5A0 7F85 E5A1 863F E5A2 87BA E5A3 88F8 E5A4 908F E5A5 F95C E5A6 6D1B E5A7 70D9 E5A8 73DE E5A9 7D61 E5AA 843D E5AB F95D E5AC 916A E5AD 99F1 E5AE F95E E5AF 4E82 E5B0 5375 E5B1 6B04 E5B2 6B12 E5B3 703E E5B4 721B E5B5 862D E5B6 9E1E E5B7 524C E5B8 8FA3 E5B9 5D50 E5BA 64E5 E5BB 652C E5BC 6B16 E5BD 6FEB E5BE 7C43 E5BF 7E9C E5C0 85CD E5C1 8964 E5C2 89BD E5C3 62C9 E5C4 81D8 E5C5 881F E5C6 5ECA E5C7 6717 E5C8 6D6A E5C9 72FC E5CA 7405 E5CB 746F E5CC 8782 E5CD 90DE E5CE 4F86 E5CF 5D0D E5D0 5FA0 E5D1 840A E5D2 51B7 E5D3 63A0 E5D4 7565 E5D5 4EAE E5D6 5006 E5D7 5169 E5D8 51C9 E5D9 6881 E5DA 6A11 E5DB 7CAE E5DC 7CB1 E5DD 7CE7 E5DE 826F E5DF 8AD2 E5E0 8F1B E5E1 91CF E5E2 4FB6 E5E3 5137 E5E4 52F5 E5E5 5442 E5E6 5EEC E5E7 616E E5E8 623E E5E9 65C5 E5EA 6ADA E5EB 6FFE E5EC 792A E5ED 85DC E5EE 8823 E5EF 95AD E5F0 9A62 E5F1 9A6A E5F2 9E97 E5F3 9ECE E5F4 529B E5F5 66C6 E5F6 6B77 E5F7 701D E5F8 792B E5F9 8F62 E5FA 9742 E5FB 6190 E5FC 6200 E5FD 6523 E5FE 6F23 E631 7149 E632 7489 E633 7DF4 E634 806F E635 84EE E636 8F26 E637 9023 E638 934A E639 51BD E63A 5217 E63B 52A3 E63C 6D0C E63D 70C8 E63E 88C2 E63F 5EC9 E640 6582 E641 6BAE E642 6FC2 E643 7C3E E644 7375 E645 4EE4 E646 4F36 E647 56F9 E648 F95F E649 5CBA E64A 5DBA E64B 601C E64C 73B2 E64D 7B2D E64E 7F9A E64F 7FCE E650 8046 E651 901E E652 9234 E653 96F6 E654 9748 E655 9818 E656 9F61 E657 4F8B E658 6FA7 E659 79AE E65A 91B4 E65B 96B7 E65C 52DE E65D F960 E65E 6488 E65F 64C4 E660 6AD3 E661 6F5E E662 7018 E663 7210 E664 76E7 E665 8001 E666 8606 E667 865C E668 8DEF E669 8F05 E66A 9732 E66B 9B6F E66C 9DFA E66D 9E75 E66E 788C E66F 797F E670 7DA0 E671 83C9 E672 9304 E673 9E7F E674 9E93 E675 8AD6 E676 58DF E677 5F04 E678 6727 E679 7027 E67A 74CF E67B 7C60 E67C 807E E67D 5121 E67E 7028 E691 7262 E692 78CA E693 8CC2 E694 8CDA E695 8CF4 E696 96F7 E697 4E86 E698 50DA E699 5BEE E69A 5ED6 E69B 6599 E69C 71CE E69D 7642 E69E 77AD E69F 804A E6A0 84FC E6A1 907C E6A2 9B27 E6A3 9F8D E6A4 58D8 E6A5 5A41 E6A6 5C62 E6A7 6A13 E6A8 6DDA E6A9 6F0F E6AA 763B E6AB 7D2F E6AC 7E37 E6AD 851E E6AE 8938 E6AF 93E4 E6B0 964B E6B1 5289 E6B2 65D2 E6B3 67F3 E6B4 69B4 E6B5 6D41 E6B6 6E9C E6B7 700F E6B8 7409 E6B9 7460 E6BA 7559 E6BB 7624 E6BC 786B E6BD 8B2C E6BE 985E E6BF 516D E6C0 622E E6C1 9678 E6C2 4F96 E6C3 502B E6C4 5D19 E6C5 6DEA E6C6 7DB8 E6C7 8F2A E6C8 5F8B E6C9 6144 E6CA 6817 E6CB F961 E6CC 9686 E6CD 52D2 E6CE 808B E6CF 51DC E6D0 51CC E6D1 695E E6D2 7A1C E6D3 7DBE E6D4 83F1 E6D5 9675 E6D6 4FDA E6D7 5229 E6D8 5398 E6D9 540F E6DA 550E E6DB 5C65 E6DC 60A7 E6DD 674E E6DE 68A8 E6DF 6D6C E6E0 7281 E6E1 72F8 E6E2 7406 E6E3 7483 E6E4 F962 E6E5 75E2 E6E6 7C6C E6E7 7F79 E6E8 7FB8 E6E9 8389 E6EA 88CF E6EB 88E1 E6EC 91CC E6ED 91D0 E6EE 96E2 E6EF 9BC9 E6F0 541D E6F1 6F7E E6F2 71D0 E6F3 7498 E6F4 85FA E6F5 8EAA E6F6 96A3 E6F7 9C57 E6F8 9E9F E6F9 6797 E6FA 6DCB E6FB 7433 E6FC 81E8 E6FD 9716 E6FE 782C E731 7ACB E732 7B20 E733 7C92 E734 6469 E735 746A E736 75F2 E737 78BC E738 78E8 E739 99AC E73A 9B54 E73B 9EBB E73C 5BDE E73D 5E55 E73E 6F20 E73F 819C E740 83AB E741 9088 E742 4E07 E743 534D E744 5A29 E745 5DD2 E746 5F4E E747 6162 E748 633D E749 6669 E74A 66FC E74B 6EFF E74C 6F2B E74D 7063 E74E 779E E74F 842C E750 8513 E751 883B E752 8F13 E753 9945 E754 9C3B E755 551C E756 62B9 E757 672B E758 6CAB E759 8309 E75A 896A E75B 977A E75C 4EA1 E75D 5984 E75E 5FD8 E75F 5FD9 E760 671B E761 7DB2 E762 7F54 E763 8292 E764 832B E765 83BD E766 8F1E E767 9099 E768 57CB E769 59B9 E76A 5A92 E76B 5BD0 E76C 6627 E76D 679A E76E 6885 E76F 6BCF E770 7164 E771 7F75 E772 8CB7 E773 8CE3 E774 9081 E775 9B45 E776 8108 E777 8C8A E778 964C E779 9A40 E77A 9EA5 E77B 5B5F E77C 6C13 E77D 731B E77E 76F2 E791 76DF E792 840C E793 51AA E794 8993 E795 514D E796 5195 E797 52C9 E798 68C9 E799 6C94 E79A 7704 E79B 7720 E79C 7DBF E79D 7DEC E79E 9762 E79F 9EB5 E7A0 6EC5 E7A1 8511 E7A2 51A5 E7A3 540D E7A4 547D E7A5 660E E7A6 669D E7A7 6927 E7A8 6E9F E7A9 76BF E7AA 7791 E7AB 8317 E7AC 84C2 E7AD 879F E7AE 9169 E7AF 9298 E7B0 9CF4 E7B1 8882 E7B2 4FAE E7B3 5192 E7B4 52DF E7B5 59C6 E7B6 5E3D E7B7 6155 E7B8 6478 E7B9 6479 E7BA 66AE E7BB 67D0 E7BC 6A21 E7BD 6BCD E7BE 6BDB E7BF 725F E7C0 7261 E7C1 7441 E7C2 7738 E7C3 77DB E7C4 8017 E7C5 82BC E7C6 8305 E7C7 8B00 E7C8 8B28 E7C9 8C8C E7CA 6728 E7CB 6C90 E7CC 7267 E7CD 76EE E7CE 7766 E7CF 7A46 E7D0 9DA9 E7D1 6B7F E7D2 6C92 E7D3 5922 E7D4 6726 E7D5 8499 E7D6 536F E7D7 5893 E7D8 5999 E7D9 5EDF E7DA 63CF E7DB 6634 E7DC 6773 E7DD 6E3A E7DE 732B E7DF 7AD7 E7E0 82D7 E7E1 9328 E7E2 52D9 E7E3 5DEB E7E4 61AE E7E5 61CB E7E6 620A E7E7 62C7 E7E8 64AB E7E9 65E0 E7EA 6959 E7EB 6B66 E7EC 6BCB E7ED 7121 E7EE 73F7 E7EF 755D E7F0 7E46 E7F1 821E E7F2 8302 E7F3 856A E7F4 8AA3 E7F5 8CBF E7F6 9727 E7F7 9D61 E7F8 58A8 E7F9 9ED8 E7FA 5011 E7FB 520E E7FC 543B E7FD 554F E7FE 6587 E831 6C76 E832 7D0A E833 7D0B E834 805E E835 868A E836 9580 E837 96EF E838 52FF E839 6C95 E83A 7269 E83B 5473 E83C 5A9A E83D 5C3E E83E 5D4B E83F 5F4C E840 5FAE E841 672A E842 68B6 E843 6963 E844 6E3C E845 6E44 E846 7709 E847 7C73 E848 7F8E E849 8587 E84A 8B0E E84B 8FF7 E84C 9761 E84D 9EF4 E84E 5CB7 E84F 60B6 E850 610D E851 61AB E852 654F E853 65FB E854 65FC E855 6C11 E856 6CEF E857 739F E858 73C9 E859 7DE1 E85A 9594 E85B 5BC6 E85C 871C E85D 8B10 E85E 525D E85F 535A E860 62CD E861 640F E862 64B2 E863 6734 E864 6A38 E865 6CCA E866 73C0 E867 749E E868 7B94 E869 7C95 E86A 7E1B E86B 818A E86C 8236 E86D 8584 E86E 8FEB E86F 96F9 E870 99C1 E871 4F34 E872 534A E873 53CD E874 53DB E875 62CC E876 642C E877 6500 E878 6591 E879 69C3 E87A 6CEE E87B 6F58 E87C 73ED E87D 7554 E87E 7622 E891 76E4 E892 76FC E893 78D0 E894 78FB E895 792C E896 7D46 E897 822C E898 87E0 E899 8FD4 E89A 9812 E89B 98EF E89C 52C3 E89D 62D4 E89E 64A5 E89F 6E24 E8A0 6F51 E8A1 767C E8A2 8DCB E8A3 91B1 E8A4 9262 E8A5 9AEE E8A6 9B43 E8A7 5023 E8A8 508D E8A9 574A E8AA 59A8 E8AB 5C28 E8AC 5E47 E8AD 5F77 E8AE 623F E8AF 653E E8B0 65B9 E8B1 65C1 E8B2 6609 E8B3 678B E8B4 699C E8B5 6EC2 E8B6 78C5 E8B7 7D21 E8B8 80AA E8B9 8180 E8BA 822B E8BB 82B3 E8BC 84A1 E8BD 868C E8BE 8A2A E8BF 8B17 E8C0 90A6 E8C1 9632 E8C2 9F90 E8C3 500D E8C4 4FF3 E8C5 F963 E8C6 57F9 E8C7 5F98 E8C8 62DC E8C9 6392 E8CA 676F E8CB 6E43 E8CC 7119 E8CD 76C3 E8CE 80CC E8CF 80DA E8D0 88F4 E8D1 88F5 E8D2 8919 E8D3 8CE0 E8D4 8F29 E8D5 914D E8D6 966A E8D7 4F2F E8D8 4F70 E8D9 5E1B E8DA 67CF E8DB 6822 E8DC 767D E8DD 767E E8DE 9B44 E8DF 5E61 E8E0 6A0A E8E1 7169 E8E2 71D4 E8E3 756A E8E4 F964 E8E5 7E41 E8E6 8543 E8E7 85E9 E8E8 98DC E8E9 4F10 E8EA 7B4F E8EB 7F70 E8EC 95A5 E8ED 51E1 E8EE 5E06 E8EF 68B5 E8F0 6C3E E8F1 6C4E E8F2 6CDB E8F3 72AF E8F4 7BC4 E8F5 8303 E8F6 6CD5 E8F7 743A E8F8 50FB E8F9 5288 E8FA 58C1 E8FB 64D8 E8FC 6A97 E8FD 74A7 E8FE 7656 E931 78A7 E932 8617 E933 95E2 E934 9739 E935 F965 E936 535E E937 5F01 E938 8B8A E939 8FA8 E93A 8FAF E93B 908A E93C 5225 E93D 77A5 E93E 9C49 E93F 9F08 E940 4E19 E941 5002 E942 5175 E943 5C5B E944 5E77 E945 661E E946 663A E947 67C4 E948 68C5 E949 70B3 E94A 7501 E94B 75C5 E94C 79C9 E94D 7ADD E94E 8F27 E94F 9920 E950 9A08 E951 4FDD E952 5821 E953 5831 E954 5BF6 E955 666E E956 6B65 E957 6D11 E958 6E7A E959 6F7D E95A 73E4 E95B 752B E95C 83E9 E95D 88DC E95E 8913 E95F 8B5C E960 8F14 E961 4F0F E962 50D5 E963 5310 E964 535C E965 5B93 E966 5FA9 E967 670D E968 798F E969 8179 E96A 832F E96B 8514 E96C 8907 E96D 8986 E96E 8F39 E96F 8F3B E970 99A5 E971 9C12 E972 672C E973 4E76 E974 4FF8 E975 5949 E976 5C01 E977 5CEF E978 5CF0 E979 6367 E97A 68D2 E97B 70FD E97C 71A2 E97D 742B E97E 7E2B E991 84EC E992 8702 E993 9022 E994 92D2 E995 9CF3 E996 4E0D E997 4ED8 E998 4FEF E999 5085 E99A 5256 E99B 526F E99C 5426 E99D 5490 E99E 57E0 E99F 592B E9A0 5A66 E9A1 5B5A E9A2 5B75 E9A3 5BCC E9A4 5E9C E9A5 F966 E9A6 6276 E9A7 6577 E9A8 65A7 E9A9 6D6E E9AA 6EA5 E9AB 7236 E9AC 7B26 E9AD 7C3F E9AE 7F36 E9AF 8150 E9B0 8151 E9B1 819A E9B2 8240 E9B3 8299 E9B4 83A9 E9B5 8A03 E9B6 8CA0 E9B7 8CE6 E9B8 8CFB E9B9 8D74 E9BA 8DBA E9BB 90E8 E9BC 91DC E9BD 961C E9BE 9644 E9BF 99D9 E9C0 9CE7 E9C1 5317 E9C2 5206 E9C3 5429 E9C4 5674 E9C5 58B3 E9C6 5954 E9C7 596E E9C8 5FFF E9C9 61A4 E9CA 626E E9CB 6610 E9CC 6C7E E9CD 711A E9CE 76C6 E9CF 7C89 E9D0 7CDE E9D1 7D1B E9D2 82AC E9D3 8CC1 E9D4 96F0 E9D5 F967 E9D6 4F5B E9D7 5F17 E9D8 5F7F E9D9 62C2 E9DA 5D29 E9DB 670B E9DC 68DA E9DD 787C E9DE 7E43 E9DF 9D6C E9E0 4E15 E9E1 5099 E9E2 5315 E9E3 532A E9E4 5351 E9E5 5983 E9E6 5A62 E9E7 5E87 E9E8 60B2 E9E9 618A E9EA 6249 E9EB 6279 E9EC 6590 E9ED 6787 E9EE 69A7 E9EF 6BD4 E9F0 6BD6 E9F1 6BD7 E9F2 6BD8 E9F3 6CB8 E9F4 F968 E9F5 7435 E9F6 75FA E9F7 7812 E9F8 7891 E9F9 79D5 E9FA 79D8 E9FB 7C83 E9FC 7DCB E9FD 7FE1 E9FE 80A5 EA31 813E EA32 81C2 EA33 83F2 EA34 871A EA35 88E8 EA36 8AB9 EA37 8B6C EA38 8CBB EA39 9119 EA3A 975E EA3B 98DB EA3C 9F3B EA3D 56AC EA3E 5B2A EA3F 5F6C EA40 658C EA41 6AB3 EA42 6BAF EA43 6D5C EA44 6FF1 EA45 7015 EA46 725D EA47 73AD EA48 8CA7 EA49 8CD3 EA4A 983B EA4B 6191 EA4C 6C37 EA4D 8058 EA4E 9A01 EA4F 4E4D EA50 4E8B EA51 4E9B EA52 4ED5 EA53 4F3A EA54 4F3C EA55 4F7F EA56 4FDF EA57 50FF EA58 53F2 EA59 53F8 EA5A 5506 EA5B 55E3 EA5C 56DB EA5D 58EB EA5E 5962 EA5F 5A11 EA60 5BEB EA61 5BFA EA62 5C04 EA63 5DF3 EA64 5E2B EA65 5F99 EA66 601D EA67 6368 EA68 659C EA69 65AF EA6A 67F6 EA6B 67FB EA6C 68AD EA6D 6B7B EA6E 6C99 EA6F 6CD7 EA70 6E23 EA71 7009 EA72 7345 EA73 7802 EA74 793E EA75 7940 EA76 7960 EA77 79C1 EA78 7BE9 EA79 7D17 EA7A 7D72 EA7B 8086 EA7C 820D EA7D 838E EA7E 84D1 EA91 86C7 EA92 88DF EA93 8A50 EA94 8A5E EA95 8B1D EA96 8CDC EA97 8D66 EA98 8FAD EA99 90AA EA9A 98FC EA9B 99DF EA9C 9E9D EA9D 524A EA9E F969 EA9F 6714 EAA0 F96A EAA1 5098 EAA2 522A EAA3 5C71 EAA4 6563 EAA5 6C55 EAA6 73CA EAA7 7523 EAA8 759D EAA9 7B97 EAAA 849C EAAB 9178 EAAC 9730 EAAD 4E77 EAAE 6492 EAAF 6BBA EAB0 715E EAB1 85A9 EAB2 4E09 EAB3 F96B EAB4 6749 EAB5 68EE EAB6 6E17 EAB7 829F EAB8 8518 EAB9 886B EABA 63F7 EABB 6F81 EABC 9212 EABD 98AF EABE 4E0A EABF 50B7 EAC0 50CF EAC1 511F EAC2 5546 EAC3 55AA EAC4 5617 EAC5 5B40 EAC6 5C19 EAC7 5CE0 EAC8 5E38 EAC9 5E8A EACA 5EA0 EACB 5EC2 EACC 60F3 EACD 6851 EACE 6A61 EACF 6E58 EAD0 723D EAD1 7240 EAD2 72C0 EAD3 76F8 EAD4 7965 EAD5 7BB1 EAD6 7FD4 EAD7 88F3 EAD8 89F4 EAD9 8A73 EADA 8C61 EADB 8CDE EADC 971C EADD 585E EADE 74BD EADF 8CFD EAE0 55C7 EAE1 F96C EAE2 7A61 EAE3 7D22 EAE4 8272 EAE5 7272 EAE6 751F EAE7 7525 EAE8 F96D EAE9 7B19 EAEA 5885 EAEB 58FB EAEC 5DBC EAED 5E8F EAEE 5EB6 EAEF 5F90 EAF0 6055 EAF1 6292 EAF2 637F EAF3 654D EAF4 6691 EAF5 66D9 EAF6 66F8 EAF7 6816 EAF8 68F2 EAF9 7280 EAFA 745E EAFB 7B6E EAFC 7D6E EAFD 7DD6 EAFE 7F72 EB31 80E5 EB32 8212 EB33 85AF EB34 897F EB35 8A93 EB36 901D EB37 92E4 EB38 9ECD EB39 9F20 EB3A 5915 EB3B 596D EB3C 5E2D EB3D 60DC EB3E 6614 EB3F 6673 EB40 6790 EB41 6C50 EB42 6DC5 EB43 6F5F EB44 77F3 EB45 78A9 EB46 84C6 EB47 91CB EB48 932B EB49 4ED9 EB4A 50CA EB4B 5148 EB4C 5584 EB4D 5B0B EB4E 5BA3 EB4F 6247 EB50 657E EB51 65CB EB52 6E32 EB53 717D EB54 7401 EB55 7444 EB56 7487 EB57 74BF EB58 766C EB59 79AA EB5A 7DDA EB5B 7E55 EB5C 7FA8 EB5D 817A EB5E 81B3 EB5F 8239 EB60 861A EB61 87EC EB62 8A75 EB63 8DE3 EB64 9078 EB65 9291 EB66 9425 EB67 994D EB68 9BAE EB69 5368 EB6A 5C51 EB6B 6954 EB6C 6CC4 EB6D 6D29 EB6E 6E2B EB6F 820C EB70 859B EB71 893B EB72 8A2D EB73 8AAA EB74 96EA EB75 9F67 EB76 5261 EB77 66B9 EB78 6BB2 EB79 7E96 EB7A 87FE EB7B 8D0D EB7C 9583 EB7D 965D EB7E 651D EB91 6D89 EB92 71EE EB93 F96E EB94 57CE EB95 59D3 EB96 5BAC EB97 6027 EB98 60FA EB99 6210 EB9A 661F EB9B 665F EB9C 7329 EB9D 73F9 EB9E 76DB EB9F 7701 EBA0 7B6C EBA1 8056 EBA2 8072 EBA3 8165 EBA4 8AA0 EBA5 9192 EBA6 4E16 EBA7 52E2 EBA8 6B72 EBA9 6D17 EBAA 7A05 EBAB 7B39 EBAC 7D30 EBAD F96F EBAE 8CB0 EBAF 53EC EBB0 562F EBB1 5851 EBB2 5BB5 EBB3 5C0F EBB4 5C11 EBB5 5DE2 EBB6 6240 EBB7 6383 EBB8 6414 EBB9 662D EBBA 68B3 EBBB 6CBC EBBC 6D88 EBBD 6EAF EBBE 701F EBBF 70A4 EBC0 71D2 EBC1 7526 EBC2 758F EBC3 758E EBC4 7619 EBC5 7B11 EBC6 7BE0 EBC7 7C2B EBC8 7D20 EBC9 7D39 EBCA 852C EBCB 856D EBCC 8607 EBCD 8A34 EBCE 900D EBCF 9061 EBD0 90B5 EBD1 92B7 EBD2 97F6 EBD3 9A37 EBD4 4FD7 EBD5 5C6C EBD6 675F EBD7 6D91 EBD8 7C9F EBD9 7E8C EBDA 8B16 EBDB 8D16 EBDC 901F EBDD 5B6B EBDE 5DFD EBDF 640D EBE0 84C0 EBE1 905C EBE2 98E1 EBE3 7387 EBE4 5B8B EBE5 609A EBE6 677E EBE7 6DDE EBE8 8A1F EBE9 8AA6 EBEA 9001 EBEB 980C EBEC 5237 EBED F970 EBEE 7051 EBEF 788E EBF0 9396 EBF1 8870 EBF2 91D7 EBF3 4FEE EBF4 53D7 EBF5 55FD EBF6 56DA EBF7 5782 EBF8 58FD EBF9 5AC2 EBFA 5B88 EBFB 5CAB EBFC 5CC0 EBFD 5E25 EBFE 6101 EC31 620D EC32 624B EC33 6388 EC34 641C EC35 6536 EC36 6578 EC37 6A39 EC38 6B8A EC39 6C34 EC3A 6D19 EC3B 6F31 EC3C 71E7 EC3D 72E9 EC3E 7378 EC3F 7407 EC40 74B2 EC41 7626 EC42 7761 EC43 79C0 EC44 7A57 EC45 7AEA EC46 7CB9 EC47 7D8F EC48 7DAC EC49 7E61 EC4A 7F9E EC4B 8129 EC4C 8331 EC4D 8490 EC4E 84DA EC4F 85EA EC50 8896 EC51 8AB0 EC52 8B90 EC53 8F38 EC54 9042 EC55 9083 EC56 916C EC57 9296 EC58 92B9 EC59 968B EC5A 96A7 EC5B 96A8 EC5C 96D6 EC5D 9700 EC5E 9808 EC5F 9996 EC60 9AD3 EC61 9B1A EC62 53D4 EC63 587E EC64 5919 EC65 5B70 EC66 5BBF EC67 6DD1 EC68 6F5A EC69 719F EC6A 7421 EC6B 74B9 EC6C 8085 EC6D 83FD EC6E 5DE1 EC6F 5F87 EC70 5FAA EC71 6042 EC72 65EC EC73 6812 EC74 696F EC75 6A53 EC76 6B89 EC77 6D35 EC78 6DF3 EC79 73E3 EC7A 76FE EC7B 77AC EC7C 7B4D EC7D 7D14 EC7E 8123 EC91 821C EC92 8340 EC93 84F4 EC94 8563 EC95 8A62 EC96 8AC4 EC97 9187 EC98 931E EC99 9806 EC9A 99B4 EC9B 620C EC9C 8853 EC9D 8FF0 EC9E 9265 EC9F 5D07 ECA0 5D27 ECA1 5D69 ECA2 745F ECA3 819D ECA4 8768 ECA5 6FD5 ECA6 62FE ECA7 7FD2 ECA8 8936 ECA9 8972 ECAA 4E1E ECAB 4E58 ECAC 50E7 ECAD 52DD ECAE 5347 ECAF 627F ECB0 6607 ECB1 7E69 ECB2 8805 ECB3 965E ECB4 4F8D ECB5 5319 ECB6 5636 ECB7 59CB ECB8 5AA4 ECB9 5C38 ECBA 5C4E ECBB 5C4D ECBC 5E02 ECBD 5F11 ECBE 6043 ECBF 65BD ECC0 662F ECC1 6642 ECC2 67BE ECC3 67F4 ECC4 731C ECC5 77E2 ECC6 793A ECC7 7FC5 ECC8 8494 ECC9 84CD ECCA 8996 ECCB 8A66 ECCC 8A69 ECCD 8AE1 ECCE 8C55 ECCF 8C7A ECD0 57F4 ECD1 5BD4 ECD2 5F0F ECD3 606F ECD4 62ED ECD5 690D ECD6 6B96 ECD7 6E5C ECD8 7184 ECD9 7BD2 ECDA 8755 ECDB 8B58 ECDC 8EFE ECDD 98DF ECDE 98FE ECDF 4F38 ECE0 4F81 ECE1 4FE1 ECE2 547B ECE3 5A20 ECE4 5BB8 ECE5 613C ECE6 65B0 ECE7 6668 ECE8 71FC ECE9 7533 ECEA 795E ECEB 7D33 ECEC 814E ECED 81E3 ECEE 8398 ECEF 85AA ECF0 85CE ECF1 8703 ECF2 8A0A ECF3 8EAB ECF4 8F9B ECF5 F971 ECF6 8FC5 ECF7 5931 ECF8 5BA4 ECF9 5BE6 ECFA 6089 ECFB 5BE9 ECFC 5C0B ECFD 5FC3 ECFE 6C81 ED31 F972 ED32 6DF1 ED33 700B ED34 751A ED35 82AF ED36 8AF6 ED37 4EC0 ED38 5341 ED39 F973 ED3A 96D9 ED3B 6C0F ED3C 4E9E ED3D 4FC4 ED3E 5152 ED3F 555E ED40 5A25 ED41 5CE8 ED42 6211 ED43 7259 ED44 82BD ED45 83AA ED46 86FE ED47 8859 ED48 8A1D ED49 963F ED4A 96C5 ED4B 9913 ED4C 9D09 ED4D 9D5D ED4E 580A ED4F 5CB3 ED50 5DBD ED51 5E44 ED52 60E1 ED53 6115 ED54 63E1 ED55 6A02 ED56 6E25 ED57 9102 ED58 9354 ED59 984E ED5A 9C10 ED5B 9F77 ED5C 5B89 ED5D 5CB8 ED5E 6309 ED5F 664F ED60 6848 ED61 773C ED62 96C1 ED63 978D ED64 9854 ED65 9B9F ED66 65A1 ED67 8B01 ED68 8ECB ED69 95BC ED6A 5535 ED6B 5CA9 ED6C 5DD6 ED6D 5EB5 ED6E 6697 ED6F 764C ED70 83F4 ED71 95C7 ED72 58D3 ED73 62BC ED74 72CE ED75 9D28 ED76 4EF0 ED77 592E ED78 600F ED79 663B ED7A 6B83 ED7B 79E7 ED7C 9D26 ED7D 5393 ED7E 54C0 ED91 57C3 ED92 5D16 ED93 611B ED94 66D6 ED95 6DAF ED96 788D ED97 827E ED98 9698 ED99 9744 ED9A 5384 ED9B 627C ED9C 6396 ED9D 6DB2 ED9E 7E0A ED9F 814B EDA0 984D EDA1 6AFB EDA2 7F4C EDA3 9DAF EDA4 9E1A EDA5 4E5F EDA6 503B EDA7 51B6 EDA8 591C EDA9 60F9 EDAA 63F6 EDAB 6930 EDAC 723A EDAD 8036 EDAE F974 EDAF 91CE EDB0 5F31 EDB1 F975 EDB2 F976 EDB3 7D04 EDB4 82E5 EDB5 846F EDB6 84BB EDB7 85E5 EDB8 8E8D EDB9 F977 EDBA 4F6F EDBB F978 EDBC F979 EDBD 58E4 EDBE 5B43 EDBF 6059 EDC0 63DA EDC1 6518 EDC2 656D EDC3 6698 EDC4 F97A EDC5 694A EDC6 6A23 EDC7 6D0B EDC8 7001 EDC9 716C EDCA 75D2 EDCB 760D EDCC 79B3 EDCD 7A70 EDCE F97B EDCF 7F8A EDD0 F97C EDD1 8944 EDD2 F97D EDD3 8B93 EDD4 91C0 EDD5 967D EDD6 F97E EDD7 990A EDD8 5704 EDD9 5FA1 EDDA 65BC EDDB 6F01 EDDC 7600 EDDD 79A6 EDDE 8A9E EDDF 99AD EDE0 9B5A EDE1 9F6C EDE2 5104 EDE3 61B6 EDE4 6291 EDE5 6A8D EDE6 81C6 EDE7 5043 EDE8 5830 EDE9 5F66 EDEA 7109 EDEB 8A00 EDEC 8AFA EDED 5B7C EDEE 8616 EDEF 4FFA EDF0 513C EDF1 56B4 EDF2 5944 EDF3 63A9 EDF4 6DF9 EDF5 5DAA EDF6 696D EDF7 5186 EDF8 4E88 EDF9 4F59 EDFA F97F EDFB F980 EDFC F981 EDFD 5982 EDFE F982 EE31 F983 EE32 6B5F EE33 6C5D EE34 F984 EE35 74B5 EE36 7916 EE37 F985 EE38 8207 EE39 8245 EE3A 8339 EE3B 8F3F EE3C 8F5D EE3D F986 EE3E 9918 EE3F F987 EE40 F988 EE41 F989 EE42 4EA6 EE43 F98A EE44 57DF EE45 5F79 EE46 6613 EE47 F98B EE48 F98C EE49 75AB EE4A 7E79 EE4B 8B6F EE4C F98D EE4D 9006 EE4E 9A5B EE4F 56A5 EE50 5827 EE51 59F8 EE52 5A1F EE53 5BB4 EE54 F98E EE55 5EF6 EE56 F98F EE57 F990 EE58 6350 EE59 633B EE5A F991 EE5B 693D EE5C 6C87 EE5D 6CBF EE5E 6D8E EE5F 6D93 EE60 6DF5 EE61 6F14 EE62 F992 EE63 70DF EE64 7136 EE65 7159 EE66 F993 EE67 71C3 EE68 71D5 EE69 F994 EE6A 784F EE6B 786F EE6C F995 EE6D 7B75 EE6E 7DE3 EE6F F996 EE70 7E2F EE71 F997 EE72 884D EE73 8EDF EE74 F998 EE75 F999 EE76 F99A EE77 925B EE78 F99B EE79 9CF6 EE7A F99C EE7B F99D EE7C F99E EE7D 6085 EE7E 6D85 EE91 F99F EE92 71B1 EE93 F9A0 EE94 F9A1 EE95 95B1 EE96 53AD EE97 F9A2 EE98 F9A3 EE99 F9A4 EE9A 67D3 EE9B F9A5 EE9C 708E EE9D 7130 EE9E 7430 EE9F 8276 EEA0 82D2 EEA1 F9A6 EEA2 95BB EEA3 9AE5 EEA4 9E7D EEA5 66C4 EEA6 F9A7 EEA7 71C1 EEA8 8449 EEA9 F9A8 EEAA F9A9 EEAB 584B EEAC F9AA EEAD F9AB EEAE 5DB8 EEAF 5F71 EEB0 F9AC EEB1 6620 EEB2 668E EEB3 6979 EEB4 69AE EEB5 6C38 EEB6 6CF3 EEB7 6E36 EEB8 6F41 EEB9 6FDA EEBA 701B EEBB 702F EEBC 7150 EEBD 71DF EEBE 7370 EEBF F9AD EEC0 745B EEC1 F9AE EEC2 74D4 EEC3 76C8 EEC4 7A4E EEC5 7E93 EEC6 F9AF EEC7 F9B0 EEC8 82F1 EEC9 8A60 EECA 8FCE EECB F9B1 EECC 9348 EECD F9B2 EECE 9719 EECF F9B3 EED0 F9B4 EED1 4E42 EED2 502A EED3 F9B5 EED4 5208 EED5 53E1 EED6 66F3 EED7 6C6D EED8 6FCA EED9 730A EEDA 777F EEDB 7A62 EEDC 82AE EEDD 85DD EEDE 8602 EEDF F9B6 EEE0 88D4 EEE1 8A63 EEE2 8B7D EEE3 8C6B EEE4 F9B7 EEE5 92B3 EEE6 F9B8 EEE7 9713 EEE8 9810 EEE9 4E94 EEEA 4F0D EEEB 4FC9 EEEC 50B2 EEED 5348 EEEE 543E EEEF 5433 EEF0 55DA EEF1 5862 EEF2 58BA EEF3 5967 EEF4 5A1B EEF5 5BE4 EEF6 609F EEF7 F9B9 EEF8 61CA EEF9 6556 EEFA 65FF EEFB 6664 EEFC 68A7 EEFD 6C5A EEFE 6FB3 EF31 70CF EF32 71AC EF33 7352 EF34 7B7D EF35 8708 EF36 8AA4 EF37 9C32 EF38 9F07 EF39 5C4B EF3A 6C83 EF3B 7344 EF3C 7389 EF3D 923A EF3E 6EAB EF3F 7465 EF40 761F EF41 7A69 EF42 7E15 EF43 860A EF44 5140 EF45 58C5 EF46 64C1 EF47 74EE EF48 7515 EF49 7670 EF4A 7FC1 EF4B 9095 EF4C 96CD EF4D 9954 EF4E 6E26 EF4F 74E6 EF50 7AA9 EF51 7AAA EF52 81E5 EF53 86D9 EF54 8778 EF55 8A1B EF56 5A49 EF57 5B8C EF58 5B9B EF59 68A1 EF5A 6900 EF5B 6D63 EF5C 73A9 EF5D 7413 EF5E 742C EF5F 7897 EF60 7DE9 EF61 7FEB EF62 8118 EF63 8155 EF64 839E EF65 8C4C EF66 962E EF67 9811 EF68 66F0 EF69 5F80 EF6A 65FA EF6B 6789 EF6C 6C6A EF6D 738B EF6E 502D EF6F 5A03 EF70 6B6A EF71 77EE EF72 5916 EF73 5D6C EF74 5DCD EF75 7325 EF76 754F EF77 F9BA EF78 F9BB EF79 50E5 EF7A 51F9 EF7B 582F EF7C 592D EF7D 5996 EF7E 59DA EF91 5BE5 EF92 F9BC EF93 F9BD EF94 5DA2 EF95 62D7 EF96 6416 EF97 6493 EF98 64FE EF99 F9BE EF9A 66DC EF9B F9BF EF9C 6A48 EF9D F9C0 EF9E 71FF EF9F 7464 EFA0 F9C1 EFA1 7A88 EFA2 7AAF EFA3 7E47 EFA4 7E5E EFA5 8000 EFA6 8170 EFA7 F9C2 EFA8 87EF EFA9 8981 EFAA 8B20 EFAB 9059 EFAC F9C3 EFAD 9080 EFAE 9952 EFAF 617E EFB0 6B32 EFB1 6D74 EFB2 7E1F EFB3 8925 EFB4 8FB1 EFB5 4FD1 EFB6 50AD EFB7 5197 EFB8 52C7 EFB9 57C7 EFBA 5889 EFBB 5BB9 EFBC 5EB8 EFBD 6142 EFBE 6995 EFBF 6D8C EFC0 6E67 EFC1 6EB6 EFC2 7194 EFC3 7462 EFC4 7528 EFC5 752C EFC6 8073 EFC7 8338 EFC8 84C9 EFC9 8E0A EFCA 9394 EFCB 93DE EFCC F9C4 EFCD 4E8E EFCE 4F51 EFCF 5076 EFD0 512A EFD1 53C8 EFD2 53CB EFD3 53F3 EFD4 5B87 EFD5 5BD3 EFD6 5C24 EFD7 611A EFD8 6182 EFD9 65F4 EFDA 725B EFDB 7397 EFDC 7440 EFDD 76C2 EFDE 7950 EFDF 7991 EFE0 79B9 EFE1 7D06 EFE2 7FBD EFE3 828B EFE4 85D5 EFE5 865E EFE6 8FC2 EFE7 9047 EFE8 90F5 EFE9 91EA EFEA 9685 EFEB 96E8 EFEC 96E9 EFED 52D6 EFEE 5F67 EFEF 65ED EFF0 6631 EFF1 682F EFF2 715C EFF3 7A36 EFF4 90C1 EFF5 980A EFF6 4E91 EFF7 F9C5 EFF8 6A52 EFF9 6B9E EFFA 6F90 EFFB 7189 EFFC 8018 EFFD 82B8 EFFE 8553 F031 904B F032 9695 F033 96F2 F034 97FB F035 851A F036 9B31 F037 4E90 F038 718A F039 96C4 F03A 5143 F03B 539F F03C 54E1 F03D 5713 F03E 5712 F03F 57A3 F040 5A9B F041 5AC4 F042 5BC3 F043 6028 F044 613F F045 63F4 F046 6C85 F047 6D39 F048 6E72 F049 6E90 F04A 7230 F04B 733F F04C 7457 F04D 82D1 F04E 8881 F04F 8F45 F050 9060 F051 F9C6 F052 9662 F053 9858 F054 9D1B F055 6708 F056 8D8A F057 925E F058 4F4D F059 5049 F05A 50DE F05B 5371 F05C 570D F05D 59D4 F05E 5A01 F05F 5C09 F060 6170 F061 6690 F062 6E2D F063 7232 F064 744B F065 7DEF F066 80C3 F067 840E F068 8466 F069 853F F06A 875F F06B 885B F06C 8918 F06D 8B02 F06E 9055 F06F 97CB F070 9B4F F071 4E73 F072 4F91 F073 5112 F074 516A F075 F9C7 F076 552F F077 55A9 F078 5B7A F079 5BA5 F07A 5E7C F07B 5E7D F07C 5EBE F07D 60A0 F07E 60DF F091 6108 F092 6109 F093 63C4 F094 6538 F095 6709 F096 F9C8 F097 67D4 F098 67DA F099 F9C9 F09A 6961 F09B 6962 F09C 6CB9 F09D 6D27 F09E F9CA F09F 6E38 F0A0 F9CB F0A1 6FE1 F0A2 7336 F0A3 7337 F0A4 F9CC F0A5 745C F0A6 7531 F0A7 F9CD F0A8 7652 F0A9 F9CE F0AA F9CF F0AB 7DAD F0AC 81FE F0AD 8438 F0AE 88D5 F0AF 8A98 F0B0 8ADB F0B1 8AED F0B2 8E30 F0B3 8E42 F0B4 904A F0B5 903E F0B6 907A F0B7 9149 F0B8 91C9 F0B9 936E F0BA F9D0 F0BB F9D1 F0BC 5809 F0BD F9D2 F0BE 6BD3 F0BF 8089 F0C0 80B2 F0C1 F9D3 F0C2 F9D4 F0C3 5141 F0C4 596B F0C5 5C39 F0C6 F9D5 F0C7 F9D6 F0C8 6F64 F0C9 73A7 F0CA 80E4 F0CB 8D07 F0CC F9D7 F0CD 9217 F0CE 958F F0CF F9D8 F0D0 F9D9 F0D1 F9DA F0D2 F9DB F0D3 807F F0D4 620E F0D5 701C F0D6 7D68 F0D7 878D F0D8 F9DC F0D9 57A0 F0DA 6069 F0DB 6147 F0DC 6BB7 F0DD 8ABE F0DE 9280 F0DF 96B1 F0E0 4E59 F0E1 541F F0E2 6DEB F0E3 852D F0E4 9670 F0E5 97F3 F0E6 98EE F0E7 63D6 F0E8 6CE3 F0E9 9091 F0EA 51DD F0EB 61C9 F0EC 81BA F0ED 9DF9 F0EE 4F9D F0EF 501A F0F0 5100 F0F1 5B9C F0F2 610F F0F3 61FF F0F4 64EC F0F5 6905 F0F6 6BC5 F0F7 7591 F0F8 77E3 F0F9 7FA9 F0FA 8264 F0FB 858F F0FC 87FB F0FD 8863 F0FE 8ABC F131 8B70 F132 91AB F133 4E8C F134 4EE5 F135 4F0A F136 F9DD F137 F9DE F138 5937 F139 59E8 F13A F9DF F13B 5DF2 F13C 5F1B F13D 5F5B F13E 6021 F13F F9E0 F140 F9E1 F141 F9E2 F142 F9E3 F143 723E F144 73E5 F145 F9E4 F146 7570 F147 75CD F148 F9E5 F149 79FB F14A F9E6 F14B 800C F14C 8033 F14D 8084 F14E 82E1 F14F 8351 F150 F9E7 F151 F9E8 F152 8CBD F153 8CB3 F154 9087 F155 F9E9 F156 F9EA F157 98F4 F158 990C F159 F9EB F15A F9EC F15B 7037 F15C 76CA F15D 7FCA F15E 7FCC F15F 7FFC F160 8B1A F161 4EBA F162 4EC1 F163 5203 F164 5370 F165 F9ED F166 54BD F167 56E0 F168 59FB F169 5BC5 F16A 5F15 F16B 5FCD F16C 6E6E F16D F9EE F16E F9EF F16F 7D6A F170 8335 F171 F9F0 F172 8693 F173 8A8D F174 F9F1 F175 976D F176 9777 F177 F9F2 F178 F9F3 F179 4E00 F17A 4F5A F17B 4F7E F17C 58F9 F17D 65E5 F17E 6EA2 F191 9038 F192 93B0 F193 99B9 F194 4EFB F195 58EC F196 598A F197 59D9 F198 6041 F199 F9F4 F19A F9F5 F19B 7A14 F19C F9F6 F19D 834F F19E 8CC3 F19F 5165 F1A0 5344 F1A1 F9F7 F1A2 F9F8 F1A3 F9F9 F1A4 4ECD F1A5 5269 F1A6 5B55 F1A7 82BF F1A8 4ED4 F1A9 523A F1AA 54A8 F1AB 59C9 F1AC 59FF F1AD 5B50 F1AE 5B57 F1AF 5B5C F1B0 6063 F1B1 6148 F1B2 6ECB F1B3 7099 F1B4 716E F1B5 7386 F1B6 74F7 F1B7 75B5 F1B8 78C1 F1B9 7D2B F1BA 8005 F1BB 81EA F1BC 8328 F1BD 8517 F1BE 85C9 F1BF 8AEE F1C0 8CC7 F1C1 96CC F1C2 4F5C F1C3 52FA F1C4 56BC F1C5 65AB F1C6 6628 F1C7 707C F1C8 70B8 F1C9 7235 F1CA 7DBD F1CB 828D F1CC 914C F1CD 96C0 F1CE 9D72 F1CF 5B71 F1D0 68E7 F1D1 6B98 F1D2 6F7A F1D3 76DE F1D4 5C91 F1D5 66AB F1D6 6F5B F1D7 7BB4 F1D8 7C2A F1D9 8836 F1DA 96DC F1DB 4E08 F1DC 4ED7 F1DD 5320 F1DE 5834 F1DF 58BB F1E0 58EF F1E1 596C F1E2 5C07 F1E3 5E33 F1E4 5E84 F1E5 5F35 F1E6 638C F1E7 66B2 F1E8 6756 F1E9 6A1F F1EA 6AA3 F1EB 6B0C F1EC 6F3F F1ED 7246 F1EE F9FA F1EF 7350 F1F0 748B F1F1 7AE0 F1F2 7CA7 F1F3 8178 F1F4 81DF F1F5 81E7 F1F6 838A F1F7 846C F1F8 8523 F1F9 8594 F1FA 85CF F1FB 88DD F1FC 8D13 F1FD 91AC F1FE 9577 F231 969C F232 518D F233 54C9 F234 5728 F235 5BB0 F236 624D F237 6750 F238 683D F239 6893 F23A 6E3D F23B 6ED3 F23C 707D F23D 7E21 F23E 88C1 F23F 8CA1 F240 8F09 F241 9F4B F242 9F4E F243 722D F244 7B8F F245 8ACD F246 931A F247 4F47 F248 4F4E F249 5132 F24A 5480 F24B 59D0 F24C 5E95 F24D 62B5 F24E 6775 F24F 696E F250 6A17 F251 6CAE F252 6E1A F253 72D9 F254 732A F255 75BD F256 7BB8 F257 7D35 F258 82E7 F259 83F9 F25A 8457 F25B 85F7 F25C 8A5B F25D 8CAF F25E 8E87 F25F 9019 F260 90B8 F261 96CE F262 9F5F F263 52E3 F264 540A F265 5AE1 F266 5BC2 F267 6458 F268 6575 F269 6EF4 F26A 72C4 F26B F9FB F26C 7684 F26D 7A4D F26E 7B1B F26F 7C4D F270 7E3E F271 7FDF F272 837B F273 8B2B F274 8CCA F275 8D64 F276 8DE1 F277 8E5F F278 8FEA F279 8FF9 F27A 9069 F27B 93D1 F27C 4F43 F27D 4F7A F27E 50B3 F291 5168 F292 5178 F293 524D F294 526A F295 5861 F296 587C F297 5960 F298 5C08 F299 5C55 F29A 5EDB F29B 609B F29C 6230 F29D 6813 F29E 6BBF F29F 6C08 F2A0 6FB1 F2A1 714E F2A2 7420 F2A3 7530 F2A4 7538 F2A5 7551 F2A6 7672 F2A7 7B4C F2A8 7B8B F2A9 7BAD F2AA 7BC6 F2AB 7E8F F2AC 8A6E F2AD 8F3E F2AE 8F49 F2AF 923F F2B0 9293 F2B1 9322 F2B2 942B F2B3 96FB F2B4 985A F2B5 986B F2B6 991E F2B7 5207 F2B8 622A F2B9 6298 F2BA 6D59 F2BB 7664 F2BC 7ACA F2BD 7BC0 F2BE 7D76 F2BF 5360 F2C0 5CBE F2C1 5E97 F2C2 6F38 F2C3 70B9 F2C4 7C98 F2C5 9711 F2C6 9B8E F2C7 9EDE F2C8 63A5 F2C9 647A F2CA 8776 F2CB 4E01 F2CC 4E95 F2CD 4EAD F2CE 505C F2CF 5075 F2D0 5448 F2D1 59C3 F2D2 5B9A F2D3 5E40 F2D4 5EAD F2D5 5EF7 F2D6 5F81 F2D7 60C5 F2D8 633A F2D9 653F F2DA 6574 F2DB 65CC F2DC 6676 F2DD 6678 F2DE 67FE F2DF 6968 F2E0 6A89 F2E1 6B63 F2E2 6C40 F2E3 6DC0 F2E4 6DE8 F2E5 6E1F F2E6 6E5E F2E7 701E F2E8 70A1 F2E9 738E F2EA 73FD F2EB 753A F2EC 775B F2ED 7887 F2EE 798E F2EF 7A0B F2F0 7A7D F2F1 7CBE F2F2 7D8E F2F3 8247 F2F4 8A02 F2F5 8AEA F2F6 8C9E F2F7 912D F2F8 914A F2F9 91D8 F2FA 9266 F2FB 92CC F2FC 9320 F2FD 9706 F2FE 9756 F331 975C F332 9802 F333 9F0E F334 5236 F335 5291 F336 557C F337 5824 F338 5E1D F339 5F1F F33A 608C F33B 63D0 F33C 68AF F33D 6FDF F33E 796D F33F 7B2C F340 81CD F341 85BA F342 88FD F343 8AF8 F344 8E44 F345 918D F346 9664 F347 969B F348 973D F349 984C F34A 9F4A F34B 4FCE F34C 5146 F34D 51CB F34E 52A9 F34F 5632 F350 5F14 F351 5F6B F352 63AA F353 64CD F354 65E9 F355 6641 F356 66FA F357 66F9 F358 671D F359 689D F35A 68D7 F35B 69FD F35C 6F15 F35D 6F6E F35E 7167 F35F 71E5 F360 722A F361 74AA F362 773A F363 7956 F364 795A F365 79DF F366 7A20 F367 7A95 F368 7C97 F369 7CDF F36A 7D44 F36B 7E70 F36C 8087 F36D 85FB F36E 86A4 F36F 8A54 F370 8ABF F371 8D99 F372 8E81 F373 9020 F374 906D F375 91E3 F376 963B F377 96D5 F378 9CE5 F379 65CF F37A 7C07 F37B 8DB3 F37C 93C3 F37D 5B58 F37E 5C0A F391 5352 F392 62D9 F393 731D F394 5027 F395 5B97 F396 5F9E F397 60B0 F398 616B F399 68D5 F39A 6DD9 F39B 742E F39C 7A2E F39D 7D42 F39E 7D9C F39F 7E31 F3A0 816B F3A1 8E2A F3A2 8E35 F3A3 937E F3A4 9418 F3A5 4F50 F3A6 5750 F3A7 5DE6 F3A8 5EA7 F3A9 632B F3AA 7F6A F3AB 4E3B F3AC 4F4F F3AD 4F8F F3AE 505A F3AF 59DD F3B0 80C4 F3B1 546A F3B2 5468 F3B3 55FE F3B4 594F F3B5 5B99 F3B6 5DDE F3B7 5EDA F3B8 665D F3B9 6731 F3BA 67F1 F3BB 682A F3BC 6CE8 F3BD 6D32 F3BE 6E4A F3BF 6F8D F3C0 70B7 F3C1 73E0 F3C2 7587 F3C3 7C4C F3C4 7D02 F3C5 7D2C F3C6 7DA2 F3C7 821F F3C8 86DB F3C9 8A3B F3CA 8A85 F3CB 8D70 F3CC 8E8A F3CD 8F33 F3CE 9031 F3CF 914E F3D0 9152 F3D1 9444 F3D2 99D0 F3D3 7AF9 F3D4 7CA5 F3D5 4FCA F3D6 5101 F3D7 51C6 F3D8 57C8 F3D9 5BEF F3DA 5CFB F3DB 6659 F3DC 6A3D F3DD 6D5A F3DE 6E96 F3DF 6FEC F3E0 710C F3E1 756F F3E2 7AE3 F3E3 8822 F3E4 9021 F3E5 9075 F3E6 96CB F3E7 99FF F3E8 8301 F3E9 4E2D F3EA 4EF2 F3EB 8846 F3EC 91CD F3ED 537D F3EE 6ADB F3EF 696B F3F0 6C41 F3F1 847A F3F2 589E F3F3 618E F3F4 66FE F3F5 62EF F3F6 70DD F3F7 7511 F3F8 75C7 F3F9 7E52 F3FA 84B8 F3FB 8B49 F3FC 8D08 F3FD 4E4B F3FE 53EA F431 54AB F432 5730 F433 5740 F434 5FD7 F435 6301 F436 6307 F437 646F F438 652F F439 65E8 F43A 667A F43B 679D F43C 67B3 F43D 6B62 F43E 6C60 F43F 6C9A F440 6F2C F441 77E5 F442 7825 F443 7949 F444 7957 F445 7D19 F446 80A2 F447 8102 F448 81F3 F449 829D F44A 82B7 F44B 8718 F44C 8A8C F44D F9FC F44E 8D04 F44F 8DBE F450 9072 F451 76F4 F452 7A19 F453 7A37 F454 7E54 F455 8077 F456 5507 F457 55D4 F458 5875 F459 632F F45A 6422 F45B 6649 F45C 664B F45D 686D F45E 699B F45F 6B84 F460 6D25 F461 6EB1 F462 73CD F463 7468 F464 74A1 F465 755B F466 75B9 F467 76E1 F468 771E F469 778B F46A 79E6 F46B 7E09 F46C 7E1D F46D 81FB F46E 852F F46F 8897 F470 8A3A F471 8CD1 F472 8EEB F473 8FB0 F474 9032 F475 93AD F476 9663 F477 9673 F478 9707 F479 4F84 F47A 53F1 F47B 59EA F47C 5AC9 F47D 5E19 F47E 684E F491 74C6 F492 75BE F493 79E9 F494 7A92 F495 81A3 F496 86ED F497 8CEA F498 8DCC F499 8FED F49A 659F F49B 6715 F49C F9FD F49D 57F7 F49E 6F57 F49F 7DDD F4A0 8F2F F4A1 93F6 F4A2 96C6 F4A3 5FB5 F4A4 61F2 F4A5 6F84 F4A6 4E14 F4A7 4F98 F4A8 501F F4A9 53C9 F4AA 55DF F4AB 5D6F F4AC 5DEE F4AD 6B21 F4AE 6B64 F4AF 78CB F4B0 7B9A F4B1 F9FE F4B2 8E49 F4B3 8ECA F4B4 906E F4B5 6349 F4B6 643E F4B7 7740 F4B8 7A84 F4B9 932F F4BA 947F F4BB 9F6A F4BC 64B0 F4BD 6FAF F4BE 71E6 F4BF 74A8 F4C0 74DA F4C1 7AC4 F4C2 7C12 F4C3 7E82 F4C4 7CB2 F4C5 7E98 F4C6 8B9A F4C7 8D0A F4C8 947D F4C9 9910 F4CA 994C F4CB 5239 F4CC 5BDF F4CD 64E6 F4CE 672D F4CF 7D2E F4D0 50ED F4D1 53C3 F4D2 5879 F4D3 6158 F4D4 6159 F4D5 61FA F4D6 65AC F4D7 7AD9 F4D8 8B92 F4D9 8B96 F4DA 5009 F4DB 5021 F4DC 5275 F4DD 5531 F4DE 5A3C F4DF 5EE0 F4E0 5F70 F4E1 6134 F4E2 655E F4E3 660C F4E4 6636 F4E5 66A2 F4E6 69CD F4E7 6EC4 F4E8 6F32 F4E9 7316 F4EA 7621 F4EB 7A93 F4EC 8139 F4ED 8259 F4EE 83D6 F4EF 84BC F4F0 50B5 F4F1 57F0 F4F2 5BC0 F4F3 5BE8 F4F4 5F69 F4F5 63A1 F4F6 7826 F4F7 7DB5 F4F8 83DC F4F9 8521 F4FA 91C7 F4FB 91F5 F4FC 518A F4FD 67F5 F4FE 7B56 F531 8CAC F532 51C4 F533 59BB F534 60BD F535 8655 F536 501C F537 F9FF F538 5254 F539 5C3A F53A 617D F53B 621A F53C 62D3 F53D 64F2 F53E 65A5 F53F 6ECC F540 7620 F541 810A F542 8E60 F543 965F F544 96BB F545 4EDF F546 5343 F547 5598 F548 5929 F549 5DDD F54A 64C5 F54B 6CC9 F54C 6DFA F54D 7394 F54E 7A7F F54F 821B F550 85A6 F551 8CE4 F552 8E10 F553 9077 F554 91E7 F555 95E1 F556 9621 F557 97C6 F558 51F8 F559 54F2 F55A 5586 F55B 5FB9 F55C 64A4 F55D 6F88 F55E 7DB4 F55F 8F1F F560 8F4D F561 9435 F562 50C9 F563 5C16 F564 6CBE F565 6DFB F566 751B F567 77BB F568 7C3D F569 7C64 F56A 8A79 F56B 8AC2 F56C 581E F56D 59BE F56E 5E16 F56F 6377 F570 7252 F571 758A F572 776B F573 8ADC F574 8CBC F575 8F12 F576 5EF3 F577 6674 F578 6DF8 F579 807D F57A 83C1 F57B 8ACB F57C 9751 F57D 9BD6 F57E FA00 F591 5243 F592 66FF F593 6D95 F594 6EEF F595 7DE0 F596 8AE6 F597 902E F598 905E F599 9AD4 F59A 521D F59B 527F F59C 54E8 F59D 6194 F59E 6284 F59F 62DB F5A0 68A2 F5A1 6912 F5A2 695A F5A3 6A35 F5A4 7092 F5A5 7126 F5A6 785D F5A7 7901 F5A8 790E F5A9 79D2 F5AA 7A0D F5AB 8096 F5AC 8278 F5AD 82D5 F5AE 8349 F5AF 8549 F5B0 8C82 F5B1 8D85 F5B2 9162 F5B3 918B F5B4 91AE F5B5 4FC3 F5B6 56D1 F5B7 71ED F5B8 77D7 F5B9 8700 F5BA 89F8 F5BB 5BF8 F5BC 5FD6 F5BD 6751 F5BE 90A8 F5BF 53E2 F5C0 585A F5C1 5BF5 F5C2 60A4 F5C3 6181 F5C4 6460 F5C5 7E3D F5C6 8070 F5C7 8525 F5C8 9283 F5C9 64AE F5CA 50AC F5CB 5D14 F5CC 6700 F5CD 589C F5CE 62BD F5CF 63A8 F5D0 690E F5D1 6978 F5D2 6A1E F5D3 6E6B F5D4 76BA F5D5 79CB F5D6 82BB F5D7 8429 F5D8 8ACF F5D9 8DA8 F5DA 8FFD F5DB 9112 F5DC 914B F5DD 919C F5DE 9310 F5DF 9318 F5E0 939A F5E1 96DB F5E2 9A36 F5E3 9C0D F5E4 4E11 F5E5 755C F5E6 795D F5E7 7AFA F5E8 7B51 F5E9 7BC9 F5EA 7E2E F5EB 84C4 F5EC 8E59 F5ED 8E74 F5EE 8EF8 F5EF 9010 F5F0 6625 F5F1 693F F5F2 7443 F5F3 51FA F5F4 672E F5F5 9EDC F5F6 5145 F5F7 5FE0 F5F8 6C96 F5F9 87F2 F5FA 885D F5FB 8877 F5FC 60B4 F5FD 81B5 F5FE 8403 F631 8D05 F632 53D6 F633 5439 F634 5634 F635 5A36 F636 5C31 F637 708A F638 7FE0 F639 805A F63A 8106 F63B 81ED F63C 8DA3 F63D 9189 F63E 9A5F F63F 9DF2 F640 5074 F641 4EC4 F642 53A0 F643 60FB F644 6E2C F645 5C64 F646 4F88 F647 5024 F648 55E4 F649 5CD9 F64A 5E5F F64B 6065 F64C 6894 F64D 6CBB F64E 6DC4 F64F 71BE F650 75D4 F651 75F4 F652 7661 F653 7A1A F654 7A49 F655 7DC7 F656 7DFB F657 7F6E F658 81F4 F659 86A9 F65A 8F1C F65B 96C9 F65C 99B3 F65D 9F52 F65E 5247 F65F 52C5 F660 98ED F661 89AA F662 4E03 F663 67D2 F664 6F06 F665 4FB5 F666 5BE2 F667 6795 F668 6C88 F669 6D78 F66A 741B F66B 7827 F66C 91DD F66D 937C F66E 87C4 F66F 79E4 F670 7A31 F671 5FEB F672 4ED6 F673 54A4 F674 553E F675 58AE F676 59A5 F677 60F0 F678 6253 F679 62D6 F67A 6736 F67B 6955 F67C 8235 F67D 9640 F67E 99B1 F691 99DD F692 502C F693 5353 F694 5544 F695 577C F696 FA01 F697 6258 F698 FA02 F699 64E2 F69A 666B F69B 67DD F69C 6FC1 F69D 6FEF F69E 7422 F69F 7438 F6A0 8A17 F6A1 9438 F6A2 5451 F6A3 5606 F6A4 5766 F6A5 5F48 F6A6 619A F6A7 6B4E F6A8 7058 F6A9 70AD F6AA 7DBB F6AB 8A95 F6AC 596A F6AD 812B F6AE 63A2 F6AF 7708 F6B0 803D F6B1 8CAA F6B2 5854 F6B3 642D F6B4 69BB F6B5 5B95 F6B6 5E11 F6B7 6E6F F6B8 FA03 F6B9 8569 F6BA 514C F6BB 53F0 F6BC 592A F6BD 6020 F6BE 614B F6BF 6B86 F6C0 6C70 F6C1 6CF0 F6C2 7B1E F6C3 80CE F6C4 82D4 F6C5 8DC6 F6C6 90B0 F6C7 98B1 F6C8 FA04 F6C9 64C7 F6CA 6FA4 F6CB 6491 F6CC 6504 F6CD 514E F6CE 5410 F6CF 571F F6D0 8A0E F6D1 615F F6D2 6876 F6D3 FA05 F6D4 75DB F6D5 7B52 F6D6 7D71 F6D7 901A F6D8 5806 F6D9 69CC F6DA 817F F6DB 892A F6DC 9000 F6DD 9839 F6DE 5078 F6DF 5957 F6E0 59AC F6E1 6295 F6E2 900F F6E3 9B2A F6E4 615D F6E5 7279 F6E6 95D6 F6E7 5761 F6E8 5A46 F6E9 5DF4 F6EA 628A F6EB 64AD F6EC 64FA F6ED 6777 F6EE 6CE2 F6EF 6D3E F6F0 722C F6F1 7436 F6F2 7834 F6F3 7F77 F6F4 82AD F6F5 8DDB F6F6 9817 F6F7 5224 F6F8 5742 F6F9 677F F6FA 7248 F6FB 74E3 F6FC 8CA9 F6FD 8FA6 F6FE 9211 F731 962A F732 516B F733 53ED F734 634C F735 4F69 F736 5504 F737 6096 F738 6557 F739 6C9B F73A 6D7F F73B 724C F73C 72FD F73D 7A17 F73E 8987 F73F 8C9D F740 5F6D F741 6F8E F742 70F9 F743 81A8 F744 610E F745 4FBF F746 504F F747 6241 F748 7247 F749 7BC7 F74A 7DE8 F74B 7FE9 F74C 904D F74D 97AD F74E 9A19 F74F 8CB6 F750 576A F751 5E73 F752 67B0 F753 840D F754 8A55 F755 5420 F756 5B16 F757 5E63 F758 5EE2 F759 5F0A F75A 6583 F75B 80BA F75C 853D F75D 9589 F75E 965B F75F 4F48 F760 5305 F761 530D F762 530F F763 5486 F764 54FA F765 5703 F766 5E03 F767 6016 F768 629B F769 62B1 F76A 6355 F76B FA06 F76C 6CE1 F76D 6D66 F76E 75B1 F76F 7832 F770 80DE F771 812F F772 82DE F773 8461 F774 84B2 F775 888D F776 8912 F777 900B F778 92EA F779 98FD F77A 9B91 F77B 5E45 F77C 66B4 F77D 66DD F77E 7011 F791 7206 F792 FA07 F793 4FF5 F794 527D F795 5F6A F796 6153 F797 6753 F798 6A19 F799 6F02 F79A 74E2 F79B 7968 F79C 8868 F79D 8C79 F79E 98C7 F79F 98C4 F7A0 9A43 F7A1 54C1 F7A2 7A1F F7A3 6953 F7A4 8AF7 F7A5 8C4A F7A6 98A8 F7A7 99AE F7A8 5F7C F7A9 62AB F7AA 75B2 F7AB 76AE F7AC 88AB F7AD 907F F7AE 9642 F7AF 5339 F7B0 5F3C F7B1 5FC5 F7B2 6CCC F7B3 73CC F7B4 7562 F7B5 758B F7B6 7B46 F7B7 82FE F7B8 999D F7B9 4E4F F7BA 903C F7BB 4E0B F7BC 4F55 F7BD 53A6 F7BE 590F F7BF 5EC8 F7C0 6630 F7C1 6CB3 F7C2 7455 F7C3 8377 F7C4 8766 F7C5 8CC0 F7C6 9050 F7C7 971E F7C8 9C15 F7C9 58D1 F7CA 5B78 F7CB 8650 F7CC 8B14 F7CD 9DB4 F7CE 5BD2 F7CF 6068 F7D0 608D F7D1 65F1 F7D2 6C57 F7D3 6F22 F7D4 6FA3 F7D5 701A F7D6 7F55 F7D7 7FF0 F7D8 9591 F7D9 9592 F7DA 9650 F7DB 97D3 F7DC 5272 F7DD 8F44 F7DE 51FD F7DF 542B F7E0 54B8 F7E1 5563 F7E2 558A F7E3 6ABB F7E4 6DB5 F7E5 7DD8 F7E6 8266 F7E7 929C F7E8 9677 F7E9 9E79 F7EA 5408 F7EB 54C8 F7EC 76D2 F7ED 86E4 F7EE 95A4 F7EF 95D4 F7F0 965C F7F1 4EA2 F7F2 4F09 F7F3 59EE F7F4 5AE6 F7F5 5DF7 F7F6 6052 F7F7 6297 F7F8 676D F7F9 6841 F7FA 6C86 F7FB 6E2F F7FC 7F38 F7FD 809B F7FE 822A F831 FA08 F832 FA09 F833 9805 F834 4EA5 F835 5055 F836 54B3 F837 5793 F838 595A F839 5B69 F83A 5BB3 F83B 61C8 F83C 6977 F83D 6D77 F83E 7023 F83F 87F9 F840 89E3 F841 8A72 F842 8AE7 F843 9082 F844 99ED F845 9AB8 F846 52BE F847 6838 F848 5016 F849 5E78 F84A 674F F84B 8347 F84C 884C F84D 4EAB F84E 5411 F84F 56AE F850 73E6 F851 9115 F852 97FF F853 9909 F854 9957 F855 9999 F856 5653 F857 589F F858 865B F859 8A31 F85A 61B2 F85B 6AF6 F85C 737B F85D 8ED2 F85E 6B47 F85F 96AA F860 9A57 F861 5955 F862 7200 F863 8D6B F864 9769 F865 4FD4 F866 5CF4 F867 5F26 F868 61F8 F869 665B F86A 6CEB F86B 70AB F86C 7384 F86D 73B9 F86E 73FE F86F 7729 F870 774D F871 7D43 F872 7D62 F873 7E23 F874 8237 F875 8852 F876 FA0A F877 8CE2 F878 9249 F879 986F F87A 5B51 F87B 7A74 F87C 8840 F87D 9801 F87E 5ACC F891 4FE0 F892 5354 F893 593E F894 5CFD F895 633E F896 6D79 F897 72F9 F898 8105 F899 8107 F89A 83A2 F89B 92CF F89C 9830 F89D 4EA8 F89E 5144 F89F 5211 F8A0 578B F8A1 5F62 F8A2 6CC2 F8A3 6ECE F8A4 7005 F8A5 7050 F8A6 70AF F8A7 7192 F8A8 73E9 F8A9 7469 F8AA 834A F8AB 87A2 F8AC 8861 F8AD 9008 F8AE 90A2 F8AF 93A3 F8B0 99A8 F8B1 516E F8B2 5F57 F8B3 60E0 F8B4 6167 F8B5 66B3 F8B6 8559 F8B7 8E4A F8B8 91AF F8B9 978B F8BA 4E4E F8BB 4E92 F8BC 547C F8BD 58D5 F8BE 58FA F8BF 597D F8C0 5CB5 F8C1 5F27 F8C2 6236 F8C3 6248 F8C4 660A F8C5 6667 F8C6 6BEB F8C7 6D69 F8C8 6DCF F8C9 6E56 F8CA 6EF8 F8CB 6F94 F8CC 6FE0 F8CD 6FE9 F8CE 705D F8CF 72D0 F8D0 7425 F8D1 745A F8D2 74E0 F8D3 7693 F8D4 795C F8D5 7CCA F8D6 7E1E F8D7 80E1 F8D8 82A6 F8D9 846B F8DA 84BF F8DB 864E F8DC 865F F8DD 8774 F8DE 8B77 F8DF 8C6A F8E0 93AC F8E1 9800 F8E2 9865 F8E3 60D1 F8E4 6216 F8E5 9177 F8E6 5A5A F8E7 660F F8E8 6DF7 F8E9 6E3E F8EA 743F F8EB 9B42 F8EC 5FFD F8ED 60DA F8EE 7B0F F8EF 54C4 F8F0 5F18 F8F1 6C5E F8F2 6CD3 F8F3 6D2A F8F4 70D8 F8F5 7D05 F8F6 8679 F8F7 8A0C F8F8 9D3B F8F9 5316 F8FA 548C F8FB 5B05 F8FC 6A3A F8FD 706B F8FE 7575 F931 798D F932 79BE F933 82B1 F934 83EF F935 8A71 F936 8B41 F937 8CA8 F938 9774 F939 FA0B F93A 64F4 F93B 652B F93C 78BA F93D 78BB F93E 7A6B F93F 4E38 F940 559A F941 5950 F942 5BA6 F943 5E7B F944 60A3 F945 63DB F946 6B61 F947 6665 F948 6853 F949 6E19 F94A 7165 F94B 74B0 F94C 7D08 F94D 9084 F94E 9A69 F94F 9C25 F950 6D3B F951 6ED1 F952 733E F953 8C41 F954 95CA F955 51F0 F956 5E4C F957 5FA8 F958 604D F959 60F6 F95A 6130 F95B 614C F95C 6643 F95D 6644 F95E 69A5 F95F 6CC1 F960 6E5F F961 6EC9 F962 6F62 F963 714C F964 749C F965 7687 F966 7BC1 F967 7C27 F968 8352 F969 8757 F96A 9051 F96B 968D F96C 9EC3 F96D 532F F96E 56DE F96F 5EFB F970 5F8A F971 6062 F972 6094 F973 61F7 F974 6666 F975 6703 F976 6A9C F977 6DEE F978 6FAE F979 7070 F97A 736A F97B 7E6A F97C 81BE F97D 8334 F97E 86D4 F991 8AA8 F992 8CC4 F993 5283 F994 7372 F995 5B96 F996 6A6B F997 9404 F998 54EE F999 5686 F99A 5B5D F99B 6548 F99C 6585 F99D 66C9 F99E 689F F99F 6D8D F9A0 6DC6 F9A1 723B F9A2 80B4 F9A3 9175 F9A4 9A4D F9A5 4FAF F9A6 5019 F9A7 539A F9A8 540E F9A9 543C F9AA 5589 F9AB 55C5 F9AC 5E3F F9AD 5F8C F9AE 673D F9AF 7166 F9B0 73DD F9B1 9005 F9B2 52DB F9B3 52F3 F9B4 5864 F9B5 58CE F9B6 7104 F9B7 718F F9B8 71FB F9B9 85B0 F9BA 8A13 F9BB 6688 F9BC 85A8 F9BD 55A7 F9BE 6684 F9BF 714A F9C0 8431 F9C1 5349 F9C2 5599 F9C3 6BC1 F9C4 5F59 F9C5 5FBD F9C6 63EE F9C7 6689 F9C8 7147 F9C9 8AF1 F9CA 8F1D F9CB 9EBE F9CC 4F11 F9CD 643A F9CE 70CB F9CF 7566 F9D0 8667 F9D1 6064 F9D2 8B4E F9D3 9DF8 F9D4 5147 F9D5 51F6 F9D6 5308 F9D7 6D36 F9D8 80F8 F9D9 9ED1 F9DA 6615 F9DB 6B23 F9DC 7098 F9DD 75D5 F9DE 5403 F9DF 5C79 F9E0 7D07 F9E1 8A16 F9E2 6B20 F9E3 6B3D F9E4 6B46 F9E5 5438 F9E6 6070 F9E7 6D3D F9E8 7FD5 F9E9 8208 F9EA 50D6 F9EB 51DE F9EC 559C F9ED 566B F9EE 56CD F9EF 59EC F9F0 5B09 F9F1 5E0C F9F2 6199 F9F3 6198 F9F4 6231 F9F5 665E F9F6 66E6 F9F7 7199 F9F8 71B9 F9F9 71BA F9FA 72A7 F9FB 79A7 F9FC 7A00 F9FD 7FB2 F9FE 8A70
191,055
17,210
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_socketserver.py
""" Test suite for socketserver. """ import contextlib import io import os import select import signal import socket import tempfile import unittest import socketserver import test.support from test.support import reap_children, reap_threads, verbose try: import _thread import threading except ImportError: threading = None test.support.requires("network") TEST_STR = b"hello world\n" HOST = test.support.HOST HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") requires_unix_sockets = unittest.skipUnless(HAVE_UNIX_SOCKETS, 'requires Unix sockets') HAVE_FORKING = hasattr(os, "fork") requires_forking = unittest.skipUnless(HAVE_FORKING, 'requires forking') def signal_alarm(n): """Call signal.alarm when it exists (i.e. not on Windows).""" if hasattr(signal, 'alarm'): signal.alarm(n) # Remember real select() to avoid interferences with mocking _real_select = select.select def receive(sock, n, timeout=20): r, w, x = _real_select([sock], [], [], timeout) if sock in r: return sock.recv(n) else: raise RuntimeError("timed out on %r" % (sock,)) if HAVE_UNIX_SOCKETS and HAVE_FORKING: class ForkingUnixStreamServer(socketserver.ForkingMixIn, socketserver.UnixStreamServer): _block_on_close = True class ForkingUnixDatagramServer(socketserver.ForkingMixIn, socketserver.UnixDatagramServer): _block_on_close = True @contextlib.contextmanager def simple_subprocess(testcase): """Tests that a custom child process is not waited on (Issue 1540386)""" pid = os.fork() if pid == 0: # Don't raise an exception; it would be caught by the test harness. os._exit(72) try: yield None except: raise finally: pid2, status = os.waitpid(pid, 0) testcase.assertEqual(pid2, pid) testcase.assertEqual(72 << 8, status) @unittest.skipUnless(threading, 'Threading required for this test.') class SocketServerTest(unittest.TestCase): """Test all socket servers.""" def setUp(self): signal_alarm(60) # Kill deadlocks after 60 seconds. self.port_seed = 0 self.test_files = [] def tearDown(self): signal_alarm(0) # Didn't deadlock. reap_children() for fn in self.test_files: try: os.remove(fn) except OSError: pass self.test_files[:] = [] def pickaddr(self, proto): if proto == socket.AF_INET: return (HOST, 0) else: # XXX: We need a way to tell AF_UNIX to pick its own name # like AF_INET provides port==0. dir = None fn = tempfile.mktemp(prefix='unix_socket.', dir=dir) self.test_files.append(fn) return fn def make_server(self, addr, svrcls, hdlrbase): class MyServer(svrcls): _block_on_close = True def handle_error(self, request, client_address): self.close_request(request) raise class MyHandler(hdlrbase): def handle(self): line = self.rfile.readline() self.wfile.write(line) if verbose: print("creating server") server = MyServer(addr, MyHandler) self.assertEqual(server.server_address, server.socket.getsockname()) return server @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) # We had the OS pick a port, so pull the real address out of # the server. addr = server.server_address if verbose: print("ADDR =", addr) print("CLASS =", svrcls) t = threading.Thread( name='%s serving' % svrcls, target=server.serve_forever, # Short poll interval to make the test finish quickly. # Time between requests is short enough that we won't wake # up spuriously too many times. kwargs={'poll_interval':0.01}) t.daemon = True # In case this function raises. t.start() if verbose: print("server running") for i in range(3): if verbose: print("test client", i) testfunc(svrcls.address_family, addr) if verbose: print("waiting for server") server.shutdown() t.join() server.server_close() self.assertEqual(-1, server.socket.fileno()) if HAVE_FORKING and isinstance(server, socketserver.ForkingMixIn): # bpo-31151: Check that ForkingMixIn.server_close() waits until # all children completed self.assertFalse(server.active_children) if verbose: print("done") def stream_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_STREAM) s.connect(addr) s.sendall(TEST_STR) buf = data = receive(s, 100) while data and b'\n' not in buf: data = receive(s, 100) buf += data self.assertEqual(buf, TEST_STR) s.close() def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) if HAVE_UNIX_SOCKETS and proto == socket.AF_UNIX: s.bind(self.pickaddr(proto)) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and b'\n' not in buf: data = receive(s, 100) buf += data self.assertEqual(buf, TEST_STR) s.close() def test_TCPServer(self): self.run_server(socketserver.TCPServer, socketserver.StreamRequestHandler, self.stream_examine) def test_ThreadingTCPServer(self): self.run_server(socketserver.ThreadingTCPServer, socketserver.StreamRequestHandler, self.stream_examine) @requires_forking def test_ForkingTCPServer(self): with simple_subprocess(self): self.run_server(socketserver.ForkingTCPServer, socketserver.StreamRequestHandler, self.stream_examine) @requires_unix_sockets def test_UnixStreamServer(self): self.run_server(socketserver.UnixStreamServer, socketserver.StreamRequestHandler, self.stream_examine) @requires_unix_sockets def test_ThreadingUnixStreamServer(self): self.run_server(socketserver.ThreadingUnixStreamServer, socketserver.StreamRequestHandler, self.stream_examine) @requires_unix_sockets @requires_forking def test_ForkingUnixStreamServer(self): with simple_subprocess(self): self.run_server(ForkingUnixStreamServer, socketserver.StreamRequestHandler, self.stream_examine) def test_UDPServer(self): self.run_server(socketserver.UDPServer, socketserver.DatagramRequestHandler, self.dgram_examine) def test_ThreadingUDPServer(self): self.run_server(socketserver.ThreadingUDPServer, socketserver.DatagramRequestHandler, self.dgram_examine) @requires_forking def test_ForkingUDPServer(self): with simple_subprocess(self): self.run_server(socketserver.ForkingUDPServer, socketserver.DatagramRequestHandler, self.dgram_examine) @requires_unix_sockets def test_UnixDatagramServer(self): self.run_server(socketserver.UnixDatagramServer, socketserver.DatagramRequestHandler, self.dgram_examine) @requires_unix_sockets def test_ThreadingUnixDatagramServer(self): self.run_server(socketserver.ThreadingUnixDatagramServer, socketserver.DatagramRequestHandler, self.dgram_examine) @requires_unix_sockets @requires_forking def test_ForkingUnixDatagramServer(self): self.run_server(ForkingUnixDatagramServer, socketserver.DatagramRequestHandler, self.dgram_examine) @reap_threads def test_shutdown(self): # Issue #2302: shutdown() should always succeed in making an # other thread leave serve_forever(). class MyServer(socketserver.TCPServer): pass class MyHandler(socketserver.StreamRequestHandler): pass threads = [] for i in range(20): s = MyServer((HOST, 0), MyHandler) t = threading.Thread( name='MyServer serving', target=s.serve_forever, kwargs={'poll_interval':0.01}) t.daemon = True # In case this function raises. threads.append((t, s)) for t, s in threads: t.start() s.shutdown() for t, s in threads: t.join() s.server_close() def test_tcpserver_bind_leak(self): # Issue #22435: the server socket wouldn't be closed if bind()/listen() # failed. # Create many servers for which bind() will fail, to see if this result # in FD exhaustion. for i in range(1024): with self.assertRaises(OverflowError): socketserver.TCPServer((HOST, -1), socketserver.StreamRequestHandler) def test_context_manager(self): with socketserver.TCPServer((HOST, 0), socketserver.StreamRequestHandler) as server: pass self.assertEqual(-1, server.socket.fileno()) class ErrorHandlerTest(unittest.TestCase): """Test that the servers pass normal exceptions from the handler to handle_error(), and that exiting exceptions like SystemExit and KeyboardInterrupt are not passed.""" def tearDown(self): test.support.unlink(test.support.TESTFN) reap_children() def test_sync_handled(self): BaseErrorTestServer(ValueError) self.check_result(handled=True) def test_sync_not_handled(self): with self.assertRaises(SystemExit): BaseErrorTestServer(SystemExit) self.check_result(handled=False) @unittest.skipUnless(threading, 'Threading required for this test.') def test_threading_handled(self): ThreadingErrorTestServer(ValueError) self.check_result(handled=True) @unittest.skipUnless(threading, 'Threading required for this test.') def test_threading_not_handled(self): ThreadingErrorTestServer(SystemExit) self.check_result(handled=False) @requires_forking def test_forking_handled(self): ForkingErrorTestServer(ValueError) self.check_result(handled=True) @requires_forking def test_forking_not_handled(self): ForkingErrorTestServer(SystemExit) self.check_result(handled=False) def check_result(self, handled): with open(test.support.TESTFN) as log: expected = 'Handler called\n' + 'Error handled\n' * handled self.assertEqual(log.read(), expected) class BaseErrorTestServer(socketserver.TCPServer): _block_on_close = True def __init__(self, exception): self.exception = exception super().__init__((HOST, 0), BadHandler) with socket.create_connection(self.server_address): pass try: self.handle_request() finally: self.server_close() self.wait_done() def handle_error(self, request, client_address): with open(test.support.TESTFN, 'a') as log: log.write('Error handled\n') def wait_done(self): pass class BadHandler(socketserver.BaseRequestHandler): def handle(self): with open(test.support.TESTFN, 'a') as log: log.write('Handler called\n') raise self.server.exception('Test error') class ThreadingErrorTestServer(socketserver.ThreadingMixIn, BaseErrorTestServer): def __init__(self, *pos, **kw): self.done = threading.Event() super().__init__(*pos, **kw) def shutdown_request(self, *pos, **kw): super().shutdown_request(*pos, **kw) self.done.set() def wait_done(self): self.done.wait() if HAVE_FORKING: class ForkingErrorTestServer(socketserver.ForkingMixIn, BaseErrorTestServer): _block_on_close = True class SocketWriterTest(unittest.TestCase): def test_basics(self): class Handler(socketserver.StreamRequestHandler): def handle(self): self.server.wfile = self.wfile self.server.wfile_fileno = self.wfile.fileno() self.server.request_fileno = self.request.fileno() server = socketserver.TCPServer((HOST, 0), Handler) self.addCleanup(server.server_close) s = socket.socket( server.address_family, socket.SOCK_STREAM, socket.IPPROTO_TCP) with s: s.connect(server.server_address) server.handle_request() self.assertIsInstance(server.wfile, io.BufferedIOBase) self.assertEqual(server.wfile_fileno, server.request_fileno) @unittest.skipUnless(threading, 'Threading required for this test.') def test_write(self): # Test that wfile.write() sends data immediately, and that it does # not truncate sends when interrupted by a Unix signal pthread_kill = test.support.get_attribute(signal, 'pthread_kill') class Handler(socketserver.StreamRequestHandler): def handle(self): self.server.sent1 = self.wfile.write(b'write data\n') # Should be sent immediately, without requiring flush() self.server.received = self.rfile.readline() big_chunk = b'\0' * test.support.SOCK_MAX_SIZE self.server.sent2 = self.wfile.write(big_chunk) server = socketserver.TCPServer((HOST, 0), Handler) self.addCleanup(server.server_close) interrupted = threading.Event() def signal_handler(signum, frame): interrupted.set() original = signal.signal(signal.SIGUSR1, signal_handler) self.addCleanup(signal.signal, signal.SIGUSR1, original) response1 = None received2 = None main_thread = threading.get_ident() def run_client(): s = socket.socket(server.address_family, socket.SOCK_STREAM, socket.IPPROTO_TCP) with s, s.makefile('rb') as reader: s.connect(server.server_address) nonlocal response1 response1 = reader.readline() s.sendall(b'client response\n') reader.read(100) # The main thread should now be blocking in a send() syscall. # But in theory, it could get interrupted by other signals, # and then retried. So keep sending the signal in a loop, in # case an earlier signal happens to be delivered at an # inconvenient moment. while True: pthread_kill(main_thread, signal.SIGUSR1) if interrupted.wait(timeout=float(1)): break nonlocal received2 received2 = len(reader.read()) background = threading.Thread(target=run_client) background.start() server.handle_request() background.join() self.assertEqual(server.sent1, len(response1)) self.assertEqual(response1, b'write data\n') self.assertEqual(server.received, b'client response\n') self.assertEqual(server.sent2, test.support.SOCK_MAX_SIZE) self.assertEqual(received2, test.support.SOCK_MAX_SIZE - 100) class MiscTestCase(unittest.TestCase): def test_all(self): # objects defined in the module should be in __all__ expected = [] for name in dir(socketserver): if not name.startswith('_'): mod_object = getattr(socketserver, name) if getattr(mod_object, '__module__', None) == 'socketserver': expected.append(name) self.assertCountEqual(socketserver.__all__, expected) def test_shutdown_request_called_if_verify_request_false(self): # Issue #26309: BaseServer should call shutdown_request even if # verify_request is False class MyServer(socketserver.TCPServer): def verify_request(self, request, client_address): return False shutdown_called = 0 def shutdown_request(self, request): self.shutdown_called += 1 socketserver.TCPServer.shutdown_request(self, request) server = MyServer((HOST, 0), socketserver.StreamRequestHandler) s = socket.socket(server.address_family, socket.SOCK_STREAM) s.connect(server.server_address) s.close() server.handle_request() self.assertEqual(server.shutdown_called, 1) server.server_close() if __name__ == "__main__": unittest.main()
17,545
505
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_future4.py
from __future__ import unicode_literals import unittest if __name__ == "__main__": unittest.main()
105
7
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_statistics.py
"""Test suite for statistics module, including helper NumericTestCase and approx_equal function. """ import cosmo import collections import decimal import doctest import math import random import sys import unittest from decimal import Decimal from fractions import Fraction # Module to be tested. import statistics # === Helper functions and class === def sign(x): """Return -1.0 for negatives, including -0.0, otherwise +1.0.""" return math.copysign(1, x) def _nan_equal(a, b): """Return True if a and b are both the same kind of NAN. >>> _nan_equal(Decimal('NAN'), Decimal('NAN')) True >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN')) True >>> _nan_equal(Decimal('NAN'), Decimal('sNAN')) False >>> _nan_equal(Decimal(42), Decimal('NAN')) False >>> _nan_equal(float('NAN'), float('NAN')) True >>> _nan_equal(float('NAN'), 0.5) False >>> _nan_equal(float('NAN'), Decimal('NAN')) False NAN payloads are not compared. """ if type(a) is not type(b): return False if isinstance(a, float): return math.isnan(a) and math.isnan(b) aexp = a.as_tuple()[2] bexp = b.as_tuple()[2] return (aexp == bexp) and (aexp in ('n', 'N')) # Both NAN or both sNAN. def _calc_errors(actual, expected): """Return the absolute and relative errors between two numbers. >>> _calc_errors(100, 75) (25, 0.25) >>> _calc_errors(100, 100) (0, 0.0) Returns the (absolute error, relative error) between the two arguments. """ base = max(abs(actual), abs(expected)) abs_err = abs(actual - expected) rel_err = abs_err/base if base else float('inf') return (abs_err, rel_err) def approx_equal(x, y, tol=1e-12, rel=1e-7): """approx_equal(x, y [, tol [, rel]]) => True|False Return True if numbers x and y are approximately equal, to within some margin of error, otherwise return False. Numbers which compare equal will also compare approximately equal. x is approximately equal to y if the difference between them is less than an absolute error tol or a relative error rel, whichever is bigger. If given, both tol and rel must be finite, non-negative numbers. If not given, default values are tol=1e-12 and rel=1e-7. >>> approx_equal(1.2589, 1.2587, tol=0.0003, rel=0) True >>> approx_equal(1.2589, 1.2587, tol=0.0001, rel=0) False Absolute error is defined as abs(x-y); if that is less than or equal to tol, x and y are considered approximately equal. Relative error is defined as abs((x-y)/x) or abs((x-y)/y), whichever is smaller, provided x or y are not zero. If that figure is less than or equal to rel, x and y are considered approximately equal. Complex numbers are not directly supported. If you wish to compare to complex numbers, extract their real and imaginary parts and compare them individually. NANs always compare unequal, even with themselves. Infinities compare approximately equal if they have the same sign (both positive or both negative). Infinities with different signs compare unequal; so do comparisons of infinities with finite numbers. """ if tol < 0 or rel < 0: raise ValueError('error tolerances must be non-negative') # NANs are never equal to anything, approximately or otherwise. if math.isnan(x) or math.isnan(y): return False # Numbers which compare equal also compare approximately equal. if x == y: # This includes the case of two infinities with the same sign. return True if math.isinf(x) or math.isinf(y): # This includes the case of two infinities of opposite sign, or # one infinity and one finite number. return False # Two finite numbers. actual_error = abs(x - y) allowed_error = max(tol, rel*max(abs(x), abs(y))) return actual_error <= allowed_error # This class exists only as somewhere to stick a docstring containing # doctests. The following docstring and tests were originally in a separate # module. Now that it has been merged in here, I need somewhere to hang the. # docstring. Ultimately, this class will die, and the information below will # either become redundant, or be moved into more appropriate places. class _DoNothing: """ When doing numeric work, especially with floats, exact equality is often not what you want. Due to round-off error, it is often a bad idea to try to compare floats with equality. Instead the usual procedure is to test them with some (hopefully small!) allowance for error. The ``approx_equal`` function allows you to specify either an absolute error tolerance, or a relative error, or both. Absolute error tolerances are simple, but you need to know the magnitude of the quantities being compared: >>> approx_equal(12.345, 12.346, tol=1e-3) True >>> approx_equal(12.345e6, 12.346e6, tol=1e-3) # tol is too small. False Relative errors are more suitable when the values you are comparing can vary in magnitude: >>> approx_equal(12.345, 12.346, rel=1e-4) True >>> approx_equal(12.345e6, 12.346e6, rel=1e-4) True but a naive implementation of relative error testing can run into trouble around zero. If you supply both an absolute tolerance and a relative error, the comparison succeeds if either individual test succeeds: >>> approx_equal(12.345e6, 12.346e6, tol=1e-3, rel=1e-4) True """ pass # We prefer this for testing numeric values that may not be exactly equal, # and avoid using TestCase.assertAlmostEqual, because it sucks :-) class NumericTestCase(unittest.TestCase): """Unit test class for numeric work. This subclasses TestCase. In addition to the standard method ``TestCase.assertAlmostEqual``, ``assertApproxEqual`` is provided. """ # By default, we expect exact equality, unless overridden. tol = rel = 0 def assertApproxEqual( self, first, second, tol=None, rel=None, msg=None ): """Test passes if ``first`` and ``second`` are approximately equal. This test passes if ``first`` and ``second`` are equal to within ``tol``, an absolute error, or ``rel``, a relative error. If either ``tol`` or ``rel`` are None or not given, they default to test attributes of the same name (by default, 0). The objects may be either numbers, or sequences of numbers. Sequences are tested element-by-element. >>> class MyTest(NumericTestCase): ... def test_number(self): ... x = 1.0/6 ... y = sum([x]*6) ... self.assertApproxEqual(y, 1.0, tol=1e-15) ... def test_sequence(self): ... a = [1.001, 1.001e-10, 1.001e10] ... b = [1.0, 1e-10, 1e10] ... self.assertApproxEqual(a, b, rel=1e-3) ... >>> import unittest >>> from io import StringIO # Suppress test runner output. >>> suite = unittest.TestLoader().loadTestsFromTestCase(MyTest) >>> unittest.TextTestRunner(stream=StringIO()).run(suite) <unittest.runner.TextTestResult run=2 errors=0 failures=0> """ if tol is None: tol = self.tol if rel is None: rel = self.rel if ( isinstance(first, collections.Sequence) and isinstance(second, collections.Sequence) ): check = self._check_approx_seq else: check = self._check_approx_num check(first, second, tol, rel, msg) def _check_approx_seq(self, first, second, tol, rel, msg): if len(first) != len(second): standardMsg = ( "sequences differ in length: %d items != %d items" % (len(first), len(second)) ) msg = self._formatMessage(msg, standardMsg) raise self.failureException(msg) for i, (a,e) in enumerate(zip(first, second)): self._check_approx_num(a, e, tol, rel, msg, i) def _check_approx_num(self, first, second, tol, rel, msg, idx=None): if approx_equal(first, second, tol, rel): # Test passes. Return early, we are done. return None # Otherwise we failed. standardMsg = self._make_std_err_msg(first, second, tol, rel, idx) msg = self._formatMessage(msg, standardMsg) raise self.failureException(msg) @staticmethod def _make_std_err_msg(first, second, tol, rel, idx): # Create the standard error message for approx_equal failures. assert first != second template = ( ' %r != %r\n' ' values differ by more than tol=%r and rel=%r\n' ' -> absolute error = %r\n' ' -> relative error = %r' ) if idx is not None: header = 'numeric sequences first differ at index %d.\n' % idx template = header + template # Calculate actual errors: abs_err, rel_err = _calc_errors(first, second) return template % (first, second, tol, rel, abs_err, rel_err) # ======================== # === Test the helpers === # ======================== class TestSign(unittest.TestCase): """Test that the helper function sign() works correctly.""" def testZeroes(self): # Test that signed zeroes report their sign correctly. self.assertEqual(sign(0.0), +1) self.assertEqual(sign(-0.0), -1) # --- Tests for approx_equal --- class ApproxEqualSymmetryTest(unittest.TestCase): # Test symmetry of approx_equal. def test_relative_symmetry(self): # Check that approx_equal treats relative error symmetrically. # (a-b)/a is usually not equal to (a-b)/b. Ensure that this # doesn't matter. # # Note: the reason for this test is that an early version # of approx_equal was not symmetric. A relative error test # would pass, or fail, depending on which value was passed # as the first argument. # args1 = [2456, 37.8, -12.45, Decimal('2.54'), Fraction(17, 54)] args2 = [2459, 37.2, -12.41, Decimal('2.59'), Fraction(15, 54)] assert len(args1) == len(args2) for a, b in zip(args1, args2): self.do_relative_symmetry(a, b) def do_relative_symmetry(self, a, b): a, b = min(a, b), max(a, b) assert a < b delta = b - a # The absolute difference between the values. rel_err1, rel_err2 = abs(delta/a), abs(delta/b) # Choose an error margin halfway between the two. rel = (rel_err1 + rel_err2)/2 # Now see that values a and b compare approx equal regardless of # which is given first. self.assertTrue(approx_equal(a, b, tol=0, rel=rel)) self.assertTrue(approx_equal(b, a, tol=0, rel=rel)) def test_symmetry(self): # Test that approx_equal(a, b) == approx_equal(b, a) args = [-23, -2, 5, 107, 93568] delta = 2 for a in args: for type_ in (int, float, Decimal, Fraction): x = type_(a)*100 y = x + delta r = abs(delta/max(x, y)) # There are five cases to check: # 1) actual error <= tol, <= rel self.do_symmetry_test(x, y, tol=delta, rel=r) self.do_symmetry_test(x, y, tol=delta+1, rel=2*r) # 2) actual error > tol, > rel self.do_symmetry_test(x, y, tol=delta-1, rel=r/2) # 3) actual error <= tol, > rel self.do_symmetry_test(x, y, tol=delta, rel=r/2) # 4) actual error > tol, <= rel self.do_symmetry_test(x, y, tol=delta-1, rel=r) self.do_symmetry_test(x, y, tol=delta-1, rel=2*r) # 5) exact equality test self.do_symmetry_test(x, x, tol=0, rel=0) self.do_symmetry_test(x, y, tol=0, rel=0) def do_symmetry_test(self, a, b, tol, rel): template = "approx_equal comparisons don't match for %r" flag1 = approx_equal(a, b, tol, rel) flag2 = approx_equal(b, a, tol, rel) self.assertEqual(flag1, flag2, template.format((a, b, tol, rel))) class ApproxEqualExactTest(unittest.TestCase): # Test the approx_equal function with exactly equal values. # Equal values should compare as approximately equal. # Test cases for exactly equal values, which should compare approx # equal regardless of the error tolerances given. def do_exactly_equal_test(self, x, tol, rel): result = approx_equal(x, x, tol=tol, rel=rel) self.assertTrue(result, 'equality failure for x=%r' % x) result = approx_equal(-x, -x, tol=tol, rel=rel) self.assertTrue(result, 'equality failure for x=%r' % -x) def test_exactly_equal_ints(self): # Test that equal int values are exactly equal. for n in [42, 19740, 14974, 230, 1795, 700245, 36587]: self.do_exactly_equal_test(n, 0, 0) def test_exactly_equal_floats(self): # Test that equal float values are exactly equal. for x in [0.42, 1.9740, 1497.4, 23.0, 179.5, 70.0245, 36.587]: self.do_exactly_equal_test(x, 0, 0) def test_exactly_equal_fractions(self): # Test that equal Fraction values are exactly equal. F = Fraction for f in [F(1, 2), F(0), F(5, 3), F(9, 7), F(35, 36), F(3, 7)]: self.do_exactly_equal_test(f, 0, 0) def test_exactly_equal_decimals(self): # Test that equal Decimal values are exactly equal. D = Decimal for d in map(D, "8.2 31.274 912.04 16.745 1.2047".split()): self.do_exactly_equal_test(d, 0, 0) def test_exactly_equal_absolute(self): # Test that equal values are exactly equal with an absolute error. for n in [16, 1013, 1372, 1198, 971, 4]: # Test as ints. self.do_exactly_equal_test(n, 0.01, 0) # Test as floats. self.do_exactly_equal_test(n/10, 0.01, 0) # Test as Fractions. f = Fraction(n, 1234) self.do_exactly_equal_test(f, 0.01, 0) def test_exactly_equal_absolute_decimals(self): # Test equal Decimal values are exactly equal with an absolute error. self.do_exactly_equal_test(Decimal("3.571"), Decimal("0.01"), 0) self.do_exactly_equal_test(-Decimal("81.3971"), Decimal("0.01"), 0) def test_exactly_equal_relative(self): # Test that equal values are exactly equal with a relative error. for x in [8347, 101.3, -7910.28, Fraction(5, 21)]: self.do_exactly_equal_test(x, 0, 0.01) self.do_exactly_equal_test(Decimal("11.68"), 0, Decimal("0.01")) def test_exactly_equal_both(self): # Test that equal values are equal when both tol and rel are given. for x in [41017, 16.742, -813.02, Fraction(3, 8)]: self.do_exactly_equal_test(x, 0.1, 0.01) D = Decimal self.do_exactly_equal_test(D("7.2"), D("0.1"), D("0.01")) class ApproxEqualUnequalTest(unittest.TestCase): # Unequal values should compare unequal with zero error tolerances. # Test cases for unequal values, with exact equality test. def do_exactly_unequal_test(self, x): for a in (x, -x): result = approx_equal(a, a+1, tol=0, rel=0) self.assertFalse(result, 'inequality failure for x=%r' % a) def test_exactly_unequal_ints(self): # Test unequal int values are unequal with zero error tolerance. for n in [951, 572305, 478, 917, 17240]: self.do_exactly_unequal_test(n) def test_exactly_unequal_floats(self): # Test unequal float values are unequal with zero error tolerance. for x in [9.51, 5723.05, 47.8, 9.17, 17.24]: self.do_exactly_unequal_test(x) def test_exactly_unequal_fractions(self): # Test that unequal Fractions are unequal with zero error tolerance. F = Fraction for f in [F(1, 5), F(7, 9), F(12, 11), F(101, 99023)]: self.do_exactly_unequal_test(f) def test_exactly_unequal_decimals(self): # Test that unequal Decimals are unequal with zero error tolerance. for d in map(Decimal, "3.1415 298.12 3.47 18.996 0.00245".split()): self.do_exactly_unequal_test(d) class ApproxEqualInexactTest(unittest.TestCase): # Inexact test cases for approx_error. # Test cases when comparing two values that are not exactly equal. # === Absolute error tests === def do_approx_equal_abs_test(self, x, delta): template = "Test failure for x={!r}, y={!r}" for y in (x + delta, x - delta): msg = template.format(x, y) self.assertTrue(approx_equal(x, y, tol=2*delta, rel=0), msg) self.assertFalse(approx_equal(x, y, tol=delta/2, rel=0), msg) def test_approx_equal_absolute_ints(self): # Test approximate equality of ints with an absolute error. for n in [-10737, -1975, -7, -2, 0, 1, 9, 37, 423, 9874, 23789110]: self.do_approx_equal_abs_test(n, 10) self.do_approx_equal_abs_test(n, 2) def test_approx_equal_absolute_floats(self): # Test approximate equality of floats with an absolute error. for x in [-284.126, -97.1, -3.4, -2.15, 0.5, 1.0, 7.8, 4.23, 3817.4]: self.do_approx_equal_abs_test(x, 1.5) self.do_approx_equal_abs_test(x, 0.01) self.do_approx_equal_abs_test(x, 0.0001) def test_approx_equal_absolute_fractions(self): # Test approximate equality of Fractions with an absolute error. delta = Fraction(1, 29) numerators = [-84, -15, -2, -1, 0, 1, 5, 17, 23, 34, 71] for f in (Fraction(n, 29) for n in numerators): self.do_approx_equal_abs_test(f, delta) self.do_approx_equal_abs_test(f, float(delta)) def test_approx_equal_absolute_decimals(self): # Test approximate equality of Decimals with an absolute error. delta = Decimal("0.01") for d in map(Decimal, "1.0 3.5 36.08 61.79 7912.3648".split()): self.do_approx_equal_abs_test(d, delta) self.do_approx_equal_abs_test(-d, delta) def test_cross_zero(self): # Test for the case of the two values having opposite signs. self.assertTrue(approx_equal(1e-5, -1e-5, tol=1e-4, rel=0)) # === Relative error tests === def do_approx_equal_rel_test(self, x, delta): template = "Test failure for x={!r}, y={!r}" for y in (x*(1+delta), x*(1-delta)): msg = template.format(x, y) self.assertTrue(approx_equal(x, y, tol=0, rel=2*delta), msg) self.assertFalse(approx_equal(x, y, tol=0, rel=delta/2), msg) def test_approx_equal_relative_ints(self): # Test approximate equality of ints with a relative error. self.assertTrue(approx_equal(64, 47, tol=0, rel=0.36)) self.assertTrue(approx_equal(64, 47, tol=0, rel=0.37)) # --- self.assertTrue(approx_equal(449, 512, tol=0, rel=0.125)) self.assertTrue(approx_equal(448, 512, tol=0, rel=0.125)) self.assertFalse(approx_equal(447, 512, tol=0, rel=0.125)) def test_approx_equal_relative_floats(self): # Test approximate equality of floats with a relative error. for x in [-178.34, -0.1, 0.1, 1.0, 36.97, 2847.136, 9145.074]: self.do_approx_equal_rel_test(x, 0.02) self.do_approx_equal_rel_test(x, 0.0001) def test_approx_equal_relative_fractions(self): # Test approximate equality of Fractions with a relative error. F = Fraction delta = Fraction(3, 8) for f in [F(3, 84), F(17, 30), F(49, 50), F(92, 85)]: for d in (delta, float(delta)): self.do_approx_equal_rel_test(f, d) self.do_approx_equal_rel_test(-f, d) def test_approx_equal_relative_decimals(self): # Test approximate equality of Decimals with a relative error. for d in map(Decimal, "0.02 1.0 5.7 13.67 94.138 91027.9321".split()): self.do_approx_equal_rel_test(d, Decimal("0.001")) self.do_approx_equal_rel_test(-d, Decimal("0.05")) # === Both absolute and relative error tests === # There are four cases to consider: # 1) actual error <= both absolute and relative error # 2) actual error <= absolute error but > relative error # 3) actual error <= relative error but > absolute error # 4) actual error > both absolute and relative error def do_check_both(self, a, b, tol, rel, tol_flag, rel_flag): check = self.assertTrue if tol_flag else self.assertFalse check(approx_equal(a, b, tol=tol, rel=0)) check = self.assertTrue if rel_flag else self.assertFalse check(approx_equal(a, b, tol=0, rel=rel)) check = self.assertTrue if (tol_flag or rel_flag) else self.assertFalse check(approx_equal(a, b, tol=tol, rel=rel)) def test_approx_equal_both1(self): # Test actual error <= both absolute and relative error. self.do_check_both(7.955, 7.952, 0.004, 3.8e-4, True, True) self.do_check_both(-7.387, -7.386, 0.002, 0.0002, True, True) def test_approx_equal_both2(self): # Test actual error <= absolute error but > relative error. self.do_check_both(7.955, 7.952, 0.004, 3.7e-4, True, False) def test_approx_equal_both3(self): # Test actual error <= relative error but > absolute error. self.do_check_both(7.955, 7.952, 0.001, 3.8e-4, False, True) def test_approx_equal_both4(self): # Test actual error > both absolute and relative error. self.do_check_both(2.78, 2.75, 0.01, 0.001, False, False) self.do_check_both(971.44, 971.47, 0.02, 3e-5, False, False) class ApproxEqualSpecialsTest(unittest.TestCase): # Test approx_equal with NANs and INFs and zeroes. def test_inf(self): for type_ in (float, Decimal): inf = type_('inf') self.assertTrue(approx_equal(inf, inf)) self.assertTrue(approx_equal(inf, inf, 0, 0)) self.assertTrue(approx_equal(inf, inf, 1, 0.01)) self.assertTrue(approx_equal(-inf, -inf)) self.assertFalse(approx_equal(inf, -inf)) self.assertFalse(approx_equal(inf, 1000)) def test_nan(self): for type_ in (float, Decimal): nan = type_('nan') for other in (nan, type_('inf'), 1000): self.assertFalse(approx_equal(nan, other)) def test_float_zeroes(self): nzero = math.copysign(0.0, -1) self.assertTrue(approx_equal(nzero, 0.0, tol=0.1, rel=0.1)) def test_decimal_zeroes(self): nzero = Decimal("-0.0") self.assertTrue(approx_equal(nzero, Decimal(0), tol=0.1, rel=0.1)) class TestApproxEqualErrors(unittest.TestCase): # Test error conditions of approx_equal. def test_bad_tol(self): # Test negative tol raises. self.assertRaises(ValueError, approx_equal, 100, 100, -1, 0.1) def test_bad_rel(self): # Test negative rel raises. self.assertRaises(ValueError, approx_equal, 100, 100, 1, -0.1) # --- Tests for NumericTestCase --- # The formatting routine that generates the error messages is complex enough # that it too needs testing. class TestNumericTestCase(unittest.TestCase): # The exact wording of NumericTestCase error messages is *not* guaranteed, # but we need to give them some sort of test to ensure that they are # generated correctly. As a compromise, we look for specific substrings # that are expected to be found even if the overall error message changes. def do_test(self, args): actual_msg = NumericTestCase._make_std_err_msg(*args) expected = self.generate_substrings(*args) for substring in expected: self.assertIn(substring, actual_msg) def test_numerictestcase_is_testcase(self): # Ensure that NumericTestCase actually is a TestCase. self.assertTrue(issubclass(NumericTestCase, unittest.TestCase)) def test_error_msg_numeric(self): # Test the error message generated for numeric comparisons. args = (2.5, 4.0, 0.5, 0.25, None) self.do_test(args) def test_error_msg_sequence(self): # Test the error message generated for sequence comparisons. args = (3.75, 8.25, 1.25, 0.5, 7) self.do_test(args) def generate_substrings(self, first, second, tol, rel, idx): """Return substrings we expect to see in error messages.""" abs_err, rel_err = _calc_errors(first, second) substrings = [ 'tol=%r' % tol, 'rel=%r' % rel, 'absolute error = %r' % abs_err, 'relative error = %r' % rel_err, ] if idx is not None: substrings.append('differ at index %d' % idx) return substrings # ======================================= # === Tests for the statistics module === # ======================================= class GlobalsTest(unittest.TestCase): module = statistics expected_metadata = ["__doc__", "__all__"] def test_meta(self): # Test for the existence of metadata. for meta in self.expected_metadata: self.assertTrue(hasattr(self.module, meta), "%s not present" % meta) def test_check_all(self): # Check everything in __all__ exists and is public. module = self.module for name in module.__all__: # No private names in __all__: self.assertFalse(name.startswith("_"), 'private name "%s" in __all__' % name) # And anything in __all__ must exist: self.assertTrue(hasattr(module, name), 'missing name "%s" in __all__' % name) class DocTests(unittest.TestCase): @unittest.skipIf(cosmo.MODE in ('tiny', 'rel'), "No docstrings in MODE=tiny/rel") @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -OO and above") def test_doc_tests(self): failed, tried = doctest.testmod(statistics, optionflags=doctest.ELLIPSIS) self.assertGreater(tried, 0) self.assertEqual(failed, 0) class StatisticsErrorTest(unittest.TestCase): def test_has_exception(self): errmsg = ( "Expected StatisticsError to be a ValueError, but got a" " subclass of %r instead." ) self.assertTrue(hasattr(statistics, 'StatisticsError')) self.assertTrue( issubclass(statistics.StatisticsError, ValueError), errmsg % statistics.StatisticsError.__base__ ) # === Tests for private utility functions === class ExactRatioTest(unittest.TestCase): # Test _exact_ratio utility. def test_int(self): for i in (-20, -3, 0, 5, 99, 10**20): self.assertEqual(statistics._exact_ratio(i), (i, 1)) def test_fraction(self): numerators = (-5, 1, 12, 38) for n in numerators: f = Fraction(n, 37) self.assertEqual(statistics._exact_ratio(f), (n, 37)) def test_float(self): self.assertEqual(statistics._exact_ratio(0.125), (1, 8)) self.assertEqual(statistics._exact_ratio(1.125), (9, 8)) data = [random.uniform(-100, 100) for _ in range(100)] for x in data: num, den = statistics._exact_ratio(x) self.assertEqual(x, num/den) def test_decimal(self): D = Decimal _exact_ratio = statistics._exact_ratio self.assertEqual(_exact_ratio(D("0.125")), (1, 8)) self.assertEqual(_exact_ratio(D("12.345")), (2469, 200)) self.assertEqual(_exact_ratio(D("-1.98")), (-99, 50)) def test_inf(self): INF = float("INF") class MyFloat(float): pass class MyDecimal(Decimal): pass for inf in (INF, -INF): for type_ in (float, MyFloat, Decimal, MyDecimal): x = type_(inf) ratio = statistics._exact_ratio(x) self.assertEqual(ratio, (x, None)) self.assertEqual(type(ratio[0]), type_) self.assertTrue(math.isinf(ratio[0])) def test_float_nan(self): NAN = float("NAN") class MyFloat(float): pass for nan in (NAN, MyFloat(NAN)): ratio = statistics._exact_ratio(nan) self.assertTrue(math.isnan(ratio[0])) self.assertIs(ratio[1], None) self.assertEqual(type(ratio[0]), type(nan)) def test_decimal_nan(self): NAN = Decimal("NAN") sNAN = Decimal("sNAN") class MyDecimal(Decimal): pass for nan in (NAN, MyDecimal(NAN), sNAN, MyDecimal(sNAN)): ratio = statistics._exact_ratio(nan) self.assertTrue(_nan_equal(ratio[0], nan)) self.assertIs(ratio[1], None) self.assertEqual(type(ratio[0]), type(nan)) class DecimalToRatioTest(unittest.TestCase): # Test _exact_ratio private function. def test_infinity(self): # Test that INFs are handled correctly. inf = Decimal('INF') self.assertEqual(statistics._exact_ratio(inf), (inf, None)) self.assertEqual(statistics._exact_ratio(-inf), (-inf, None)) def test_nan(self): # Test that NANs are handled correctly. for nan in (Decimal('NAN'), Decimal('sNAN')): num, den = statistics._exact_ratio(nan) # Because NANs always compare non-equal, we cannot use assertEqual. # Nor can we use an identity test, as we don't guarantee anything # about the object identity. self.assertTrue(_nan_equal(num, nan)) self.assertIs(den, None) def test_sign(self): # Test sign is calculated correctly. numbers = [Decimal("9.8765e12"), Decimal("9.8765e-12")] for d in numbers: # First test positive decimals. assert d > 0 num, den = statistics._exact_ratio(d) self.assertGreaterEqual(num, 0) self.assertGreater(den, 0) # Then test negative decimals. num, den = statistics._exact_ratio(-d) self.assertLessEqual(num, 0) self.assertGreater(den, 0) def test_negative_exponent(self): # Test result when the exponent is negative. t = statistics._exact_ratio(Decimal("0.1234")) self.assertEqual(t, (617, 5000)) def test_positive_exponent(self): # Test results when the exponent is positive. t = statistics._exact_ratio(Decimal("1.234e7")) self.assertEqual(t, (12340000, 1)) def test_regression_20536(self): # Regression test for issue 20536. # See http://bugs.python.org/issue20536 t = statistics._exact_ratio(Decimal("1e2")) self.assertEqual(t, (100, 1)) t = statistics._exact_ratio(Decimal("1.47e5")) self.assertEqual(t, (147000, 1)) class IsFiniteTest(unittest.TestCase): # Test _isfinite private function. def test_finite(self): # Test that finite numbers are recognised as finite. for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")): self.assertTrue(statistics._isfinite(x)) def test_infinity(self): # Test that INFs are not recognised as finite. for x in (float("inf"), Decimal("inf")): self.assertFalse(statistics._isfinite(x)) def test_nan(self): # Test that NANs are not recognised as finite. for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")): self.assertFalse(statistics._isfinite(x)) class CoerceTest(unittest.TestCase): # Test that private function _coerce correctly deals with types. # The coercion rules are currently an implementation detail, although at # some point that should change. The tests and comments here define the # correct implementation. # Pre-conditions of _coerce: # # - The first time _sum calls _coerce, the # - coerce(T, S) will never be called with bool as the first argument; # this is a pre-condition, guarded with an assertion. # # - coerce(T, T) will always return T; we assume T is a valid numeric # type. Violate this assumption at your own risk. # # - Apart from as above, bool is treated as if it were actually int. # # - coerce(int, X) and coerce(X, int) return X. # - def test_bool(self): # bool is somewhat special, due to the pre-condition that it is # never given as the first argument to _coerce, and that it cannot # be subclassed. So we test it specially. for T in (int, float, Fraction, Decimal): self.assertIs(statistics._coerce(T, bool), T) class MyClass(T): pass self.assertIs(statistics._coerce(MyClass, bool), MyClass) def assertCoerceTo(self, A, B): """Assert that type A coerces to B.""" self.assertIs(statistics._coerce(A, B), B) self.assertIs(statistics._coerce(B, A), B) def check_coerce_to(self, A, B): """Checks that type A coerces to B, including subclasses.""" # Assert that type A is coerced to B. self.assertCoerceTo(A, B) # Subclasses of A are also coerced to B. class SubclassOfA(A): pass self.assertCoerceTo(SubclassOfA, B) # A, and subclasses of A, are coerced to subclasses of B. class SubclassOfB(B): pass self.assertCoerceTo(A, SubclassOfB) self.assertCoerceTo(SubclassOfA, SubclassOfB) def assertCoerceRaises(self, A, B): """Assert that coercing A to B, or vice versa, raises TypeError.""" self.assertRaises(TypeError, statistics._coerce, (A, B)) self.assertRaises(TypeError, statistics._coerce, (B, A)) def check_type_coercions(self, T): """Check that type T coerces correctly with subclasses of itself.""" assert T is not bool # Coercing a type with itself returns the same type. self.assertIs(statistics._coerce(T, T), T) # Coercing a type with a subclass of itself returns the subclass. class U(T): pass class V(T): pass class W(U): pass for typ in (U, V, W): self.assertCoerceTo(T, typ) self.assertCoerceTo(U, W) # Coercing two subclasses that aren't parent/child is an error. self.assertCoerceRaises(U, V) self.assertCoerceRaises(V, W) def test_int(self): # Check that int coerces correctly. self.check_type_coercions(int) for typ in (float, Fraction, Decimal): self.check_coerce_to(int, typ) def test_fraction(self): # Check that Fraction coerces correctly. self.check_type_coercions(Fraction) self.check_coerce_to(Fraction, float) def test_decimal(self): # Check that Decimal coerces correctly. self.check_type_coercions(Decimal) def test_float(self): # Check that float coerces correctly. self.check_type_coercions(float) def test_non_numeric_types(self): for bad_type in (str, list, type(None), tuple, dict): for good_type in (int, float, Fraction, Decimal): self.assertCoerceRaises(good_type, bad_type) def test_incompatible_types(self): # Test that incompatible types raise. for T in (float, Fraction): class MySubclass(T): pass self.assertCoerceRaises(T, Decimal) self.assertCoerceRaises(MySubclass, Decimal) class ConvertTest(unittest.TestCase): # Test private _convert function. def check_exact_equal(self, x, y): """Check that x equals y, and has the same type as well.""" self.assertEqual(x, y) self.assertIs(type(x), type(y)) def test_int(self): # Test conversions to int. x = statistics._convert(Fraction(71), int) self.check_exact_equal(x, 71) class MyInt(int): pass x = statistics._convert(Fraction(17), MyInt) self.check_exact_equal(x, MyInt(17)) def test_fraction(self): # Test conversions to Fraction. x = statistics._convert(Fraction(95, 99), Fraction) self.check_exact_equal(x, Fraction(95, 99)) class MyFraction(Fraction): def __truediv__(self, other): return self.__class__(super().__truediv__(other)) x = statistics._convert(Fraction(71, 13), MyFraction) self.check_exact_equal(x, MyFraction(71, 13)) def test_float(self): # Test conversions to float. x = statistics._convert(Fraction(-1, 2), float) self.check_exact_equal(x, -0.5) class MyFloat(float): def __truediv__(self, other): return self.__class__(super().__truediv__(other)) x = statistics._convert(Fraction(9, 8), MyFloat) self.check_exact_equal(x, MyFloat(1.125)) def test_decimal(self): # Test conversions to Decimal. x = statistics._convert(Fraction(1, 40), Decimal) self.check_exact_equal(x, Decimal("0.025")) class MyDecimal(Decimal): def __truediv__(self, other): return self.__class__(super().__truediv__(other)) x = statistics._convert(Fraction(-15, 16), MyDecimal) self.check_exact_equal(x, MyDecimal("-0.9375")) def test_inf(self): for INF in (float('inf'), Decimal('inf')): for inf in (INF, -INF): x = statistics._convert(inf, type(inf)) self.check_exact_equal(x, inf) def test_nan(self): for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')): x = statistics._convert(nan, type(nan)) self.assertTrue(_nan_equal(x, nan)) class FailNegTest(unittest.TestCase): """Test _fail_neg private function.""" def test_pass_through(self): # Test that values are passed through unchanged. values = [1, 2.0, Fraction(3), Decimal(4)] new = list(statistics._fail_neg(values)) self.assertEqual(values, new) def test_negatives_raise(self): # Test that negatives raise an exception. for x in [1, 2.0, Fraction(3), Decimal(4)]: seq = [-x] it = statistics._fail_neg(seq) self.assertRaises(statistics.StatisticsError, next, it) def test_error_msg(self): # Test that a given error message is used. msg = "badness #%d" % random.randint(10000, 99999) try: next(statistics._fail_neg([-1], msg)) except statistics.StatisticsError as e: errmsg = e.args[0] else: self.fail("expected exception, but it didn't happen") self.assertEqual(errmsg, msg) # === Tests for public functions === class UnivariateCommonMixin: # Common tests for most univariate functions that take a data argument. def test_no_args(self): # Fail if given no arguments. self.assertRaises(TypeError, self.func) def test_empty_data(self): # Fail when the data argument (first argument) is empty. for empty in ([], (), iter([])): self.assertRaises(statistics.StatisticsError, self.func, empty) def prepare_data(self): """Return int data for various tests.""" data = list(range(10)) while data == sorted(data): random.shuffle(data) return data def test_no_inplace_modifications(self): # Test that the function does not modify its input data. data = self.prepare_data() assert len(data) != 1 # Necessary to avoid infinite loop. assert data != sorted(data) saved = data[:] assert data is not saved _ = self.func(data) self.assertListEqual(data, saved, "data has been modified") def test_order_doesnt_matter(self): # Test that the order of data points doesn't change the result. # CAUTION: due to floating point rounding errors, the result actually # may depend on the order. Consider this test representing an ideal. # To avoid this test failing, only test with exact values such as ints # or Fractions. data = [1, 2, 3, 3, 3, 4, 5, 6]*100 expected = self.func(data) random.shuffle(data) actual = self.func(data) self.assertEqual(expected, actual) def test_type_of_data_collection(self): # Test that the type of iterable data doesn't effect the result. class MyList(list): pass class MyTuple(tuple): pass def generator(data): return (obj for obj in data) data = self.prepare_data() expected = self.func(data) for kind in (list, tuple, iter, MyList, MyTuple, generator): result = self.func(kind(data)) self.assertEqual(result, expected) def test_range_data(self): # Test that functions work with range objects. data = range(20, 50, 3) expected = self.func(list(data)) self.assertEqual(self.func(data), expected) def test_bad_arg_types(self): # Test that function raises when given data of the wrong type. # Don't roll the following into a loop like this: # for bad in list_of_bad: # self.check_for_type_error(bad) # # Since assertRaises doesn't show the arguments that caused the test # failure, it is very difficult to debug these test failures when the # following are in a loop. self.check_for_type_error(None) self.check_for_type_error(23) self.check_for_type_error(42.0) self.check_for_type_error(object()) def check_for_type_error(self, *args): self.assertRaises(TypeError, self.func, *args) def test_type_of_data_element(self): # Check the type of data elements doesn't affect the numeric result. # This is a weaker test than UnivariateTypeMixin.testTypesConserved, # because it checks the numeric result by equality, but not by type. class MyFloat(float): def __truediv__(self, other): return type(self)(super().__truediv__(other)) def __add__(self, other): return type(self)(super().__add__(other)) __radd__ = __add__ raw = self.prepare_data() expected = self.func(raw) for kind in (float, MyFloat, Decimal, Fraction): data = [kind(x) for x in raw] result = type(expected)(self.func(data)) self.assertEqual(result, expected) class UnivariateTypeMixin: """Mixin class for type-conserving functions. This mixin class holds test(s) for functions which conserve the type of individual data points. E.g. the mean of a list of Fractions should itself be a Fraction. Not all tests to do with types need go in this class. Only those that rely on the function returning the same type as its input data. """ def prepare_types_for_conservation_test(self): """Return the types which are expected to be conserved.""" class MyFloat(float): def __truediv__(self, other): return type(self)(super().__truediv__(other)) def __rtruediv__(self, other): return type(self)(super().__rtruediv__(other)) def __sub__(self, other): return type(self)(super().__sub__(other)) def __rsub__(self, other): return type(self)(super().__rsub__(other)) def __pow__(self, other): return type(self)(super().__pow__(other)) def __add__(self, other): return type(self)(super().__add__(other)) __radd__ = __add__ return (float, Decimal, Fraction, MyFloat) def test_types_conserved(self): # Test that functions keeps the same type as their data points. # (Excludes mixed data types.) This only tests the type of the return # result, not the value. data = self.prepare_data() for kind in self.prepare_types_for_conservation_test(): d = [kind(x) for x in data] result = self.func(d) self.assertIs(type(result), kind) class TestSumCommon(UnivariateCommonMixin, UnivariateTypeMixin): # Common test cases for statistics._sum() function. # This test suite looks only at the numeric value returned by _sum, # after conversion to the appropriate type. def setUp(self): def simplified_sum(*args): T, value, n = statistics._sum(*args) return statistics._coerce(value, T) self.func = simplified_sum class TestSum(NumericTestCase): # Test cases for statistics._sum() function. # These tests look at the entire three value tuple returned by _sum. def setUp(self): self.func = statistics._sum def test_empty_data(self): # Override test for empty data. for data in ([], (), iter([])): self.assertEqual(self.func(data), (int, Fraction(0), 0)) self.assertEqual(self.func(data, 23), (int, Fraction(23), 0)) self.assertEqual(self.func(data, 2.3), (float, Fraction(2.3), 0)) def test_ints(self): self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), (int, Fraction(60), 8)) self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), (int, Fraction(1008), 5)) def test_floats(self): self.assertEqual(self.func([0.25]*20), (float, Fraction(5.0), 20)) self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), (float, Fraction(3.125), 4)) def test_fractions(self): self.assertEqual(self.func([Fraction(1, 1000)]*500), (Fraction, Fraction(1, 2), 500)) def test_decimals(self): D = Decimal data = [D("0.001"), D("5.246"), D("1.702"), D("-0.025"), D("3.974"), D("2.328"), D("4.617"), D("2.843"), ] self.assertEqual(self.func(data), (Decimal, Decimal("20.686"), 8)) def test_compare_with_math_fsum(self): # Compare with the math.fsum function. # Ideally we ought to get the exact same result, but sometimes # we differ by a very slight amount :-( data = [random.uniform(-100, 1000) for _ in range(1000)] self.assertApproxEqual(float(self.func(data)[1]), math.fsum(data), rel=2e-16) def test_start_argument(self): # Test that the optional start argument works correctly. data = [random.uniform(1, 1000) for _ in range(100)] t = self.func(data)[1] self.assertEqual(t+42, self.func(data, 42)[1]) self.assertEqual(t-23, self.func(data, -23)[1]) self.assertEqual(t+Fraction(1e20), self.func(data, 1e20)[1]) def test_strings_fail(self): # Sum of strings should fail. self.assertRaises(TypeError, self.func, [1, 2, 3], '999') self.assertRaises(TypeError, self.func, [1, 2, 3, '999']) def test_bytes_fail(self): # Sum of bytes should fail. self.assertRaises(TypeError, self.func, [1, 2, 3], b'999') self.assertRaises(TypeError, self.func, [1, 2, 3, b'999']) def test_mixed_sum(self): # Mixed input types are not (currently) allowed. # Check that mixed data types fail. self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)]) # And so does mixed start argument. self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1)) class SumTortureTest(NumericTestCase): def test_torture(self): # Tim Peters' torture test for sum, and variants of same. self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), (float, Fraction(20000.0), 40000)) self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), (float, Fraction(20000.0), 40000)) T, num, count = statistics._sum([1e-100, 1, 1e-100, -1]*10000) self.assertIs(T, float) self.assertEqual(count, 40000) self.assertApproxEqual(float(num), 2.0e-96, rel=5e-16) class SumSpecialValues(NumericTestCase): # Test that sum works correctly with IEEE-754 special values. def test_nan(self): for type_ in (float, Decimal): nan = type_('nan') result = statistics._sum([1, nan, 2])[1] self.assertIs(type(result), type_) self.assertTrue(math.isnan(result)) def check_infinity(self, x, inf): """Check x is an infinity of the same type and sign as inf.""" self.assertTrue(math.isinf(x)) self.assertIs(type(x), type(inf)) self.assertEqual(x > 0, inf > 0) assert x == inf def do_test_inf(self, inf): # Adding a single infinity gives infinity. result = statistics._sum([1, 2, inf, 3])[1] self.check_infinity(result, inf) # Adding two infinities of the same sign also gives infinity. result = statistics._sum([1, 2, inf, 3, inf, 4])[1] self.check_infinity(result, inf) def test_float_inf(self): inf = float('inf') for sign in (+1, -1): self.do_test_inf(sign*inf) def test_decimal_inf(self): inf = Decimal('inf') for sign in (+1, -1): self.do_test_inf(sign*inf) def test_float_mismatched_infs(self): # Test that adding two infinities of opposite sign gives a NAN. inf = float('inf') result = statistics._sum([1, 2, inf, 3, -inf, 4])[1] self.assertTrue(math.isnan(result)) def test_decimal_extendedcontext_mismatched_infs_to_nan(self): # Test adding Decimal INFs with opposite sign returns NAN. inf = Decimal('inf') data = [1, 2, inf, 3, -inf, 4] with decimal.localcontext(decimal.ExtendedContext): self.assertTrue(math.isnan(statistics._sum(data)[1])) def test_decimal_basiccontext_mismatched_infs_to_nan(self): # Test adding Decimal INFs with opposite sign raises InvalidOperation. inf = Decimal('inf') data = [1, 2, inf, 3, -inf, 4] with decimal.localcontext(decimal.BasicContext): self.assertRaises(decimal.InvalidOperation, statistics._sum, data) def test_decimal_snan_raises(self): # Adding sNAN should raise InvalidOperation. sNAN = Decimal('sNAN') data = [1, sNAN, 2] self.assertRaises(decimal.InvalidOperation, statistics._sum, data) # === Tests for averages === class AverageMixin(UnivariateCommonMixin): # Mixin class holding common tests for averages. def test_single_value(self): # Average of a single value is the value itself. for x in (23, 42.5, 1.3e15, Fraction(15, 19), Decimal('0.28')): self.assertEqual(self.func([x]), x) def prepare_values_for_repeated_single_test(self): return (3.5, 17, 2.5e15, Fraction(61, 67), Decimal('4.9712')) def test_repeated_single_value(self): # The average of a single repeated value is the value itself. for x in self.prepare_values_for_repeated_single_test(): for count in (2, 5, 10, 20): with self.subTest(x=x, count=count): data = [x]*count self.assertEqual(self.func(data), x) class TestMean(NumericTestCase, AverageMixin, UnivariateTypeMixin): def setUp(self): self.func = statistics.mean def test_torture_pep(self): # "Torture Test" from PEP-450. self.assertEqual(self.func([1e100, 1, 3, -1e100]), 1) def test_ints(self): # Test mean with ints. data = [0, 1, 2, 3, 3, 3, 4, 5, 5, 6, 7, 7, 7, 7, 8, 9] random.shuffle(data) self.assertEqual(self.func(data), 4.8125) def test_floats(self): # Test mean with floats. data = [17.25, 19.75, 20.0, 21.5, 21.75, 23.25, 25.125, 27.5] random.shuffle(data) self.assertEqual(self.func(data), 22.015625) def test_decimals(self): # Test mean with Decimals. D = Decimal data = [D("1.634"), D("2.517"), D("3.912"), D("4.072"), D("5.813")] random.shuffle(data) self.assertEqual(self.func(data), D("3.5896")) def test_fractions(self): # Test mean with Fractions. F = Fraction data = [F(1, 2), F(2, 3), F(3, 4), F(4, 5), F(5, 6), F(6, 7), F(7, 8)] random.shuffle(data) self.assertEqual(self.func(data), F(1479, 1960)) def test_inf(self): # Test mean with infinities. raw = [1, 3, 5, 7, 9] # Use only ints, to avoid TypeError later. for kind in (float, Decimal): for sign in (1, -1): inf = kind("inf")*sign data = raw + [inf] result = self.func(data) self.assertTrue(math.isinf(result)) self.assertEqual(result, inf) def test_mismatched_infs(self): # Test mean with infinities of opposite sign. data = [2, 4, 6, float('inf'), 1, 3, 5, float('-inf')] result = self.func(data) self.assertTrue(math.isnan(result)) def test_nan(self): # Test mean with NANs. raw = [1, 3, 5, 7, 9] # Use only ints, to avoid TypeError later. for kind in (float, Decimal): inf = kind("nan") data = raw + [inf] result = self.func(data) self.assertTrue(math.isnan(result)) def test_big_data(self): # Test adding a large constant to every data point. c = 1e9 data = [3.4, 4.5, 4.9, 6.7, 6.8, 7.2, 8.0, 8.1, 9.4] expected = self.func(data) + c assert expected != c result = self.func([x+c for x in data]) self.assertEqual(result, expected) def test_doubled_data(self): # Mean of [a,b,c...z] should be same as for [a,a,b,b,c,c...z,z]. data = [random.uniform(-3, 5) for _ in range(1000)] expected = self.func(data) actual = self.func(data*2) self.assertApproxEqual(actual, expected) def test_regression_20561(self): # Regression test for issue 20561. # See http://bugs.python.org/issue20561 d = Decimal('1e4') self.assertEqual(statistics.mean([d]), d) def test_regression_25177(self): # Regression test for issue 25177. # Ensure very big and very small floats don't overflow. # See http://bugs.python.org/issue25177. self.assertEqual(statistics.mean( [8.988465674311579e+307, 8.98846567431158e+307]), 8.98846567431158e+307) big = 8.98846567431158e+307 tiny = 5e-324 for n in (2, 3, 5, 200): self.assertEqual(statistics.mean([big]*n), big) self.assertEqual(statistics.mean([tiny]*n), tiny) class TestHarmonicMean(NumericTestCase, AverageMixin, UnivariateTypeMixin): def setUp(self): self.func = statistics.harmonic_mean def prepare_data(self): # Override mixin method. values = super().prepare_data() values.remove(0) return values def prepare_values_for_repeated_single_test(self): # Override mixin method. return (3.5, 17, 2.5e15, Fraction(61, 67), Decimal('4.125')) def test_zero(self): # Test that harmonic mean returns zero when given zero. values = [1, 0, 2] self.assertEqual(self.func(values), 0) def test_negative_error(self): # Test that harmonic mean raises when given a negative value. exc = statistics.StatisticsError for values in ([-1], [1, -2, 3]): with self.subTest(values=values): self.assertRaises(exc, self.func, values) def test_ints(self): # Test harmonic mean with ints. data = [2, 4, 4, 8, 16, 16] random.shuffle(data) self.assertEqual(self.func(data), 6*4/5) def test_floats_exact(self): # Test harmonic mean with some carefully chosen floats. data = [1/8, 1/4, 1/4, 1/2, 1/2] random.shuffle(data) self.assertEqual(self.func(data), 1/4) self.assertEqual(self.func([0.25, 0.5, 1.0, 1.0]), 0.5) def test_singleton_lists(self): # Test that harmonic mean([x]) returns (approximately) x. for x in range(1, 101): self.assertEqual(self.func([x]), x) def test_decimals_exact(self): # Test harmonic mean with some carefully chosen Decimals. D = Decimal self.assertEqual(self.func([D(15), D(30), D(60), D(60)]), D(30)) data = [D("0.05"), D("0.10"), D("0.20"), D("0.20")] random.shuffle(data) self.assertEqual(self.func(data), D("0.10")) data = [D("1.68"), D("0.32"), D("5.94"), D("2.75")] random.shuffle(data) self.assertEqual(self.func(data), D(66528)/70723) def test_fractions(self): # Test harmonic mean with Fractions. F = Fraction data = [F(1, 2), F(2, 3), F(3, 4), F(4, 5), F(5, 6), F(6, 7), F(7, 8)] random.shuffle(data) self.assertEqual(self.func(data), F(7*420, 4029)) def test_inf(self): # Test harmonic mean with infinity. values = [2.0, float('inf'), 1.0] self.assertEqual(self.func(values), 2.0) def test_nan(self): # Test harmonic mean with NANs. values = [2.0, float('nan'), 1.0] self.assertTrue(math.isnan(self.func(values))) def test_multiply_data_points(self): # Test multiplying every data point by a constant. c = 111 data = [3.4, 4.5, 4.9, 6.7, 6.8, 7.2, 8.0, 8.1, 9.4] expected = self.func(data)*c result = self.func([x*c for x in data]) self.assertEqual(result, expected) def test_doubled_data(self): # Harmonic mean of [a,b...z] should be same as for [a,a,b,b...z,z]. data = [random.uniform(1, 5) for _ in range(1000)] expected = self.func(data) actual = self.func(data*2) self.assertApproxEqual(actual, expected) class TestMedian(NumericTestCase, AverageMixin): # Common tests for median and all median.* functions. def setUp(self): self.func = statistics.median def prepare_data(self): """Overload method from UnivariateCommonMixin.""" data = super().prepare_data() if len(data)%2 != 1: data.append(2) return data def test_even_ints(self): # Test median with an even number of int data points. data = [1, 2, 3, 4, 5, 6] assert len(data)%2 == 0 self.assertEqual(self.func(data), 3.5) def test_odd_ints(self): # Test median with an odd number of int data points. data = [1, 2, 3, 4, 5, 6, 9] assert len(data)%2 == 1 self.assertEqual(self.func(data), 4) def test_odd_fractions(self): # Test median works with an odd number of Fractions. F = Fraction data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7)] assert len(data)%2 == 1 random.shuffle(data) self.assertEqual(self.func(data), F(3, 7)) def test_even_fractions(self): # Test median works with an even number of Fractions. F = Fraction data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), F(1, 2)) def test_odd_decimals(self): # Test median works with an odd number of Decimals. D = Decimal data = [D('2.5'), D('3.1'), D('4.2'), D('5.7'), D('5.8')] assert len(data)%2 == 1 random.shuffle(data) self.assertEqual(self.func(data), D('4.2')) def test_even_decimals(self): # Test median works with an even number of Decimals. D = Decimal data = [D('1.2'), D('2.5'), D('3.1'), D('4.2'), D('5.7'), D('5.8')] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), D('3.65')) class TestMedianDataType(NumericTestCase, UnivariateTypeMixin): # Test conservation of data element type for median. def setUp(self): self.func = statistics.median def prepare_data(self): data = list(range(15)) assert len(data)%2 == 1 while data == sorted(data): random.shuffle(data) return data class TestMedianLow(TestMedian, UnivariateTypeMixin): def setUp(self): self.func = statistics.median_low def test_even_ints(self): # Test median_low with an even number of ints. data = [1, 2, 3, 4, 5, 6] assert len(data)%2 == 0 self.assertEqual(self.func(data), 3) def test_even_fractions(self): # Test median_low works with an even number of Fractions. F = Fraction data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), F(3, 7)) def test_even_decimals(self): # Test median_low works with an even number of Decimals. D = Decimal data = [D('1.1'), D('2.2'), D('3.3'), D('4.4'), D('5.5'), D('6.6')] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), D('3.3')) class TestMedianHigh(TestMedian, UnivariateTypeMixin): def setUp(self): self.func = statistics.median_high def test_even_ints(self): # Test median_high with an even number of ints. data = [1, 2, 3, 4, 5, 6] assert len(data)%2 == 0 self.assertEqual(self.func(data), 4) def test_even_fractions(self): # Test median_high works with an even number of Fractions. F = Fraction data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), F(4, 7)) def test_even_decimals(self): # Test median_high works with an even number of Decimals. D = Decimal data = [D('1.1'), D('2.2'), D('3.3'), D('4.4'), D('5.5'), D('6.6')] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), D('4.4')) class TestMedianGrouped(TestMedian): # Test median_grouped. # Doesn't conserve data element types, so don't use TestMedianType. def setUp(self): self.func = statistics.median_grouped def test_odd_number_repeated(self): # Test median.grouped with repeated median values. data = [12, 13, 14, 14, 14, 15, 15] assert len(data)%2 == 1 self.assertEqual(self.func(data), 14) #--- data = [12, 13, 14, 14, 14, 14, 15] assert len(data)%2 == 1 self.assertEqual(self.func(data), 13.875) #--- data = [5, 10, 10, 15, 20, 20, 20, 20, 25, 25, 30] assert len(data)%2 == 1 self.assertEqual(self.func(data, 5), 19.375) #--- data = [16, 18, 18, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 26, 28] assert len(data)%2 == 1 self.assertApproxEqual(self.func(data, 2), 20.66666667, tol=1e-8) def test_even_number_repeated(self): # Test median.grouped with repeated median values. data = [5, 10, 10, 15, 20, 20, 20, 25, 25, 30] assert len(data)%2 == 0 self.assertApproxEqual(self.func(data, 5), 19.16666667, tol=1e-8) #--- data = [2, 3, 4, 4, 4, 5] assert len(data)%2 == 0 self.assertApproxEqual(self.func(data), 3.83333333, tol=1e-8) #--- data = [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6] assert len(data)%2 == 0 self.assertEqual(self.func(data), 4.5) #--- data = [3, 4, 4, 4, 5, 5, 5, 5, 6, 6] assert len(data)%2 == 0 self.assertEqual(self.func(data), 4.75) def test_repeated_single_value(self): # Override method from AverageMixin. # Yet again, failure of median_grouped to conserve the data type # causes me headaches :-( for x in (5.3, 68, 4.3e17, Fraction(29, 101), Decimal('32.9714')): for count in (2, 5, 10, 20): data = [x]*count self.assertEqual(self.func(data), float(x)) def test_odd_fractions(self): # Test median_grouped works with an odd number of Fractions. F = Fraction data = [F(5, 4), F(9, 4), F(13, 4), F(13, 4), F(17, 4)] assert len(data)%2 == 1 random.shuffle(data) self.assertEqual(self.func(data), 3.0) def test_even_fractions(self): # Test median_grouped works with an even number of Fractions. F = Fraction data = [F(5, 4), F(9, 4), F(13, 4), F(13, 4), F(17, 4), F(17, 4)] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), 3.25) def test_odd_decimals(self): # Test median_grouped works with an odd number of Decimals. D = Decimal data = [D('5.5'), D('6.5'), D('6.5'), D('7.5'), D('8.5')] assert len(data)%2 == 1 random.shuffle(data) self.assertEqual(self.func(data), 6.75) def test_even_decimals(self): # Test median_grouped works with an even number of Decimals. D = Decimal data = [D('5.5'), D('5.5'), D('6.5'), D('6.5'), D('7.5'), D('8.5')] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), 6.5) #--- data = [D('5.5'), D('5.5'), D('6.5'), D('7.5'), D('7.5'), D('8.5')] assert len(data)%2 == 0 random.shuffle(data) self.assertEqual(self.func(data), 7.0) def test_interval(self): # Test median_grouped with interval argument. data = [2.25, 2.5, 2.5, 2.75, 2.75, 3.0, 3.0, 3.25, 3.5, 3.75] self.assertEqual(self.func(data, 0.25), 2.875) data = [2.25, 2.5, 2.5, 2.75, 2.75, 2.75, 3.0, 3.0, 3.25, 3.5, 3.75] self.assertApproxEqual(self.func(data, 0.25), 2.83333333, tol=1e-8) data = [220, 220, 240, 260, 260, 260, 260, 280, 280, 300, 320, 340] self.assertEqual(self.func(data, 20), 265.0) def test_data_type_error(self): # Test median_grouped with str, bytes data types for data and interval data = ["", "", ""] self.assertRaises(TypeError, self.func, data) #--- data = [b"", b"", b""] self.assertRaises(TypeError, self.func, data) #--- data = [1, 2, 3] interval = "" self.assertRaises(TypeError, self.func, data, interval) #--- data = [1, 2, 3] interval = b"" self.assertRaises(TypeError, self.func, data, interval) class TestMode(NumericTestCase, AverageMixin, UnivariateTypeMixin): # Test cases for the discrete version of mode. def setUp(self): self.func = statistics.mode def prepare_data(self): """Overload method from UnivariateCommonMixin.""" # Make sure test data has exactly one mode. return [1, 1, 1, 1, 3, 4, 7, 9, 0, 8, 2] def test_range_data(self): # Override test from UnivariateCommonMixin. data = range(20, 50, 3) self.assertRaises(statistics.StatisticsError, self.func, data) def test_nominal_data(self): # Test mode with nominal data. data = 'abcbdb' self.assertEqual(self.func(data), 'b') data = 'fe fi fo fum fi fi'.split() self.assertEqual(self.func(data), 'fi') def test_discrete_data(self): # Test mode with discrete numeric data. data = list(range(10)) for i in range(10): d = data + [i] random.shuffle(d) self.assertEqual(self.func(d), i) def test_bimodal_data(self): # Test mode with bimodal data. data = [1, 1, 2, 2, 2, 2, 3, 4, 5, 6, 6, 6, 6, 7, 8, 9, 9] assert data.count(2) == data.count(6) == 4 # Check for an exception. self.assertRaises(statistics.StatisticsError, self.func, data) def test_unique_data_failure(self): # Test mode exception when data points are all unique. data = list(range(10)) self.assertRaises(statistics.StatisticsError, self.func, data) def test_none_data(self): # Test that mode raises TypeError if given None as data. # This test is necessary because the implementation of mode uses # collections.Counter, which accepts None and returns an empty dict. self.assertRaises(TypeError, self.func, None) def test_counter_data(self): # Test that a Counter is treated like any other iterable. data = collections.Counter([1, 1, 1, 2]) # Since the keys of the counter are treated as data points, not the # counts, this should raise. self.assertRaises(statistics.StatisticsError, self.func, data) # === Tests for variances and standard deviations === class VarianceStdevMixin(UnivariateCommonMixin): # Mixin class holding common tests for variance and std dev. # Subclasses should inherit from this before NumericTestClass, in order # to see the rel attribute below. See testShiftData for an explanation. rel = 1e-12 def test_single_value(self): # Deviation of a single value is zero. for x in (11, 19.8, 4.6e14, Fraction(21, 34), Decimal('8.392')): self.assertEqual(self.func([x]), 0) def test_repeated_single_value(self): # The deviation of a single repeated value is zero. for x in (7.2, 49, 8.1e15, Fraction(3, 7), Decimal('62.4802')): for count in (2, 3, 5, 15): data = [x]*count self.assertEqual(self.func(data), 0) def test_domain_error_regression(self): # Regression test for a domain error exception. # (Thanks to Geremy Condra.) data = [0.123456789012345]*10000 # All the items are identical, so variance should be exactly zero. # We allow some small round-off error, but not much. result = self.func(data) self.assertApproxEqual(result, 0.0, tol=5e-17) self.assertGreaterEqual(result, 0) # A negative result must fail. def test_shift_data(self): # Test that shifting the data by a constant amount does not affect # the variance or stdev. Or at least not much. # Due to rounding, this test should be considered an ideal. We allow # some tolerance away from "no change at all" by setting tol and/or rel # attributes. Subclasses may set tighter or looser error tolerances. raw = [1.03, 1.27, 1.94, 2.04, 2.58, 3.14, 4.75, 4.98, 5.42, 6.78] expected = self.func(raw) # Don't set shift too high, the bigger it is, the more rounding error. shift = 1e5 data = [x + shift for x in raw] self.assertApproxEqual(self.func(data), expected) def test_shift_data_exact(self): # Like test_shift_data, but result is always exact. raw = [1, 3, 3, 4, 5, 7, 9, 10, 11, 16] assert all(x==int(x) for x in raw) expected = self.func(raw) shift = 10**9 data = [x + shift for x in raw] self.assertEqual(self.func(data), expected) def test_iter_list_same(self): # Test that iter data and list data give the same result. # This is an explicit test that iterators and lists are treated the # same; justification for this test over and above the similar test # in UnivariateCommonMixin is that an earlier design had variance and # friends swap between one- and two-pass algorithms, which would # sometimes give different results. data = [random.uniform(-3, 8) for _ in range(1000)] expected = self.func(data) self.assertEqual(self.func(iter(data)), expected) class TestPVariance(VarianceStdevMixin, NumericTestCase, UnivariateTypeMixin): # Tests for population variance. def setUp(self): self.func = statistics.pvariance def test_exact_uniform(self): # Test the variance against an exact result for uniform data. data = list(range(10000)) random.shuffle(data) expected = (10000**2 - 1)/12 # Exact value. self.assertEqual(self.func(data), expected) def test_ints(self): # Test population variance with int data. data = [4, 7, 13, 16] exact = 22.5 self.assertEqual(self.func(data), exact) def test_fractions(self): # Test population variance with Fraction data. F = Fraction data = [F(1, 4), F(1, 4), F(3, 4), F(7, 4)] exact = F(3, 8) result = self.func(data) self.assertEqual(result, exact) self.assertIsInstance(result, Fraction) def test_decimals(self): # Test population variance with Decimal data. D = Decimal data = [D("12.1"), D("12.2"), D("12.5"), D("12.9")] exact = D('0.096875') result = self.func(data) self.assertEqual(result, exact) self.assertIsInstance(result, Decimal) class TestVariance(VarianceStdevMixin, NumericTestCase, UnivariateTypeMixin): # Tests for sample variance. def setUp(self): self.func = statistics.variance def test_single_value(self): # Override method from VarianceStdevMixin. for x in (35, 24.7, 8.2e15, Fraction(19, 30), Decimal('4.2084')): self.assertRaises(statistics.StatisticsError, self.func, [x]) def test_ints(self): # Test sample variance with int data. data = [4, 7, 13, 16] exact = 30 self.assertEqual(self.func(data), exact) def test_fractions(self): # Test sample variance with Fraction data. F = Fraction data = [F(1, 4), F(1, 4), F(3, 4), F(7, 4)] exact = F(1, 2) result = self.func(data) self.assertEqual(result, exact) self.assertIsInstance(result, Fraction) def test_decimals(self): # Test sample variance with Decimal data. D = Decimal data = [D(2), D(2), D(7), D(9)] exact = 4*D('9.5')/D(3) result = self.func(data) self.assertEqual(result, exact) self.assertIsInstance(result, Decimal) class TestPStdev(VarianceStdevMixin, NumericTestCase): # Tests for population standard deviation. def setUp(self): self.func = statistics.pstdev def test_compare_to_variance(self): # Test that stdev is, in fact, the square root of variance. data = [random.uniform(-17, 24) for _ in range(1000)] expected = math.sqrt(statistics.pvariance(data)) self.assertEqual(self.func(data), expected) class TestStdev(VarianceStdevMixin, NumericTestCase): # Tests for sample standard deviation. def setUp(self): self.func = statistics.stdev def test_single_value(self): # Override method from VarianceStdevMixin. for x in (81, 203.74, 3.9e14, Fraction(5, 21), Decimal('35.719')): self.assertRaises(statistics.StatisticsError, self.func, [x]) def test_compare_to_variance(self): # Test that stdev is, in fact, the square root of variance. data = [random.uniform(-2, 9) for _ in range(1000)] expected = math.sqrt(statistics.variance(data)) self.assertEqual(self.func(data), expected) # === Run tests === def load_tests(loader, tests, ignore): """Used for doctest/unittest integration.""" tests.addTests(doctest.DocTestSuite()) return tests if __name__ == "__main__": unittest.main()
76,220
1,996
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_unary.py
"""Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2""" import unittest class UnaryOpTestCase(unittest.TestCase): def test_negative(self): self.assertTrue(-2 == 0 - 2) self.assertEqual(-0, 0) self.assertEqual(--2, 2) self.assertTrue(-2 == 0 - 2) self.assertTrue(-2.0 == 0 - 2.0) self.assertTrue(-2j == 0 - 2j) def test_positive(self): self.assertEqual(+2, 2) self.assertEqual(+0, 0) self.assertEqual(++2, 2) self.assertEqual(+2, 2) self.assertEqual(+2.0, 2.0) self.assertEqual(+2j, 2j) def test_invert(self): self.assertTrue(-2 == 0 - 2) self.assertEqual(-0, 0) self.assertEqual(--2, 2) self.assertTrue(-2 == 0 - 2) def test_no_overflow(self): nines = "9" * 32 self.assertTrue(eval("+" + nines) == 10**32-1) self.assertTrue(eval("-" + nines) == -(10**32-1)) self.assertTrue(eval("~" + nines) == ~(10**32-1)) def test_negation_of_exponentiation(self): # Make sure '**' does the right thing; these form a # regression test for SourceForge bug #456756. self.assertEqual(-2 ** 3, -8) self.assertEqual((-2) ** 3, -8) self.assertEqual(-2 ** 4, -16) self.assertEqual((-2) ** 4, 16) def test_bad_types(self): for op in '+', '-', '~': self.assertRaises(TypeError, eval, op + "b'a'") self.assertRaises(TypeError, eval, op + "'a'") self.assertRaises(TypeError, eval, "~2j") self.assertRaises(TypeError, eval, "~2.0") if __name__ == "__main__": unittest.main()
1,665
54
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_strptime.py
"""PyUnit testing against strptime""" import unittest import time import locale import re import os from test import support from datetime import date as datetime_date import _strptime class getlang_Tests(unittest.TestCase): """Test _getlang""" def test_basic(self): self.assertEqual(_strptime._getlang(), locale.getlocale(locale.LC_TIME)) class LocaleTime_Tests(unittest.TestCase): """Tests for _strptime.LocaleTime. All values are lower-cased when stored in LocaleTime, so make sure to compare values after running ``lower`` on them. """ def setUp(self): """Create time tuple based on current time.""" self.time_tuple = time.localtime() self.LT_ins = _strptime.LocaleTime() def compare_against_time(self, testing, directive, tuple_position, error_msg): """Helper method that tests testing against directive based on the tuple_position of time_tuple. Uses error_msg as error message. """ strftime_output = time.strftime(directive, self.time_tuple).lower() comparison = testing[self.time_tuple[tuple_position]] self.assertIn(strftime_output, testing, "%s: not found in tuple" % error_msg) self.assertEqual(comparison, strftime_output, "%s: position within tuple incorrect; %s != %s" % (error_msg, comparison, strftime_output)) def test_weekday(self): # Make sure that full and abbreviated weekday names are correct in # both string and position with tuple self.compare_against_time(self.LT_ins.f_weekday, '%A', 6, "Testing of full weekday name failed") self.compare_against_time(self.LT_ins.a_weekday, '%a', 6, "Testing of abbreviated weekday name failed") def test_month(self): # Test full and abbreviated month names; both string and position # within the tuple self.compare_against_time(self.LT_ins.f_month, '%B', 1, "Testing against full month name failed") self.compare_against_time(self.LT_ins.a_month, '%b', 1, "Testing against abbreviated month name failed") def test_am_pm(self): # Make sure AM/PM representation done properly strftime_output = time.strftime("%p", self.time_tuple).lower() self.assertIn(strftime_output, self.LT_ins.am_pm, "AM/PM representation not in tuple") if self.time_tuple[3] < 12: position = 0 else: position = 1 self.assertEqual(self.LT_ins.am_pm[position], strftime_output, "AM/PM representation in the wrong position within the tuple") def test_timezone(self): # Make sure timezone is correct timezone = time.strftime("%Z", self.time_tuple).lower() if timezone: self.assertTrue(timezone in self.LT_ins.timezone[0] or timezone in self.LT_ins.timezone[1], "timezone %s not found in %s" % (timezone, self.LT_ins.timezone)) def test_date_time(self): # Check that LC_date_time, LC_date, and LC_time are correct # the magic date is used so as to not have issues with %c when day of # the month is a single digit and has a leading space. This is not an # issue since strptime still parses it correctly. The problem is # testing these directives for correctness by comparing strftime # output. magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0) strftime_output = time.strftime("%c", magic_date) self.assertEqual(time.strftime(self.LT_ins.LC_date_time, magic_date), strftime_output, "LC_date_time incorrect") strftime_output = time.strftime("%x", magic_date) self.assertEqual(time.strftime(self.LT_ins.LC_date, magic_date), strftime_output, "LC_date incorrect") strftime_output = time.strftime("%X", magic_date) self.assertEqual(time.strftime(self.LT_ins.LC_time, magic_date), strftime_output, "LC_time incorrect") LT = _strptime.LocaleTime() LT.am_pm = ('', '') self.assertTrue(LT.LC_time, "LocaleTime's LC directives cannot handle " "empty strings") def test_lang(self): # Make sure lang is set to what _getlang() returns # Assuming locale has not changed between now and when self.LT_ins was created self.assertEqual(self.LT_ins.lang, _strptime._getlang()) class TimeRETests(unittest.TestCase): """Tests for TimeRE.""" def setUp(self): """Construct generic TimeRE object.""" self.time_re = _strptime.TimeRE() self.locale_time = _strptime.LocaleTime() def test_pattern(self): # Test TimeRE.pattern pattern_string = self.time_re.pattern(r"%a %A %d") self.assertTrue(pattern_string.find(self.locale_time.a_weekday[2]) != -1, "did not find abbreviated weekday in pattern string '%s'" % pattern_string) self.assertTrue(pattern_string.find(self.locale_time.f_weekday[4]) != -1, "did not find full weekday in pattern string '%s'" % pattern_string) self.assertTrue(pattern_string.find(self.time_re['d']) != -1, "did not find 'd' directive pattern string '%s'" % pattern_string) def test_pattern_escaping(self): # Make sure any characters in the format string that might be taken as # regex syntax is escaped. pattern_string = self.time_re.pattern(r"\d+") self.assertIn(r"\\d\+", pattern_string, "%s does not have re characters escaped properly" % pattern_string) def test_compile(self): # Check that compiled regex is correct found = self.time_re.compile(r"%A").match(self.locale_time.f_weekday[6]) self.assertTrue(found and found.group('A') == self.locale_time.f_weekday[6], "re object for '%A' failed") compiled = self.time_re.compile(r"%a %b") found = compiled.match("%s %s" % (self.locale_time.a_weekday[4], self.locale_time.a_month[4])) self.assertTrue(found, "Match failed with '%s' regex and '%s' string" % (compiled.pattern, "%s %s" % (self.locale_time.a_weekday[4], self.locale_time.a_month[4]))) self.assertTrue(found.group('a') == self.locale_time.a_weekday[4] and found.group('b') == self.locale_time.a_month[4], "re object couldn't find the abbreviated weekday month in " "'%s' using '%s'; group 'a' = '%s', group 'b' = %s'" % (found.string, found.re.pattern, found.group('a'), found.group('b'))) for directive in ('a','A','b','B','c','d','G','H','I','j','m','M','p', 'S','u','U','V','w','W','x','X','y','Y','Z','%'): compiled = self.time_re.compile("%" + directive) found = compiled.match(time.strftime("%" + directive)) self.assertTrue(found, "Matching failed on '%s' using '%s' regex" % (time.strftime("%" + directive), compiled.pattern)) def test_blankpattern(self): # Make sure when tuple or something has no values no regex is generated. # Fixes bug #661354 test_locale = _strptime.LocaleTime() test_locale.timezone = (frozenset(), frozenset()) self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '', "with timezone == ('',''), TimeRE().pattern('%Z') != ''") def test_matching_with_escapes(self): # Make sure a format that requires escaping of characters works compiled_re = self.time_re.compile(r"\w+ %m") found = compiled_re.match(r"\w+ 10") self.assertTrue(found, r"Escaping failed of format '\w+ 10'") def test_locale_data_w_regex_metacharacters(self): # Check that if locale data contains regex metacharacters they are # escaped properly. # Discovered by bug #1039270 . locale_time = _strptime.LocaleTime() locale_time.timezone = (frozenset(("utc", "gmt", "Tokyo (standard time)")), frozenset("Tokyo (daylight time)")) time_re = _strptime.TimeRE(locale_time) self.assertTrue(time_re.compile("%Z").match("Tokyo (standard time)"), "locale data that contains regex metacharacters is not" " properly escaped") def test_whitespace_substitution(self): # When pattern contains whitespace, make sure it is taken into account # so as to not allow subpatterns to end up next to each other and # "steal" characters from each other. pattern = self.time_re.pattern('%j %H') self.assertFalse(re.match(pattern, "180")) self.assertTrue(re.match(pattern, "18 0")) class StrptimeTests(unittest.TestCase): """Tests for _strptime.strptime.""" def setUp(self): """Create testing time tuple.""" self.time_tuple = time.gmtime() def test_ValueError(self): # Make sure ValueError is raised when match fails or format is bad self.assertRaises(ValueError, _strptime._strptime_time, data_string="%d", format="%A") for bad_format in ("%", "% ", "%e"): try: _strptime._strptime_time("2005", bad_format) except ValueError: continue except Exception as err: self.fail("'%s' raised %s, not ValueError" % (bad_format, err.__class__.__name__)) else: self.fail("'%s' did not raise ValueError" % bad_format) # Ambiguous or incomplete cases using ISO year/week/weekday directives # 1. ISO week (%V) is specified, but the year is specified with %Y # instead of %G with self.assertRaises(ValueError): _strptime._strptime("1999 50", "%Y %V") # 2. ISO year (%G) and ISO week (%V) are specified, but weekday is not with self.assertRaises(ValueError): _strptime._strptime("1999 51", "%G %V") # 3. ISO year (%G) and weekday are specified, but ISO week (%V) is not for w in ('A', 'a', 'w', 'u'): with self.assertRaises(ValueError): _strptime._strptime("1999 51","%G %{}".format(w)) # 4. ISO year is specified alone (e.g. time.strptime('2015', '%G')) with self.assertRaises(ValueError): _strptime._strptime("2015", "%G") # 5. Julian/ordinal day (%j) is specified with %G, but not %Y with self.assertRaises(ValueError): _strptime._strptime("1999 256", "%G %j") def test_strptime_exception_context(self): # check that this doesn't chain exceptions needlessly (see #17572) with self.assertRaises(ValueError) as e: _strptime._strptime_time('', '%D') self.assertIs(e.exception.__suppress_context__, True) # additional check for IndexError branch (issue #19545) with self.assertRaises(ValueError) as e: _strptime._strptime_time('19', '%Y %') self.assertIs(e.exception.__suppress_context__, True) def test_unconverteddata(self): # Check ValueError is raised when there is unconverted data self.assertRaises(ValueError, _strptime._strptime_time, "10 12", "%m") def helper(self, directive, position): """Helper fxn in testing.""" strf_output = time.strftime("%" + directive, self.time_tuple) strp_output = _strptime._strptime_time(strf_output, "%" + directive) self.assertTrue(strp_output[position] == self.time_tuple[position], "testing of '%s' directive failed; '%s' -> %s != %s" % (directive, strf_output, strp_output[position], self.time_tuple[position])) def test_year(self): # Test that the year is handled properly for directive in ('y', 'Y'): self.helper(directive, 0) # Must also make sure %y values are correct for bounds set by Open Group for century, bounds in ((1900, ('69', '99')), (2000, ('00', '68'))): for bound in bounds: strp_output = _strptime._strptime_time(bound, '%y') expected_result = century + int(bound) self.assertTrue(strp_output[0] == expected_result, "'y' test failed; passed in '%s' " "and returned '%s'" % (bound, strp_output[0])) def test_month(self): # Test for month directives for directive in ('B', 'b', 'm'): self.helper(directive, 1) def test_day(self): # Test for day directives self.helper('d', 2) def test_hour(self): # Test hour directives self.helper('H', 3) strf_output = time.strftime("%I %p", self.time_tuple) strp_output = _strptime._strptime_time(strf_output, "%I %p") self.assertTrue(strp_output[3] == self.time_tuple[3], "testing of '%%I %%p' directive failed; '%s' -> %s != %s" % (strf_output, strp_output[3], self.time_tuple[3])) def test_minute(self): # Test minute directives self.helper('M', 4) def test_second(self): # Test second directives self.helper('S', 5) def test_fraction(self): # Test microseconds import datetime d = datetime.datetime(2012, 12, 20, 12, 34, 56, 78987) tup, frac = _strptime._strptime(str(d), format="%Y-%m-%d %H:%M:%S.%f") self.assertEqual(frac, d.microsecond) def test_weekday(self): # Test weekday directives for directive in ('A', 'a', 'w', 'u'): self.helper(directive,6) def test_julian(self): # Test julian directives self.helper('j', 7) def test_timezone(self): # Test timezone directives. # When gmtime() is used with %Z, entire result of strftime() is empty. # Check for equal timezone names deals with bad locale info when this # occurs; first found in FreeBSD 4.4. strp_output = _strptime._strptime_time("UTC", "%Z") self.assertEqual(strp_output.tm_isdst, 0) strp_output = _strptime._strptime_time("GMT", "%Z") self.assertEqual(strp_output.tm_isdst, 0) time_tuple = time.localtime() strf_output = time.strftime("%Z") #UTC does not have a timezone strp_output = _strptime._strptime_time(strf_output, "%Z") locale_time = _strptime.LocaleTime() if time.tzname[0] != time.tzname[1] or not time.daylight: self.assertTrue(strp_output[8] == time_tuple[8], "timezone check failed; '%s' -> %s != %s" % (strf_output, strp_output[8], time_tuple[8])) else: self.assertTrue(strp_output[8] == -1, "LocaleTime().timezone has duplicate values and " "time.daylight but timezone value not set to -1") def test_bad_timezone(self): # Explicitly test possibility of bad timezone; # when time.tzname[0] == time.tzname[1] and time.daylight tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): self.skipTest('need non-UTC/GMT timezone') with support.swap_attr(time, 'tzname', (tz_name, tz_name)), \ support.swap_attr(time, 'daylight', 1), \ support.swap_attr(time, 'tzset', lambda: None): time.tzname = (tz_name, tz_name) time.daylight = 1 tz_value = _strptime._strptime_time(tz_name, "%Z")[8] self.assertEqual(tz_value, -1, "%s lead to a timezone value of %s instead of -1 when " "time.daylight set to %s and passing in %s" % (time.tzname, tz_value, time.daylight, tz_name)) def test_date_time(self): # Test %c directive for position in range(6): self.helper('c', position) def test_date(self): # Test %x directive for position in range(0,3): self.helper('x', position) def test_time(self): # Test %X directive for position in range(3,6): self.helper('X', position) def test_percent(self): # Make sure % signs are handled properly strf_output = time.strftime("%m %% %Y", self.time_tuple) strp_output = _strptime._strptime_time(strf_output, "%m %% %Y") self.assertTrue(strp_output[0] == self.time_tuple[0] and strp_output[1] == self.time_tuple[1], "handling of percent sign failed") def test_caseinsensitive(self): # Should handle names case-insensitively. strf_output = time.strftime("%B", self.time_tuple) self.assertTrue(_strptime._strptime_time(strf_output.upper(), "%B"), "strptime does not handle ALL-CAPS names properly") self.assertTrue(_strptime._strptime_time(strf_output.lower(), "%B"), "strptime does not handle lowercase names properly") self.assertTrue(_strptime._strptime_time(strf_output.capitalize(), "%B"), "strptime does not handle capword names properly") def test_defaults(self): # Default return value should be (1900, 1, 1, 0, 0, 0, 0, 1, 0) defaults = (1900, 1, 1, 0, 0, 0, 0, 1, -1) strp_output = _strptime._strptime_time('1', '%m') self.assertTrue(strp_output == defaults, "Default values for strptime() are incorrect;" " %s != %s" % (strp_output, defaults)) def test_escaping(self): # Make sure all characters that have regex significance are escaped. # Parentheses are in a purposeful order; will cause an error of # unbalanced parentheses when the regex is compiled if they are not # escaped. # Test instigated by bug #796149 . need_escaping = r".^$*+?{}\[]|)(" self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping)) def test_feb29_on_leap_year_without_year(self): time.strptime("Feb 29", "%b %d") def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): self.assertLess( time.strptime("Feb 29", "%b %d"), time.strptime("Mar 1", "%b %d")) class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" def test_twelve_noon_midnight(self): eq = self.assertEqual eq(time.strptime('12 PM', '%I %p')[3], 12) eq(time.strptime('12 AM', '%I %p')[3], 0) eq(_strptime._strptime_time('12 PM', '%I %p')[3], 12) eq(_strptime._strptime_time('12 AM', '%I %p')[3], 0) class JulianTests(unittest.TestCase): """Test a _strptime regression that all julian (1-366) are accepted""" def test_all_julian_days(self): eq = self.assertEqual for i in range(1, 367): # use 2004, since it is a leap year, we have 366 days eq(_strptime._strptime_time('%d 2004' % i, '%j %Y')[7], i) class CalculationTests(unittest.TestCase): """Test that strptime() fills in missing info correctly""" def setUp(self): self.time_tuple = time.gmtime() def test_julian_calculation(self): # Make sure that when Julian is missing that it is calculated format_string = "%Y %m %d %H %M %S %w %Z" result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple), format_string) self.assertTrue(result.tm_yday == self.time_tuple.tm_yday, "Calculation of tm_yday failed; %s != %s" % (result.tm_yday, self.time_tuple.tm_yday)) def test_gregorian_calculation(self): # Test that Gregorian date can be calculated from Julian day format_string = "%Y %H %M %S %w %j %Z" result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple), format_string) self.assertTrue(result.tm_year == self.time_tuple.tm_year and result.tm_mon == self.time_tuple.tm_mon and result.tm_mday == self.time_tuple.tm_mday, "Calculation of Gregorian date failed; " "%s-%s-%s != %s-%s-%s" % (result.tm_year, result.tm_mon, result.tm_mday, self.time_tuple.tm_year, self.time_tuple.tm_mon, self.time_tuple.tm_mday)) def test_day_of_week_calculation(self): # Test that the day of the week is calculated as needed format_string = "%Y %m %d %H %S %j %Z" result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple), format_string) self.assertTrue(result.tm_wday == self.time_tuple.tm_wday, "Calculation of day of the week failed; " "%s != %s" % (result.tm_wday, self.time_tuple.tm_wday)) if support.is_android: # Issue #26929: strftime() on Android incorrectly formats %V or %G for # the last or the first incomplete week in a year. _ymd_excluded = ((1905, 1, 1), (1906, 12, 31), (2008, 12, 29), (1917, 12, 31)) _formats_excluded = ('%G %V',) else: _ymd_excluded = () _formats_excluded = () def test_week_of_year_and_day_of_week_calculation(self): # Should be able to infer date if given year, week of year (%U or %W) # and day of the week def test_helper(ymd_tuple, test_reason): for year_week_format in ('%Y %W', '%Y %U', '%G %V'): if (year_week_format in self._formats_excluded and ymd_tuple in self._ymd_excluded): return for weekday_format in ('%w', '%u', '%a', '%A'): format_string = year_week_format + ' ' + weekday_format with self.subTest(test_reason, date=ymd_tuple, format=format_string): dt_date = datetime_date(*ymd_tuple) strp_input = dt_date.strftime(format_string) strp_output = _strptime._strptime_time(strp_input, format_string) msg = "%r: %s != %s" % (strp_input, strp_output[7], dt_date.timetuple()[7]) self.assertEqual(strp_output[:3], ymd_tuple, msg) test_helper((1901, 1, 3), "week 0") test_helper((1901, 1, 8), "common case") test_helper((1901, 1, 13), "day on Sunday") test_helper((1901, 1, 14), "day on Monday") test_helper((1905, 1, 1), "Jan 1 on Sunday") test_helper((1906, 1, 1), "Jan 1 on Monday") test_helper((1906, 1, 7), "first Sunday in a year starting on Monday") test_helper((1905, 12, 31), "Dec 31 on Sunday") test_helper((1906, 12, 31), "Dec 31 on Monday") test_helper((2008, 12, 29), "Monday in the last week of the year") test_helper((2008, 12, 22), "Monday in the second-to-last week of the " "year") test_helper((1978, 10, 23), "randomly chosen date") test_helper((2004, 12, 18), "randomly chosen date") test_helper((1978, 10, 23), "year starting and ending on Monday while " "date not on Sunday or Monday") test_helper((1917, 12, 17), "year starting and ending on Monday with " "a Monday not at the beginning or end " "of the year") test_helper((1917, 12, 31), "Dec 31 on Monday with year starting and " "ending on Monday") test_helper((2007, 1, 7), "First Sunday of 2007") test_helper((2007, 1, 14), "Second Sunday of 2007") test_helper((2006, 12, 31), "Last Sunday of 2006") test_helper((2006, 12, 24), "Second to last Sunday of 2006") def test_week_0(self): def check(value, format, *expected): self.assertEqual(_strptime._strptime_time(value, format)[:-1], expected) check('2015 0 0', '%Y %U %w', 2014, 12, 28, 0, 0, 0, 6, 362) check('2015 0 0', '%Y %W %w', 2015, 1, 4, 0, 0, 0, 6, 4) check('2015 1 1', '%G %V %u', 2014, 12, 29, 0, 0, 0, 0, 363) check('2015 0 1', '%Y %U %w', 2014, 12, 29, 0, 0, 0, 0, 363) check('2015 0 1', '%Y %W %w', 2014, 12, 29, 0, 0, 0, 0, 363) check('2015 1 2', '%G %V %u', 2014, 12, 30, 0, 0, 0, 1, 364) check('2015 0 2', '%Y %U %w', 2014, 12, 30, 0, 0, 0, 1, 364) check('2015 0 2', '%Y %W %w', 2014, 12, 30, 0, 0, 0, 1, 364) check('2015 1 3', '%G %V %u', 2014, 12, 31, 0, 0, 0, 2, 365) check('2015 0 3', '%Y %U %w', 2014, 12, 31, 0, 0, 0, 2, 365) check('2015 0 3', '%Y %W %w', 2014, 12, 31, 0, 0, 0, 2, 365) check('2015 1 4', '%G %V %u', 2015, 1, 1, 0, 0, 0, 3, 1) check('2015 0 4', '%Y %U %w', 2015, 1, 1, 0, 0, 0, 3, 1) check('2015 0 4', '%Y %W %w', 2015, 1, 1, 0, 0, 0, 3, 1) check('2015 1 5', '%G %V %u', 2015, 1, 2, 0, 0, 0, 4, 2) check('2015 0 5', '%Y %U %w', 2015, 1, 2, 0, 0, 0, 4, 2) check('2015 0 5', '%Y %W %w', 2015, 1, 2, 0, 0, 0, 4, 2) check('2015 1 6', '%G %V %u', 2015, 1, 3, 0, 0, 0, 5, 3) check('2015 0 6', '%Y %U %w', 2015, 1, 3, 0, 0, 0, 5, 3) check('2015 0 6', '%Y %W %w', 2015, 1, 3, 0, 0, 0, 5, 3) check('2015 1 7', '%G %V %u', 2015, 1, 4, 0, 0, 0, 6, 4) check('2009 0 0', '%Y %U %w', 2008, 12, 28, 0, 0, 0, 6, 363) check('2009 0 0', '%Y %W %w', 2009, 1, 4, 0, 0, 0, 6, 4) check('2009 1 1', '%G %V %u', 2008, 12, 29, 0, 0, 0, 0, 364) check('2009 0 1', '%Y %U %w', 2008, 12, 29, 0, 0, 0, 0, 364) check('2009 0 1', '%Y %W %w', 2008, 12, 29, 0, 0, 0, 0, 364) check('2009 1 2', '%G %V %u', 2008, 12, 30, 0, 0, 0, 1, 365) check('2009 0 2', '%Y %U %w', 2008, 12, 30, 0, 0, 0, 1, 365) check('2009 0 2', '%Y %W %w', 2008, 12, 30, 0, 0, 0, 1, 365) check('2009 1 3', '%G %V %u', 2008, 12, 31, 0, 0, 0, 2, 366) check('2009 0 3', '%Y %U %w', 2008, 12, 31, 0, 0, 0, 2, 366) check('2009 0 3', '%Y %W %w', 2008, 12, 31, 0, 0, 0, 2, 366) check('2009 1 4', '%G %V %u', 2009, 1, 1, 0, 0, 0, 3, 1) check('2009 0 4', '%Y %U %w', 2009, 1, 1, 0, 0, 0, 3, 1) check('2009 0 4', '%Y %W %w', 2009, 1, 1, 0, 0, 0, 3, 1) check('2009 1 5', '%G %V %u', 2009, 1, 2, 0, 0, 0, 4, 2) check('2009 0 5', '%Y %U %w', 2009, 1, 2, 0, 0, 0, 4, 2) check('2009 0 5', '%Y %W %w', 2009, 1, 2, 0, 0, 0, 4, 2) check('2009 1 6', '%G %V %u', 2009, 1, 3, 0, 0, 0, 5, 3) check('2009 0 6', '%Y %U %w', 2009, 1, 3, 0, 0, 0, 5, 3) check('2009 0 6', '%Y %W %w', 2009, 1, 3, 0, 0, 0, 5, 3) check('2009 1 7', '%G %V %u', 2009, 1, 4, 0, 0, 0, 6, 4) class CacheTests(unittest.TestCase): """Test that caching works properly.""" def test_time_re_recreation(self): # Make sure cache is recreated when current locale does not match what # cached object was created with. _strptime._strptime_time("10", "%d") _strptime._strptime_time("2005", "%Y") _strptime._TimeRE_cache.locale_time.lang = "Ni" original_time_re = _strptime._TimeRE_cache _strptime._strptime_time("10", "%d") self.assertIsNot(original_time_re, _strptime._TimeRE_cache) self.assertEqual(len(_strptime._regex_cache), 1) def test_regex_cleanup(self): # Make sure cached regexes are discarded when cache becomes "full". try: del _strptime._regex_cache['%d'] except KeyError: pass bogus_key = 0 while len(_strptime._regex_cache) <= _strptime._CACHE_MAX_SIZE: _strptime._regex_cache[bogus_key] = None bogus_key += 1 _strptime._strptime_time("10", "%d") self.assertEqual(len(_strptime._regex_cache), 1) def test_new_localetime(self): # A new LocaleTime instance should be created when a new TimeRE object # is created. locale_time_id = _strptime._TimeRE_cache.locale_time _strptime._TimeRE_cache.locale_time.lang = "Ni" _strptime._strptime_time("10", "%d") self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) def test_TimeRE_recreation_locale(self): # The TimeRE instance should be recreated upon changing the locale. locale_info = locale.getlocale(locale.LC_TIME) try: locale.setlocale(locale.LC_TIME, ('en_US', 'UTF8')) except locale.Error: self.skipTest('test needs en_US.UTF8 locale') try: _strptime._strptime_time('10', '%d') # Get id of current cache object. first_time_re = _strptime._TimeRE_cache try: # Change the locale and force a recreation of the cache. locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8')) _strptime._strptime_time('10', '%d') # Get the new cache object's id. second_time_re = _strptime._TimeRE_cache # They should not be equal. self.assertIsNot(first_time_re, second_time_re) # Possible test locale is not supported while initial locale is. # If this is the case just suppress the exception and fall-through # to the resetting to the original locale. except locale.Error: self.skipTest('test needs de_DE.UTF8 locale') # Make sure we don't trample on the locale setting once we leave the # test. finally: locale.setlocale(locale.LC_TIME, locale_info) @support.run_with_tz('STD-1DST,M4.1.0,M10.1.0') def test_TimeRE_recreation_timezone(self): # The TimeRE instance should be recreated upon changing the timezone. oldtzname = time.tzname tm = _strptime._strptime_time(time.tzname[0], '%Z') self.assertEqual(tm.tm_isdst, 0) tm = _strptime._strptime_time(time.tzname[1], '%Z') self.assertEqual(tm.tm_isdst, 1) # Get id of current cache object. first_time_re = _strptime._TimeRE_cache # Change the timezone and force a recreation of the cache. os.environ['TZ'] = 'EST+05EDT,M3.2.0,M11.1.0' time.tzset() tm = _strptime._strptime_time(time.tzname[0], '%Z') self.assertEqual(tm.tm_isdst, 0) tm = _strptime._strptime_time(time.tzname[1], '%Z') self.assertEqual(tm.tm_isdst, 1) # Get the new cache object's id. second_time_re = _strptime._TimeRE_cache # They should not be equal. self.assertIsNot(first_time_re, second_time_re) # Make sure old names no longer accepted. with self.assertRaises(ValueError): _strptime._strptime_time(oldtzname[0], '%Z') with self.assertRaises(ValueError): _strptime._strptime_time(oldtzname[1], '%Z') if __name__ == '__main__': unittest.main()
32,327
674
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_ucn.py
""" Test script for the Unicode implementation. Written by Bill Tutt. Modified for Python 2.0 by Fredrik Lundh ([email protected]) (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" import unittest import unicodedata from test import support from http.client import HTTPException from test.test_normalization import check_version try: from _testcapi import INT_MAX, PY_SSIZE_T_MAX, UINT_MAX except ImportError: INT_MAX = PY_SSIZE_T_MAX = UINT_MAX = 2**64 - 1 class UnicodeNamesTest(unittest.TestCase): def checkletter(self, name, code): # Helper that put all \N escapes inside eval'd raw strings, # to make sure this script runs even if the compiler # chokes on \N escapes res = eval(r'"\N{%s}"' % name) self.assertEqual(res, code) return res def test_general(self): # General and case insensitivity test: chars = [ "LATIN CAPITAL LETTER T", "LATIN SMALL LETTER H", "LATIN SMALL LETTER E", "SPACE", "LATIN SMALL LETTER R", "LATIN CAPITAL LETTER E", "LATIN SMALL LETTER D", "SPACE", "LATIN SMALL LETTER f", "LATIN CAPITAL LeTtEr o", "LATIN SMaLl LETTER x", "SPACE", "LATIN SMALL LETTER A", "LATIN SMALL LETTER T", "LATIN SMALL LETTER E", "SPACE", "LATIN SMALL LETTER T", "LATIN SMALL LETTER H", "LATIN SMALL LETTER E", "SpAcE", "LATIN SMALL LETTER S", "LATIN SMALL LETTER H", "LATIN small LETTER e", "LATIN small LETTER e", "LATIN SMALL LETTER P", "FULL STOP" ] string = "The rEd fOx ate the sheep." self.assertEqual( "".join([self.checkletter(*args) for args in zip(chars, string)]), string ) def test_ascii_letters(self): for char in "".join(map(chr, range(ord("a"), ord("z")))): name = "LATIN SMALL LETTER %s" % char.upper() code = unicodedata.lookup(name) self.assertEqual(unicodedata.name(code), name) def test_hangul_syllables(self): self.checkletter("HANGUL SYLLABLE GA", "\uac00") self.checkletter("HANGUL SYLLABLE GGWEOSS", "\uafe8") self.checkletter("HANGUL SYLLABLE DOLS", "\ub3d0") self.checkletter("HANGUL SYLLABLE RYAN", "\ub7b8") self.checkletter("HANGUL SYLLABLE MWIK", "\ubba0") self.checkletter("HANGUL SYLLABLE BBWAEM", "\ubf88") self.checkletter("HANGUL SYLLABLE SSEOL", "\uc370") self.checkletter("HANGUL SYLLABLE YI", "\uc758") self.checkletter("HANGUL SYLLABLE JJYOSS", "\ucb40") self.checkletter("HANGUL SYLLABLE KYEOLS", "\ucf28") self.checkletter("HANGUL SYLLABLE PAN", "\ud310") self.checkletter("HANGUL SYLLABLE HWEOK", "\ud6f8") self.checkletter("HANGUL SYLLABLE HIH", "\ud7a3") self.assertRaises(ValueError, unicodedata.name, "\ud7a4") def test_cjk_unified_ideographs(self): self.checkletter("CJK UNIFIED IDEOGRAPH-3400", "\u3400") self.checkletter("CJK UNIFIED IDEOGRAPH-4DB5", "\u4db5") self.checkletter("CJK UNIFIED IDEOGRAPH-4E00", "\u4e00") self.checkletter("CJK UNIFIED IDEOGRAPH-9FCB", "\u9fCB") self.checkletter("CJK UNIFIED IDEOGRAPH-20000", "\U00020000") self.checkletter("CJK UNIFIED IDEOGRAPH-2A6D6", "\U0002a6d6") self.checkletter("CJK UNIFIED IDEOGRAPH-2A700", "\U0002A700") self.checkletter("CJK UNIFIED IDEOGRAPH-2B734", "\U0002B734") self.checkletter("CJK UNIFIED IDEOGRAPH-2B740", "\U0002B740") self.checkletter("CJK UNIFIED IDEOGRAPH-2B81D", "\U0002B81D") def test_bmp_characters(self): for code in range(0x10000): char = chr(code) name = unicodedata.name(char, None) if name is not None: self.assertEqual(unicodedata.lookup(name), char) def test_misc_symbols(self): self.checkletter("PILCROW SIGN", "\u00b6") self.checkletter("REPLACEMENT CHARACTER", "\uFFFD") self.checkletter("HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK", "\uFF9F") self.checkletter("FULLWIDTH LATIN SMALL LETTER A", "\uFF41") def test_aliases(self): # Check that the aliases defined in the NameAliases.txt file work. # This should be updated when new aliases are added or the file # should be downloaded and parsed instead. See #12753. aliases = [ ('LATIN CAPITAL LETTER GHA', 0x01A2), ('LATIN SMALL LETTER GHA', 0x01A3), ('KANNADA LETTER LLLA', 0x0CDE), ('LAO LETTER FO FON', 0x0E9D), ('LAO LETTER FO FAY', 0x0E9F), ('LAO LETTER RO', 0x0EA3), ('LAO LETTER LO', 0x0EA5), ('TIBETAN MARK BKA- SHOG GI MGO RGYAN', 0x0FD0), ('YI SYLLABLE ITERATION MARK', 0xA015), ('PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRACKET', 0xFE18), ('BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS', 0x1D0C5) ] for alias, codepoint in aliases: self.checkletter(alias, chr(codepoint)) name = unicodedata.name(chr(codepoint)) self.assertNotEqual(name, alias) self.assertEqual(unicodedata.lookup(alias), unicodedata.lookup(name)) with self.assertRaises(KeyError): unicodedata.ucd_3_2_0.lookup(alias) def test_aliases_names_in_pua_range(self): # We are storing aliases in the PUA 15, but their names shouldn't leak for cp in range(0xf0000, 0xf0100): with self.assertRaises(ValueError) as cm: unicodedata.name(chr(cp)) self.assertEqual(str(cm.exception), 'no such name') def test_named_sequences_names_in_pua_range(self): # We are storing named seq in the PUA 15, but their names shouldn't leak for cp in range(0xf0100, 0xf0fff): with self.assertRaises(ValueError) as cm: unicodedata.name(chr(cp)) self.assertEqual(str(cm.exception), 'no such name') def test_named_sequences_sample(self): # Check a few named sequences. See #12753. sequences = [ ('LATIN SMALL LETTER R WITH TILDE', '\u0072\u0303'), ('TAMIL SYLLABLE SAI', '\u0BB8\u0BC8'), ('TAMIL SYLLABLE MOO', '\u0BAE\u0BCB'), ('TAMIL SYLLABLE NNOO', '\u0BA3\u0BCB'), ('TAMIL CONSONANT KSS', '\u0B95\u0BCD\u0BB7\u0BCD'), ] for seqname, codepoints in sequences: self.assertEqual(unicodedata.lookup(seqname), codepoints) with self.assertRaises(SyntaxError): self.checkletter(seqname, None) with self.assertRaises(KeyError): unicodedata.ucd_3_2_0.lookup(seqname) def test_named_sequences_full(self): # Check all the named sequences url = ("http://www.pythontest.net/unicode/%s/NamedSequences.txt" % unicodedata.unidata_version) try: testdata = support.open_urlresource(url, encoding="utf-8", check=check_version) except (OSError, HTTPException): self.skipTest("Could not retrieve " + url) self.addCleanup(testdata.close) for line in testdata: line = line.strip() if not line or line.startswith('#'): continue seqname, codepoints = line.split(';') codepoints = ''.join(chr(int(cp, 16)) for cp in codepoints.split()) self.assertEqual(unicodedata.lookup(seqname), codepoints) with self.assertRaises(SyntaxError): self.checkletter(seqname, None) with self.assertRaises(KeyError): unicodedata.ucd_3_2_0.lookup(seqname) def test_errors(self): self.assertRaises(TypeError, unicodedata.name) self.assertRaises(TypeError, unicodedata.name, 'xx') self.assertRaises(TypeError, unicodedata.lookup) self.assertRaises(KeyError, unicodedata.lookup, 'unknown') def test_strict_error_handling(self): # bogus character name self.assertRaises( UnicodeError, str, b"\\N{blah}", 'unicode-escape', 'strict' ) # long bogus character name self.assertRaises( UnicodeError, str, bytes("\\N{%s}" % ("x" * 100000), "ascii"), 'unicode-escape', 'strict' ) # missing closing brace self.assertRaises( UnicodeError, str, b"\\N{SPACE", 'unicode-escape', 'strict' ) # missing opening brace self.assertRaises( UnicodeError, str, b"\\NSPACE", 'unicode-escape', 'strict' ) @support.cpython_only @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") @support.bigmemtest(size=UINT_MAX + 1, memuse=2 + 1, dry_run=False) def test_issue16335(self, size): # very very long bogus character name x = b'\\N{SPACE' + b'x' * (UINT_MAX + 1) + b'}' self.assertEqual(len(x), len(b'\\N{SPACE}') + (UINT_MAX + 1)) self.assertRaisesRegex(UnicodeError, 'unknown Unicode character name', x.decode, 'unicode-escape' ) if __name__ == "__main__": unittest.main()
9,576
238
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_fileinput.py
''' Tests for fileinput module. Nick Mathewson ''' import os import sys import re import fileinput import collections import builtins import tempfile import unittest try: import bz2 except ImportError: bz2 = None try: import gzip except ImportError: gzip = None from io import BytesIO, StringIO from fileinput import FileInput, hook_encoded from encodings import utf_7 from test.support import verbose, TESTFN, check_warnings from test.support import unlink as safe_unlink from test import support from unittest import mock # The fileinput module has 2 interfaces: the FileInput class which does # all the work, and a few functions (input, etc.) that use a global _state # variable. class BaseTests: # Write a content (str or bytes) to temp file, and return the # temp file's name. def writeTmp(self, content, *, mode='w'): # opening in text mode is the default fd, name = tempfile.mkstemp() self.addCleanup(support.unlink, name) with open(fd, mode) as f: f.write(content) return name class LineReader: def __init__(self): self._linesread = [] @property def linesread(self): try: return self._linesread[:] finally: self._linesread = [] def openhook(self, filename, mode): self.it = iter(filename.splitlines(True)) return self def readline(self, size=None): line = next(self.it, '') self._linesread.append(line) return line def readlines(self, hint=-1): lines = [] size = 0 while True: line = self.readline() if not line: return lines lines.append(line) size += len(line) if size >= hint: return lines def close(self): pass class BufferSizesTests(BaseTests, unittest.TestCase): def test_buffer_sizes(self): # First, run the tests with default and teeny buffer size. for round, bs in (0, 0), (1, 30): t1 = self.writeTmp(''.join("Line %s of file 1\n" % (i+1) for i in range(15))) t2 = self.writeTmp(''.join("Line %s of file 2\n" % (i+1) for i in range(10))) t3 = self.writeTmp(''.join("Line %s of file 3\n" % (i+1) for i in range(5))) t4 = self.writeTmp(''.join("Line %s of file 4\n" % (i+1) for i in range(1))) if bs: with self.assertWarns(DeprecationWarning): self.buffer_size_test(t1, t2, t3, t4, bs, round) else: self.buffer_size_test(t1, t2, t3, t4, bs, round) def buffer_size_test(self, t1, t2, t3, t4, bs=0, round=0): pat = re.compile(r'LINE (\d+) OF FILE (\d+)') start = 1 + round*6 if verbose: print('%s. Simple iteration (bs=%s)' % (start+0, bs)) fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) lines = list(fi) fi.close() self.assertEqual(len(lines), 31) self.assertEqual(lines[4], 'Line 5 of file 1\n') self.assertEqual(lines[30], 'Line 1 of file 4\n') self.assertEqual(fi.lineno(), 31) self.assertEqual(fi.filename(), t4) if verbose: print('%s. Status variables (bs=%s)' % (start+1, bs)) fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) s = "x" while s and s != 'Line 6 of file 2\n': s = fi.readline() self.assertEqual(fi.filename(), t2) self.assertEqual(fi.lineno(), 21) self.assertEqual(fi.filelineno(), 6) self.assertFalse(fi.isfirstline()) self.assertFalse(fi.isstdin()) if verbose: print('%s. Nextfile (bs=%s)' % (start+2, bs)) fi.nextfile() self.assertEqual(fi.readline(), 'Line 1 of file 3\n') self.assertEqual(fi.lineno(), 22) fi.close() if verbose: print('%s. Stdin (bs=%s)' % (start+3, bs)) fi = FileInput(files=(t1, t2, t3, t4, '-'), bufsize=bs) savestdin = sys.stdin try: sys.stdin = StringIO("Line 1 of stdin\nLine 2 of stdin\n") lines = list(fi) self.assertEqual(len(lines), 33) self.assertEqual(lines[32], 'Line 2 of stdin\n') self.assertEqual(fi.filename(), '<stdin>') fi.nextfile() finally: sys.stdin = savestdin if verbose: print('%s. Boundary conditions (bs=%s)' % (start+4, bs)) fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) self.assertEqual(fi.lineno(), 0) self.assertEqual(fi.filename(), None) fi.nextfile() self.assertEqual(fi.lineno(), 0) self.assertEqual(fi.filename(), None) if verbose: print('%s. Inplace (bs=%s)' % (start+5, bs)) savestdout = sys.stdout try: fi = FileInput(files=(t1, t2, t3, t4), inplace=1, bufsize=bs) for line in fi: line = line[:-1].upper() print(line) fi.close() finally: sys.stdout = savestdout fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs) for line in fi: self.assertEqual(line[-1], '\n') m = pat.match(line[:-1]) self.assertNotEqual(m, None) self.assertEqual(int(m.group(1)), fi.filelineno()) fi.close() class UnconditionallyRaise: def __init__(self, exception_type): self.exception_type = exception_type self.invoked = False def __call__(self, *args, **kwargs): self.invoked = True raise self.exception_type() class FileInputTests(BaseTests, unittest.TestCase): def test_zero_byte_files(self): t1 = self.writeTmp("") t2 = self.writeTmp("") t3 = self.writeTmp("The only line there is.\n") t4 = self.writeTmp("") fi = FileInput(files=(t1, t2, t3, t4)) line = fi.readline() self.assertEqual(line, 'The only line there is.\n') self.assertEqual(fi.lineno(), 1) self.assertEqual(fi.filelineno(), 1) self.assertEqual(fi.filename(), t3) line = fi.readline() self.assertFalse(line) self.assertEqual(fi.lineno(), 1) self.assertEqual(fi.filelineno(), 0) self.assertEqual(fi.filename(), t4) fi.close() def test_files_that_dont_end_with_newline(self): t1 = self.writeTmp("A\nB\nC") t2 = self.writeTmp("D\nE\nF") fi = FileInput(files=(t1, t2)) lines = list(fi) self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"]) self.assertEqual(fi.filelineno(), 3) self.assertEqual(fi.lineno(), 6) ## def test_unicode_filenames(self): ## # XXX A unicode string is always returned by writeTmp. ## # So is this needed? ## t1 = self.writeTmp("A\nB") ## encoding = sys.getfilesystemencoding() ## if encoding is None: ## encoding = 'ascii' ## fi = FileInput(files=str(t1, encoding)) ## lines = list(fi) ## self.assertEqual(lines, ["A\n", "B"]) def test_fileno(self): t1 = self.writeTmp("A\nB") t2 = self.writeTmp("C\nD") fi = FileInput(files=(t1, t2)) self.assertEqual(fi.fileno(), -1) line = next(fi) self.assertNotEqual(fi.fileno(), -1) fi.nextfile() self.assertEqual(fi.fileno(), -1) line = list(fi) self.assertEqual(fi.fileno(), -1) def test_opening_mode(self): try: # invalid mode, should raise ValueError fi = FileInput(mode="w") self.fail("FileInput should reject invalid mode argument") except ValueError: pass # try opening in universal newline mode t1 = self.writeTmp(b"A\nB\r\nC\rD", mode="wb") with check_warnings(('', DeprecationWarning)): fi = FileInput(files=t1, mode="U") with check_warnings(('', DeprecationWarning)): lines = list(fi) self.assertEqual(lines, ["A\n", "B\n", "C\n", "D"]) def test_stdin_binary_mode(self): with mock.patch('sys.stdin') as m_stdin: m_stdin.buffer = BytesIO(b'spam, bacon, sausage, and spam') fi = FileInput(files=['-'], mode='rb') lines = list(fi) self.assertEqual(lines, [b'spam, bacon, sausage, and spam']) def test_detached_stdin_binary_mode(self): orig_stdin = sys.stdin try: sys.stdin = BytesIO(b'spam, bacon, sausage, and spam') self.assertFalse(hasattr(sys.stdin, 'buffer')) fi = FileInput(files=['-'], mode='rb') lines = list(fi) self.assertEqual(lines, [b'spam, bacon, sausage, and spam']) finally: sys.stdin = orig_stdin def test_file_opening_hook(self): try: # cannot use openhook and inplace mode fi = FileInput(inplace=1, openhook=lambda f, m: None) self.fail("FileInput should raise if both inplace " "and openhook arguments are given") except ValueError: pass try: fi = FileInput(openhook=1) self.fail("FileInput should check openhook for being callable") except ValueError: pass class CustomOpenHook: def __init__(self): self.invoked = False def __call__(self, *args): self.invoked = True return open(*args) t = self.writeTmp("\n") custom_open_hook = CustomOpenHook() with FileInput([t], openhook=custom_open_hook) as fi: fi.readline() self.assertTrue(custom_open_hook.invoked, "openhook not invoked") def test_readline(self): with open(TESTFN, 'wb') as f: f.write(b'A\nB\r\nC\r') # Fill TextIOWrapper buffer. f.write(b'123456789\n' * 1000) # Issue #20501: readline() shouldn't read whole file. f.write(b'\x80') self.addCleanup(safe_unlink, TESTFN) with FileInput(files=TESTFN, openhook=hook_encoded('ascii')) as fi: try: self.assertEqual(fi.readline(), 'A\n') self.assertEqual(fi.readline(), 'B\n') self.assertEqual(fi.readline(), 'C\n') except UnicodeDecodeError: self.fail('Read to end of file') with self.assertRaises(UnicodeDecodeError): # Read to the end of file. list(fi) self.assertEqual(fi.readline(), '') self.assertEqual(fi.readline(), '') def test_readline_binary_mode(self): with open(TESTFN, 'wb') as f: f.write(b'A\nB\r\nC\rD') self.addCleanup(safe_unlink, TESTFN) with FileInput(files=TESTFN, mode='rb') as fi: self.assertEqual(fi.readline(), b'A\n') self.assertEqual(fi.readline(), b'B\r\n') self.assertEqual(fi.readline(), b'C\rD') # Read to the end of file. self.assertEqual(fi.readline(), b'') self.assertEqual(fi.readline(), b'') def test_context_manager(self): t1 = self.writeTmp("A\nB\nC") t2 = self.writeTmp("D\nE\nF") with FileInput(files=(t1, t2)) as fi: lines = list(fi) self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"]) self.assertEqual(fi.filelineno(), 3) self.assertEqual(fi.lineno(), 6) self.assertEqual(fi._files, ()) def test_close_on_exception(self): t1 = self.writeTmp("") try: with FileInput(files=t1) as fi: raise OSError except OSError: self.assertEqual(fi._files, ()) def test_empty_files_list_specified_to_constructor(self): with FileInput(files=[]) as fi: self.assertEqual(fi._files, ('-',)) def test__getitem__(self): """Tests invoking FileInput.__getitem__() with the current line number""" t = self.writeTmp("line1\nline2\n") with FileInput(files=[t]) as fi: retval1 = fi[0] self.assertEqual(retval1, "line1\n") retval2 = fi[1] self.assertEqual(retval2, "line2\n") def test__getitem__invalid_key(self): """Tests invoking FileInput.__getitem__() with an index unequal to the line number""" t = self.writeTmp("line1\nline2\n") with FileInput(files=[t]) as fi: with self.assertRaises(RuntimeError) as cm: fi[1] self.assertEqual(cm.exception.args, ("accessing lines out of order",)) def test__getitem__eof(self): """Tests invoking FileInput.__getitem__() with the line number but at end-of-input""" t = self.writeTmp('') with FileInput(files=[t]) as fi: with self.assertRaises(IndexError) as cm: fi[0] self.assertEqual(cm.exception.args, ("end of input reached",)) def test_nextfile_oserror_deleting_backup(self): """Tests invoking FileInput.nextfile() when the attempt to delete the backup file would raise OSError. This error is expected to be silently ignored""" os_unlink_orig = os.unlink os_unlink_replacement = UnconditionallyRaise(OSError) try: t = self.writeTmp("\n") self.addCleanup(support.unlink, t + '.bak') with FileInput(files=[t], inplace=True) as fi: next(fi) # make sure the file is opened os.unlink = os_unlink_replacement fi.nextfile() finally: os.unlink = os_unlink_orig # sanity check to make sure that our test scenario was actually hit self.assertTrue(os_unlink_replacement.invoked, "os.unlink() was not invoked") def test_readline_os_fstat_raises_OSError(self): """Tests invoking FileInput.readline() when os.fstat() raises OSError. This exception should be silently discarded.""" os_fstat_orig = os.fstat os_fstat_replacement = UnconditionallyRaise(OSError) try: t = self.writeTmp("\n") with FileInput(files=[t], inplace=True) as fi: os.fstat = os_fstat_replacement fi.readline() finally: os.fstat = os_fstat_orig # sanity check to make sure that our test scenario was actually hit self.assertTrue(os_fstat_replacement.invoked, "os.fstat() was not invoked") @unittest.skipIf(not hasattr(os, "chmod"), "os.chmod does not exist") def test_readline_os_chmod_raises_OSError(self): """Tests invoking FileInput.readline() when os.chmod() raises OSError. This exception should be silently discarded.""" os_chmod_orig = os.chmod os_chmod_replacement = UnconditionallyRaise(OSError) try: t = self.writeTmp("\n") with FileInput(files=[t], inplace=True) as fi: os.chmod = os_chmod_replacement fi.readline() finally: os.chmod = os_chmod_orig # sanity check to make sure that our test scenario was actually hit self.assertTrue(os_chmod_replacement.invoked, "os.fstat() was not invoked") def test_fileno_when_ValueError_raised(self): class FilenoRaisesValueError(UnconditionallyRaise): def __init__(self): UnconditionallyRaise.__init__(self, ValueError) def fileno(self): self.__call__() unconditionally_raise_ValueError = FilenoRaisesValueError() t = self.writeTmp("\n") with FileInput(files=[t]) as fi: file_backup = fi._file try: fi._file = unconditionally_raise_ValueError result = fi.fileno() finally: fi._file = file_backup # make sure the file gets cleaned up # sanity check to make sure that our test scenario was actually hit self.assertTrue(unconditionally_raise_ValueError.invoked, "_file.fileno() was not invoked") self.assertEqual(result, -1, "fileno() should return -1") def test_readline_buffering(self): src = LineReader() with FileInput(files=['line1\nline2', 'line3\n'], openhook=src.openhook) as fi: self.assertEqual(src.linesread, []) self.assertEqual(fi.readline(), 'line1\n') self.assertEqual(src.linesread, ['line1\n']) self.assertEqual(fi.readline(), 'line2') self.assertEqual(src.linesread, ['line2']) self.assertEqual(fi.readline(), 'line3\n') self.assertEqual(src.linesread, ['', 'line3\n']) self.assertEqual(fi.readline(), '') self.assertEqual(src.linesread, ['']) self.assertEqual(fi.readline(), '') self.assertEqual(src.linesread, []) def test_iteration_buffering(self): src = LineReader() with FileInput(files=['line1\nline2', 'line3\n'], openhook=src.openhook) as fi: self.assertEqual(src.linesread, []) self.assertEqual(next(fi), 'line1\n') self.assertEqual(src.linesread, ['line1\n']) self.assertEqual(next(fi), 'line2') self.assertEqual(src.linesread, ['line2']) self.assertEqual(next(fi), 'line3\n') self.assertEqual(src.linesread, ['', 'line3\n']) self.assertRaises(StopIteration, next, fi) self.assertEqual(src.linesread, ['']) self.assertRaises(StopIteration, next, fi) self.assertEqual(src.linesread, []) class MockFileInput: """A class that mocks out fileinput.FileInput for use during unit tests""" def __init__(self, files=None, inplace=False, backup="", bufsize=0, mode="r", openhook=None): self.files = files self.inplace = inplace self.backup = backup self.bufsize = bufsize self.mode = mode self.openhook = openhook self._file = None self.invocation_counts = collections.defaultdict(lambda: 0) self.return_values = {} def close(self): self.invocation_counts["close"] += 1 def nextfile(self): self.invocation_counts["nextfile"] += 1 return self.return_values["nextfile"] def filename(self): self.invocation_counts["filename"] += 1 return self.return_values["filename"] def lineno(self): self.invocation_counts["lineno"] += 1 return self.return_values["lineno"] def filelineno(self): self.invocation_counts["filelineno"] += 1 return self.return_values["filelineno"] def fileno(self): self.invocation_counts["fileno"] += 1 return self.return_values["fileno"] def isfirstline(self): self.invocation_counts["isfirstline"] += 1 return self.return_values["isfirstline"] def isstdin(self): self.invocation_counts["isstdin"] += 1 return self.return_values["isstdin"] class BaseFileInputGlobalMethodsTest(unittest.TestCase): """Base class for unit tests for the global function of the fileinput module.""" def setUp(self): self._orig_state = fileinput._state self._orig_FileInput = fileinput.FileInput fileinput.FileInput = MockFileInput def tearDown(self): fileinput.FileInput = self._orig_FileInput fileinput._state = self._orig_state def assertExactlyOneInvocation(self, mock_file_input, method_name): # assert that the method with the given name was invoked once actual_count = mock_file_input.invocation_counts[method_name] self.assertEqual(actual_count, 1, method_name) # assert that no other unexpected methods were invoked actual_total_count = len(mock_file_input.invocation_counts) self.assertEqual(actual_total_count, 1) class Test_fileinput_input(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.input()""" def test_state_is_not_None_and_state_file_is_not_None(self): """Tests invoking fileinput.input() when fileinput._state is not None and its _file attribute is also not None. Expect RuntimeError to be raised with a meaningful error message and for fileinput._state to *not* be modified.""" instance = MockFileInput() instance._file = object() fileinput._state = instance with self.assertRaises(RuntimeError) as cm: fileinput.input() self.assertEqual(("input() already active",), cm.exception.args) self.assertIs(instance, fileinput._state, "fileinput._state") def test_state_is_not_None_and_state_file_is_None(self): """Tests invoking fileinput.input() when fileinput._state is not None but its _file attribute *is* None. Expect it to create and return a new fileinput.FileInput object with all method parameters passed explicitly to the __init__() method; also ensure that fileinput._state is set to the returned instance.""" instance = MockFileInput() instance._file = None fileinput._state = instance self.do_test_call_input() def test_state_is_None(self): """Tests invoking fileinput.input() when fileinput._state is None Expect it to create and return a new fileinput.FileInput object with all method parameters passed explicitly to the __init__() method; also ensure that fileinput._state is set to the returned instance.""" fileinput._state = None self.do_test_call_input() def do_test_call_input(self): """Tests that fileinput.input() creates a new fileinput.FileInput object, passing the given parameters unmodified to fileinput.FileInput.__init__(). Note that this test depends on the monkey patching of fileinput.FileInput done by setUp().""" files = object() inplace = object() backup = object() bufsize = object() mode = object() openhook = object() # call fileinput.input() with different values for each argument result = fileinput.input(files=files, inplace=inplace, backup=backup, bufsize=bufsize, mode=mode, openhook=openhook) # ensure fileinput._state was set to the returned object self.assertIs(result, fileinput._state, "fileinput._state") # ensure the parameters to fileinput.input() were passed directly # to FileInput.__init__() self.assertIs(files, result.files, "files") self.assertIs(inplace, result.inplace, "inplace") self.assertIs(backup, result.backup, "backup") self.assertIs(bufsize, result.bufsize, "bufsize") self.assertIs(mode, result.mode, "mode") self.assertIs(openhook, result.openhook, "openhook") class Test_fileinput_close(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.close()""" def test_state_is_None(self): """Tests that fileinput.close() does nothing if fileinput._state is None""" fileinput._state = None fileinput.close() self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests that fileinput.close() invokes close() on fileinput._state and sets _state=None""" instance = MockFileInput() fileinput._state = instance fileinput.close() self.assertExactlyOneInvocation(instance, "close") self.assertIsNone(fileinput._state) class Test_fileinput_nextfile(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.nextfile()""" def test_state_is_None(self): """Tests fileinput.nextfile() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.nextfile() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.nextfile() when fileinput._state is not None. Ensure that it invokes fileinput._state.nextfile() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" nextfile_retval = object() instance = MockFileInput() instance.return_values["nextfile"] = nextfile_retval fileinput._state = instance retval = fileinput.nextfile() self.assertExactlyOneInvocation(instance, "nextfile") self.assertIs(retval, nextfile_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_filename(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.filename()""" def test_state_is_None(self): """Tests fileinput.filename() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.filename() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.filename() when fileinput._state is not None. Ensure that it invokes fileinput._state.filename() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" filename_retval = object() instance = MockFileInput() instance.return_values["filename"] = filename_retval fileinput._state = instance retval = fileinput.filename() self.assertExactlyOneInvocation(instance, "filename") self.assertIs(retval, filename_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_lineno(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.lineno()""" def test_state_is_None(self): """Tests fileinput.lineno() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.lineno() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.lineno() when fileinput._state is not None. Ensure that it invokes fileinput._state.lineno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" lineno_retval = object() instance = MockFileInput() instance.return_values["lineno"] = lineno_retval fileinput._state = instance retval = fileinput.lineno() self.assertExactlyOneInvocation(instance, "lineno") self.assertIs(retval, lineno_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_filelineno(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.filelineno()""" def test_state_is_None(self): """Tests fileinput.filelineno() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.filelineno() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.filelineno() when fileinput._state is not None. Ensure that it invokes fileinput._state.filelineno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" filelineno_retval = object() instance = MockFileInput() instance.return_values["filelineno"] = filelineno_retval fileinput._state = instance retval = fileinput.filelineno() self.assertExactlyOneInvocation(instance, "filelineno") self.assertIs(retval, filelineno_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_fileno(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.fileno()""" def test_state_is_None(self): """Tests fileinput.fileno() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.fileno() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.fileno() when fileinput._state is not None. Ensure that it invokes fileinput._state.fileno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" fileno_retval = object() instance = MockFileInput() instance.return_values["fileno"] = fileno_retval instance.fileno_retval = fileno_retval fileinput._state = instance retval = fileinput.fileno() self.assertExactlyOneInvocation(instance, "fileno") self.assertIs(retval, fileno_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_isfirstline(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.isfirstline()""" def test_state_is_None(self): """Tests fileinput.isfirstline() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.isfirstline() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.isfirstline() when fileinput._state is not None. Ensure that it invokes fileinput._state.isfirstline() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" isfirstline_retval = object() instance = MockFileInput() instance.return_values["isfirstline"] = isfirstline_retval fileinput._state = instance retval = fileinput.isfirstline() self.assertExactlyOneInvocation(instance, "isfirstline") self.assertIs(retval, isfirstline_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_isstdin(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.isstdin()""" def test_state_is_None(self): """Tests fileinput.isstdin() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.isstdin() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.isstdin() when fileinput._state is not None. Ensure that it invokes fileinput._state.isstdin() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" isstdin_retval = object() instance = MockFileInput() instance.return_values["isstdin"] = isstdin_retval fileinput._state = instance retval = fileinput.isstdin() self.assertExactlyOneInvocation(instance, "isstdin") self.assertIs(retval, isstdin_retval) self.assertIs(fileinput._state, instance) class InvocationRecorder: def __init__(self): self.invocation_count = 0 def __call__(self, *args, **kwargs): self.invocation_count += 1 self.last_invocation = (args, kwargs) class Test_hook_compressed(unittest.TestCase): """Unit tests for fileinput.hook_compressed()""" def setUp(self): self.fake_open = InvocationRecorder() def test_empty_string(self): self.do_test_use_builtin_open("", 1) def test_no_ext(self): self.do_test_use_builtin_open("abcd", 2) @unittest.skipUnless(gzip, "Requires gzip and zlib") def test_gz_ext_fake(self): original_open = gzip.open gzip.open = self.fake_open try: result = fileinput.hook_compressed("test.gz", 3) finally: gzip.open = original_open self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, (("test.gz", 3), {})) @unittest.skipUnless(bz2, "Requires bz2") def test_bz2_ext_fake(self): original_open = bz2.BZ2File bz2.BZ2File = self.fake_open try: result = fileinput.hook_compressed("test.bz2", 4) finally: bz2.BZ2File = original_open self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, (("test.bz2", 4), {})) def test_blah_ext(self): self.do_test_use_builtin_open("abcd.blah", 5) def test_gz_ext_builtin(self): self.do_test_use_builtin_open("abcd.Gz", 6) def test_bz2_ext_builtin(self): self.do_test_use_builtin_open("abcd.Bz2", 7) def do_test_use_builtin_open(self, filename, mode): original_open = self.replace_builtin_open(self.fake_open) try: result = fileinput.hook_compressed(filename, mode) finally: self.replace_builtin_open(original_open) self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, ((filename, mode), {})) @staticmethod def replace_builtin_open(new_open_func): original_open = builtins.open builtins.open = new_open_func return original_open class Test_hook_encoded(unittest.TestCase): """Unit tests for fileinput.hook_encoded()""" def test(self): encoding = object() errors = object() result = fileinput.hook_encoded(encoding, errors=errors) fake_open = InvocationRecorder() original_open = builtins.open builtins.open = fake_open try: filename = object() mode = object() open_result = result(filename, mode) finally: builtins.open = original_open self.assertEqual(fake_open.invocation_count, 1) args, kwargs = fake_open.last_invocation self.assertIs(args[0], filename) self.assertIs(args[1], mode) self.assertIs(kwargs.pop('encoding'), encoding) self.assertIs(kwargs.pop('errors'), errors) self.assertFalse(kwargs) def test_errors(self): with open(TESTFN, 'wb') as f: f.write(b'\x80abc') self.addCleanup(safe_unlink, TESTFN) def check(errors, expected_lines): with FileInput(files=TESTFN, mode='r', openhook=hook_encoded('utf-8', errors=errors)) as fi: lines = list(fi) self.assertEqual(lines, expected_lines) check('ignore', ['abc']) with self.assertRaises(UnicodeDecodeError): check('strict', ['abc']) check('replace', ['\ufffdabc']) check('backslashreplace', ['\\x80abc']) def test_modes(self): with open(TESTFN, 'wb') as f: # UTF-7 is a convenient, seldom used encoding f.write(b'A\nB\r\nC\rD+IKw-') self.addCleanup(safe_unlink, TESTFN) def check(mode, expected_lines): with FileInput(files=TESTFN, mode=mode, openhook=hook_encoded('utf-7')) as fi: lines = list(fi) self.assertEqual(lines, expected_lines) check('r', ['A\n', 'B\n', 'C\n', 'D\u20ac']) with self.assertWarns(DeprecationWarning): check('rU', ['A\n', 'B\n', 'C\n', 'D\u20ac']) with self.assertWarns(DeprecationWarning): check('U', ['A\n', 'B\n', 'C\n', 'D\u20ac']) with self.assertRaises(ValueError): check('rb', ['A\n', 'B\r\n', 'C\r', 'D\u20ac']) class MiscTest(unittest.TestCase): def test_all(self): support.check__all__(self, fileinput) if __name__ == "__main__": unittest.main()
37,476
979
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/keycert3.pem
-----BEGIN PRIVATE KEY----- MIIG/QIBADANBgkqhkiG9w0BAQEFAASCBucwggbjAgEAAoIBgQCfKC83Qe9/ZGMW YhbpARRiKco6mJI9CNNeaf7A89TE+w5Y3GSwS8uzqp5C6QebZzPNueg8HYoTwN85 Z3xM036/Qw9KhQVth+XDAqM+19e5KHkYcxg3d3ZI1HgY170eakaLBvMDN5ULoFOw Is2PtwM2o9cjd5mfSuWttI6+fCqop8/l8cerG9iX2GH39p3iWwWoTZuYndAA9qYv 07YWajuQ1ESWKPjHYGTnMvu4xIzibC1mXd2M6u/IjNO6g426SKFaRDWQkx01gIV/ CyKs9DgZoeMHkKZuPqZVOxOK+A/NrmrqHFsPIsrs5wk7QAVju5/X1skpn/UGQlmM RwBaQULOs1FagA+54RXU6qUPW0YmhJ4xOB4gHHD1vjAKEsRZ7/6zcxMyOm+M1DbK RTH4NWjVWpnY8XaVGdRhtTpH9MjycpKhF+D2Zdy2tQXtqu2GdcMnUedt13fn9xDu P4PophE0ip/IMgn+kb4m9e+S+K9lldQl0B+4BcGWAqHelh2KuU0CAwEAAQKCAYEA lKiWIYjmyRjdLKUGPTES9vWNvNmRjozV0RQ0LcoSbMMLDZkeO0UwyWqOVHUQ8+ib jIcfEjeNJxI57oZopeHOO5vJhpNlFH+g7ltiW2qERqA1K88lSXm99Bzw6FNqhCRE K8ub5N9fyfJA+P4o/xm0WK8EXk5yIUV17p/9zJJxzgKgv2jsVTi3QG2OZGvn4Oug ByomMZEGHkBDzdxz8c/cP1Tlk1RFuwSgews178k2xq7AYSM/s0YmHi7b/RSvptX6 1v8P8kXNUe4AwTaNyrlvF2lwIadZ8h1hA7tCE2n44b7a7KfhAkwcbr1T59ioYh6P zxsyPT678uD51dbtD/DXJCcoeeFOb8uzkR2KNcrnQzZpCJnRq4Gp5ybxwsxxuzpr gz0gbNlhuWtE7EoSzmIK9t+WTS7IM2CvZymd6/OAh1Fuw6AQhSp64XRp3OfMMAAC Ie2EPtKj4islWGT8VoUjuRYGmdRh4duAH1dkiAXOWA3R7y5a1/y/iE8KE8BtxocB AoHBAM8aiURgpu1Fs0Oqz6izec7KSLL3l8hmW+MKUOfk/Ybng6FrTFsL5YtzR+Ap wW4wwWnnIKEc1JLiZ7g8agRETK8hr5PwFXUn/GSWC0SMsazLJToySQS5LOV0tLzK kJ3jtNU7tnlDGNkCHTHSoVL2T/8t+IkZI/h5Z6wjlYPvU2Iu0nVIXtiG+alv4A6M Hrh9l5or4mjB6rGnVXeYohLkCm6s/W97ahVxLMcEdbsBo1prm2JqGnSoiR/tEFC/ QHQnbQKBwQDEu7kW0Yg9sZ89QtYtVQ1YpixFZORaUeRIRLnpEs1w7L1mCbOZ2Lj9 JHxsH05cYAc7HJfPwwxv3+3aGAIC/dfu4VSwEFtatAzUpzlhzKS5+HQCWB4JUNNU MQ3+FwK2xQX4Ph8t+OzrFiYcK2g0An5UxWMa2HWIAWUOhnTOydAVsoH6yP31cVm4 0hxoABCwflaNLNGjRUyfBpLTAcNu/YtcE+KREy7YAAgXXrhRSO4XpLsSXwLnLT7/ YOkoBWDcTWECgcBPWnSUDZCIQ3efithMZJBciqd2Y2X19Dpq8O31HImD4jtOY0V7 cUB/wSkeHAGwjd/eCyA2e0x8B2IEdqmMfvr+86JJxekC3dJYXCFvH5WIhsH53YCa 3bT1KlWCLP9ib/g+58VQC0R/Cc9T4sfLePNH7D5ZkZd1wlbV30CPr+i8KwKay6MD xhvtLx+jk07GE+E9wmjbCMo7TclyrLoVEOlqZMAqshgApT+p9eyCPetwXuDHwa3n WxhHclcZCV7R4rUCgcAkdGSnxcvpIrDPOUNWwxvmAWTStw9ZbTNP8OxCNCm9cyDl d4bAS1h8D/a+Uk7C70hnu7Sl2w7C7Eu2zhwRUdhhe3+l4GINPK/j99i6NqGPlGpq xMlMEJ4YS768BqeKFpg0l85PRoEgTsphDeoROSUPsEPdBZ9BxIBlYKTkbKESZDGR twzYHljx1n1NCDYPflmrb1KpXn4EOcObNghw2KqqNUUWfOeBPwBA1FxzM4BrAStp DBINpGS4Dc0mjViVegECgcA3hTtm82XdxQXj9LQmb/E3lKx/7H87XIOeNMmvjYuZ iS9wKrkF+u42vyoDxcKMCnxP5056wpdST4p56r+SBwVTHcc3lGBSGcMTIfwRXrj3 thOA2our2n4ouNIsYyTlcsQSzifwmpRmVMRPxl9fYVdEWUgB83FgHT0D9avvZnF9 t9OccnGJXShAIZIBADhVj/JwG4FbaX42NijD5PNpVLk1Y17OV0I576T9SfaQoBjJ aH1M/zC4aVaS0DYB/Gxq7v8= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) Serial Number: cb:2d:80:99:5a:69:52:5c Signature Algorithm: sha256WithRSAEncryption Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server Validity Not Before: Aug 29 14:23:16 2018 GMT Not After : Jul 7 14:23:16 2028 GMT Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=localhost Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (3072 bit) Modulus: 00:9f:28:2f:37:41:ef:7f:64:63:16:62:16:e9:01: 14:62:29:ca:3a:98:92:3d:08:d3:5e:69:fe:c0:f3: d4:c4:fb:0e:58:dc:64:b0:4b:cb:b3:aa:9e:42:e9: 07:9b:67:33:cd:b9:e8:3c:1d:8a:13:c0:df:39:67: 7c:4c:d3:7e:bf:43:0f:4a:85:05:6d:87:e5:c3:02: a3:3e:d7:d7:b9:28:79:18:73:18:37:77:76:48:d4: 78:18:d7:bd:1e:6a:46:8b:06:f3:03:37:95:0b:a0: 53:b0:22:cd:8f:b7:03:36:a3:d7:23:77:99:9f:4a: e5:ad:b4:8e:be:7c:2a:a8:a7:cf:e5:f1:c7:ab:1b: d8:97:d8:61:f7:f6:9d:e2:5b:05:a8:4d:9b:98:9d: d0:00:f6:a6:2f:d3:b6:16:6a:3b:90:d4:44:96:28: f8:c7:60:64:e7:32:fb:b8:c4:8c:e2:6c:2d:66:5d: dd:8c:ea:ef:c8:8c:d3:ba:83:8d:ba:48:a1:5a:44: 35:90:93:1d:35:80:85:7f:0b:22:ac:f4:38:19:a1: e3:07:90:a6:6e:3e:a6:55:3b:13:8a:f8:0f:cd:ae: 6a:ea:1c:5b:0f:22:ca:ec:e7:09:3b:40:05:63:bb: 9f:d7:d6:c9:29:9f:f5:06:42:59:8c:47:00:5a:41: 42:ce:b3:51:5a:80:0f:b9:e1:15:d4:ea:a5:0f:5b: 46:26:84:9e:31:38:1e:20:1c:70:f5:be:30:0a:12: c4:59:ef:fe:b3:73:13:32:3a:6f:8c:d4:36:ca:45: 31:f8:35:68:d5:5a:99:d8:f1:76:95:19:d4:61:b5: 3a:47:f4:c8:f2:72:92:a1:17:e0:f6:65:dc:b6:b5: 05:ed:aa:ed:86:75:c3:27:51:e7:6d:d7:77:e7:f7: 10:ee:3f:83:e8:a6:11:34:8a:9f:c8:32:09:fe:91: be:26:f5:ef:92:f8:af:65:95:d4:25:d0:1f:b8:05: c1:96:02:a1:de:96:1d:8a:b9:4d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Alternative Name: DNS:localhost X509v3 Key Usage: critical Digital Signature, Key Encipherment X509v3 Extended Key Usage: TLS Web Server Authentication, TLS Web Client Authentication X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: 8F:EA:1D:E3:33:5C:00:16:B3:8B:6F:6B:6F:D3:4C:CB:B5:CB:7C:55 X509v3 Authority Key Identifier: keyid:DD:BF:CA:DA:E6:D1:34:BA:37:75:21:CA:6F:9A:08:28:F2:35:B6:48 DirName:/C=XY/O=Python Software Foundation CA/CN=our-ca-server serial:CB:2D:80:99:5A:69:52:5B Authority Information Access: CA Issuers - URI:http://testca.pythontest.net/testca/pycacert.cer OCSP - URI:http://testca.pythontest.net/testca/ocsp/ X509v3 CRL Distribution Points: Full Name: URI:http://testca.pythontest.net/testca/revocation.crl Signature Algorithm: sha256WithRSAEncryption 27:f5:8c:59:10:f4:c6:e7:28:00:bf:ba:8d:7b:13:03:f1:1c: a6:5f:b3:06:55:a4:22:b9:db:b2:d5:46:bd:f7:0c:dd:43:6e: b4:79:65:67:21:0c:2a:55:ee:40:8e:85:9f:9f:47:bb:0a:2a: 4d:b6:64:74:98:a0:7f:ae:dc:f1:2e:db:42:77:18:e0:75:8b: 26:35:68:c3:41:ed:6b:c8:77:72:6f:6a:9a:5d:55:69:02:fd: 5a:54:c8:57:cb:b0:65:03:16:e2:0f:00:39:99:66:a0:9b:88: 93:17:e2:5a:2d:79:35:5f:97:57:78:c4:af:f5:99:5e:86:ab: d3:11:ad:1a:a2:0d:fa:52:10:b9:fe:bf:9d:ce:33:d9:86:b2: 9c:16:f8:d6:75:08:8a:db:0a:e5:b4:2b:16:7f:b4:f9:2a:9f: c3:d2:77:d7:cd:65:1e:f4:6c:1e:eb:59:b9:f0:ae:5f:a4:1f: cc:4a:c4:b9:7a:a9:d9:6b:32:68:3b:e1:65:b0:84:b7:90:c4: ae:fe:f4:37:4f:21:a0:de:9f:3a:b1:e5:cc:16:04:66:3f:0b: 41:dc:42:3d:20:3e:ec:b7:95:2b:35:57:fa:be:7f:b6:3a:ba: ca:4f:58:fe:75:3e:08:89:2c:8c:b0:5d:2e:f9:89:10:2b:f9: 41:46:4f:3c:00:b7:27:d3:65:24:28:17:23:26:31:42:ea:7e: 4e:93:e4:7b:68:54:ca:9f:46:f3:ef:2b:e9:85:0c:b5:84:b2: d5:35:34:80:75:2b:f0:91:23:b8:08:01:8e:b9:0a:54:d4:fb: 34:52:fe:d9:45:f0:80:3b:b6:c1:6f:82:d1:1f:f2:3b:08:f6: 46:a6:96:27:61:4b:58:32:7a:0e:1d:59:c5:44:ad:5e:1a:79: 33:c1:d4:05:2f:4a:d3:d8:42:42:8d:33:e3:63:ca:d5:87:97: 9b:4d:b8:1a:03:34:bb:1c:d2:02:3f:59:23:e2:23:80:88:63: c2:f0:a2:63:a8:8b -----BEGIN CERTIFICATE----- MIIF8TCCBFmgAwIBAgIJAMstgJlaaVJcMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNV BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xODA4MjkxNDIzMTZaFw0yODA3MDcx NDIzMTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEj MCEGA1UECgwaUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMMCWxv Y2FsaG9zdDCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAJ8oLzdB739k YxZiFukBFGIpyjqYkj0I015p/sDz1MT7DljcZLBLy7OqnkLpB5tnM8256DwdihPA 3zlnfEzTfr9DD0qFBW2H5cMCoz7X17koeRhzGDd3dkjUeBjXvR5qRosG8wM3lQug U7AizY+3Azaj1yN3mZ9K5a20jr58Kqinz+Xxx6sb2JfYYff2neJbBahNm5id0AD2 pi/TthZqO5DURJYo+MdgZOcy+7jEjOJsLWZd3Yzq78iM07qDjbpIoVpENZCTHTWA hX8LIqz0OBmh4weQpm4+plU7E4r4D82uauocWw8iyuznCTtABWO7n9fWySmf9QZC WYxHAFpBQs6zUVqAD7nhFdTqpQ9bRiaEnjE4HiAccPW+MAoSxFnv/rNzEzI6b4zU NspFMfg1aNVamdjxdpUZ1GG1Okf0yPJykqEX4PZl3La1Be2q7YZ1wydR523Xd+f3 EO4/g+imETSKn8gyCf6Rvib175L4r2WV1CXQH7gFwZYCod6WHYq5TQIDAQABo4IB wDCCAbwwFAYDVR0RBA0wC4IJbG9jYWxob3N0MA4GA1UdDwEB/wQEAwIFoDAdBgNV HSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4E FgQUj+od4zNcABazi29rb9NMy7XLfFUwfQYDVR0jBHYwdIAU3b/K2ubRNLo3dSHK b5oIKPI1tkihUaRPME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29m dHdhcmUgRm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcoIJAMst gJlaaVJbMIGDBggrBgEFBQcBAQR3MHUwPAYIKwYBBQUHMAKGMGh0dHA6Ly90ZXN0 Y2EucHl0aG9udGVzdC5uZXQvdGVzdGNhL3B5Y2FjZXJ0LmNlcjA1BggrBgEFBQcw AYYpaHR0cDovL3Rlc3RjYS5weXRob250ZXN0Lm5ldC90ZXN0Y2Evb2NzcC8wQwYD VR0fBDwwOjA4oDagNIYyaHR0cDovL3Rlc3RjYS5weXRob250ZXN0Lm5ldC90ZXN0 Y2EvcmV2b2NhdGlvbi5jcmwwDQYJKoZIhvcNAQELBQADggGBACf1jFkQ9MbnKAC/ uo17EwPxHKZfswZVpCK527LVRr33DN1DbrR5ZWchDCpV7kCOhZ+fR7sKKk22ZHSY oH+u3PEu20J3GOB1iyY1aMNB7WvId3JvappdVWkC/VpUyFfLsGUDFuIPADmZZqCb iJMX4loteTVfl1d4xK/1mV6Gq9MRrRqiDfpSELn+v53OM9mGspwW+NZ1CIrbCuW0 KxZ/tPkqn8PSd9fNZR70bB7rWbnwrl+kH8xKxLl6qdlrMmg74WWwhLeQxK7+9DdP IaDenzqx5cwWBGY/C0HcQj0gPuy3lSs1V/q+f7Y6uspPWP51PgiJLIywXS75iRAr +UFGTzwAtyfTZSQoFyMmMULqfk6T5HtoVMqfRvPvK+mFDLWEstU1NIB1K/CRI7gI AY65ClTU+zRS/tlF8IA7tsFvgtEf8jsI9kamlidhS1gyeg4dWcVErV4aeTPB1AUv StPYQkKNM+NjytWHl5tNuBoDNLsc0gI/WSPiI4CIY8LwomOoiw== -----END CERTIFICATE-----
9,440
165
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_scope.py
import unittest import weakref from test.support import check_syntax_error, cpython_only class ScopeTests(unittest.TestCase): def testSimpleNesting(self): def make_adder(x): def adder(y): return x + y return adder inc = make_adder(1) plus10 = make_adder(10) self.assertEqual(inc(1), 2) self.assertEqual(plus10(-2), 8) def testExtraNesting(self): def make_adder2(x): def extra(): # check freevars passing through non-use scopes def adder(y): return x + y return adder return extra() inc = make_adder2(1) plus10 = make_adder2(10) self.assertEqual(inc(1), 2) self.assertEqual(plus10(-2), 8) def testSimpleAndRebinding(self): def make_adder3(x): def adder(y): return x + y x = x + 1 # check tracking of assignment to x in defining scope return adder inc = make_adder3(0) plus10 = make_adder3(9) self.assertEqual(inc(1), 2) self.assertEqual(plus10(-2), 8) def testNestingGlobalNoFree(self): def make_adder4(): # XXX add exta level of indirection def nest(): def nest(): def adder(y): return global_x + y # check that plain old globals work return adder return nest() return nest() global_x = 1 adder = make_adder4() self.assertEqual(adder(1), 2) global_x = 10 self.assertEqual(adder(-2), 8) def testNestingThroughClass(self): def make_adder5(x): class Adder: def __call__(self, y): return x + y return Adder() inc = make_adder5(1) plus10 = make_adder5(10) self.assertEqual(inc(1), 2) self.assertEqual(plus10(-2), 8) def testNestingPlusFreeRefToGlobal(self): def make_adder6(x): global global_nest_x def adder(y): return global_nest_x + y global_nest_x = x return adder inc = make_adder6(1) plus10 = make_adder6(10) self.assertEqual(inc(1), 11) # there's only one global self.assertEqual(plus10(-2), 8) def testNearestEnclosingScope(self): def f(x): def g(y): x = 42 # check that this masks binding in f() def h(z): return x + z return h return g(2) test_func = f(10) self.assertEqual(test_func(5), 47) def testMixedFreevarsAndCellvars(self): def identity(x): return x def f(x, y, z): def g(a, b, c): a = a + x # 3 def h(): # z * (4 + 9) # 3 * 13 return identity(z * (b + y)) y = c + z # 9 return h return g g = f(1, 2, 3) h = g(2, 4, 6) self.assertEqual(h(), 39) def testFreeVarInMethod(self): def test(): method_and_var = "var" class Test: def method_and_var(self): return "method" def test(self): return method_and_var def actual_global(self): return str("global") def str(self): return str(self) return Test() t = test() self.assertEqual(t.test(), "var") self.assertEqual(t.method_and_var(), "method") self.assertEqual(t.actual_global(), "global") method_and_var = "var" class Test: # this class is not nested, so the rules are different def method_and_var(self): return "method" def test(self): return method_and_var def actual_global(self): return str("global") def str(self): return str(self) t = Test() self.assertEqual(t.test(), "var") self.assertEqual(t.method_and_var(), "method") self.assertEqual(t.actual_global(), "global") def testCellIsKwonlyArg(self): # Issue 1409: Initialisation of a cell value, # when it comes from a keyword-only parameter def foo(*, a=17): def bar(): return a + 5 return bar() + 3 self.assertEqual(foo(a=42), 50) self.assertEqual(foo(), 25) def testRecursion(self): def f(x): def fact(n): if n == 0: return 1 else: return n * fact(n - 1) if x >= 0: return fact(x) else: raise ValueError("x must be >= 0") self.assertEqual(f(6), 720) def testUnoptimizedNamespaces(self): check_syntax_error(self, """if 1: def unoptimized_clash1(strip): def f(s): from sys import * return getrefcount(s) # ambiguity: free or local return f """) check_syntax_error(self, """if 1: def unoptimized_clash2(): from sys import * def f(s): return getrefcount(s) # ambiguity: global or local return f """) check_syntax_error(self, """if 1: def unoptimized_clash2(): from sys import * def g(): def f(s): return getrefcount(s) # ambiguity: global or local return f """) check_syntax_error(self, """if 1: def f(): def g(): from sys import * return getrefcount # global or local? """) def testLambdas(self): f1 = lambda x: lambda y: x + y inc = f1(1) plus10 = f1(10) self.assertEqual(inc(1), 2) self.assertEqual(plus10(5), 15) f2 = lambda x: (lambda : lambda y: x + y)() inc = f2(1) plus10 = f2(10) self.assertEqual(inc(1), 2) self.assertEqual(plus10(5), 15) f3 = lambda x: lambda y: global_x + y global_x = 1 inc = f3(None) self.assertEqual(inc(2), 3) f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y) g = f8(1, 2, 3) h = g(2, 4, 6) self.assertEqual(h(), 18) def testUnboundLocal(self): def errorInOuter(): print(y) def inner(): return y y = 1 def errorInInner(): def inner(): return y inner() y = 1 self.assertRaises(UnboundLocalError, errorInOuter) self.assertRaises(NameError, errorInInner) def testUnboundLocal_AfterDel(self): # #4617: It is now legal to delete a cell variable. # The following functions must obviously compile, # and give the correct error when accessing the deleted name. def errorInOuter(): y = 1 del y print(y) def inner(): return y def errorInInner(): def inner(): return y y = 1 del y inner() self.assertRaises(UnboundLocalError, errorInOuter) self.assertRaises(NameError, errorInInner) def testUnboundLocal_AugAssign(self): # test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation exec("""if 1: global_x = 1 def f(): global_x += 1 try: f() except UnboundLocalError: pass else: fail('scope of global_x not correctly determined') """, {'fail': self.fail}) def testComplexDefinitions(self): def makeReturner(*lst): def returner(): return lst return returner self.assertEqual(makeReturner(1,2,3)(), (1,2,3)) def makeReturner2(**kwargs): def returner(): return kwargs return returner self.assertEqual(makeReturner2(a=11)()['a'], 11) def testScopeOfGlobalStmt(self): # Examples posted by Samuele Pedroni to python-dev on 3/1/2001 exec("""if 1: # I x = 7 def f(): x = 1 def g(): global x def i(): def h(): return x return h() return i() return g() self.assertEqual(f(), 7) self.assertEqual(x, 7) # II x = 7 def f(): x = 1 def g(): x = 2 def i(): def h(): return x return h() return i() return g() self.assertEqual(f(), 2) self.assertEqual(x, 7) # III x = 7 def f(): x = 1 def g(): global x x = 2 def i(): def h(): return x return h() return i() return g() self.assertEqual(f(), 2) self.assertEqual(x, 2) # IV x = 7 def f(): x = 3 def g(): global x x = 2 def i(): def h(): return x return h() return i() return g() self.assertEqual(f(), 2) self.assertEqual(x, 2) # XXX what about global statements in class blocks? # do they affect methods? x = 12 class Global: global x x = 13 def set(self, val): x = val def get(self): return x g = Global() self.assertEqual(g.get(), 13) g.set(15) self.assertEqual(g.get(), 13) """) def testLeaks(self): class Foo: count = 0 def __init__(self): Foo.count += 1 def __del__(self): Foo.count -= 1 def f1(): x = Foo() def f2(): return x f2() for i in range(100): f1() self.assertEqual(Foo.count, 0) def testClassAndGlobal(self): exec("""if 1: def test(x): class Foo: global x def __call__(self, y): return x + y return Foo() x = 0 self.assertEqual(test(6)(2), 8) x = -1 self.assertEqual(test(3)(2), 5) looked_up_by_load_name = False class X: # Implicit globals inside classes are be looked up by LOAD_NAME, not # LOAD_GLOBAL. locals()['looked_up_by_load_name'] = True passed = looked_up_by_load_name self.assertTrue(X.passed) """) def testLocalsFunction(self): def f(x): def g(y): def h(z): return y + z w = x + y y += 3 return locals() return g d = f(2)(4) self.assertIn('h', d) del d['h'] self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6}) def testLocalsClass(self): # This test verifies that calling locals() does not pollute # the local namespace of the class with free variables. Old # versions of Python had a bug, where a free variable being # passed through a class namespace would be inserted into # locals() by locals() or exec or a trace function. # # The real bug lies in frame code that copies variables # between fast locals and the locals dict, e.g. when executing # a trace function. def f(x): class C: x = 12 def m(self): return x locals() return C self.assertEqual(f(1).x, 12) def f(x): class C: y = x def m(self): return x z = list(locals()) return C varnames = f(1).z self.assertNotIn("x", varnames) self.assertIn("y", varnames) @cpython_only def testLocalsClass_WithTrace(self): # Issue23728: after the trace function returns, the locals() # dictionary is used to update all variables, this used to # include free variables. But in class statements, free # variables are not inserted... import sys self.addCleanup(sys.settrace, sys.gettrace()) sys.settrace(lambda a,b,c:None) x = 12 class C: def f(self): return x self.assertEqual(x, 12) # Used to raise UnboundLocalError def testBoundAndFree(self): # var is bound and free in class def f(x): class C: def m(self): return x a = x return C inst = f(3)() self.assertEqual(inst.a, inst.m()) @cpython_only def testInteractionWithTraceFunc(self): import sys def tracer(a,b,c): return tracer def adaptgetter(name, klass, getter): kind, des = getter if kind == 1: # AV happens when stepping from this line to next if des == "": des = "_%s__%s" % (klass.__name__, name) return lambda obj: getattr(obj, des) class TestClass: pass self.addCleanup(sys.settrace, sys.gettrace()) sys.settrace(tracer) adaptgetter("foo", TestClass, (1, "")) sys.settrace(None) self.assertRaises(TypeError, sys.settrace) def testEvalExecFreeVars(self): def f(x): return lambda: x + 1 g = f(3) self.assertRaises(TypeError, eval, g.__code__) try: exec(g.__code__, {}) except TypeError: pass else: self.fail("exec should have failed, because code contained free vars") def testListCompLocalVars(self): try: print(bad) except NameError: pass else: print("bad should not be defined") def x(): [bad for s in 'a b' for bad in s.split()] x() try: print(bad) except NameError: pass def testEvalFreeVars(self): def f(x): def g(): x eval("x + 1") return g f(4)() def testFreeingCell(self): # Test what happens when a finalizer accesses # the cell where the object was stored. class Special: def __del__(self): nestedcell_get() def testNonLocalFunction(self): def f(x): def inc(): nonlocal x x += 1 return x def dec(): nonlocal x x -= 1 return x return inc, dec inc, dec = f(0) self.assertEqual(inc(), 1) self.assertEqual(inc(), 2) self.assertEqual(dec(), 1) self.assertEqual(dec(), 0) def testNonLocalMethod(self): def f(x): class c: def inc(self): nonlocal x x += 1 return x def dec(self): nonlocal x x -= 1 return x return c() c = f(0) self.assertEqual(c.inc(), 1) self.assertEqual(c.inc(), 2) self.assertEqual(c.dec(), 1) self.assertEqual(c.dec(), 0) def testGlobalInParallelNestedFunctions(self): # A symbol table bug leaked the global statement from one # function to other nested functions in the same block. # This test verifies that a global statement in the first # function does not affect the second function. local_ns = {} global_ns = {} exec("""if 1: def f(): y = 1 def g(): global y return y def h(): return y + 1 return g, h y = 9 g, h = f() result9 = g() result2 = h() """, local_ns, global_ns) self.assertEqual(2, global_ns["result2"]) self.assertEqual(9, global_ns["result9"]) def testNonLocalClass(self): def f(x): class c: nonlocal x x += 1 def get(self): return x return c() c = f(0) self.assertEqual(c.get(), 1) self.assertNotIn("x", c.__class__.__dict__) def testNonLocalGenerator(self): def f(x): def g(y): nonlocal x for i in range(y): x += 1 yield x return g g = f(0) self.assertEqual(list(g(5)), [1, 2, 3, 4, 5]) def testNestedNonLocal(self): def f(x): def g(): nonlocal x x -= 2 def h(): nonlocal x x += 4 return x return h return g g = f(1) h = g() self.assertEqual(h(), 3) def testTopIsNotSignificant(self): # See #9997. def top(a): pass def b(): global a def testClassNamespaceOverridesClosure(self): # See #17853. x = 42 class X: locals()["x"] = 43 y = x self.assertEqual(X.y, 43) class X: locals()["x"] = 43 del x self.assertFalse(hasattr(X, "x")) self.assertEqual(x, 42) @cpython_only def testCellLeak(self): # Issue 17927. # # The issue was that if self was part of a cycle involving the # frame of a method call, *and* the method contained a nested # function referencing self, thereby forcing 'self' into a # cell, setting self to None would not be enough to break the # frame -- the frame had another reference to the instance, # which could not be cleared by the code running in the frame # (though it will be cleared when the frame is collected). # Without the lambda, setting self to None is enough to break # the cycle. class Tester: def dig(self): if 0: lambda: self try: 1/0 except Exception as exc: self.exc = exc self = None # Break the cycle tester = Tester() tester.dig() ref = weakref.ref(tester) del tester self.assertIsNone(ref()) if __name__ == '__main__': unittest.main()
20,177
762
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_pipes.py
import pipes import os import string import unittest import shutil from test.support import TESTFN, run_unittest, unlink, reap_children if os.name != 'posix': raise unittest.SkipTest('pipes module only works on posix') TESTFN2 = TESTFN + "2" # tr a-z A-Z is not portable, so make the ranges explicit s_command = 'tr %s %s' % (string.ascii_lowercase, string.ascii_uppercase) class SimplePipeTests(unittest.TestCase): def tearDown(self): for f in (TESTFN, TESTFN2): unlink(f) def testSimplePipe1(self): if shutil.which('tr') is None: self.skipTest('tr is not available') t = pipes.Template() t.append(s_command, pipes.STDIN_STDOUT) f = t.open(TESTFN, 'w') f.write('hello world #1') f.close() with open(TESTFN) as f: self.assertEqual(f.read(), 'HELLO WORLD #1') def testSimplePipe2(self): if shutil.which('tr') is None: self.skipTest('tr is not available') with open(TESTFN, 'w') as f: f.write('hello world #2') t = pipes.Template() t.append(s_command + ' < $IN > $OUT', pipes.FILEIN_FILEOUT) t.copy(TESTFN, TESTFN2) with open(TESTFN2) as f: self.assertEqual(f.read(), 'HELLO WORLD #2') def testSimplePipe3(self): if shutil.which('tr') is None: self.skipTest('tr is not available') with open(TESTFN, 'w') as f: f.write('hello world #2') t = pipes.Template() t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT) f = t.open(TESTFN, 'r') try: self.assertEqual(f.read(), 'HELLO WORLD #2') finally: f.close() def testEmptyPipeline1(self): # copy through empty pipe d = 'empty pipeline test COPY' with open(TESTFN, 'w') as f: f.write(d) with open(TESTFN2, 'w') as f: f.write('') t=pipes.Template() t.copy(TESTFN, TESTFN2) with open(TESTFN2) as f: self.assertEqual(f.read(), d) def testEmptyPipeline2(self): # read through empty pipe d = 'empty pipeline test READ' with open(TESTFN, 'w') as f: f.write(d) t=pipes.Template() f = t.open(TESTFN, 'r') try: self.assertEqual(f.read(), d) finally: f.close() def testEmptyPipeline3(self): # write through empty pipe d = 'empty pipeline test WRITE' t = pipes.Template() with t.open(TESTFN, 'w') as f: f.write(d) with open(TESTFN) as f: self.assertEqual(f.read(), d) def testRepr(self): t = pipes.Template() self.assertEqual(repr(t), "<Template instance, steps=[]>") t.append('tr a-z A-Z', pipes.STDIN_STDOUT) self.assertEqual(repr(t), "<Template instance, steps=[('tr a-z A-Z', '--')]>") def testSetDebug(self): t = pipes.Template() t.debug(False) self.assertEqual(t.debugging, False) t.debug(True) self.assertEqual(t.debugging, True) def testReadOpenSink(self): # check calling open('r') on a pipe ending with # a sink raises ValueError t = pipes.Template() t.append('boguscmd', pipes.SINK) self.assertRaises(ValueError, t.open, 'bogusfile', 'r') def testWriteOpenSource(self): # check calling open('w') on a pipe ending with # a source raises ValueError t = pipes.Template() t.prepend('boguscmd', pipes.SOURCE) self.assertRaises(ValueError, t.open, 'bogusfile', 'w') def testBadAppendOptions(self): t = pipes.Template() # try a non-string command self.assertRaises(TypeError, t.append, 7, pipes.STDIN_STDOUT) # try a type that isn't recognized self.assertRaises(ValueError, t.append, 'boguscmd', 'xx') # shouldn't be able to append a source self.assertRaises(ValueError, t.append, 'boguscmd', pipes.SOURCE) # check appending two sinks t = pipes.Template() t.append('boguscmd', pipes.SINK) self.assertRaises(ValueError, t.append, 'boguscmd', pipes.SINK) # command needing file input but with no $IN t = pipes.Template() self.assertRaises(ValueError, t.append, 'boguscmd $OUT', pipes.FILEIN_FILEOUT) t = pipes.Template() self.assertRaises(ValueError, t.append, 'boguscmd', pipes.FILEIN_STDOUT) # command needing file output but with no $OUT t = pipes.Template() self.assertRaises(ValueError, t.append, 'boguscmd $IN', pipes.FILEIN_FILEOUT) t = pipes.Template() self.assertRaises(ValueError, t.append, 'boguscmd', pipes.STDIN_FILEOUT) def testBadPrependOptions(self): t = pipes.Template() # try a non-string command self.assertRaises(TypeError, t.prepend, 7, pipes.STDIN_STDOUT) # try a type that isn't recognized self.assertRaises(ValueError, t.prepend, 'tr a-z A-Z', 'xx') # shouldn't be able to prepend a sink self.assertRaises(ValueError, t.prepend, 'boguscmd', pipes.SINK) # check prepending two sources t = pipes.Template() t.prepend('boguscmd', pipes.SOURCE) self.assertRaises(ValueError, t.prepend, 'boguscmd', pipes.SOURCE) # command needing file input but with no $IN t = pipes.Template() self.assertRaises(ValueError, t.prepend, 'boguscmd $OUT', pipes.FILEIN_FILEOUT) t = pipes.Template() self.assertRaises(ValueError, t.prepend, 'boguscmd', pipes.FILEIN_STDOUT) # command needing file output but with no $OUT t = pipes.Template() self.assertRaises(ValueError, t.prepend, 'boguscmd $IN', pipes.FILEIN_FILEOUT) t = pipes.Template() self.assertRaises(ValueError, t.prepend, 'boguscmd', pipes.STDIN_FILEOUT) def testBadOpenMode(self): t = pipes.Template() self.assertRaises(ValueError, t.open, 'bogusfile', 'x') def testClone(self): t = pipes.Template() t.append('tr a-z A-Z', pipes.STDIN_STDOUT) u = t.clone() self.assertNotEqual(id(t), id(u)) self.assertEqual(t.steps, u.steps) self.assertNotEqual(id(t.steps), id(u.steps)) self.assertEqual(t.debugging, u.debugging) def test_main(): run_unittest(SimplePipeTests) reap_children() if __name__ == "__main__": test_main()
6,751
204
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_bigaddrspace.py
""" These tests are meant to exercise that requests to create objects bigger than what the address space allows are properly met with an OverflowError (rather than crash weirdly). Primarily, this means 32-bit builds with at least 2 GB of available memory. You need to pass the -M option to regrtest (e.g. "-M 2.1G") for tests to be enabled. """ from test import support from test.support import bigaddrspacetest, MAX_Py_ssize_t import unittest import operator import sys class BytesTest(unittest.TestCase): @bigaddrspacetest def test_concat(self): # Allocate a bytestring that's near the maximum size allowed by # the address space, and then try to build a new, larger one through # concatenation. try: x = b"x" * (MAX_Py_ssize_t - 128) self.assertRaises(OverflowError, operator.add, x, b"x" * 128) finally: x = None @bigaddrspacetest def test_optimized_concat(self): try: x = b"x" * (MAX_Py_ssize_t - 128) with self.assertRaises(OverflowError) as cm: # this statement used a fast path in ceval.c x = x + b"x" * 128 with self.assertRaises(OverflowError) as cm: # this statement used a fast path in ceval.c x += b"x" * 128 finally: x = None @bigaddrspacetest def test_repeat(self): try: x = b"x" * (MAX_Py_ssize_t - 128) self.assertRaises(OverflowError, operator.mul, x, 128) finally: x = None class StrTest(unittest.TestCase): unicodesize = 2 if sys.maxunicode < 65536 else 4 @bigaddrspacetest def test_concat(self): try: # Create a string that would fill almost the address space x = "x" * int(MAX_Py_ssize_t // (1.1 * self.unicodesize)) # Unicode objects trigger MemoryError in case an operation that's # going to cause a size overflow is executed self.assertRaises(MemoryError, operator.add, x, x) finally: x = None @bigaddrspacetest def test_optimized_concat(self): try: x = "x" * int(MAX_Py_ssize_t // (1.1 * self.unicodesize)) with self.assertRaises(MemoryError) as cm: # this statement uses a fast path in ceval.c x = x + x with self.assertRaises(MemoryError) as cm: # this statement uses a fast path in ceval.c x += x finally: x = None @bigaddrspacetest def test_repeat(self): try: x = "x" * int(MAX_Py_ssize_t // (1.1 * self.unicodesize)) self.assertRaises(MemoryError, operator.mul, x, 2) finally: x = None def test_main(): support.run_unittest(BytesTest, StrTest) if __name__ == '__main__': if len(sys.argv) > 1: support.set_memlimit(sys.argv[1]) test_main()
2,989
102
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_multibytecodec.py
# # test_multibytecodec.py # Unit test for multibytecodec itself # from test import support from test.support import TESTFN import unittest, io, codecs, sys import _multibytecodec from encodings import iso2022_jp ALL_CJKENCODINGS = [ # _codecs_cn 'gb2312', 'gbk', 'gb18030', 'hz', # _codecs_hk 'big5hkscs', # _codecs_jp 'cp932', 'shift_jis', 'euc_jp', 'euc_jisx0213', 'shift_jisx0213', 'euc_jis_2004', 'shift_jis_2004', # _codecs_kr 'cp949', 'euc_kr', 'johab', # _codecs_tw 'big5', 'cp950', # _codecs_iso2022 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004', 'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', ] class Test_MultibyteCodec(unittest.TestCase): def test_nullcoding(self): for enc in ALL_CJKENCODINGS: self.assertEqual(b''.decode(enc), '') self.assertEqual(str(b'', enc), '') self.assertEqual(''.encode(enc), b'') def test_str_decode(self): for enc in ALL_CJKENCODINGS: self.assertEqual('abcd'.encode(enc), b'abcd') def test_errorcallback_longindex(self): dec = codecs.getdecoder('euc-kr') myreplace = lambda exc: ('', sys.maxsize+1) codecs.register_error('test.cjktest', myreplace) self.assertRaises(IndexError, dec, b'apple\x92ham\x93spam', 'test.cjktest') def test_errorcallback_custom_ignore(self): # Issue #23215: MemoryError with custom error handlers and multibyte codecs data = 100 * "\udc00" codecs.register_error("test.ignore", codecs.ignore_errors) for enc in ALL_CJKENCODINGS: self.assertEqual(data.encode(enc, "test.ignore"), b'') def test_codingspec(self): try: for enc in ALL_CJKENCODINGS: code = '# coding: {}\n'.format(enc) exec(code) finally: support.unlink(TESTFN) def test_init_segfault(self): # bug #3305: this used to segfault self.assertRaises(AttributeError, _multibytecodec.MultibyteStreamReader, None) self.assertRaises(AttributeError, _multibytecodec.MultibyteStreamWriter, None) def test_decode_unicode(self): # Trying to decode a unicode string should raise a TypeError for enc in ALL_CJKENCODINGS: self.assertRaises(TypeError, codecs.getdecoder(enc), "") class Test_IncrementalEncoder(unittest.TestCase): def test_stateless(self): # cp949 encoder isn't stateful at all. encoder = codecs.getincrementalencoder('cp949')() self.assertEqual(encoder.encode('\ud30c\uc774\uc36c \ub9c8\uc744'), b'\xc6\xc4\xc0\xcc\xbd\xe3 \xb8\xb6\xc0\xbb') self.assertEqual(encoder.reset(), None) self.assertEqual(encoder.encode('\u2606\u223c\u2606', True), b'\xa1\xd9\xa1\xad\xa1\xd9') self.assertEqual(encoder.reset(), None) self.assertEqual(encoder.encode('', True), b'') self.assertEqual(encoder.encode('', False), b'') self.assertEqual(encoder.reset(), None) def test_stateful(self): # jisx0213 encoder is stateful for a few code points. eg) # U+00E6 => A9DC # U+00E6 U+0300 => ABC4 # U+0300 => ABDC encoder = codecs.getincrementalencoder('jisx0213')() self.assertEqual(encoder.encode('\u00e6\u0300'), b'\xab\xc4') self.assertEqual(encoder.encode('\u00e6'), b'') self.assertEqual(encoder.encode('\u0300'), b'\xab\xc4') self.assertEqual(encoder.encode('\u00e6', True), b'\xa9\xdc') self.assertEqual(encoder.reset(), None) self.assertEqual(encoder.encode('\u0300'), b'\xab\xdc') self.assertEqual(encoder.encode('\u00e6'), b'') self.assertEqual(encoder.encode('', True), b'\xa9\xdc') self.assertEqual(encoder.encode('', True), b'') def test_stateful_keep_buffer(self): encoder = codecs.getincrementalencoder('jisx0213')() self.assertEqual(encoder.encode('\u00e6'), b'') self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123') self.assertEqual(encoder.encode('\u0300\u00e6'), b'\xab\xc4') self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123') self.assertEqual(encoder.reset(), None) self.assertEqual(encoder.encode('\u0300'), b'\xab\xdc') self.assertEqual(encoder.encode('\u00e6'), b'') self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123') self.assertEqual(encoder.encode('', True), b'\xa9\xdc') def test_issue5640(self): encoder = codecs.getincrementalencoder('shift-jis')('backslashreplace') self.assertEqual(encoder.encode('\xff'), b'\\xff') self.assertEqual(encoder.encode('\n'), b'\n') class Test_IncrementalDecoder(unittest.TestCase): def test_dbcs(self): # cp949 decoder is simple with only 1 or 2 bytes sequences. decoder = codecs.getincrementaldecoder('cp949')() self.assertEqual(decoder.decode(b'\xc6\xc4\xc0\xcc\xbd'), '\ud30c\uc774') self.assertEqual(decoder.decode(b'\xe3 \xb8\xb6\xc0\xbb'), '\uc36c \ub9c8\uc744') self.assertEqual(decoder.decode(b''), '') def test_dbcs_keep_buffer(self): decoder = codecs.getincrementaldecoder('cp949')() self.assertEqual(decoder.decode(b'\xc6\xc4\xc0'), '\ud30c') self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True) self.assertEqual(decoder.decode(b'\xcc'), '\uc774') self.assertEqual(decoder.decode(b'\xc6\xc4\xc0'), '\ud30c') self.assertRaises(UnicodeDecodeError, decoder.decode, b'\xcc\xbd', True) self.assertEqual(decoder.decode(b'\xcc'), '\uc774') def test_iso2022(self): decoder = codecs.getincrementaldecoder('iso2022-jp')() ESC = b'\x1b' self.assertEqual(decoder.decode(ESC + b'('), '') self.assertEqual(decoder.decode(b'B', True), '') self.assertEqual(decoder.decode(ESC + b'$'), '') self.assertEqual(decoder.decode(b'B@$'), '\u4e16') self.assertEqual(decoder.decode(b'@$@'), '\u4e16') self.assertEqual(decoder.decode(b'$', True), '\u4e16') self.assertEqual(decoder.reset(), None) self.assertEqual(decoder.decode(b'@$'), '@$') self.assertEqual(decoder.decode(ESC + b'$'), '') self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True) self.assertEqual(decoder.decode(b'B@$'), '\u4e16') def test_decode_unicode(self): # Trying to decode a unicode string should raise a TypeError for enc in ALL_CJKENCODINGS: decoder = codecs.getincrementaldecoder(enc)() self.assertRaises(TypeError, decoder.decode, "") class Test_StreamReader(unittest.TestCase): def test_bug1728403(self): try: f = open(TESTFN, 'wb') try: f.write(b'\xa1') finally: f.close() f = codecs.open(TESTFN, encoding='cp949') try: self.assertRaises(UnicodeDecodeError, f.read, 2) finally: f.close() finally: support.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase): def test_gb18030(self): s= io.BytesIO() c = codecs.getwriter('gb18030')(s) c.write('123') self.assertEqual(s.getvalue(), b'123') c.write('\U00012345') self.assertEqual(s.getvalue(), b'123\x907\x959') c.write('\uac00\u00ac') self.assertEqual(s.getvalue(), b'123\x907\x959\x827\xcf5\x810\x851') def test_utf_8(self): s= io.BytesIO() c = codecs.getwriter('utf-8')(s) c.write('123') self.assertEqual(s.getvalue(), b'123') c.write('\U00012345') self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85') c.write('\uac00\u00ac') self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85' b'\xea\xb0\x80\xc2\xac') def test_streamwriter_strwrite(self): s = io.BytesIO() wr = codecs.getwriter('gb18030')(s) wr.write('abcd') self.assertEqual(s.getvalue(), b'abcd') class Test_ISO2022(unittest.TestCase): def test_g2(self): iso2022jp2 = b'\x1b(B:hu4:unit\x1b.A\x1bNi de famille' uni = ':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) def test_iso2022_jp_g0(self): self.assertNotIn(b'\x0e', '\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): e = '\u3406'.encode(encoding) self.assertFalse(any(x > 0x80 for x in e)) def test_bug1572832(self): for x in range(0x10000, 0x110000): # Any ISO 2022 codec will cause the segfault chr(x).encode('iso_2022_jp', 'ignore') class TestStateful(unittest.TestCase): text = '\u4E16\u4E16' encoding = 'iso-2022-jp' expected = b'\x1b$B@$@$' reset = b'\x1b(B' expected_reset = expected + reset def test_encode(self): self.assertEqual(self.text.encode(self.encoding), self.expected_reset) def test_incrementalencoder(self): encoder = codecs.getincrementalencoder(self.encoding)() output = b''.join( encoder.encode(char) for char in self.text) self.assertEqual(output, self.expected) self.assertEqual(encoder.encode('', final=True), self.reset) self.assertEqual(encoder.encode('', final=True), b'') def test_incrementalencoder_final(self): encoder = codecs.getincrementalencoder(self.encoding)() last_index = len(self.text) - 1 output = b''.join( encoder.encode(char, index == last_index) for index, char in enumerate(self.text)) self.assertEqual(output, self.expected_reset) self.assertEqual(encoder.encode('', final=True), b'') class TestHZStateful(TestStateful): text = '\u804a\u804a' encoding = 'hz' expected = b'~{ADAD' reset = b'~}' expected_reset = expected + reset def test_main(): support.run_unittest(__name__) if __name__ == "__main__": test_main()
10,339
272
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_gc.py
import unittest from test.support import (verbose, refcount_test, run_unittest, strip_python_stderr, cpython_only, start_threads, temp_dir, requires_type_collecting, TESTFN, unlink) from test.support.script_helper import assert_python_ok, make_script import sys import time import gc import weakref try: import _thread import threading except ImportError: threading = None try: from _testcapi import with_tp_del except ImportError: def with_tp_del(cls): class C(object): def __new__(cls, *args, **kwargs): raise TypeError('requires _testcapi.with_tp_del') return C ### Support code ############################################################################### # Bug 1055820 has several tests of longstanding bugs involving weakrefs and # cyclic gc. # An instance of C1055820 has a self-loop, so becomes cyclic trash when # unreachable. class C1055820(object): def __init__(self, i): self.i = i self.loop = self class GC_Detector(object): # Create an instance I. Then gc hasn't happened again so long as # I.gc_happened is false. def __init__(self): self.gc_happened = False def it_happened(ignored): self.gc_happened = True # Create a piece of cyclic trash that triggers it_happened when # gc collects it. self.wr = weakref.ref(C1055820(666), it_happened) @with_tp_del class Uncollectable(object): """Create a reference cycle with multiple __del__ methods. An object in a reference cycle will never have zero references, and so must be garbage collected. If one or more objects in the cycle have __del__ methods, the gc refuses to guess an order, and leaves the cycle uncollected.""" def __init__(self, partner=None): if partner is None: self.partner = Uncollectable(partner=self) else: self.partner = partner def __tp_del__(self): pass ### Tests ############################################################################### class GCTests(unittest.TestCase): def test_list(self): l = [] l.append(l) gc.collect() del l self.assertEqual(gc.collect(), 1) def test_dict(self): d = {} d[1] = d gc.collect() del d self.assertEqual(gc.collect(), 1) def test_tuple(self): # since tuples are immutable we close the loop with a list l = [] t = (l,) l.append(t) gc.collect() del t del l self.assertEqual(gc.collect(), 2) def test_class(self): class A: pass A.a = A gc.collect() del A self.assertNotEqual(gc.collect(), 0) def test_newstyleclass(self): class A(object): pass gc.collect() del A self.assertNotEqual(gc.collect(), 0) def test_instance(self): class A: pass a = A() a.a = a gc.collect() del a self.assertNotEqual(gc.collect(), 0) @requires_type_collecting def test_newinstance(self): class A(object): pass a = A() a.a = a gc.collect() del a self.assertNotEqual(gc.collect(), 0) class B(list): pass class C(B, A): pass a = C() a.a = a gc.collect() del a self.assertNotEqual(gc.collect(), 0) del B, C self.assertNotEqual(gc.collect(), 0) A.a = A() del A self.assertNotEqual(gc.collect(), 0) self.assertEqual(gc.collect(), 0) def test_method(self): # Tricky: self.__init__ is a bound method, it references the instance. class A: def __init__(self): self.init = self.__init__ a = A() gc.collect() del a self.assertNotEqual(gc.collect(), 0) @cpython_only def test_legacy_finalizer(self): # A() is uncollectable if it is part of a cycle, make sure it shows up # in gc.garbage. @with_tp_del class A: def __tp_del__(self): pass class B: pass a = A() a.a = a id_a = id(a) b = B() b.b = b gc.collect() del a del b self.assertNotEqual(gc.collect(), 0) for obj in gc.garbage: if id(obj) == id_a: del obj.a break else: self.fail("didn't find obj in garbage (finalizer)") gc.garbage.remove(obj) @cpython_only def test_legacy_finalizer_newclass(self): # A() is uncollectable if it is part of a cycle, make sure it shows up # in gc.garbage. @with_tp_del class A(object): def __tp_del__(self): pass class B(object): pass a = A() a.a = a id_a = id(a) b = B() b.b = b gc.collect() del a del b self.assertNotEqual(gc.collect(), 0) for obj in gc.garbage: if id(obj) == id_a: del obj.a break else: self.fail("didn't find obj in garbage (finalizer)") gc.garbage.remove(obj) def test_function(self): # Tricky: f -> d -> f, code should call d.clear() after the exec to # break the cycle. d = {} exec("def f(): pass\n", d) gc.collect() del d self.assertEqual(gc.collect(), 2) @refcount_test def test_frame(self): def f(): frame = sys._getframe() gc.collect() f() self.assertEqual(gc.collect(), 1) def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L) def test_del(self): # __del__ methods can trigger collection, make this to happen thresholds = gc.get_threshold() gc.enable() gc.set_threshold(1) class A: def __del__(self): dir(self) a = A() del a gc.disable() gc.set_threshold(*thresholds) def test_del_newclass(self): # __del__ methods can trigger collection, make this to happen thresholds = gc.get_threshold() gc.enable() gc.set_threshold(1) class A(object): def __del__(self): dir(self) a = A() del a gc.disable() gc.set_threshold(*thresholds) # The following two tests are fragile: # They precisely count the number of allocations, # which is highly implementation-dependent. # For example, disposed tuples are not freed, but reused. # To minimize variations, though, we first store the get_count() results # and check them at the end. @refcount_test def test_get_count(self): gc.collect() a, b, c = gc.get_count() x = [] d, e, f = gc.get_count() self.assertEqual((b, c), (0, 0)) self.assertEqual((e, f), (0, 0)) # This is less fragile than asserting that a equals 0. self.assertLess(a, 5) # Between the two calls to get_count(), at least one object was # created (the list). self.assertGreater(d, a) @refcount_test def test_collect_generations(self): gc.collect() # This object will "trickle" into generation N + 1 after # each call to collect(N) x = [] gc.collect(0) # x is now in gen 1 a, b, c = gc.get_count() gc.collect(1) # x is now in gen 2 d, e, f = gc.get_count() gc.collect(2) # x is now in gen 3 g, h, i = gc.get_count() # We don't check a, d, g since their exact values depends on # internal implementation details of the interpreter. self.assertEqual((b, c), (1, 0)) self.assertEqual((e, f), (0, 1)) self.assertEqual((h, i), (0, 0)) def test_trashcan(self): class Ouch: n = 0 def __del__(self): Ouch.n = Ouch.n + 1 if Ouch.n % 17 == 0: gc.collect() # "trashcan" is a hack to prevent stack overflow when deallocating # very deeply nested tuples etc. It works in part by abusing the # type pointer and refcount fields, and that can yield horrible # problems when gc tries to traverse the structures. # If this test fails (as it does in 2.0, 2.1 and 2.2), it will # most likely die via segfault. # Note: In 2.3 the possibility for compiling without cyclic gc was # removed, and that in turn allows the trashcan mechanism to work # via much simpler means (e.g., it never abuses the type pointer or # refcount fields anymore). Since it's much less likely to cause a # problem now, the various constants in this expensive (we force a lot # of full collections) test are cut back from the 2.2 version. gc.enable() N = 150 for count in range(2): t = [] for i in range(N): t = [t, Ouch()] u = [] for i in range(N): u = [u, Ouch()] v = {} for i in range(N): v = {1: v, 2: Ouch()} gc.disable() @unittest.skipUnless(threading, "test meaningless on builds without threads") def test_trashcan_threads(self): # Issue #13992: trashcan mechanism should be thread-safe NESTING = 60 N_THREADS = 2 def sleeper_gen(): """A generator that releases the GIL when closed or dealloc'ed.""" try: yield finally: time.sleep(0.000001) class C(list): # Appending to a list is atomic, which avoids the use of a lock. inits = [] dels = [] def __init__(self, alist): self[:] = alist C.inits.append(None) def __del__(self): # This __del__ is called by subtype_dealloc(). C.dels.append(None) # `g` will release the GIL when garbage-collected. This # helps assert subtype_dealloc's behaviour when threads # switch in the middle of it. g = sleeper_gen() next(g) # Now that __del__ is finished, subtype_dealloc will proceed # to call list_dealloc, which also uses the trashcan mechanism. def make_nested(): """Create a sufficiently nested container object so that the trashcan mechanism is invoked when deallocating it.""" x = C([]) for i in range(NESTING): x = [C([x])] del x def run_thread(): """Exercise make_nested() in a loop.""" while not exit: make_nested() old_switchinterval = sys.getswitchinterval() sys.setswitchinterval(1e-5) try: exit = [] threads = [] for i in range(N_THREADS): t = threading.Thread(target=run_thread) threads.append(t) with start_threads(threads, lambda: exit.append(1)): time.sleep(1.0) finally: sys.setswitchinterval(old_switchinterval) gc.collect() self.assertEqual(len(C.inits), len(C.dels)) def test_boom(self): class Boom: def __getattr__(self, someattribute): del self.attr raise AttributeError a = Boom() b = Boom() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # a<->b are in a trash cycle now. Collection will invoke # Boom.__getattr__ (to see whether a and b have __del__ methods), and # __getattr__ deletes the internal "attr" attributes as a side effect. # That causes the trash cycle to get reclaimed via refcounts falling to # 0, thus mutating the trash graph as a side effect of merely asking # whether __del__ exists. This used to (before 2.3b1) crash Python. # Now __getattr__ isn't called. self.assertEqual(gc.collect(), 4) self.assertEqual(len(gc.garbage), garbagelen) def test_boom2(self): class Boom2: def __init__(self): self.x = 0 def __getattr__(self, someattribute): self.x += 1 if self.x > 1: del self.attr raise AttributeError a = Boom2() b = Boom2() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # Much like test_boom(), except that __getattr__ doesn't break the # cycle until the second time gc checks for __del__. As of 2.3b1, # there isn't a second time, so this simply cleans up the trash cycle. # We expect a, b, a.__dict__ and b.__dict__ (4 objects) to get # reclaimed this way. self.assertEqual(gc.collect(), 4) self.assertEqual(len(gc.garbage), garbagelen) def test_boom_new(self): # boom__new and boom2_new are exactly like boom and boom2, except use # new-style classes. class Boom_New(object): def __getattr__(self, someattribute): del self.attr raise AttributeError a = Boom_New() b = Boom_New() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b self.assertEqual(gc.collect(), 4) self.assertEqual(len(gc.garbage), garbagelen) def test_boom2_new(self): class Boom2_New(object): def __init__(self): self.x = 0 def __getattr__(self, someattribute): self.x += 1 if self.x > 1: del self.attr raise AttributeError a = Boom2_New() b = Boom2_New() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b self.assertEqual(gc.collect(), 4) self.assertEqual(len(gc.garbage), garbagelen) def test_get_referents(self): alist = [1, 3, 5] got = gc.get_referents(alist) got.sort() self.assertEqual(got, alist) atuple = tuple(alist) got = gc.get_referents(atuple) got.sort() self.assertEqual(got, alist) adict = {1: 3, 5: 7} expected = [1, 3, 5, 7] got = gc.get_referents(adict) got.sort() self.assertEqual(got, expected) got = gc.get_referents([1, 2], {3: 4}, (0, 0, 0)) got.sort() self.assertEqual(got, [0, 0] + list(range(5))) self.assertEqual(gc.get_referents(1, 'a', 4j), []) def test_is_tracked(self): # Atomic built-in types are not tracked, user-defined objects and # mutable containers are. # NOTE: types with special optimizations (e.g. tuple) have tests # in their own test files instead. self.assertFalse(gc.is_tracked(None)) self.assertFalse(gc.is_tracked(1)) self.assertFalse(gc.is_tracked(1.0)) self.assertFalse(gc.is_tracked(1.0 + 5.0j)) self.assertFalse(gc.is_tracked(True)) self.assertFalse(gc.is_tracked(False)) self.assertFalse(gc.is_tracked(b"a")) self.assertFalse(gc.is_tracked("a")) self.assertFalse(gc.is_tracked(bytearray(b"a"))) self.assertFalse(gc.is_tracked(type)) self.assertFalse(gc.is_tracked(int)) self.assertFalse(gc.is_tracked(object)) self.assertFalse(gc.is_tracked(object())) class UserClass: pass class UserInt(int): pass # Base class is object; no extra fields. class UserClassSlots: __slots__ = () # Base class is fixed size larger than object; no extra fields. class UserFloatSlots(float): __slots__ = () # Base class is variable size; no extra fields. class UserIntSlots(int): __slots__ = () self.assertTrue(gc.is_tracked(gc)) self.assertTrue(gc.is_tracked(UserClass)) self.assertTrue(gc.is_tracked(UserClass())) self.assertTrue(gc.is_tracked(UserInt())) self.assertTrue(gc.is_tracked([])) self.assertTrue(gc.is_tracked(set())) self.assertFalse(gc.is_tracked(UserClassSlots())) self.assertFalse(gc.is_tracked(UserFloatSlots())) self.assertFalse(gc.is_tracked(UserIntSlots())) def test_bug1055820b(self): # Corresponds to temp2b.py in the bug report. ouch = [] def callback(ignored): ouch[:] = [wr() for wr in WRs] Cs = [C1055820(i) for i in range(2)] WRs = [weakref.ref(c, callback) for c in Cs] c = None gc.collect() self.assertEqual(len(ouch), 0) # Make the two instances trash, and collect again. The bug was that # the callback materialized a strong reference to an instance, but gc # cleared the instance's dict anyway. Cs = None gc.collect() self.assertEqual(len(ouch), 2) # else the callbacks didn't run for x in ouch: # If the callback resurrected one of these guys, the instance # would be damaged, with an empty __dict__. self.assertEqual(x, None) def test_bug21435(self): # This is a poor test - its only virtue is that it happened to # segfault on Tim's Windows box before the patch for 21435 was # applied. That's a nasty bug relying on specific pieces of cyclic # trash appearing in exactly the right order in finalize_garbage()'s # input list. # But there's no reliable way to force that order from Python code, # so over time chances are good this test won't really be testing much # of anything anymore. Still, if it blows up, there's _some_ # problem ;-) gc.collect() class A: pass class B: def __init__(self, x): self.x = x def __del__(self): self.attr = None def do_work(): a = A() b = B(A()) a.attr = b b.attr = a do_work() gc.collect() # this blows up (bad C pointer) when it fails @cpython_only def test_garbage_at_shutdown(self): import subprocess code = """if 1: import gc import _testcapi @_testcapi.with_tp_del class X: def __init__(self, name): self.name = name def __repr__(self): return "<X %%r>" %% self.name def __tp_del__(self): pass x = X('first') x.x = x x.y = X('second') del x gc.set_debug(%s) """ def run_command(code): p = subprocess.Popen([sys.executable, "-Wd", "-c", code], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() p.stdout.close() p.stderr.close() self.assertEqual(p.returncode, 0) self.assertEqual(stdout.strip(), b"") return strip_python_stderr(stderr) stderr = run_command(code % "0") self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at " b"shutdown; use", stderr) self.assertNotIn(b"<X 'first'>", stderr) # With DEBUG_UNCOLLECTABLE, the garbage list gets printed stderr = run_command(code % "gc.DEBUG_UNCOLLECTABLE") self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at " b"shutdown", stderr) self.assertTrue( (b"[<X 'first'>, <X 'second'>]" in stderr) or (b"[<X 'second'>, <X 'first'>]" in stderr), stderr) # With DEBUG_SAVEALL, no additional message should get printed # (because gc.garbage also contains normally reclaimable cyclic # references, and its elements get printed at runtime anyway). stderr = run_command(code % "gc.DEBUG_SAVEALL") self.assertNotIn(b"uncollectable objects at shutdown", stderr) @requires_type_collecting def test_gc_main_module_at_shutdown(self): # Create a reference cycle through the __main__ module and check # it gets collected at interpreter shutdown. code = """if 1: class C: def __del__(self): print('__del__ called') l = [C()] l.append(l) """ rc, out, err = assert_python_ok('-c', code) self.assertEqual(out.strip(), b'__del__ called') @requires_type_collecting def test_gc_ordinary_module_at_shutdown(self): # Same as above, but with a non-__main__ module. with temp_dir() as script_dir: module = """if 1: class C: def __del__(self): print('__del__ called') l = [C()] l.append(l) """ code = """if 1: import sys sys.path.insert(0, %r) import gctest """ % (script_dir,) make_script(script_dir, 'gctest', module) rc, out, err = assert_python_ok('-c', code) self.assertEqual(out.strip(), b'__del__ called') @requires_type_collecting def test_global_del_SystemExit(self): code = """if 1: class ClassWithDel: def __del__(self): print('__del__ called') a = ClassWithDel() a.link = a raise SystemExit(0)""" self.addCleanup(unlink, TESTFN) with open(TESTFN, 'w') as script: script.write(code) rc, out, err = assert_python_ok(TESTFN) self.assertEqual(out.strip(), b'__del__ called') def test_get_stats(self): stats = gc.get_stats() self.assertEqual(len(stats), 3) for st in stats: self.assertIsInstance(st, dict) self.assertEqual(set(st), {"collected", "collections", "uncollectable"}) self.assertGreaterEqual(st["collected"], 0) self.assertGreaterEqual(st["collections"], 0) self.assertGreaterEqual(st["uncollectable"], 0) # Check that collection counts are incremented correctly if gc.isenabled(): self.addCleanup(gc.enable) gc.disable() old = gc.get_stats() gc.collect(0) new = gc.get_stats() self.assertEqual(new[0]["collections"], old[0]["collections"] + 1) self.assertEqual(new[1]["collections"], old[1]["collections"]) self.assertEqual(new[2]["collections"], old[2]["collections"]) gc.collect(2) new = gc.get_stats() self.assertEqual(new[0]["collections"], old[0]["collections"] + 1) self.assertEqual(new[1]["collections"], old[1]["collections"]) self.assertEqual(new[2]["collections"], old[2]["collections"] + 1) class GCCallbackTests(unittest.TestCase): def setUp(self): # Save gc state and disable it. self.enabled = gc.isenabled() gc.disable() self.debug = gc.get_debug() gc.set_debug(0) gc.callbacks.append(self.cb1) gc.callbacks.append(self.cb2) self.othergarbage = [] def tearDown(self): # Restore gc state del self.visit gc.callbacks.remove(self.cb1) gc.callbacks.remove(self.cb2) gc.set_debug(self.debug) if self.enabled: gc.enable() # destroy any uncollectables gc.collect() for obj in gc.garbage: if isinstance(obj, Uncollectable): obj.partner = None del gc.garbage[:] del self.othergarbage gc.collect() def preclean(self): # Remove all fluff from the system. Invoke this function # manually rather than through self.setUp() for maximum # safety. self.visit = [] gc.collect() garbage, gc.garbage[:] = gc.garbage[:], [] self.othergarbage.append(garbage) self.visit = [] def cb1(self, phase, info): self.visit.append((1, phase, dict(info))) def cb2(self, phase, info): self.visit.append((2, phase, dict(info))) if phase == "stop" and hasattr(self, "cleanup"): # Clean Uncollectable from garbage uc = [e for e in gc.garbage if isinstance(e, Uncollectable)] gc.garbage[:] = [e for e in gc.garbage if not isinstance(e, Uncollectable)] for e in uc: e.partner = None def test_collect(self): self.preclean() gc.collect() # Algorithmically verify the contents of self.visit # because it is long and tortuous. # Count the number of visits to each callback n = [v[0] for v in self.visit] n1 = [i for i in n if i == 1] n2 = [i for i in n if i == 2] self.assertEqual(n1, [1]*2) self.assertEqual(n2, [2]*2) # Count that we got the right number of start and stop callbacks. n = [v[1] for v in self.visit] n1 = [i for i in n if i == "start"] n2 = [i for i in n if i == "stop"] self.assertEqual(n1, ["start"]*2) self.assertEqual(n2, ["stop"]*2) # Check that we got the right info dict for all callbacks for v in self.visit: info = v[2] self.assertTrue("generation" in info) self.assertTrue("collected" in info) self.assertTrue("uncollectable" in info) def test_collect_generation(self): self.preclean() gc.collect(2) for v in self.visit: info = v[2] self.assertEqual(info["generation"], 2) @cpython_only def test_collect_garbage(self): self.preclean() # Each of these cause four objects to be garbage: Two # Uncolectables and their instance dicts. Uncollectable() Uncollectable() C1055820(666) gc.collect() for v in self.visit: if v[1] != "stop": continue info = v[2] self.assertEqual(info["collected"], 2) self.assertEqual(info["uncollectable"], 8) # We should now have the Uncollectables in gc.garbage self.assertEqual(len(gc.garbage), 4) for e in gc.garbage: self.assertIsInstance(e, Uncollectable) # Now, let our callback handle the Uncollectable instances self.cleanup=True self.visit = [] gc.garbage[:] = [] gc.collect() for v in self.visit: if v[1] != "stop": continue info = v[2] self.assertEqual(info["collected"], 0) self.assertEqual(info["uncollectable"], 4) # Uncollectables should be gone self.assertEqual(len(gc.garbage), 0) class GCTogglingTests(unittest.TestCase): def setUp(self): gc.enable() def tearDown(self): gc.disable() def test_bug1055820c(self): # Corresponds to temp2c.py in the bug report. This is pretty # elaborate. c0 = C1055820(0) # Move c0 into generation 2. gc.collect() c1 = C1055820(1) c1.keep_c0_alive = c0 del c0.loop # now only c1 keeps c0 alive c2 = C1055820(2) c2wr = weakref.ref(c2) # no callback! ouch = [] def callback(ignored): ouch[:] = [c2wr()] # The callback gets associated with a wr on an object in generation 2. c0wr = weakref.ref(c0, callback) c0 = c1 = c2 = None # What we've set up: c0, c1, and c2 are all trash now. c0 is in # generation 2. The only thing keeping it alive is that c1 points to # it. c1 and c2 are in generation 0, and are in self-loops. There's a # global weakref to c2 (c2wr), but that weakref has no callback. # There's also a global weakref to c0 (c0wr), and that does have a # callback, and that callback references c2 via c2wr(). # # c0 has a wr with callback, which references c2wr # ^ # | # | Generation 2 above dots #. . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . # | Generation 0 below dots # | # | # ^->c1 ^->c2 has a wr but no callback # | | | | # <--v <--v # # So this is the nightmare: when generation 0 gets collected, we see # that c2 has a callback-free weakref, and c1 doesn't even have a # weakref. Collecting generation 0 doesn't see c0 at all, and c0 is # the only object that has a weakref with a callback. gc clears c1 # and c2. Clearing c1 has the side effect of dropping the refcount on # c0 to 0, so c0 goes away (despite that it's in an older generation) # and c0's wr callback triggers. That in turn materializes a reference # to c2 via c2wr(), but c2 gets cleared anyway by gc. # We want to let gc happen "naturally", to preserve the distinction # between generations. junk = [] i = 0 detector = GC_Detector() while not detector.gc_happened: i += 1 if i > 10000: self.fail("gc didn't happen after 10000 iterations") self.assertEqual(len(ouch), 0) junk.append([]) # this will eventually trigger gc self.assertEqual(len(ouch), 1) # else the callback wasn't invoked for x in ouch: # If the callback resurrected c2, the instance would be damaged, # with an empty __dict__. self.assertEqual(x, None) def test_bug1055820d(self): # Corresponds to temp2d.py in the bug report. This is very much like # test_bug1055820c, but uses a __del__ method instead of a weakref # callback to sneak in a resurrection of cyclic trash. ouch = [] class D(C1055820): def __del__(self): ouch[:] = [c2wr()] d0 = D(0) # Move all the above into generation 2. gc.collect() c1 = C1055820(1) c1.keep_d0_alive = d0 del d0.loop # now only c1 keeps d0 alive c2 = C1055820(2) c2wr = weakref.ref(c2) # no callback! d0 = c1 = c2 = None # What we've set up: d0, c1, and c2 are all trash now. d0 is in # generation 2. The only thing keeping it alive is that c1 points to # it. c1 and c2 are in generation 0, and are in self-loops. There's # a global weakref to c2 (c2wr), but that weakref has no callback. # There are no other weakrefs. # # d0 has a __del__ method that references c2wr # ^ # | # | Generation 2 above dots #. . . . . . . .|. . . . . . . . . . . . . . . . . . . . . . . . # | Generation 0 below dots # | # | # ^->c1 ^->c2 has a wr but no callback # | | | | # <--v <--v # # So this is the nightmare: when generation 0 gets collected, we see # that c2 has a callback-free weakref, and c1 doesn't even have a # weakref. Collecting generation 0 doesn't see d0 at all. gc clears # c1 and c2. Clearing c1 has the side effect of dropping the refcount # on d0 to 0, so d0 goes away (despite that it's in an older # generation) and d0's __del__ triggers. That in turn materializes # a reference to c2 via c2wr(), but c2 gets cleared anyway by gc. # We want to let gc happen "naturally", to preserve the distinction # between generations. detector = GC_Detector() junk = [] i = 0 while not detector.gc_happened: i += 1 if i > 10000: self.fail("gc didn't happen after 10000 iterations") self.assertEqual(len(ouch), 0) junk.append([]) # this will eventually trigger gc self.assertEqual(len(ouch), 1) # else __del__ wasn't invoked for x in ouch: # If __del__ resurrected c2, the instance would be damaged, with an # empty __dict__. self.assertEqual(x, None) def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests, GCCallbackTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print("restoring automatic collection") # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable() if __name__ == "__main__": test_main()
34,659
1,048
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_venv.py
""" Test harness for the venv module. Copyright (C) 2011-2012 Vinay Sajip. Licensed to the PSF under a contributor agreement. """ import ensurepip import os import os.path import re import struct import subprocess import sys import tempfile from test.support import (captured_stdout, captured_stderr, requires_zlib, can_symlink, EnvironmentVarGuard, rmtree) import unittest import venv try: import _thread import threading except ImportError: threading = None try: import ctypes except ImportError: ctypes = None skipInVenv = unittest.skipIf(sys.prefix != sys.base_prefix, 'Test not appropriate in a venv') def check_output(cmd, encoding=None): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding=encoding) out, err = p.communicate() if p.returncode: raise subprocess.CalledProcessError( p.returncode, cmd, out, err) return out, err class BaseTest(unittest.TestCase): """Base class for venv tests.""" maxDiff = 80 * 50 def setUp(self): self.env_dir = os.path.realpath(tempfile.mkdtemp()) if os.name == 'nt': self.bindir = 'Scripts' self.lib = ('Lib',) self.include = 'Include' else: self.bindir = 'bin' self.lib = ('lib', 'python%d.%d' % sys.version_info[:2]) self.include = 'include' if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ: executable = os.environ['__PYVENV_LAUNCHER__'] else: executable = sys.executable self.exe = os.path.split(executable)[-1] def tearDown(self): rmtree(self.env_dir) def run_with_capture(self, func, *args, **kwargs): with captured_stdout() as output: with captured_stderr() as error: func(*args, **kwargs) return output.getvalue(), error.getvalue() def get_env_file(self, *args): return os.path.join(self.env_dir, *args) def get_text_file_contents(self, *args): with open(self.get_env_file(*args), 'r') as f: result = f.read() return result class BasicTest(BaseTest): """Test venv module functionality.""" def isdir(self, *args): fn = self.get_env_file(*args) self.assertTrue(os.path.isdir(fn)) def test_defaults(self): """ Test the create function with default arguments. """ rmtree(self.env_dir) self.run_with_capture(venv.create, self.env_dir) self.isdir(self.bindir) self.isdir(self.include) self.isdir(*self.lib) # Issue 21197 p = self.get_env_file('lib64') conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and (sys.platform != 'darwin')) if conditions: self.assertTrue(os.path.islink(p)) else: self.assertFalse(os.path.exists(p)) data = self.get_text_file_contents('pyvenv.cfg') if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__' in os.environ): executable = os.environ['__PYVENV_LAUNCHER__'] else: executable = sys.executable path = os.path.dirname(executable) self.assertIn('home = %s' % path, data) fn = self.get_env_file(self.bindir, self.exe) if not os.path.exists(fn): # diagnostics for Windows buildbot failures bd = self.get_env_file(self.bindir) print('Contents of %r:' % bd) print(' %r' % os.listdir(bd)) self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn) def test_prompt(self): env_name = os.path.split(self.env_dir)[1] builder = venv.EnvBuilder() context = builder.ensure_directories(self.env_dir) self.assertEqual(context.prompt, '(%s) ' % env_name) builder = venv.EnvBuilder(prompt='My prompt') context = builder.ensure_directories(self.env_dir) self.assertEqual(context.prompt, '(My prompt) ') @skipInVenv def test_prefixes(self): """ Test that the prefix values are as expected. """ #check our prefixes self.assertEqual(sys.base_prefix, sys.prefix) self.assertEqual(sys.base_exec_prefix, sys.exec_prefix) # check a venv's prefixes rmtree(self.env_dir) self.run_with_capture(venv.create, self.env_dir) envpy = os.path.join(self.env_dir, self.bindir, self.exe) cmd = [envpy, '-c', None] for prefix, expected in ( ('prefix', self.env_dir), ('prefix', self.env_dir), ('base_prefix', sys.prefix), ('base_exec_prefix', sys.exec_prefix)): cmd[2] = 'import sys; print(sys.%s)' % prefix out, err = check_output(cmd) self.assertEqual(out.strip(), expected.encode()) if sys.platform == 'win32': ENV_SUBDIRS = ( ('Scripts',), ('Include',), ('Lib',), ('Lib', 'site-packages'), ) else: ENV_SUBDIRS = ( ('bin',), ('include',), ('lib',), ('lib', 'python%d.%d' % sys.version_info[:2]), ('lib', 'python%d.%d' % sys.version_info[:2], 'site-packages'), ) def create_contents(self, paths, filename): """ Create some files in the environment which are unrelated to the virtual environment. """ for subdirs in paths: d = os.path.join(self.env_dir, *subdirs) os.mkdir(d) fn = os.path.join(d, filename) with open(fn, 'wb') as f: f.write(b'Still here?') def test_overwrite_existing(self): """ Test creating environment in an existing directory. """ self.create_contents(self.ENV_SUBDIRS, 'foo') venv.create(self.env_dir) for subdirs in self.ENV_SUBDIRS: fn = os.path.join(self.env_dir, *(subdirs + ('foo',))) self.assertTrue(os.path.exists(fn)) with open(fn, 'rb') as f: self.assertEqual(f.read(), b'Still here?') builder = venv.EnvBuilder(clear=True) builder.create(self.env_dir) for subdirs in self.ENV_SUBDIRS: fn = os.path.join(self.env_dir, *(subdirs + ('foo',))) self.assertFalse(os.path.exists(fn)) def clear_directory(self, path): for fn in os.listdir(path): fn = os.path.join(path, fn) if os.path.islink(fn) or os.path.isfile(fn): os.remove(fn) elif os.path.isdir(fn): rmtree(fn) def test_unoverwritable_fails(self): #create a file clashing with directories in the env dir for paths in self.ENV_SUBDIRS[:3]: fn = os.path.join(self.env_dir, *paths) with open(fn, 'wb') as f: f.write(b'') self.assertRaises((ValueError, OSError), venv.create, self.env_dir) self.clear_directory(self.env_dir) def test_upgrade(self): """ Test upgrading an existing environment directory. """ # See Issue #21643: the loop needs to run twice to ensure # that everything works on the upgrade (the first run just creates # the venv). for upgrade in (False, True): builder = venv.EnvBuilder(upgrade=upgrade) self.run_with_capture(builder.create, self.env_dir) self.isdir(self.bindir) self.isdir(self.include) self.isdir(*self.lib) fn = self.get_env_file(self.bindir, self.exe) if not os.path.exists(fn): # diagnostics for Windows buildbot failures bd = self.get_env_file(self.bindir) print('Contents of %r:' % bd) print(' %r' % os.listdir(bd)) self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn) def test_isolation(self): """ Test isolation from system site-packages """ for ssp, s in ((True, 'true'), (False, 'false')): builder = venv.EnvBuilder(clear=True, system_site_packages=ssp) builder.create(self.env_dir) data = self.get_text_file_contents('pyvenv.cfg') self.assertIn('include-system-site-packages = %s\n' % s, data) @unittest.skipUnless(can_symlink(), 'Needs symlinks') def test_symlinking(self): """ Test symlinking works as expected """ for usl in (False, True): builder = venv.EnvBuilder(clear=True, symlinks=usl) builder.create(self.env_dir) fn = self.get_env_file(self.bindir, self.exe) # Don't test when False, because e.g. 'python' is always # symlinked to 'python3.3' in the env, even when symlinking in # general isn't wanted. if usl: self.assertTrue(os.path.islink(fn)) # If a venv is created from a source build and that venv is used to # run the test, the pyvenv.cfg in the venv created in the test will # point to the venv being used to run the test, and we lose the link # to the source build - so Python can't initialise properly. @skipInVenv def test_executable(self): """ Test that the sys.executable value is as expected. """ rmtree(self.env_dir) self.run_with_capture(venv.create, self.env_dir) envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.exe) out, err = check_output([envpy, '-c', 'import sys; print(sys.executable)']) self.assertEqual(out.strip(), envpy.encode()) @unittest.skipUnless(can_symlink(), 'Needs symlinks') def test_executable_symlinks(self): """ Test that the sys.executable value is as expected. """ rmtree(self.env_dir) builder = venv.EnvBuilder(clear=True, symlinks=True) builder.create(self.env_dir) envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.exe) out, err = check_output([envpy, '-c', 'import sys; print(sys.executable)']) self.assertEqual(out.strip(), envpy.encode()) @unittest.skipUnless(os.name == 'nt', 'only relevant on Windows') def test_unicode_in_batch_file(self): """ Test handling of Unicode paths """ rmtree(self.env_dir) env_dir = os.path.join(os.path.realpath(self.env_dir), 'ϼўТλФЙ') builder = venv.EnvBuilder(clear=True) builder.create(env_dir) activate = os.path.join(env_dir, self.bindir, 'activate.bat') envpy = os.path.join(env_dir, self.bindir, self.exe) out, err = check_output( [activate, '&', self.exe, '-c', 'print(0)'], encoding='oem', ) self.assertEqual(out.strip(), '0') @skipInVenv class EnsurePipTest(BaseTest): """Test venv module installation of pip.""" def assert_pip_not_installed(self): envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.exe) out, err = check_output([envpy, '-c', 'try:\n import pip\nexcept ImportError:\n print("OK")']) # We force everything to text, so unittest gives the detailed diff # if we get unexpected results err = err.decode("latin-1") # Force to text, prevent decoding errors self.assertEqual(err, "") out = out.decode("latin-1") # Force to text, prevent decoding errors self.assertEqual(out.strip(), "OK") def test_no_pip_by_default(self): rmtree(self.env_dir) self.run_with_capture(venv.create, self.env_dir) self.assert_pip_not_installed() def test_explicit_no_pip(self): rmtree(self.env_dir) self.run_with_capture(venv.create, self.env_dir, with_pip=False) self.assert_pip_not_installed() def test_devnull(self): # Fix for issue #20053 uses os.devnull to force a config file to # appear empty. However http://bugs.python.org/issue20541 means # that doesn't currently work properly on Windows. Once that is # fixed, the "win_location" part of test_with_pip should be restored with open(os.devnull, "rb") as f: self.assertEqual(f.read(), b"") # Issue #20541: os.path.exists('nul') is False on Windows if os.devnull.lower() == 'nul': self.assertFalse(os.path.exists(os.devnull)) else: self.assertTrue(os.path.exists(os.devnull)) def do_test_with_pip(self, system_site_packages): rmtree(self.env_dir) with EnvironmentVarGuard() as envvars: # pip's cross-version compatibility may trigger deprecation # warnings in current versions of Python. Ensure related # environment settings don't cause venv to fail. envvars["PYTHONWARNINGS"] = "e" # ensurepip is different enough from a normal pip invocation # that we want to ensure it ignores the normal pip environment # variable settings. We set PIP_NO_INSTALL here specifically # to check that ensurepip (and hence venv) ignores it. # See http://bugs.python.org/issue19734 envvars["PIP_NO_INSTALL"] = "1" # Also check that we ignore the pip configuration file # See http://bugs.python.org/issue20053 with tempfile.TemporaryDirectory() as home_dir: envvars["HOME"] = home_dir bad_config = "[global]\nno-install=1" # Write to both config file names on all platforms to reduce # cross-platform variation in test code behaviour win_location = ("pip", "pip.ini") posix_location = (".pip", "pip.conf") # Skips win_location due to http://bugs.python.org/issue20541 for dirname, fname in (posix_location,): dirpath = os.path.join(home_dir, dirname) os.mkdir(dirpath) fpath = os.path.join(dirpath, fname) with open(fpath, 'w') as f: f.write(bad_config) # Actually run the create command with all that unhelpful # config in place to ensure we ignore it try: self.run_with_capture(venv.create, self.env_dir, system_site_packages=system_site_packages, with_pip=True) except subprocess.CalledProcessError as exc: # The output this produces can be a little hard to read, # but at least it has all the details details = exc.output.decode(errors="replace") msg = "{}\n\n**Subprocess Output**\n{}" self.fail(msg.format(exc, details)) # Ensure pip is available in the virtual environment envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.exe) out, err = check_output([envpy, '-Im', 'pip', '--version']) # We force everything to text, so unittest gives the detailed diff # if we get unexpected results err = err.decode("latin-1") # Force to text, prevent decoding errors self.assertEqual(err, "") out = out.decode("latin-1") # Force to text, prevent decoding errors expected_version = "pip {}".format(ensurepip.version()) self.assertEqual(out[:len(expected_version)], expected_version) env_dir = os.fsencode(self.env_dir).decode("latin-1") self.assertIn(env_dir, out) # http://bugs.python.org/issue19728 # Check the private uninstall command provided for the Windows # installers works (at least in a virtual environment) with EnvironmentVarGuard() as envvars: out, err = check_output([envpy, '-Im', 'ensurepip._uninstall']) # We force everything to text, so unittest gives the detailed diff # if we get unexpected results err = err.decode("latin-1") # Force to text, prevent decoding errors # Ignore the warning: # "The directory '$HOME/.cache/pip/http' or its parent directory # is not owned by the current user and the cache has been disabled. # Please check the permissions and owner of that directory. If # executing pip with sudo, you may want sudo's -H flag." # where $HOME is replaced by the HOME environment variable. err = re.sub("^The directory .* or its parent directory is not owned " "by the current user .*$", "", err, flags=re.MULTILINE) self.assertEqual(err.rstrip(), "") # Being fairly specific regarding the expected behaviour for the # initial bundling phase in Python 3.4. If the output changes in # future pip versions, this test can likely be relaxed further. out = out.decode("latin-1") # Force to text, prevent decoding errors self.assertIn("Successfully uninstalled pip", out) self.assertIn("Successfully uninstalled setuptools", out) # Check pip is now gone from the virtual environment. This only # applies in the system_site_packages=False case, because in the # other case, pip may still be available in the system site-packages if not system_site_packages: self.assert_pip_not_installed() @unittest.skipUnless(threading, 'some dependencies of pip import threading' ' module unconditionally') # Issue #26610: pip/pep425tags.py requires ctypes @unittest.skipUnless(ctypes, 'pip requires ctypes') @requires_zlib def test_with_pip(self): self.do_test_with_pip(False) self.do_test_with_pip(True) if __name__ == "__main__": unittest.main()
18,226
449
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/math_testcases.txt
-- Testcases for functions in math. -- -- Each line takes the form: -- -- <testid> <function> <input_value> -> <output_value> <flags> -- -- where: -- -- <testid> is a short name identifying the test, -- -- <function> is the function to be tested (exp, cos, asinh, ...), -- -- <input_value> is a string representing a floating-point value -- -- <output_value> is the expected (ideal) output value, again -- represented as a string. -- -- <flags> is a list of the floating-point flags required by C99 -- -- The possible flags are: -- -- divide-by-zero : raised when a finite input gives a -- mathematically infinite result. -- -- overflow : raised when a finite input gives a finite result that -- is too large to fit in the usual range of an IEEE 754 double. -- -- invalid : raised for invalid inputs (e.g., sqrt(-1)) -- -- ignore-sign : indicates that the sign of the result is -- unspecified; e.g., if the result is given as inf, -- then both -inf and inf should be accepted as correct. -- -- Flags may appear in any order. -- -- Lines beginning with '--' (like this one) start a comment, and are -- ignored. Blank lines, or lines containing only whitespace, are also -- ignored. -- Many of the values below were computed with the help of -- version 2.4 of the MPFR library for multiple-precision -- floating-point computations with correct rounding. All output -- values in this file are (modulo yet-to-be-discovered bugs) -- correctly rounded, provided that each input and output decimal -- floating-point value below is interpreted as a representation of -- the corresponding nearest IEEE 754 double-precision value. See the -- MPFR homepage at http://www.mpfr.org for more information about the -- MPFR project. ------------------------- -- erf: error function -- ------------------------- erf0000 erf 0.0 -> 0.0 erf0001 erf -0.0 -> -0.0 erf0002 erf inf -> 1.0 erf0003 erf -inf -> -1.0 erf0004 erf nan -> nan -- tiny values erf0010 erf 1e-308 -> 1.1283791670955125e-308 erf0011 erf 5e-324 -> 4.9406564584124654e-324 erf0012 erf 1e-10 -> 1.1283791670955126e-10 -- small integers erf0020 erf 1 -> 0.84270079294971489 erf0021 erf 2 -> 0.99532226501895271 erf0022 erf 3 -> 0.99997790950300136 erf0023 erf 4 -> 0.99999998458274209 erf0024 erf 5 -> 0.99999999999846256 erf0025 erf 6 -> 1.0 erf0030 erf -1 -> -0.84270079294971489 erf0031 erf -2 -> -0.99532226501895271 erf0032 erf -3 -> -0.99997790950300136 erf0033 erf -4 -> -0.99999998458274209 erf0034 erf -5 -> -0.99999999999846256 erf0035 erf -6 -> -1.0 -- huge values should all go to +/-1, depending on sign erf0040 erf -40 -> -1.0 erf0041 erf 1e16 -> 1.0 erf0042 erf -1e150 -> -1.0 erf0043 erf 1.7e308 -> 1.0 -- Issue 8986: inputs x with exp(-x*x) near the underflow threshold -- incorrectly signalled overflow on some platforms. erf0100 erf 26.2 -> 1.0 erf0101 erf 26.4 -> 1.0 erf0102 erf 26.6 -> 1.0 erf0103 erf 26.8 -> 1.0 erf0104 erf 27.0 -> 1.0 erf0105 erf 27.2 -> 1.0 erf0106 erf 27.4 -> 1.0 erf0107 erf 27.6 -> 1.0 erf0110 erf -26.2 -> -1.0 erf0111 erf -26.4 -> -1.0 erf0112 erf -26.6 -> -1.0 erf0113 erf -26.8 -> -1.0 erf0114 erf -27.0 -> -1.0 erf0115 erf -27.2 -> -1.0 erf0116 erf -27.4 -> -1.0 erf0117 erf -27.6 -> -1.0 ---------------------------------------- -- erfc: complementary error function -- ---------------------------------------- erfc0000 erfc 0.0 -> 1.0 erfc0001 erfc -0.0 -> 1.0 erfc0002 erfc inf -> 0.0 erfc0003 erfc -inf -> 2.0 erfc0004 erfc nan -> nan -- tiny values erfc0010 erfc 1e-308 -> 1.0 erfc0011 erfc 5e-324 -> 1.0 erfc0012 erfc 1e-10 -> 0.99999999988716204 -- small integers erfc0020 erfc 1 -> 0.15729920705028513 erfc0021 erfc 2 -> 0.0046777349810472662 erfc0022 erfc 3 -> 2.2090496998585441e-05 erfc0023 erfc 4 -> 1.541725790028002e-08 erfc0024 erfc 5 -> 1.5374597944280349e-12 erfc0025 erfc 6 -> 2.1519736712498913e-17 erfc0030 erfc -1 -> 1.8427007929497148 erfc0031 erfc -2 -> 1.9953222650189528 erfc0032 erfc -3 -> 1.9999779095030015 erfc0033 erfc -4 -> 1.9999999845827421 erfc0034 erfc -5 -> 1.9999999999984626 erfc0035 erfc -6 -> 2.0 -- as x -> infinity, erfc(x) behaves like exp(-x*x)/x/sqrt(pi) erfc0040 erfc 20 -> 5.3958656116079012e-176 erfc0041 erfc 25 -> 8.3001725711965228e-274 erfc0042 erfc 27 -> 5.2370464393526292e-319 erfc0043 erfc 28 -> 0.0 -- huge values erfc0050 erfc -40 -> 2.0 erfc0051 erfc 1e16 -> 0.0 erfc0052 erfc -1e150 -> 2.0 erfc0053 erfc 1.7e308 -> 0.0 -- Issue 8986: inputs x with exp(-x*x) near the underflow threshold -- incorrectly signalled overflow on some platforms. erfc0100 erfc 26.2 -> 1.6432507924389461e-300 erfc0101 erfc 26.4 -> 4.4017768588035426e-305 erfc0102 erfc 26.6 -> 1.0885125885442269e-309 erfc0103 erfc 26.8 -> 2.4849621571966629e-314 erfc0104 erfc 27.0 -> 5.2370464393526292e-319 erfc0105 erfc 27.2 -> 9.8813129168249309e-324 erfc0106 erfc 27.4 -> 0.0 erfc0107 erfc 27.6 -> 0.0 erfc0110 erfc -26.2 -> 2.0 erfc0111 erfc -26.4 -> 2.0 erfc0112 erfc -26.6 -> 2.0 erfc0113 erfc -26.8 -> 2.0 erfc0114 erfc -27.0 -> 2.0 erfc0115 erfc -27.2 -> 2.0 erfc0116 erfc -27.4 -> 2.0 erfc0117 erfc -27.6 -> 2.0 --------------------------------------------------------- -- lgamma: log of absolute value of the gamma function -- --------------------------------------------------------- -- special values lgam0000 lgamma 0.0 -> inf divide-by-zero lgam0001 lgamma -0.0 -> inf divide-by-zero lgam0002 lgamma inf -> inf lgam0003 lgamma -inf -> inf lgam0004 lgamma nan -> nan -- negative integers lgam0010 lgamma -1 -> inf divide-by-zero lgam0011 lgamma -2 -> inf divide-by-zero lgam0012 lgamma -1e16 -> inf divide-by-zero lgam0013 lgamma -1e300 -> inf divide-by-zero lgam0014 lgamma -1.79e308 -> inf divide-by-zero -- small positive integers give factorials lgam0020 lgamma 1 -> 0.0 lgam0021 lgamma 2 -> 0.0 lgam0022 lgamma 3 -> 0.69314718055994529 lgam0023 lgamma 4 -> 1.791759469228055 lgam0024 lgamma 5 -> 3.1780538303479458 lgam0025 lgamma 6 -> 4.7874917427820458 -- half integers lgam0030 lgamma 0.5 -> 0.57236494292470008 lgam0031 lgamma 1.5 -> -0.12078223763524522 lgam0032 lgamma 2.5 -> 0.28468287047291918 lgam0033 lgamma 3.5 -> 1.2009736023470743 lgam0034 lgamma -0.5 -> 1.2655121234846454 lgam0035 lgamma -1.5 -> 0.86004701537648098 lgam0036 lgamma -2.5 -> -0.056243716497674054 lgam0037 lgamma -3.5 -> -1.309006684993042 -- values near 0 lgam0040 lgamma 0.1 -> 2.252712651734206 lgam0041 lgamma 0.01 -> 4.5994798780420219 lgam0042 lgamma 1e-8 -> 18.420680738180209 lgam0043 lgamma 1e-16 -> 36.841361487904734 lgam0044 lgamma 1e-30 -> 69.077552789821368 lgam0045 lgamma 1e-160 -> 368.41361487904732 lgam0046 lgamma 1e-308 -> 709.19620864216608 lgam0047 lgamma 5.6e-309 -> 709.77602713741896 lgam0048 lgamma 5.5e-309 -> 709.79404564292167 lgam0049 lgamma 1e-309 -> 711.49879373516012 lgam0050 lgamma 1e-323 -> 743.74692474082133 lgam0051 lgamma 5e-324 -> 744.44007192138122 lgam0060 lgamma -0.1 -> 2.3689613327287886 lgam0061 lgamma -0.01 -> 4.6110249927528013 lgam0062 lgamma -1e-8 -> 18.420680749724522 lgam0063 lgamma -1e-16 -> 36.841361487904734 lgam0064 lgamma -1e-30 -> 69.077552789821368 lgam0065 lgamma -1e-160 -> 368.41361487904732 lgam0066 lgamma -1e-308 -> 709.19620864216608 lgam0067 lgamma -5.6e-309 -> 709.77602713741896 lgam0068 lgamma -5.5e-309 -> 709.79404564292167 lgam0069 lgamma -1e-309 -> 711.49879373516012 lgam0070 lgamma -1e-323 -> 743.74692474082133 lgam0071 lgamma -5e-324 -> 744.44007192138122 -- values near negative integers lgam0080 lgamma -0.99999999999999989 -> 36.736800569677101 lgam0081 lgamma -1.0000000000000002 -> 36.043653389117154 lgam0082 lgamma -1.9999999999999998 -> 35.350506208557213 lgam0083 lgamma -2.0000000000000004 -> 34.657359027997266 lgam0084 lgamma -100.00000000000001 -> -331.85460524980607 lgam0085 lgamma -99.999999999999986 -> -331.85460524980596 -- large inputs lgam0100 lgamma 170 -> 701.43726380873704 lgam0101 lgamma 171 -> 706.57306224578736 lgam0102 lgamma 171.624 -> 709.78077443669895 lgam0103 lgamma 171.625 -> 709.78591682948365 lgam0104 lgamma 172 -> 711.71472580228999 lgam0105 lgamma 2000 -> 13198.923448054265 lgam0106 lgamma 2.55998332785163e305 -> 1.7976931348623099e+308 lgam0107 lgamma 2.55998332785164e305 -> inf overflow lgam0108 lgamma 1.7e308 -> inf overflow -- inputs for which gamma(x) is tiny lgam0120 lgamma -100.5 -> -364.90096830942736 lgam0121 lgamma -160.5 -> -656.88005261126432 lgam0122 lgamma -170.5 -> -707.99843314507882 lgam0123 lgamma -171.5 -> -713.14301641168481 lgam0124 lgamma -176.5 -> -738.95247590846486 lgam0125 lgamma -177.5 -> -744.13144651738037 lgam0126 lgamma -178.5 -> -749.3160351186001 lgam0130 lgamma -1000.5 -> -5914.4377011168517 lgam0131 lgamma -30000.5 -> -279278.6629959144 lgam0132 lgamma -4503599627370495.5 -> -1.5782258434492883e+17 -- results close to 0: positive argument ... lgam0150 lgamma 0.99999999999999989 -> 6.4083812134800075e-17 lgam0151 lgamma 1.0000000000000002 -> -1.2816762426960008e-16 lgam0152 lgamma 1.9999999999999998 -> -9.3876980655431170e-17 lgam0153 lgamma 2.0000000000000004 -> 1.8775396131086244e-16 -- ... and negative argument lgam0160 lgamma -2.7476826467 -> -5.2477408147689136e-11 lgam0161 lgamma -2.457024738 -> 3.3464637541912932e-10 --------------------------- -- gamma: Gamma function -- --------------------------- -- special values gam0000 gamma 0.0 -> inf divide-by-zero gam0001 gamma -0.0 -> -inf divide-by-zero gam0002 gamma inf -> inf gam0003 gamma -inf -> nan invalid gam0004 gamma nan -> nan -- negative integers inputs are invalid gam0010 gamma -1 -> nan invalid gam0011 gamma -2 -> nan invalid gam0012 gamma -1e16 -> nan invalid gam0013 gamma -1e300 -> nan invalid -- small positive integers give factorials gam0020 gamma 1 -> 1 gam0021 gamma 2 -> 1 gam0022 gamma 3 -> 2 gam0023 gamma 4 -> 6 gam0024 gamma 5 -> 24 gam0025 gamma 6 -> 120 -- half integers gam0030 gamma 0.5 -> 1.7724538509055161 gam0031 gamma 1.5 -> 0.88622692545275805 gam0032 gamma 2.5 -> 1.3293403881791370 gam0033 gamma 3.5 -> 3.3233509704478426 gam0034 gamma -0.5 -> -3.5449077018110322 gam0035 gamma -1.5 -> 2.3632718012073548 gam0036 gamma -2.5 -> -0.94530872048294190 gam0037 gamma -3.5 -> 0.27008820585226911 -- values near 0 gam0040 gamma 0.1 -> 9.5135076986687306 gam0041 gamma 0.01 -> 99.432585119150602 gam0042 gamma 1e-8 -> 99999999.422784343 gam0043 gamma 1e-16 -> 10000000000000000 gam0044 gamma 1e-30 -> 9.9999999999999988e+29 gam0045 gamma 1e-160 -> 1.0000000000000000e+160 gam0046 gamma 1e-308 -> 1.0000000000000000e+308 gam0047 gamma 5.6e-309 -> 1.7857142857142848e+308 gam0048 gamma 5.5e-309 -> inf overflow gam0049 gamma 1e-309 -> inf overflow gam0050 gamma 1e-323 -> inf overflow gam0051 gamma 5e-324 -> inf overflow gam0060 gamma -0.1 -> -10.686287021193193 gam0061 gamma -0.01 -> -100.58719796441078 gam0062 gamma -1e-8 -> -100000000.57721567 gam0063 gamma -1e-16 -> -10000000000000000 gam0064 gamma -1e-30 -> -9.9999999999999988e+29 gam0065 gamma -1e-160 -> -1.0000000000000000e+160 gam0066 gamma -1e-308 -> -1.0000000000000000e+308 gam0067 gamma -5.6e-309 -> -1.7857142857142848e+308 gam0068 gamma -5.5e-309 -> -inf overflow gam0069 gamma -1e-309 -> -inf overflow gam0070 gamma -1e-323 -> -inf overflow gam0071 gamma -5e-324 -> -inf overflow -- values near negative integers gam0080 gamma -0.99999999999999989 -> -9007199254740992.0 gam0081 gamma -1.0000000000000002 -> 4503599627370495.5 gam0082 gamma -1.9999999999999998 -> 2251799813685248.5 gam0083 gamma -2.0000000000000004 -> -1125899906842623.5 gam0084 gamma -100.00000000000001 -> -7.5400833348831090e-145 gam0085 gamma -99.999999999999986 -> 7.5400833348840962e-145 -- large inputs gam0100 gamma 170 -> 4.2690680090047051e+304 gam0101 gamma 171 -> 7.2574156153079990e+306 gam0102 gamma 171.624 -> 1.7942117599248104e+308 gam0103 gamma 171.625 -> inf overflow gam0104 gamma 172 -> inf overflow gam0105 gamma 2000 -> inf overflow gam0106 gamma 1.7e308 -> inf overflow -- inputs for which gamma(x) is tiny gam0120 gamma -100.5 -> -3.3536908198076787e-159 gam0121 gamma -160.5 -> -5.2555464470078293e-286 gam0122 gamma -170.5 -> -3.3127395215386074e-308 gam0123 gamma -171.5 -> 1.9316265431711902e-310 gam0124 gamma -176.5 -> -1.1956388629358166e-321 gam0125 gamma -177.5 -> 4.9406564584124654e-324 gam0126 gamma -178.5 -> -0.0 gam0127 gamma -179.5 -> 0.0 gam0128 gamma -201.0001 -> 0.0 gam0129 gamma -202.9999 -> -0.0 gam0130 gamma -1000.5 -> -0.0 gam0131 gamma -1000000000.3 -> -0.0 gam0132 gamma -4503599627370495.5 -> 0.0 -- inputs that cause problems for the standard reflection formula, -- thanks to loss of accuracy in 1-x gam0140 gamma -63.349078729022985 -> 4.1777971677761880e-88 gam0141 gamma -127.45117632943295 -> 1.1831110896236810e-214 ----------------------------------------------------------- -- log1p: log(1 + x), without precision loss for small x -- ----------------------------------------------------------- -- special values log1p0000 log1p 0.0 -> 0.0 log1p0001 log1p -0.0 -> -0.0 log1p0002 log1p inf -> inf log1p0003 log1p -inf -> nan invalid log1p0004 log1p nan -> nan -- singularity at -1.0 log1p0010 log1p -1.0 -> -inf divide-by-zero log1p0011 log1p -0.9999999999999999 -> -36.736800569677101 -- finite values < 1.0 are invalid log1p0020 log1p -1.0000000000000002 -> nan invalid log1p0021 log1p -1.1 -> nan invalid log1p0022 log1p -2.0 -> nan invalid log1p0023 log1p -1e300 -> nan invalid -- tiny x: log1p(x) ~ x log1p0110 log1p 5e-324 -> 5e-324 log1p0111 log1p 1e-320 -> 1e-320 log1p0112 log1p 1e-300 -> 1e-300 log1p0113 log1p 1e-150 -> 1e-150 log1p0114 log1p 1e-20 -> 1e-20 log1p0120 log1p -5e-324 -> -5e-324 log1p0121 log1p -1e-320 -> -1e-320 log1p0122 log1p -1e-300 -> -1e-300 log1p0123 log1p -1e-150 -> -1e-150 log1p0124 log1p -1e-20 -> -1e-20 -- some (mostly) random small and moderate-sized values log1p0200 log1p -0.89156889782277482 -> -2.2216403106762863 log1p0201 log1p -0.23858496047770464 -> -0.27257668276980057 log1p0202 log1p -0.011641726191307515 -> -0.011710021654495657 log1p0203 log1p -0.0090126398571693817 -> -0.0090534993825007650 log1p0204 log1p -0.00023442805985712781 -> -0.00023445554240995693 log1p0205 log1p -1.5672870980936349e-5 -> -1.5672993801662046e-5 log1p0206 log1p -7.9650013274825295e-6 -> -7.9650330482740401e-6 log1p0207 log1p -2.5202948343227410e-7 -> -2.5202951519170971e-7 log1p0208 log1p -8.2446372820745855e-11 -> -8.2446372824144559e-11 log1p0209 log1p -8.1663670046490789e-12 -> -8.1663670046824230e-12 log1p0210 log1p 7.0351735084656292e-18 -> 7.0351735084656292e-18 log1p0211 log1p 5.2732161907375226e-12 -> 5.2732161907236188e-12 log1p0212 log1p 1.0000000000000000e-10 -> 9.9999999995000007e-11 log1p0213 log1p 2.1401273266000197e-9 -> 2.1401273243099470e-9 log1p0214 log1p 1.2668914653979560e-8 -> 1.2668914573728861e-8 log1p0215 log1p 1.6250007816299069e-6 -> 1.6249994613175672e-6 log1p0216 log1p 8.3740495645839399e-6 -> 8.3740145024266269e-6 log1p0217 log1p 3.0000000000000001e-5 -> 2.9999550008999799e-5 log1p0218 log1p 0.0070000000000000001 -> 0.0069756137364252423 log1p0219 log1p 0.013026235315053002 -> 0.012942123564008787 log1p0220 log1p 0.013497160797236184 -> 0.013406885521915038 log1p0221 log1p 0.027625599078135284 -> 0.027250897463483054 log1p0222 log1p 0.14179687245544870 -> 0.13260322540908789 -- large values log1p0300 log1p 1.7976931348623157e+308 -> 709.78271289338397 log1p0301 log1p 1.0000000000000001e+300 -> 690.77552789821368 log1p0302 log1p 1.0000000000000001e+70 -> 161.18095650958321 log1p0303 log1p 10000000000.000000 -> 23.025850930040455 -- other values transferred from testLog1p in test_math log1p0400 log1p -0.63212055882855767 -> -1.0000000000000000 log1p0401 log1p 1.7182818284590451 -> 1.0000000000000000 log1p0402 log1p 1.0000000000000000 -> 0.69314718055994529 log1p0403 log1p 1.2379400392853803e+27 -> 62.383246250395075 ----------------------------------------------------------- -- expm1: exp(x) - 1, without precision loss for small x -- ----------------------------------------------------------- -- special values expm10000 expm1 0.0 -> 0.0 expm10001 expm1 -0.0 -> -0.0 expm10002 expm1 inf -> inf expm10003 expm1 -inf -> -1.0 expm10004 expm1 nan -> nan -- expm1(x) ~ x for tiny x expm10010 expm1 5e-324 -> 5e-324 expm10011 expm1 1e-320 -> 1e-320 expm10012 expm1 1e-300 -> 1e-300 expm10013 expm1 1e-150 -> 1e-150 expm10014 expm1 1e-20 -> 1e-20 expm10020 expm1 -5e-324 -> -5e-324 expm10021 expm1 -1e-320 -> -1e-320 expm10022 expm1 -1e-300 -> -1e-300 expm10023 expm1 -1e-150 -> -1e-150 expm10024 expm1 -1e-20 -> -1e-20 -- moderate sized values, where direct evaluation runs into trouble expm10100 expm1 1e-10 -> 1.0000000000500000e-10 expm10101 expm1 -9.9999999999999995e-08 -> -9.9999995000000163e-8 expm10102 expm1 3.0000000000000001e-05 -> 3.0000450004500034e-5 expm10103 expm1 -0.0070000000000000001 -> -0.0069755570667648951 expm10104 expm1 -0.071499208740094633 -> -0.069002985744820250 expm10105 expm1 -0.063296004180116799 -> -0.061334416373633009 expm10106 expm1 0.02390954035597756 -> 0.024197665143819942 expm10107 expm1 0.085637352649044901 -> 0.089411184580357767 expm10108 expm1 0.5966174947411006 -> 0.81596588596501485 expm10109 expm1 0.30247206212075139 -> 0.35319987035848677 expm10110 expm1 0.74574727375889516 -> 1.1080161116737459 expm10111 expm1 0.97767512926555711 -> 1.6582689207372185 expm10112 expm1 0.8450154566787712 -> 1.3280137976535897 expm10113 expm1 -0.13979260323125264 -> -0.13046144381396060 expm10114 expm1 -0.52899322039643271 -> -0.41080213643695923 expm10115 expm1 -0.74083261478900631 -> -0.52328317124797097 expm10116 expm1 -0.93847766984546055 -> -0.60877704724085946 expm10117 expm1 10.0 -> 22025.465794806718 expm10118 expm1 27.0 -> 532048240600.79865 expm10119 expm1 123 -> 2.6195173187490626e+53 expm10120 expm1 -12.0 -> -0.99999385578764666 expm10121 expm1 -35.100000000000001 -> -0.99999999999999944 -- extreme negative values expm10201 expm1 -37.0 -> -0.99999999999999989 expm10200 expm1 -38.0 -> -1.0 expm10210 expm1 -710.0 -> -1.0 -- the formula expm1(x) = 2 * sinh(x/2) * exp(x/2) doesn't work so -- well when exp(x/2) is subnormal or underflows to zero; check we're -- not using it! expm10211 expm1 -1420.0 -> -1.0 expm10212 expm1 -1450.0 -> -1.0 expm10213 expm1 -1500.0 -> -1.0 expm10214 expm1 -1e50 -> -1.0 expm10215 expm1 -1.79e308 -> -1.0 -- extreme positive values expm10300 expm1 300 -> 1.9424263952412558e+130 expm10301 expm1 700 -> 1.0142320547350045e+304 -- the next test (expm10302) is disabled because it causes failure on -- OS X 10.4/Intel: apparently all values over 709.78 produce an -- overflow on that platform. See issue #7575. -- expm10302 expm1 709.78271289328393 -> 1.7976931346824240e+308 expm10303 expm1 709.78271289348402 -> inf overflow expm10304 expm1 1000 -> inf overflow expm10305 expm1 1e50 -> inf overflow expm10306 expm1 1.79e308 -> inf overflow -- weaker version of expm10302 expm10307 expm1 709.5 -> 1.3549863193146328e+308 ------------------------- -- log2: log to base 2 -- ------------------------- -- special values log20000 log2 0.0 -> -inf divide-by-zero log20001 log2 -0.0 -> -inf divide-by-zero log20002 log2 inf -> inf log20003 log2 -inf -> nan invalid log20004 log2 nan -> nan -- exact value at 1.0 log20010 log2 1.0 -> 0.0 -- negatives log20020 log2 -5e-324 -> nan invalid log20021 log2 -1.0 -> nan invalid log20022 log2 -1.7e-308 -> nan invalid -- exact values at powers of 2 log20100 log2 2.0 -> 1.0 log20101 log2 4.0 -> 2.0 log20102 log2 8.0 -> 3.0 log20103 log2 16.0 -> 4.0 log20104 log2 32.0 -> 5.0 log20105 log2 64.0 -> 6.0 log20106 log2 128.0 -> 7.0 log20107 log2 256.0 -> 8.0 log20108 log2 512.0 -> 9.0 log20109 log2 1024.0 -> 10.0 log20110 log2 2048.0 -> 11.0 log20200 log2 0.5 -> -1.0 log20201 log2 0.25 -> -2.0 log20202 log2 0.125 -> -3.0 log20203 log2 0.0625 -> -4.0 -- values close to 1.0 log20300 log2 1.0000000000000002 -> 3.2034265038149171e-16 log20301 log2 1.0000000001 -> 1.4426951601859516e-10 log20302 log2 1.00001 -> 1.4426878274712997e-5 log20310 log2 0.9999999999999999 -> -1.6017132519074588e-16 log20311 log2 0.9999999999 -> -1.4426951603302210e-10 log20312 log2 0.99999 -> -1.4427022544056922e-5 -- tiny values log20400 log2 5e-324 -> -1074.0 log20401 log2 1e-323 -> -1073.0 log20402 log2 1.5e-323 -> -1072.4150374992789 log20403 log2 2e-323 -> -1072.0 log20410 log2 1e-308 -> -1023.1538532253076 log20411 log2 2.2250738585072014e-308 -> -1022.0 log20412 log2 4.4501477170144028e-308 -> -1021.0 log20413 log2 1e-307 -> -1019.8319251304202 -- huge values log20500 log2 1.7976931348623157e+308 -> 1024.0 log20501 log2 1.7e+308 -> 1023.9193879716706 log20502 log2 8.9884656743115795e+307 -> 1023.0 -- selection of random values log20600 log2 -7.2174324841039838e+289 -> nan invalid log20601 log2 -2.861319734089617e+265 -> nan invalid log20602 log2 -4.3507646894008962e+257 -> nan invalid log20603 log2 -6.6717265307520224e+234 -> nan invalid log20604 log2 -3.9118023786619294e+229 -> nan invalid log20605 log2 -1.5478221302505161e+206 -> nan invalid log20606 log2 -1.4380485131364602e+200 -> nan invalid log20607 log2 -3.7235198730382645e+185 -> nan invalid log20608 log2 -1.0472242235095724e+184 -> nan invalid log20609 log2 -5.0141781956163884e+160 -> nan invalid log20610 log2 -2.1157958031160324e+124 -> nan invalid log20611 log2 -7.9677558612567718e+90 -> nan invalid log20612 log2 -5.5553906194063732e+45 -> nan invalid log20613 log2 -16573900952607.953 -> nan invalid log20614 log2 -37198371019.888618 -> nan invalid log20615 log2 -6.0727115121422674e-32 -> nan invalid log20616 log2 -2.5406841656526057e-38 -> nan invalid log20617 log2 -4.9056766703267657e-43 -> nan invalid log20618 log2 -2.1646786075228305e-71 -> nan invalid log20619 log2 -2.470826790488573e-78 -> nan invalid log20620 log2 -3.8661709303489064e-165 -> nan invalid log20621 log2 -1.0516496976649986e-182 -> nan invalid log20622 log2 -1.5935458614317996e-255 -> nan invalid log20623 log2 -2.8750977267336654e-293 -> nan invalid log20624 log2 -7.6079466794732585e-296 -> nan invalid log20625 log2 3.2073253539988545e-307 -> -1018.1505544209213 log20626 log2 1.674937885472249e-244 -> -809.80634755783126 log20627 log2 1.0911259044931283e-214 -> -710.76679472274213 log20628 log2 2.0275372624809709e-154 -> -510.55719818383272 log20629 log2 7.3926087369631841e-115 -> -379.13564735312292 log20630 log2 1.3480198206342423e-86 -> -285.25497445094436 log20631 log2 8.9927384655719947e-83 -> -272.55127136401637 log20632 log2 3.1452398713597487e-60 -> -197.66251564496875 log20633 log2 7.0706573215457351e-55 -> -179.88420087782217 log20634 log2 3.1258285390731669e-49 -> -161.13023800505653 log20635 log2 8.2253046627829942e-41 -> -133.15898277355879 log20636 log2 7.8691367397519897e+49 -> 165.75068202732419 log20637 log2 2.9920561983925013e+64 -> 214.18453534573757 log20638 log2 4.7827254553946841e+77 -> 258.04629628445673 log20639 log2 3.1903566496481868e+105 -> 350.47616767491166 log20640 log2 5.6195082449502419e+113 -> 377.86831861008250 log20641 log2 9.9625658250651047e+125 -> 418.55752921228753 log20642 log2 2.7358945220961532e+145 -> 483.13158636923413 log20643 log2 2.785842387926931e+174 -> 579.49360214860280 log20644 log2 2.4169172507252751e+193 -> 642.40529039289652 log20645 log2 3.1689091206395632e+205 -> 682.65924573798395 log20646 log2 2.535995592365391e+208 -> 692.30359597460460 log20647 log2 6.2011236566089916e+233 -> 776.64177576730913 log20648 log2 2.1843274820677632e+253 -> 841.57499717289647 log20649 log2 8.7493931063474791e+297 -> 989.74182713073981
23,742
634
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_tuple.py
from test import support, seq_tests import unittest import gc import pickle class TupleTest(seq_tests.CommonTest): type2test = tuple def test_getitem_error(self): msg = "tuple indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): ()['a'] def test_constructors(self): super().test_constructors() # calling built-in types without argument must return empty self.assertEqual(tuple(), ()) t0_3 = (0, 1, 2, 3) t0_3_bis = tuple(t0_3) self.assertTrue(t0_3 is t0_3_bis) self.assertEqual(tuple([]), ()) self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3)) self.assertEqual(tuple(''), ()) self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm')) def test_truth(self): super().test_truth() self.assertTrue(not ()) self.assertTrue((42, )) def test_len(self): super().test_len() self.assertEqual(len(()), 0) self.assertEqual(len((0,)), 1) self.assertEqual(len((0, 1, 2)), 3) def test_iadd(self): super().test_iadd() u = (0, 1) u2 = u u += (2, 3) self.assertTrue(u is not u2) def test_imul(self): super().test_imul() u = (0, 1) u2 = u u *= 3 self.assertTrue(u is not u2) def test_tupleresizebug(self): # Check that a specific bug in _PyTuple_Resize() is squashed. def f(): for i in range(1000): yield i self.assertEqual(list(tuple(f())), list(range(1000))) def test_hash(self): # See SF bug 942952: Weakness in tuple hash # The hash should: # be non-commutative # should spread-out closely spaced values # should not exhibit cancellation in tuples like (x,(x,y)) # should be distinct from element hashes: hash(x)!=hash((x,)) # This test exercises those cases. # For a pure random hash and N=50, the expected number of occupied # buckets when tossing 252,600 balls into 2**32 buckets # is 252,592.6, or about 7.4 expected collisions. The # standard deviation is 2.73. On a box with 64-bit hash # codes, no collisions are expected. Here we accept no # more than 15 collisions. Any worse and the hash function # is sorely suspect. N=50 base = list(range(N)) xp = [(i, j) for i in base for j in base] inps = base + [(i, j) for i in base for j in xp] + \ [(i, j) for i in xp for j in base] + xp + list(zip(base)) collisions = len(inps) - len(set(map(hash, inps))) self.assertTrue(collisions <= 15) def test_repr(self): l0 = tuple() l2 = (0, 1, 2) a0 = self.type2test(l0) a2 = self.type2test(l2) self.assertEqual(str(a0), repr(l0)) self.assertEqual(str(a2), repr(l2)) self.assertEqual(repr(a0), "()") self.assertEqual(repr(a2), "(0, 1, 2)") def _not_tracked(self, t): # Nested tuples can take several collections to untrack gc.collect() gc.collect() self.assertFalse(gc.is_tracked(t), t) def _tracked(self, t): self.assertTrue(gc.is_tracked(t), t) gc.collect() gc.collect() self.assertTrue(gc.is_tracked(t), t) @support.cpython_only def test_track_literals(self): # Test GC-optimization of tuple literals x, y, z = 1.5, "a", [] self._not_tracked(()) self._not_tracked((1,)) self._not_tracked((1, 2)) self._not_tracked((1, 2, "a")) self._not_tracked((1, 2, (None, True, False, ()), int)) self._not_tracked((object(),)) self._not_tracked(((1, x), y, (2, 3))) # Tuples with mutable elements are always tracked, even if those # elements are not tracked right now. self._tracked(([],)) self._tracked(([1],)) self._tracked(({},)) self._tracked((set(),)) self._tracked((x, y, z)) def check_track_dynamic(self, tp, always_track): x, y, z = 1.5, "a", [] check = self._tracked if always_track else self._not_tracked check(tp()) check(tp([])) check(tp(set())) check(tp([1, x, y])) check(tp(obj for obj in [1, x, y])) check(tp(set([1, x, y]))) check(tp(tuple([obj]) for obj in [1, x, y])) check(tuple(tp([obj]) for obj in [1, x, y])) self._tracked(tp([z])) self._tracked(tp([[x, y]])) self._tracked(tp([{x: y}])) self._tracked(tp(obj for obj in [x, y, z])) self._tracked(tp(tuple([obj]) for obj in [x, y, z])) self._tracked(tuple(tp([obj]) for obj in [x, y, z])) @support.cpython_only def test_track_dynamic(self): # Test GC-optimization of dynamically constructed tuples. self.check_track_dynamic(tuple, False) @support.cpython_only def test_track_subtypes(self): # Tuple subtypes must always be tracked class MyTuple(tuple): pass self.check_track_dynamic(MyTuple, True) @support.cpython_only def test_bug7466(self): # Trying to untrack an unfinished tuple could crash Python self._not_tracked(tuple(gc.collect() for i in range(101))) def test_repr_large(self): # Check the repr of large list objects def check(n): l = (0,) * n s = repr(l) self.assertEqual(s, '(' + ', '.join(['0'] * n) + ')') check(10) # check our checking code check(1000000) def test_iterator_pickle(self): # Userlist iterators don't support pickling yet since # they are based on generators. data = self.type2test([4, 5, 6, 7]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): itorg = iter(data) d = pickle.dumps(itorg, proto) it = pickle.loads(d) self.assertEqual(type(itorg), type(it)) self.assertEqual(self.type2test(it), self.type2test(data)) it = pickle.loads(d) next(it) d = pickle.dumps(it, proto) self.assertEqual(self.type2test(it), self.type2test(data)[1:]) def test_reversed_pickle(self): data = self.type2test([4, 5, 6, 7]) for proto in range(pickle.HIGHEST_PROTOCOL + 1): itorg = reversed(data) d = pickle.dumps(itorg, proto) it = pickle.loads(d) self.assertEqual(type(itorg), type(it)) self.assertEqual(self.type2test(it), self.type2test(reversed(data))) it = pickle.loads(d) next(it) d = pickle.dumps(it, proto) self.assertEqual(self.type2test(it), self.type2test(reversed(data))[1:]) def test_no_comdat_folding(self): # Issue 8847: In the PGO build, the MSVC linker's COMDAT folding # optimization causes failures in code that relies on distinct # function addresses. class T(tuple): pass with self.assertRaises(TypeError): [3,] + T((1,2)) def test_lexicographic_ordering(self): # Issue 21100 a = self.type2test([1, 2]) b = self.type2test([1, 2, 0]) c = self.type2test([1, 3]) self.assertLess(a, b) self.assertLess(b, c) if __name__ == "__main__": unittest.main()
7,522
222
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/test_asyncore.py
import asyncore import unittest import select import os import socket import sys import time import errno import struct from test import support from io import BytesIO if support.PGO: raise unittest.SkipTest("test is not helpful for PGO") try: import _thread import threading except ImportError: threading = None TIMEOUT = 3 HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX') class dummysocket: def __init__(self): self.closed = False def close(self): self.closed = True def fileno(self): return 42 class dummychannel: def __init__(self): self.socket = dummysocket() def close(self): self.socket.close() class exitingdummy: def __init__(self): pass def handle_read_event(self): raise asyncore.ExitNow() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event class crashingdummy: def __init__(self): self.error_handled = False def handle_read_event(self): raise Exception() handle_write_event = handle_read_event handle_close = handle_read_event handle_expt_event = handle_read_event def handle_error(self): self.error_handled = True # used when testing senders; just collects what it gets until newline is sent def capture_server(evt, buf, serv): try: serv.listen() conn, addr = serv.accept() except socket.timeout: pass else: n = 200 start = time.time() while n > 0 and time.time() - start < 3.0: r, w, e = select.select([conn], [], [], 0.1) if r: n -= 1 data = conn.recv(10) # keep everything except for the newline terminator buf.write(data.replace(b'\n', b'')) if b'\n' in data: break time.sleep(0.01) conn.close() finally: serv.close() evt.set() def bind_af_aware(sock, addr): """Helper function to bind a socket according to its family.""" if HAS_UNIX_SOCKETS and sock.family == socket.AF_UNIX: # Make sure the path doesn't exist. support.unlink(addr) support.bind_unix_socket(sock, addr) else: sock.bind(addr) class HelperFunctionTests(unittest.TestCase): def test_readwriteexc(self): # Check exception handling behavior of read, write and _exception # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore read/write/_exception calls tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.read, tr1) self.assertRaises(asyncore.ExitNow, asyncore.write, tr1) self.assertRaises(asyncore.ExitNow, asyncore._exception, tr1) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() asyncore.read(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore.write(tr2) self.assertEqual(tr2.error_handled, True) tr2 = crashingdummy() asyncore._exception(tr2) self.assertEqual(tr2.error_handled, True) # asyncore.readwrite uses constants in the select module that # are not present in Windows systems (see this thread: # http://mail.python.org/pipermail/python-list/2001-October/109973.html) # These constants should be present as long as poll is available @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') def test_readwrite(self): # Check that correct methods are called by readwrite() attributes = ('read', 'expt', 'write', 'closed', 'error_handled') expected = ( (select.POLLIN, 'read'), (select.POLLPRI, 'expt'), (select.POLLOUT, 'write'), (select.POLLERR, 'closed'), (select.POLLHUP, 'closed'), (select.POLLNVAL, 'closed'), ) class testobj: def __init__(self): self.read = False self.write = False self.closed = False self.expt = False self.error_handled = False def handle_read_event(self): self.read = True def handle_write_event(self): self.write = True def handle_close(self): self.closed = True def handle_expt_event(self): self.expt = True def handle_error(self): self.error_handled = True for flag, expectedattr in expected: tobj = testobj() self.assertEqual(getattr(tobj, expectedattr), False) asyncore.readwrite(tobj, flag) # Only the attribute modified by the routine we expect to be # called should be True. for attr in attributes: self.assertEqual(getattr(tobj, attr), attr==expectedattr) # check that ExitNow exceptions in the object handler method # bubbles all the way up through asyncore readwrite call tr1 = exitingdummy() self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag) # check that an exception other than ExitNow in the object handler # method causes the handle_error method to get called tr2 = crashingdummy() self.assertEqual(tr2.error_handled, False) asyncore.readwrite(tr2, flag) self.assertEqual(tr2.error_handled, True) def test_closeall(self): self.closeall_check(False) def test_closeall_default(self): self.closeall_check(True) def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True) def test_compact_traceback(self): try: raise Exception("I don't like spam!") except: real_t, real_v, real_tb = sys.exc_info() r = asyncore.compact_traceback() else: self.fail("Expected exception") (f, function, line), t, v, info = r self.assertEqual(os.path.split(f)[-1], 'test_asyncore.py') self.assertEqual(function, 'test_compact_traceback') self.assertEqual(t, real_t) self.assertEqual(v, real_v) self.assertEqual(info, '[%s|%s|%s]' % (f, function, line)) class DispatcherTests(unittest.TestCase): def setUp(self): pass def tearDown(self): asyncore.close_all() def test_basic(self): d = asyncore.dispatcher() self.assertEqual(d.readable(), True) self.assertEqual(d.writable(), True) def test_repr(self): d = asyncore.dispatcher() self.assertEqual(repr(d), '<asyncore.dispatcher at %#x>' % id(d)) def test_log(self): d = asyncore.dispatcher() # capture output of dispatcher.log() (to stderr) l1 = "Lovely spam! Wonderful spam!" l2 = "I don't like spam!" with support.captured_stderr() as stderr: d.log(l1) d.log(l2) lines = stderr.getvalue().splitlines() self.assertEqual(lines, ['log: %s' % l1, 'log: %s' % l2]) def test_log_info(self): d = asyncore.dispatcher() # capture output of dispatcher.log_info() (to stdout via print) l1 = "Have you got anything without spam?" l2 = "Why can't she have egg bacon spam and sausage?" l3 = "THAT'S got spam in it!" with support.captured_stdout() as stdout: d.log_info(l1, 'EGGS') d.log_info(l2) d.log_info(l3, 'SPAM') lines = stdout.getvalue().splitlines() expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3] self.assertEqual(lines, expected) def test_unhandled(self): d = asyncore.dispatcher() d.ignore_log_types = () # capture output of dispatcher.log_info() (to stdout via print) with support.captured_stdout() as stdout: d.handle_expt() d.handle_read() d.handle_write() d.handle_connect() lines = stdout.getvalue().splitlines() expected = ['warning: unhandled incoming priority event', 'warning: unhandled read event', 'warning: unhandled write event', 'warning: unhandled connect event'] self.assertEqual(lines, expected) def test_strerror(self): # refers to bug #8573 err = asyncore._strerror(errno.EPERM) if hasattr(os, 'strerror'): self.assertEqual(err, os.strerror(errno.EPERM)) err = asyncore._strerror(-1) self.assertTrue(err != "") class dispatcherwithsend_noread(asyncore.dispatcher_with_send): def readable(self): return False def handle_connect(self): pass class DispatcherWithSendTests(unittest.TestCase): def setUp(self): pass def tearDown(self): asyncore.close_all() @unittest.skipUnless(threading, 'Threading required for this test.') @support.reap_threads def test_send(self): evt = threading.Event() sock = socket.socket() sock.settimeout(3) port = support.bind_port(sock) cap = BytesIO() args = (evt, cap, sock) t = threading.Thread(target=capture_server, args=args) t.start() try: # wait a little longer for the server to initialize (it sometimes # refuses connections on slow machines without this wait) time.sleep(0.2) data = b"Suppose there isn't a 16-ton weight?" d = dispatcherwithsend_noread() d.create_socket() d.connect((support.HOST, port)) # give time for socket to connect time.sleep(0.1) d.send(data) d.send(data) d.send(b'\n') n = 1000 while d.out_buffer and n > 0: asyncore.poll() n -= 1 evt.wait() self.assertEqual(cap.getvalue(), data*2) finally: t.join(timeout=TIMEOUT) if t.is_alive(): self.fail("join() timed out") @unittest.skipUnless(hasattr(asyncore, 'file_wrapper'), 'asyncore.file_wrapper required') class FileWrapperTest(unittest.TestCase): def setUp(self): self.d = b"It's not dead, it's sleeping!" with open(support.TESTFN, 'wb') as file: file.write(self.d) def tearDown(self): support.unlink(support.TESTFN) def test_recv(self): fd = os.open(support.TESTFN, os.O_RDONLY) w = asyncore.file_wrapper(fd) os.close(fd) self.assertNotEqual(w.fd, fd) self.assertNotEqual(w.fileno(), fd) self.assertEqual(w.recv(13), b"It's not dead") self.assertEqual(w.read(6), b", it's") w.close() self.assertRaises(OSError, w.read, 1) def test_send(self): d1 = b"Come again?" d2 = b"I want to buy some cheese." fd = os.open(support.TESTFN, os.O_WRONLY | os.O_APPEND) w = asyncore.file_wrapper(fd) os.close(fd) w.write(d1) w.send(d2) w.close() with open(support.TESTFN, 'rb') as file: self.assertEqual(file.read(), self.d + d1 + d2) @unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'), 'asyncore.file_dispatcher required') def test_dispatcher(self): fd = os.open(support.TESTFN, os.O_RDONLY) data = [] class FileDispatcher(asyncore.file_dispatcher): def handle_read(self): data.append(self.recv(29)) s = FileDispatcher(fd) os.close(fd) asyncore.loop(timeout=0.01, use_poll=True, count=2) self.assertEqual(b"".join(data), self.d) def test_resource_warning(self): # Issue #11453 fd = os.open(support.TESTFN, os.O_RDONLY) f = asyncore.file_wrapper(fd) os.close(fd) with support.check_warnings(('', ResourceWarning)): f = None support.gc_collect() def test_close_twice(self): fd = os.open(support.TESTFN, os.O_RDONLY) f = asyncore.file_wrapper(fd) os.close(fd) os.close(f.fd) # file_wrapper dupped fd with self.assertRaises(OSError): f.close() self.assertEqual(f.fd, -1) # calling close twice should not fail f.close() class BaseTestHandler(asyncore.dispatcher): def __init__(self, sock=None): asyncore.dispatcher.__init__(self, sock) self.flag = False def handle_accept(self): raise Exception("handle_accept not supposed to be called") def handle_accepted(self): raise Exception("handle_accepted not supposed to be called") def handle_connect(self): raise Exception("handle_connect not supposed to be called") def handle_expt(self): raise Exception("handle_expt not supposed to be called") def handle_close(self): raise Exception("handle_close not supposed to be called") def handle_error(self): raise class BaseServer(asyncore.dispatcher): """A server which listens on an address and dispatches the connection to a handler. """ def __init__(self, family, addr, handler=BaseTestHandler): asyncore.dispatcher.__init__(self) self.create_socket(family) self.set_reuse_addr() bind_af_aware(self.socket, addr) self.listen(5) self.handler = handler @property def address(self): return self.socket.getsockname() def handle_accepted(self, sock, addr): self.handler(sock) def handle_error(self): raise class BaseClient(BaseTestHandler): def __init__(self, family, address): BaseTestHandler.__init__(self) self.create_socket(family) self.connect(address) def handle_connect(self): pass class BaseTestAPI: def tearDown(self): asyncore.close_all(ignore_all=True) def loop_waiting_for_flag(self, instance, timeout=5): timeout = float(timeout) / 100 count = 100 while asyncore.socket_map and count > 0: asyncore.loop(timeout=0.01, count=1, use_poll=self.use_poll) if instance.flag: return count -= 1 time.sleep(timeout) self.fail("flag not set") def test_handle_connect(self): # make sure handle_connect is called on connect() class TestClient(BaseClient): def handle_connect(self): self.flag = True server = BaseServer(self.family, self.addr) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) def test_handle_accept(self): # make sure handle_accept() is called when a client connects class TestListener(BaseTestHandler): def __init__(self, family, addr): BaseTestHandler.__init__(self) self.create_socket(family) bind_af_aware(self.socket, addr) self.listen(5) self.address = self.socket.getsockname() def handle_accept(self): self.flag = True server = TestListener(self.family, self.addr) client = BaseClient(self.family, server.address) self.loop_waiting_for_flag(server) def test_handle_accepted(self): # make sure handle_accepted() is called when a client connects class TestListener(BaseTestHandler): def __init__(self, family, addr): BaseTestHandler.__init__(self) self.create_socket(family) bind_af_aware(self.socket, addr) self.listen(5) self.address = self.socket.getsockname() def handle_accept(self): asyncore.dispatcher.handle_accept(self) def handle_accepted(self, sock, addr): sock.close() self.flag = True server = TestListener(self.family, self.addr) client = BaseClient(self.family, server.address) self.loop_waiting_for_flag(server) def test_handle_read(self): # make sure handle_read is called on data received class TestClient(BaseClient): def handle_read(self): self.flag = True class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.send(b'x' * 1024) server = BaseServer(self.family, self.addr, TestHandler) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) def test_handle_write(self): # make sure handle_write is called class TestClient(BaseClient): def handle_write(self): self.flag = True server = BaseServer(self.family, self.addr) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) def test_handle_close(self): # make sure handle_close is called when the other end closes # the connection class TestClient(BaseClient): def handle_read(self): # in order to make handle_close be called we are supposed # to make at least one recv() call self.recv(1024) def handle_close(self): self.flag = True self.close() class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.close() server = BaseServer(self.family, self.addr, TestHandler) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) def test_handle_close_after_conn_broken(self): # Check that ECONNRESET/EPIPE is correctly handled (issues #5661 and # #11265). data = b'\0' * 128 class TestClient(BaseClient): def handle_write(self): self.send(data) def handle_close(self): self.flag = True self.close() def handle_expt(self): self.flag = True self.close() class TestHandler(BaseTestHandler): def handle_read(self): self.recv(len(data)) self.close() def writable(self): return False server = BaseServer(self.family, self.addr, TestHandler) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) @unittest.skipIf(sys.platform.startswith("sunos"), "OOB support is broken on Solaris") def test_handle_expt(self): # Make sure handle_expt is called on OOB data received. # Note: this might fail on some platforms as OOB data is # tenuously supported and rarely used. if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX: self.skipTest("Not applicable to AF_UNIX sockets.") if sys.platform == "darwin" and self.use_poll: self.skipTest("poll may fail on macOS; see issue #28087") class TestClient(BaseClient): def handle_expt(self): self.socket.recv(1024, socket.MSG_OOB) self.flag = True class TestHandler(BaseTestHandler): def __init__(self, conn): BaseTestHandler.__init__(self, conn) self.socket.send(bytes(chr(244), 'latin-1'), socket.MSG_OOB) server = BaseServer(self.family, self.addr, TestHandler) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) def test_handle_error(self): class TestClient(BaseClient): def handle_write(self): 1.0 / 0 def handle_error(self): self.flag = True try: raise except ZeroDivisionError: pass else: raise Exception("exception not raised") server = BaseServer(self.family, self.addr) client = TestClient(self.family, server.address) self.loop_waiting_for_flag(client) def test_connection_attributes(self): server = BaseServer(self.family, self.addr) client = BaseClient(self.family, server.address) # we start disconnected self.assertFalse(server.connected) self.assertTrue(server.accepting) # this can't be taken for granted across all platforms #self.assertFalse(client.connected) self.assertFalse(client.accepting) # execute some loops so that client connects to server asyncore.loop(timeout=0.01, use_poll=self.use_poll, count=100) self.assertFalse(server.connected) self.assertTrue(server.accepting) self.assertTrue(client.connected) self.assertFalse(client.accepting) # disconnect the client client.close() self.assertFalse(server.connected) self.assertTrue(server.accepting) self.assertFalse(client.connected) self.assertFalse(client.accepting) # stop serving server.close() self.assertFalse(server.connected) self.assertFalse(server.accepting) def test_create_socket(self): s = asyncore.dispatcher() s.create_socket(self.family) self.assertEqual(s.socket.family, self.family) SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', 0) sock_type = socket.SOCK_STREAM | SOCK_NONBLOCK if hasattr(socket, 'SOCK_CLOEXEC'): self.assertIn(s.socket.type, (sock_type | socket.SOCK_CLOEXEC, sock_type)) else: self.assertEqual(s.socket.type, sock_type) def test_bind(self): if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX: self.skipTest("Not applicable to AF_UNIX sockets.") s1 = asyncore.dispatcher() s1.create_socket(self.family) s1.bind(self.addr) s1.listen(5) port = s1.socket.getsockname()[1] s2 = asyncore.dispatcher() s2.create_socket(self.family) # EADDRINUSE indicates the socket was correctly bound self.assertRaises(OSError, s2.bind, (self.addr[0], port)) def test_set_reuse_addr(self): if HAS_UNIX_SOCKETS and self.family == socket.AF_UNIX: self.skipTest("Not applicable to AF_UNIX sockets.") with socket.socket(self.family) as sock: try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) except OSError: unittest.skip("SO_REUSEADDR not supported on this platform") else: # if SO_REUSEADDR succeeded for sock we expect asyncore # to do the same s = asyncore.dispatcher(socket.socket(self.family)) self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) s.socket.close() s.create_socket(self.family) s.set_reuse_addr() self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) @unittest.skipUnless(threading, 'Threading required for this test.') @support.reap_threads def test_quick_connect(self): # see: http://bugs.python.org/issue10340 if self.family not in (socket.AF_INET, getattr(socket, "AF_INET6", object())): self.skipTest("test specific to AF_INET and AF_INET6") server = BaseServer(self.family, self.addr) # run the thread 500 ms: the socket should be connected in 200 ms t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=5)) t.start() try: with socket.socket(self.family, socket.SOCK_STREAM) as s: s.settimeout(.2) s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0)) try: s.connect(server.address) except OSError: pass finally: t.join(timeout=TIMEOUT) if t.is_alive(): self.fail("join() timed out") class TestAPI_UseIPv4Sockets(BaseTestAPI): family = socket.AF_INET addr = (support.HOST, 0) @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 support required') class TestAPI_UseIPv6Sockets(BaseTestAPI): family = socket.AF_INET6 addr = (support.HOSTv6, 0) @unittest.skipUnless(HAS_UNIX_SOCKETS, 'Unix sockets required') class TestAPI_UseUnixSockets(BaseTestAPI): if HAS_UNIX_SOCKETS: family = socket.AF_UNIX addr = support.TESTFN def tearDown(self): support.unlink(self.addr) BaseTestAPI.tearDown(self) class TestAPI_UseIPv4Select(TestAPI_UseIPv4Sockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') class TestAPI_UseIPv4Poll(TestAPI_UseIPv4Sockets, unittest.TestCase): use_poll = True class TestAPI_UseIPv6Select(TestAPI_UseIPv6Sockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') class TestAPI_UseIPv6Poll(TestAPI_UseIPv6Sockets, unittest.TestCase): use_poll = True class TestAPI_UseUnixSocketsSelect(TestAPI_UseUnixSockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') class TestAPI_UseUnixSocketsPoll(TestAPI_UseUnixSockets, unittest.TestCase): use_poll = True if __name__ == "__main__": unittest.main()
26,931
849
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/nullbytecert.pem
Certificate: Data: Version: 3 (0x2) Serial Number: 0 (0x0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/[email protected] Validity Not Before: Aug 7 13:11:52 2013 GMT Not After : Aug 7 13:12:52 2013 GMT Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/[email protected] Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3: 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97: 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2: 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1: 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4: 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8: a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02: 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75: ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91: 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d: 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30: 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7: f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12: f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5: ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb: d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f: 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da: 2f:85 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C X509v3 Key Usage: Digital Signature, Non Repudiation, Key Encipherment X509v3 Subject Alternative Name: ************************************************************* WARNING: The values for DNS, email and URI are WRONG. OpenSSL doesn't print the text after a NULL byte. ************************************************************* DNS:altnull.python.org, email:[email protected], URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1 Signature Algorithm: sha1WithRSAEncryption ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5: a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44: 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37: 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3: 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86: de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac: 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4: 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60: d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5: 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60: 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6: 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d: 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e: 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6: c1:ca:a9:94 -----BEGIN CERTIFICATE----- MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL 08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251 bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9 i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ= -----END CERTIFICATE-----
5,435
91
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/tokenize_tests.txt
# Tests for the 'tokenize' module. # Large bits stolen from test_grammar.py. # Comments "#" #' #" #\ # # abc '''# #''' x = 1 # # Balancing continuation a = (3, 4, 5, 6) y = [3, 4, 5] z = {'a':5, 'b':6} x = (len(repr(y)) + 5*x - a[ 3 ] - x + len({ } ) ) # Backslash means line continuation: x = 1 \ + 1 # Backslash does not means continuation in comments :\ x = 0 # Ordinary integers 0xff != 255 0o377 != 255 2147483647 != 0o17777777777 -2147483647-1 != 0o20000000000 0o37777777777 != -1 0xffffffff != -1; 0o37777777777 != -1; -0o1234567 == 0O001234567; 0b10101 == 0B00010101 # Long integers x = 0 x = 0 x = 0xffffffffffffffff x = 0xffffffffffffffff x = 0o77777777777777777 x = 0B11101010111111111 x = 123456789012345678901234567890 x = 123456789012345678901234567890 # Floating-point numbers x = 3.14 x = 314. x = 0.314 # XXX x = 000.314 x = .314 x = 3e14 x = 3E14 x = 3e-14 x = 3e+14 x = 3.e14 x = .3e14 x = 3.1e4 # String literals x = ''; y = ""; x = '\''; y = "'"; x = '"'; y = "\""; x = "doesn't \"shrink\" does it" y = 'doesn\'t "shrink" does it' x = "does \"shrink\" doesn't it" y = 'does "shrink" doesn\'t it' x = """ The "quick" brown fox jumps over the 'lazy' dog. """ y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' y = ''' The "quick" brown fox jumps over the 'lazy' dog. '''; y = "\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the 'lazy' dog.\n\ "; y = '\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the \'lazy\' dog.\n\ '; x = r'\\' + R'\\' x = r'\'' + '' y = r''' foo bar \\ baz''' + R''' foo''' y = r"""foo bar \\ baz """ + R'''spam ''' x = b'abc' + B'ABC' y = b"abc" + B"ABC" x = br'abc' + Br'ABC' + bR'ABC' + BR'ABC' y = br"abc" + Br"ABC" + bR"ABC" + BR"ABC" x = rb'abc' + rB'ABC' + Rb'ABC' + RB'ABC' y = rb"abc" + rB"ABC" + Rb"ABC" + RB"ABC" x = br'\\' + BR'\\' x = rb'\\' + RB'\\' x = br'\'' + '' x = rb'\'' + '' y = br''' foo bar \\ baz''' + BR''' foo''' y = Br"""foo bar \\ baz """ + bR'''spam ''' y = rB"""foo bar \\ baz """ + Rb'''spam ''' # Indentation if 1: x = 2 if 1: x = 2 if 1: while 0: if 0: x = 2 x = 2 if 0: if 2: while 0: if 1: x = 2 # Operators def d22(a, b, c=1, d=2): pass def d01v(a=1, *restt, **restd): pass (x, y) != ({'a':1}, {'b':2}) # comparison if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 != 1 in 1 not in 1 is 1 is not 1: pass # binary x = 1 & 1 x = 1 ^ 1 x = 1 | 1 # shift x = 1 << 1 >> 1 # additive x = 1 - 1 + 1 - 1 + 1 # multiplicative x = 1 / 1 * 1 % 1 # unary x = ~1 ^ 1 & 1 | 1 & 1 ^ -1 x = -1*1/1 + 1*1 - ---1*1 # selector import sys, time x = sys.modules['time'].time() @staticmethod def foo(): pass @staticmethod def foo(x:1)->1: pass
2,718
190
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/test/CP949.TXT
# # Name: cp949 to Unicode table # Unicode version: 2.0 # Table version: 2.01 # Table format: Format A # Date: 1/7/2000 # # Contact: [email protected] # # General notes: none # # Format: Three tab-separated columns # Column #1 is the cp949 code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # # The entries are in cp949 order # 00 0000 01 0001 02 0002 03 0003 04 0004 05 0005 06 0006 07 0007 08 0008 09 0009 0A 000A 0B 000B 0C 000C 0D 000D 0E 000E 0F 000F 10 0010 11 0011 12 0012 13 0013 14 0014 15 0015 16 0016 17 0017 18 0018 19 0019 1A 001A 1B 001B 1C 001C 1D 001D 1E 001E 1F 001F 20 0020 21 0021 22 0022 23 0023 24 0024 25 0025 26 0026 27 0027 28 0028 29 0029 2A 002A 2B 002B 2C 002C 2D 002D 2E 002E 2F 002F 30 0030 31 0031 32 0032 33 0033 34 0034 35 0035 36 0036 37 0037 38 0038 39 0039 3A 003A 3B 003B 3C 003C 3D 003D 3E 003E 3F 003F 40 0040 41 0041 42 0042 43 0043 44 0044 45 0045 46 0046 47 0047 48 0048 49 0049 4A 004A 4B 004B 4C 004C 4D 004D 4E 004E 4F 004F 50 0050 51 0051 52 0052 53 0053 54 0054 55 0055 56 0056 57 0057 58 0058 59 0059 5A 005A 5B 005B 5C 005C 5D 005D 5E 005E 5F 005F 60 0060 61 0061 62 0062 63 0063 64 0064 65 0065 66 0066 67 0067 68 0068 69 0069 6A 006A 6B 006B 6C 006C 6D 006D 6E 006E 6F 006F 70 0070 71 0071 72 0072 73 0073 74 0074 75 0075 76 0076 77 0077 78 0078 79 0079 7A 007A 7B 007B 7C 007C 7D 007D 7E 007E 7F 007F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF 8141 AC02 8142 AC03 8143 AC05 8144 AC06 8145 AC0B 8146 AC0C 8147 AC0D 8148 AC0E 8149 AC0F 814A AC18 814B AC1E 814C AC1F 814D AC21 814E AC22 814F AC23 8150 AC25 8151 AC26 8152 AC27 8153 AC28 8154 AC29 8155 AC2A 8156 AC2B 8157 AC2E 8158 AC32 8159 AC33 815A AC34 8161 AC35 8162 AC36 8163 AC37 8164 AC3A 8165 AC3B 8166 AC3D 8167 AC3E 8168 AC3F 8169 AC41 816A AC42 816B AC43 816C AC44 816D AC45 816E AC46 816F AC47 8170 AC48 8171 AC49 8172 AC4A 8173 AC4C 8174 AC4E 8175 AC4F 8176 AC50 8177 AC51 8178 AC52 8179 AC53 817A AC55 8181 AC56 8182 AC57 8183 AC59 8184 AC5A 8185 AC5B 8186 AC5D 8187 AC5E 8188 AC5F 8189 AC60 818A AC61 818B AC62 818C AC63 818D AC64 818E AC65 818F AC66 8190 AC67 8191 AC68 8192 AC69 8193 AC6A 8194 AC6B 8195 AC6C 8196 AC6D 8197 AC6E 8198 AC6F 8199 AC72 819A AC73 819B AC75 819C AC76 819D AC79 819E AC7B 819F AC7C 81A0 AC7D 81A1 AC7E 81A2 AC7F 81A3 AC82 81A4 AC87 81A5 AC88 81A6 AC8D 81A7 AC8E 81A8 AC8F 81A9 AC91 81AA AC92 81AB AC93 81AC AC95 81AD AC96 81AE AC97 81AF AC98 81B0 AC99 81B1 AC9A 81B2 AC9B 81B3 AC9E 81B4 ACA2 81B5 ACA3 81B6 ACA4 81B7 ACA5 81B8 ACA6 81B9 ACA7 81BA ACAB 81BB ACAD 81BC ACAE 81BD ACB1 81BE ACB2 81BF ACB3 81C0 ACB4 81C1 ACB5 81C2 ACB6 81C3 ACB7 81C4 ACBA 81C5 ACBE 81C6 ACBF 81C7 ACC0 81C8 ACC2 81C9 ACC3 81CA ACC5 81CB ACC6 81CC ACC7 81CD ACC9 81CE ACCA 81CF ACCB 81D0 ACCD 81D1 ACCE 81D2 ACCF 81D3 ACD0 81D4 ACD1 81D5 ACD2 81D6 ACD3 81D7 ACD4 81D8 ACD6 81D9 ACD8 81DA ACD9 81DB ACDA 81DC ACDB 81DD ACDC 81DE ACDD 81DF ACDE 81E0 ACDF 81E1 ACE2 81E2 ACE3 81E3 ACE5 81E4 ACE6 81E5 ACE9 81E6 ACEB 81E7 ACED 81E8 ACEE 81E9 ACF2 81EA ACF4 81EB ACF7 81EC ACF8 81ED ACF9 81EE ACFA 81EF ACFB 81F0 ACFE 81F1 ACFF 81F2 AD01 81F3 AD02 81F4 AD03 81F5 AD05 81F6 AD07 81F7 AD08 81F8 AD09 81F9 AD0A 81FA AD0B 81FB AD0E 81FC AD10 81FD AD12 81FE AD13 8241 AD14 8242 AD15 8243 AD16 8244 AD17 8245 AD19 8246 AD1A 8247 AD1B 8248 AD1D 8249 AD1E 824A AD1F 824B AD21 824C AD22 824D AD23 824E AD24 824F AD25 8250 AD26 8251 AD27 8252 AD28 8253 AD2A 8254 AD2B 8255 AD2E 8256 AD2F 8257 AD30 8258 AD31 8259 AD32 825A AD33 8261 AD36 8262 AD37 8263 AD39 8264 AD3A 8265 AD3B 8266 AD3D 8267 AD3E 8268 AD3F 8269 AD40 826A AD41 826B AD42 826C AD43 826D AD46 826E AD48 826F AD4A 8270 AD4B 8271 AD4C 8272 AD4D 8273 AD4E 8274 AD4F 8275 AD51 8276 AD52 8277 AD53 8278 AD55 8279 AD56 827A AD57 8281 AD59 8282 AD5A 8283 AD5B 8284 AD5C 8285 AD5D 8286 AD5E 8287 AD5F 8288 AD60 8289 AD62 828A AD64 828B AD65 828C AD66 828D AD67 828E AD68 828F AD69 8290 AD6A 8291 AD6B 8292 AD6E 8293 AD6F 8294 AD71 8295 AD72 8296 AD77 8297 AD78 8298 AD79 8299 AD7A 829A AD7E 829B AD80 829C AD83 829D AD84 829E AD85 829F AD86 82A0 AD87 82A1 AD8A 82A2 AD8B 82A3 AD8D 82A4 AD8E 82A5 AD8F 82A6 AD91 82A7 AD92 82A8 AD93 82A9 AD94 82AA AD95 82AB AD96 82AC AD97 82AD AD98 82AE AD99 82AF AD9A 82B0 AD9B 82B1 AD9E 82B2 AD9F 82B3 ADA0 82B4 ADA1 82B5 ADA2 82B6 ADA3 82B7 ADA5 82B8 ADA6 82B9 ADA7 82BA ADA8 82BB ADA9 82BC ADAA 82BD ADAB 82BE ADAC 82BF ADAD 82C0 ADAE 82C1 ADAF 82C2 ADB0 82C3 ADB1 82C4 ADB2 82C5 ADB3 82C6 ADB4 82C7 ADB5 82C8 ADB6 82C9 ADB8 82CA ADB9 82CB ADBA 82CC ADBB 82CD ADBC 82CE ADBD 82CF ADBE 82D0 ADBF 82D1 ADC2 82D2 ADC3 82D3 ADC5 82D4 ADC6 82D5 ADC7 82D6 ADC9 82D7 ADCA 82D8 ADCB 82D9 ADCC 82DA ADCD 82DB ADCE 82DC ADCF 82DD ADD2 82DE ADD4 82DF ADD5 82E0 ADD6 82E1 ADD7 82E2 ADD8 82E3 ADD9 82E4 ADDA 82E5 ADDB 82E6 ADDD 82E7 ADDE 82E8 ADDF 82E9 ADE1 82EA ADE2 82EB ADE3 82EC ADE5 82ED ADE6 82EE ADE7 82EF ADE8 82F0 ADE9 82F1 ADEA 82F2 ADEB 82F3 ADEC 82F4 ADED 82F5 ADEE 82F6 ADEF 82F7 ADF0 82F8 ADF1 82F9 ADF2 82FA ADF3 82FB ADF4 82FC ADF5 82FD ADF6 82FE ADF7 8341 ADFA 8342 ADFB 8343 ADFD 8344 ADFE 8345 AE02 8346 AE03 8347 AE04 8348 AE05 8349 AE06 834A AE07 834B AE0A 834C AE0C 834D AE0E 834E AE0F 834F AE10 8350 AE11 8351 AE12 8352 AE13 8353 AE15 8354 AE16 8355 AE17 8356 AE18 8357 AE19 8358 AE1A 8359 AE1B 835A AE1C 8361 AE1D 8362 AE1E 8363 AE1F 8364 AE20 8365 AE21 8366 AE22 8367 AE23 8368 AE24 8369 AE25 836A AE26 836B AE27 836C AE28 836D AE29 836E AE2A 836F AE2B 8370 AE2C 8371 AE2D 8372 AE2E 8373 AE2F 8374 AE32 8375 AE33 8376 AE35 8377 AE36 8378 AE39 8379 AE3B 837A AE3C 8381 AE3D 8382 AE3E 8383 AE3F 8384 AE42 8385 AE44 8386 AE47 8387 AE48 8388 AE49 8389 AE4B 838A AE4F 838B AE51 838C AE52 838D AE53 838E AE55 838F AE57 8390 AE58 8391 AE59 8392 AE5A 8393 AE5B 8394 AE5E 8395 AE62 8396 AE63 8397 AE64 8398 AE66 8399 AE67 839A AE6A 839B AE6B 839C AE6D 839D AE6E 839E AE6F 839F AE71 83A0 AE72 83A1 AE73 83A2 AE74 83A3 AE75 83A4 AE76 83A5 AE77 83A6 AE7A 83A7 AE7E 83A8 AE7F 83A9 AE80 83AA AE81 83AB AE82 83AC AE83 83AD AE86 83AE AE87 83AF AE88 83B0 AE89 83B1 AE8A 83B2 AE8B 83B3 AE8D 83B4 AE8E 83B5 AE8F 83B6 AE90 83B7 AE91 83B8 AE92 83B9 AE93 83BA AE94 83BB AE95 83BC AE96 83BD AE97 83BE AE98 83BF AE99 83C0 AE9A 83C1 AE9B 83C2 AE9C 83C3 AE9D 83C4 AE9E 83C5 AE9F 83C6 AEA0 83C7 AEA1 83C8 AEA2 83C9 AEA3 83CA AEA4 83CB AEA5 83CC AEA6 83CD AEA7 83CE AEA8 83CF AEA9 83D0 AEAA 83D1 AEAB 83D2 AEAC 83D3 AEAD 83D4 AEAE 83D5 AEAF 83D6 AEB0 83D7 AEB1 83D8 AEB2 83D9 AEB3 83DA AEB4 83DB AEB5 83DC AEB6 83DD AEB7 83DE AEB8 83DF AEB9 83E0 AEBA 83E1 AEBB 83E2 AEBF 83E3 AEC1 83E4 AEC2 83E5 AEC3 83E6 AEC5 83E7 AEC6 83E8 AEC7 83E9 AEC8 83EA AEC9 83EB AECA 83EC AECB 83ED AECE 83EE AED2 83EF AED3 83F0 AED4 83F1 AED5 83F2 AED6 83F3 AED7 83F4 AEDA 83F5 AEDB 83F6 AEDD 83F7 AEDE 83F8 AEDF 83F9 AEE0 83FA AEE1 83FB AEE2 83FC AEE3 83FD AEE4 83FE AEE5 8441 AEE6 8442 AEE7 8443 AEE9 8444 AEEA 8445 AEEC 8446 AEEE 8447 AEEF 8448 AEF0 8449 AEF1 844A AEF2 844B AEF3 844C AEF5 844D AEF6 844E AEF7 844F AEF9 8450 AEFA 8451 AEFB 8452 AEFD 8453 AEFE 8454 AEFF 8455 AF00 8456 AF01 8457 AF02 8458 AF03 8459 AF04 845A AF05 8461 AF06 8462 AF09 8463 AF0A 8464 AF0B 8465 AF0C 8466 AF0E 8467 AF0F 8468 AF11 8469 AF12 846A AF13 846B AF14 846C AF15 846D AF16 846E AF17 846F AF18 8470 AF19 8471 AF1A 8472 AF1B 8473 AF1C 8474 AF1D 8475 AF1E 8476 AF1F 8477 AF20 8478 AF21 8479 AF22 847A AF23 8481 AF24 8482 AF25 8483 AF26 8484 AF27 8485 AF28 8486 AF29 8487 AF2A 8488 AF2B 8489 AF2E 848A AF2F 848B AF31 848C AF33 848D AF35 848E AF36 848F AF37 8490 AF38 8491 AF39 8492 AF3A 8493 AF3B 8494 AF3E 8495 AF40 8496 AF44 8497 AF45 8498 AF46 8499 AF47 849A AF4A 849B AF4B 849C AF4C 849D AF4D 849E AF4E 849F AF4F 84A0 AF51 84A1 AF52 84A2 AF53 84A3 AF54 84A4 AF55 84A5 AF56 84A6 AF57 84A7 AF58 84A8 AF59 84A9 AF5A 84AA AF5B 84AB AF5E 84AC AF5F 84AD AF60 84AE AF61 84AF AF62 84B0 AF63 84B1 AF66 84B2 AF67 84B3 AF68 84B4 AF69 84B5 AF6A 84B6 AF6B 84B7 AF6C 84B8 AF6D 84B9 AF6E 84BA AF6F 84BB AF70 84BC AF71 84BD AF72 84BE AF73 84BF AF74 84C0 AF75 84C1 AF76 84C2 AF77 84C3 AF78 84C4 AF7A 84C5 AF7B 84C6 AF7C 84C7 AF7D 84C8 AF7E 84C9 AF7F 84CA AF81 84CB AF82 84CC AF83 84CD AF85 84CE AF86 84CF AF87 84D0 AF89 84D1 AF8A 84D2 AF8B 84D3 AF8C 84D4 AF8D 84D5 AF8E 84D6 AF8F 84D7 AF92 84D8 AF93 84D9 AF94 84DA AF96 84DB AF97 84DC AF98 84DD AF99 84DE AF9A 84DF AF9B 84E0 AF9D 84E1 AF9E 84E2 AF9F 84E3 AFA0 84E4 AFA1 84E5 AFA2 84E6 AFA3 84E7 AFA4 84E8 AFA5 84E9 AFA6 84EA AFA7 84EB AFA8 84EC AFA9 84ED AFAA 84EE AFAB 84EF AFAC 84F0 AFAD 84F1 AFAE 84F2 AFAF 84F3 AFB0 84F4 AFB1 84F5 AFB2 84F6 AFB3 84F7 AFB4 84F8 AFB5 84F9 AFB6 84FA AFB7 84FB AFBA 84FC AFBB 84FD AFBD 84FE AFBE 8541 AFBF 8542 AFC1 8543 AFC2 8544 AFC3 8545 AFC4 8546 AFC5 8547 AFC6 8548 AFCA 8549 AFCC 854A AFCF 854B AFD0 854C AFD1 854D AFD2 854E AFD3 854F AFD5 8550 AFD6 8551 AFD7 8552 AFD8 8553 AFD9 8554 AFDA 8555 AFDB 8556 AFDD 8557 AFDE 8558 AFDF 8559 AFE0 855A AFE1 8561 AFE2 8562 AFE3 8563 AFE4 8564 AFE5 8565 AFE6 8566 AFE7 8567 AFEA 8568 AFEB 8569 AFEC 856A AFED 856B AFEE 856C AFEF 856D AFF2 856E AFF3 856F AFF5 8570 AFF6 8571 AFF7 8572 AFF9 8573 AFFA 8574 AFFB 8575 AFFC 8576 AFFD 8577 AFFE 8578 AFFF 8579 B002 857A B003 8581 B005 8582 B006 8583 B007 8584 B008 8585 B009 8586 B00A 8587 B00B 8588 B00D 8589 B00E 858A B00F 858B B011 858C B012 858D B013 858E B015 858F B016 8590 B017 8591 B018 8592 B019 8593 B01A 8594 B01B 8595 B01E 8596 B01F 8597 B020 8598 B021 8599 B022 859A B023 859B B024 859C B025 859D B026 859E B027 859F B029 85A0 B02A 85A1 B02B 85A2 B02C 85A3 B02D 85A4 B02E 85A5 B02F 85A6 B030 85A7 B031 85A8 B032 85A9 B033 85AA B034 85AB B035 85AC B036 85AD B037 85AE B038 85AF B039 85B0 B03A 85B1 B03B 85B2 B03C 85B3 B03D 85B4 B03E 85B5 B03F 85B6 B040 85B7 B041 85B8 B042 85B9 B043 85BA B046 85BB B047 85BC B049 85BD B04B 85BE B04D 85BF B04F 85C0 B050 85C1 B051 85C2 B052 85C3 B056 85C4 B058 85C5 B05A 85C6 B05B 85C7 B05C 85C8 B05E 85C9 B05F 85CA B060 85CB B061 85CC B062 85CD B063 85CE B064 85CF B065 85D0 B066 85D1 B067 85D2 B068 85D3 B069 85D4 B06A 85D5 B06B 85D6 B06C 85D7 B06D 85D8 B06E 85D9 B06F 85DA B070 85DB B071 85DC B072 85DD B073 85DE B074 85DF B075 85E0 B076 85E1 B077 85E2 B078 85E3 B079 85E4 B07A 85E5 B07B 85E6 B07E 85E7 B07F 85E8 B081 85E9 B082 85EA B083 85EB B085 85EC B086 85ED B087 85EE B088 85EF B089 85F0 B08A 85F1 B08B 85F2 B08E 85F3 B090 85F4 B092 85F5 B093 85F6 B094 85F7 B095 85F8 B096 85F9 B097 85FA B09B 85FB B09D 85FC B09E 85FD B0A3 85FE B0A4 8641 B0A5 8642 B0A6 8643 B0A7 8644 B0AA 8645 B0B0 8646 B0B2 8647 B0B6 8648 B0B7 8649 B0B9 864A B0BA 864B B0BB 864C B0BD 864D B0BE 864E B0BF 864F B0C0 8650 B0C1 8651 B0C2 8652 B0C3 8653 B0C6 8654 B0CA 8655 B0CB 8656 B0CC 8657 B0CD 8658 B0CE 8659 B0CF 865A B0D2 8661 B0D3 8662 B0D5 8663 B0D6 8664 B0D7 8665 B0D9 8666 B0DA 8667 B0DB 8668 B0DC 8669 B0DD 866A B0DE 866B B0DF 866C B0E1 866D B0E2 866E B0E3 866F B0E4 8670 B0E6 8671 B0E7 8672 B0E8 8673 B0E9 8674 B0EA 8675 B0EB 8676 B0EC 8677 B0ED 8678 B0EE 8679 B0EF 867A B0F0 8681 B0F1 8682 B0F2 8683 B0F3 8684 B0F4 8685 B0F5 8686 B0F6 8687 B0F7 8688 B0F8 8689 B0F9 868A B0FA 868B B0FB 868C B0FC 868D B0FD 868E B0FE 868F B0FF 8690 B100 8691 B101 8692 B102 8693 B103 8694 B104 8695 B105 8696 B106 8697 B107 8698 B10A 8699 B10D 869A B10E 869B B10F 869C B111 869D B114 869E B115 869F B116 86A0 B117 86A1 B11A 86A2 B11E 86A3 B11F 86A4 B120 86A5 B121 86A6 B122 86A7 B126 86A8 B127 86A9 B129 86AA B12A 86AB B12B 86AC B12D 86AD B12E 86AE B12F 86AF B130 86B0 B131 86B1 B132 86B2 B133 86B3 B136 86B4 B13A 86B5 B13B 86B6 B13C 86B7 B13D 86B8 B13E 86B9 B13F 86BA B142 86BB B143 86BC B145 86BD B146 86BE B147 86BF B149 86C0 B14A 86C1 B14B 86C2 B14C 86C3 B14D 86C4 B14E 86C5 B14F 86C6 B152 86C7 B153 86C8 B156 86C9 B157 86CA B159 86CB B15A 86CC B15B 86CD B15D 86CE B15E 86CF B15F 86D0 B161 86D1 B162 86D2 B163 86D3 B164 86D4 B165 86D5 B166 86D6 B167 86D7 B168 86D8 B169 86D9 B16A 86DA B16B 86DB B16C 86DC B16D 86DD B16E 86DE B16F 86DF B170 86E0 B171 86E1 B172 86E2 B173 86E3 B174 86E4 B175 86E5 B176 86E6 B177 86E7 B17A 86E8 B17B 86E9 B17D 86EA B17E 86EB B17F 86EC B181 86ED B183 86EE B184 86EF B185 86F0 B186 86F1 B187 86F2 B18A 86F3 B18C 86F4 B18E 86F5 B18F 86F6 B190 86F7 B191 86F8 B195 86F9 B196 86FA B197 86FB B199 86FC B19A 86FD B19B 86FE B19D 8741 B19E 8742 B19F 8743 B1A0 8744 B1A1 8745 B1A2 8746 B1A3 8747 B1A4 8748 B1A5 8749 B1A6 874A B1A7 874B B1A9 874C B1AA 874D B1AB 874E B1AC 874F B1AD 8750 B1AE 8751 B1AF 8752 B1B0 8753 B1B1 8754 B1B2 8755 B1B3 8756 B1B4 8757 B1B5 8758 B1B6 8759 B1B7 875A B1B8 8761 B1B9 8762 B1BA 8763 B1BB 8764 B1BC 8765 B1BD 8766 B1BE 8767 B1BF 8768 B1C0 8769 B1C1 876A B1C2 876B B1C3 876C B1C4 876D B1C5 876E B1C6 876F B1C7 8770 B1C8 8771 B1C9 8772 B1CA 8773 B1CB 8774 B1CD 8775 B1CE 8776 B1CF 8777 B1D1 8778 B1D2 8779 B1D3 877A B1D5 8781 B1D6 8782 B1D7 8783 B1D8 8784 B1D9 8785 B1DA 8786 B1DB 8787 B1DE 8788 B1E0 8789 B1E1 878A B1E2 878B B1E3 878C B1E4 878D B1E5 878E B1E6 878F B1E7 8790 B1EA 8791 B1EB 8792 B1ED 8793 B1EE 8794 B1EF 8795 B1F1 8796 B1F2 8797 B1F3 8798 B1F4 8799 B1F5 879A B1F6 879B B1F7 879C B1F8 879D B1FA 879E B1FC 879F B1FE 87A0 B1FF 87A1 B200 87A2 B201 87A3 B202 87A4 B203 87A5 B206 87A6 B207 87A7 B209 87A8 B20A 87A9 B20D 87AA B20E 87AB B20F 87AC B210 87AD B211 87AE B212 87AF B213 87B0 B216 87B1 B218 87B2 B21A 87B3 B21B 87B4 B21C 87B5 B21D 87B6 B21E 87B7 B21F 87B8 B221 87B9 B222 87BA B223 87BB B224 87BC B225 87BD B226 87BE B227 87BF B228 87C0 B229 87C1 B22A 87C2 B22B 87C3 B22C 87C4 B22D 87C5 B22E 87C6 B22F 87C7 B230 87C8 B231 87C9 B232 87CA B233 87CB B235 87CC B236 87CD B237 87CE B238 87CF B239 87D0 B23A 87D1 B23B 87D2 B23D 87D3 B23E 87D4 B23F 87D5 B240 87D6 B241 87D7 B242 87D8 B243 87D9 B244 87DA B245 87DB B246 87DC B247 87DD B248 87DE B249 87DF B24A 87E0 B24B 87E1 B24C 87E2 B24D 87E3 B24E 87E4 B24F 87E5 B250 87E6 B251 87E7 B252 87E8 B253 87E9 B254 87EA B255 87EB B256 87EC B257 87ED B259 87EE B25A 87EF B25B 87F0 B25D 87F1 B25E 87F2 B25F 87F3 B261 87F4 B262 87F5 B263 87F6 B264 87F7 B265 87F8 B266 87F9 B267 87FA B26A 87FB B26B 87FC B26C 87FD B26D 87FE B26E 8841 B26F 8842 B270 8843 B271 8844 B272 8845 B273 8846 B276 8847 B277 8848 B278 8849 B279 884A B27A 884B B27B 884C B27D 884D B27E 884E B27F 884F B280 8850 B281 8851 B282 8852 B283 8853 B286 8854 B287 8855 B288 8856 B28A 8857 B28B 8858 B28C 8859 B28D 885A B28E 8861 B28F 8862 B292 8863 B293 8864 B295 8865 B296 8866 B297 8867 B29B 8868 B29C 8869 B29D 886A B29E 886B B29F 886C B2A2 886D B2A4 886E B2A7 886F B2A8 8870 B2A9 8871 B2AB 8872 B2AD 8873 B2AE 8874 B2AF 8875 B2B1 8876 B2B2 8877 B2B3 8878 B2B5 8879 B2B6 887A B2B7 8881 B2B8 8882 B2B9 8883 B2BA 8884 B2BB 8885 B2BC 8886 B2BD 8887 B2BE 8888 B2BF 8889 B2C0 888A B2C1 888B B2C2 888C B2C3 888D B2C4 888E B2C5 888F B2C6 8890 B2C7 8891 B2CA 8892 B2CB 8893 B2CD 8894 B2CE 8895 B2CF 8896 B2D1 8897 B2D3 8898 B2D4 8899 B2D5 889A B2D6 889B B2D7 889C B2DA 889D B2DC 889E B2DE 889F B2DF 88A0 B2E0 88A1 B2E1 88A2 B2E3 88A3 B2E7 88A4 B2E9 88A5 B2EA 88A6 B2F0 88A7 B2F1 88A8 B2F2 88A9 B2F6 88AA B2FC 88AB B2FD 88AC B2FE 88AD B302 88AE B303 88AF B305 88B0 B306 88B1 B307 88B2 B309 88B3 B30A 88B4 B30B 88B5 B30C 88B6 B30D 88B7 B30E 88B8 B30F 88B9 B312 88BA B316 88BB B317 88BC B318 88BD B319 88BE B31A 88BF B31B 88C0 B31D 88C1 B31E 88C2 B31F 88C3 B320 88C4 B321 88C5 B322 88C6 B323 88C7 B324 88C8 B325 88C9 B326 88CA B327 88CB B328 88CC B329 88CD B32A 88CE B32B 88CF B32C 88D0 B32D 88D1 B32E 88D2 B32F 88D3 B330 88D4 B331 88D5 B332 88D6 B333 88D7 B334 88D8 B335 88D9 B336 88DA B337 88DB B338 88DC B339 88DD B33A 88DE B33B 88DF B33C 88E0 B33D 88E1 B33E 88E2 B33F 88E3 B340 88E4 B341 88E5 B342 88E6 B343 88E7 B344 88E8 B345 88E9 B346 88EA B347 88EB B348 88EC B349 88ED B34A 88EE B34B 88EF B34C 88F0 B34D 88F1 B34E 88F2 B34F 88F3 B350 88F4 B351 88F5 B352 88F6 B353 88F7 B357 88F8 B359 88F9 B35A 88FA B35D 88FB B360 88FC B361 88FD B362 88FE B363 8941 B366 8942 B368 8943 B36A 8944 B36C 8945 B36D 8946 B36F 8947 B372 8948 B373 8949 B375 894A B376 894B B377 894C B379 894D B37A 894E B37B 894F B37C 8950 B37D 8951 B37E 8952 B37F 8953 B382 8954 B386 8955 B387 8956 B388 8957 B389 8958 B38A 8959 B38B 895A B38D 8961 B38E 8962 B38F 8963 B391 8964 B392 8965 B393 8966 B395 8967 B396 8968 B397 8969 B398 896A B399 896B B39A 896C B39B 896D B39C 896E B39D 896F B39E 8970 B39F 8971 B3A2 8972 B3A3 8973 B3A4 8974 B3A5 8975 B3A6 8976 B3A7 8977 B3A9 8978 B3AA 8979 B3AB 897A B3AD 8981 B3AE 8982 B3AF 8983 B3B0 8984 B3B1 8985 B3B2 8986 B3B3 8987 B3B4 8988 B3B5 8989 B3B6 898A B3B7 898B B3B8 898C B3B9 898D B3BA 898E B3BB 898F B3BC 8990 B3BD 8991 B3BE 8992 B3BF 8993 B3C0 8994 B3C1 8995 B3C2 8996 B3C3 8997 B3C6 8998 B3C7 8999 B3C9 899A B3CA 899B B3CD 899C B3CF 899D B3D1 899E B3D2 899F B3D3 89A0 B3D6 89A1 B3D8 89A2 B3DA 89A3 B3DC 89A4 B3DE 89A5 B3DF 89A6 B3E1 89A7 B3E2 89A8 B3E3 89A9 B3E5 89AA B3E6 89AB B3E7 89AC B3E9 89AD B3EA 89AE B3EB 89AF B3EC 89B0 B3ED 89B1 B3EE 89B2 B3EF 89B3 B3F0 89B4 B3F1 89B5 B3F2 89B6 B3F3 89B7 B3F4 89B8 B3F5 89B9 B3F6 89BA B3F7 89BB B3F8 89BC B3F9 89BD B3FA 89BE B3FB 89BF B3FD 89C0 B3FE 89C1 B3FF 89C2 B400 89C3 B401 89C4 B402 89C5 B403 89C6 B404 89C7 B405 89C8 B406 89C9 B407 89CA B408 89CB B409 89CC B40A 89CD B40B 89CE B40C 89CF B40D 89D0 B40E 89D1 B40F 89D2 B411 89D3 B412 89D4 B413 89D5 B414 89D6 B415 89D7 B416 89D8 B417 89D9 B419 89DA B41A 89DB B41B 89DC B41D 89DD B41E 89DE B41F 89DF B421 89E0 B422 89E1 B423 89E2 B424 89E3 B425 89E4 B426 89E5 B427 89E6 B42A 89E7 B42C 89E8 B42D 89E9 B42E 89EA B42F 89EB B430 89EC B431 89ED B432 89EE B433 89EF B435 89F0 B436 89F1 B437 89F2 B438 89F3 B439 89F4 B43A 89F5 B43B 89F6 B43C 89F7 B43D 89F8 B43E 89F9 B43F 89FA B440 89FB B441 89FC B442 89FD B443 89FE B444 8A41 B445 8A42 B446 8A43 B447 8A44 B448 8A45 B449 8A46 B44A 8A47 B44B 8A48 B44C 8A49 B44D 8A4A B44E 8A4B B44F 8A4C B452 8A4D B453 8A4E B455 8A4F B456 8A50 B457 8A51 B459 8A52 B45A 8A53 B45B 8A54 B45C 8A55 B45D 8A56 B45E 8A57 B45F 8A58 B462 8A59 B464 8A5A B466 8A61 B467 8A62 B468 8A63 B469 8A64 B46A 8A65 B46B 8A66 B46D 8A67 B46E 8A68 B46F 8A69 B470 8A6A B471 8A6B B472 8A6C B473 8A6D B474 8A6E B475 8A6F B476 8A70 B477 8A71 B478 8A72 B479 8A73 B47A 8A74 B47B 8A75 B47C 8A76 B47D 8A77 B47E 8A78 B47F 8A79 B481 8A7A B482 8A81 B483 8A82 B484 8A83 B485 8A84 B486 8A85 B487 8A86 B489 8A87 B48A 8A88 B48B 8A89 B48C 8A8A B48D 8A8B B48E 8A8C B48F 8A8D B490 8A8E B491 8A8F B492 8A90 B493 8A91 B494 8A92 B495 8A93 B496 8A94 B497 8A95 B498 8A96 B499 8A97 B49A 8A98 B49B 8A99 B49C 8A9A B49E 8A9B B49F 8A9C B4A0 8A9D B4A1 8A9E B4A2 8A9F B4A3 8AA0 B4A5 8AA1 B4A6 8AA2 B4A7 8AA3 B4A9 8AA4 B4AA 8AA5 B4AB 8AA6 B4AD 8AA7 B4AE 8AA8 B4AF 8AA9 B4B0 8AAA B4B1 8AAB B4B2 8AAC B4B3 8AAD B4B4 8AAE B4B6 8AAF B4B8 8AB0 B4BA 8AB1 B4BB 8AB2 B4BC 8AB3 B4BD 8AB4 B4BE 8AB5 B4BF 8AB6 B4C1 8AB7 B4C2 8AB8 B4C3 8AB9 B4C5 8ABA B4C6 8ABB B4C7 8ABC B4C9 8ABD B4CA 8ABE B4CB 8ABF B4CC 8AC0 B4CD 8AC1 B4CE 8AC2 B4CF 8AC3 B4D1 8AC4 B4D2 8AC5 B4D3 8AC6 B4D4 8AC7 B4D6 8AC8 B4D7 8AC9 B4D8 8ACA B4D9 8ACB B4DA 8ACC B4DB 8ACD B4DE 8ACE B4DF 8ACF B4E1 8AD0 B4E2 8AD1 B4E5 8AD2 B4E7 8AD3 B4E8 8AD4 B4E9 8AD5 B4EA 8AD6 B4EB 8AD7 B4EE 8AD8 B4F0 8AD9 B4F2 8ADA B4F3 8ADB B4F4 8ADC B4F5 8ADD B4F6 8ADE B4F7 8ADF B4F9 8AE0 B4FA 8AE1 B4FB 8AE2 B4FC 8AE3 B4FD 8AE4 B4FE 8AE5 B4FF 8AE6 B500 8AE7 B501 8AE8 B502 8AE9 B503 8AEA B504 8AEB B505 8AEC B506 8AED B507 8AEE B508 8AEF B509 8AF0 B50A 8AF1 B50B 8AF2 B50C 8AF3 B50D 8AF4 B50E 8AF5 B50F 8AF6 B510 8AF7 B511 8AF8 B512 8AF9 B513 8AFA B516 8AFB B517 8AFC B519 8AFD B51A 8AFE B51D 8B41 B51E 8B42 B51F 8B43 B520 8B44 B521 8B45 B522 8B46 B523 8B47 B526 8B48 B52B 8B49 B52C 8B4A B52D 8B4B B52E 8B4C B52F 8B4D B532 8B4E B533 8B4F B535 8B50 B536 8B51 B537 8B52 B539 8B53 B53A 8B54 B53B 8B55 B53C 8B56 B53D 8B57 B53E 8B58 B53F 8B59 B542 8B5A B546 8B61 B547 8B62 B548 8B63 B549 8B64 B54A 8B65 B54E 8B66 B54F 8B67 B551 8B68 B552 8B69 B553 8B6A B555 8B6B B556 8B6C B557 8B6D B558 8B6E B559 8B6F B55A 8B70 B55B 8B71 B55E 8B72 B562 8B73 B563 8B74 B564 8B75 B565 8B76 B566 8B77 B567 8B78 B568 8B79 B569 8B7A B56A 8B81 B56B 8B82 B56C 8B83 B56D 8B84 B56E 8B85 B56F 8B86 B570 8B87 B571 8B88 B572 8B89 B573 8B8A B574 8B8B B575 8B8C B576 8B8D B577 8B8E B578 8B8F B579 8B90 B57A 8B91 B57B 8B92 B57C 8B93 B57D 8B94 B57E 8B95 B57F 8B96 B580 8B97 B581 8B98 B582 8B99 B583 8B9A B584 8B9B B585 8B9C B586 8B9D B587 8B9E B588 8B9F B589 8BA0 B58A 8BA1 B58B 8BA2 B58C 8BA3 B58D 8BA4 B58E 8BA5 B58F 8BA6 B590 8BA7 B591 8BA8 B592 8BA9 B593 8BAA B594 8BAB B595 8BAC B596 8BAD B597 8BAE B598 8BAF B599 8BB0 B59A 8BB1 B59B 8BB2 B59C 8BB3 B59D 8BB4 B59E 8BB5 B59F 8BB6 B5A2 8BB7 B5A3 8BB8 B5A5 8BB9 B5A6 8BBA B5A7 8BBB B5A9 8BBC B5AC 8BBD B5AD 8BBE B5AE 8BBF B5AF 8BC0 B5B2 8BC1 B5B6 8BC2 B5B7 8BC3 B5B8 8BC4 B5B9 8BC5 B5BA 8BC6 B5BE 8BC7 B5BF 8BC8 B5C1 8BC9 B5C2 8BCA B5C3 8BCB B5C5 8BCC B5C6 8BCD B5C7 8BCE B5C8 8BCF B5C9 8BD0 B5CA 8BD1 B5CB 8BD2 B5CE 8BD3 B5D2 8BD4 B5D3 8BD5 B5D4 8BD6 B5D5 8BD7 B5D6 8BD8 B5D7 8BD9 B5D9 8BDA B5DA 8BDB B5DB 8BDC B5DC 8BDD B5DD 8BDE B5DE 8BDF B5DF 8BE0 B5E0 8BE1 B5E1 8BE2 B5E2 8BE3 B5E3 8BE4 B5E4 8BE5 B5E5 8BE6 B5E6 8BE7 B5E7 8BE8 B5E8 8BE9 B5E9 8BEA B5EA 8BEB B5EB 8BEC B5ED 8BED B5EE 8BEE B5EF 8BEF B5F0 8BF0 B5F1 8BF1 B5F2 8BF2 B5F3 8BF3 B5F4 8BF4 B5F5 8BF5 B5F6 8BF6 B5F7 8BF7 B5F8 8BF8 B5F9 8BF9 B5FA 8BFA B5FB 8BFB B5FC 8BFC B5FD 8BFD B5FE 8BFE B5FF 8C41 B600 8C42 B601 8C43 B602 8C44 B603 8C45 B604 8C46 B605 8C47 B606 8C48 B607 8C49 B608 8C4A B609 8C4B B60A 8C4C B60B 8C4D B60C 8C4E B60D 8C4F B60E 8C50 B60F 8C51 B612 8C52 B613 8C53 B615 8C54 B616 8C55 B617 8C56 B619 8C57 B61A 8C58 B61B 8C59 B61C 8C5A B61D 8C61 B61E 8C62 B61F 8C63 B620 8C64 B621 8C65 B622 8C66 B623 8C67 B624 8C68 B626 8C69 B627 8C6A B628 8C6B B629 8C6C B62A 8C6D B62B 8C6E B62D 8C6F B62E 8C70 B62F 8C71 B630 8C72 B631 8C73 B632 8C74 B633 8C75 B635 8C76 B636 8C77 B637 8C78 B638 8C79 B639 8C7A B63A 8C81 B63B 8C82 B63C 8C83 B63D 8C84 B63E 8C85 B63F 8C86 B640 8C87 B641 8C88 B642 8C89 B643 8C8A B644 8C8B B645 8C8C B646 8C8D B647 8C8E B649 8C8F B64A 8C90 B64B 8C91 B64C 8C92 B64D 8C93 B64E 8C94 B64F 8C95 B650 8C96 B651 8C97 B652 8C98 B653 8C99 B654 8C9A B655 8C9B B656 8C9C B657 8C9D B658 8C9E B659 8C9F B65A 8CA0 B65B 8CA1 B65C 8CA2 B65D 8CA3 B65E 8CA4 B65F 8CA5 B660 8CA6 B661 8CA7 B662 8CA8 B663 8CA9 B665 8CAA B666 8CAB B667 8CAC B669 8CAD B66A 8CAE B66B 8CAF B66C 8CB0 B66D 8CB1 B66E 8CB2 B66F 8CB3 B670 8CB4 B671 8CB5 B672 8CB6 B673 8CB7 B674 8CB8 B675 8CB9 B676 8CBA B677 8CBB B678 8CBC B679 8CBD B67A 8CBE B67B 8CBF B67C 8CC0 B67D 8CC1 B67E 8CC2 B67F 8CC3 B680 8CC4 B681 8CC5 B682 8CC6 B683 8CC7 B684 8CC8 B685 8CC9 B686 8CCA B687 8CCB B688 8CCC B689 8CCD B68A 8CCE B68B 8CCF B68C 8CD0 B68D 8CD1 B68E 8CD2 B68F 8CD3 B690 8CD4 B691 8CD5 B692 8CD6 B693 8CD7 B694 8CD8 B695 8CD9 B696 8CDA B697 8CDB B698 8CDC B699 8CDD B69A 8CDE B69B 8CDF B69E 8CE0 B69F 8CE1 B6A1 8CE2 B6A2 8CE3 B6A3 8CE4 B6A5 8CE5 B6A6 8CE6 B6A7 8CE7 B6A8 8CE8 B6A9 8CE9 B6AA 8CEA B6AD 8CEB B6AE 8CEC B6AF 8CED B6B0 8CEE B6B2 8CEF B6B3 8CF0 B6B4 8CF1 B6B5 8CF2 B6B6 8CF3 B6B7 8CF4 B6B8 8CF5 B6B9 8CF6 B6BA 8CF7 B6BB 8CF8 B6BC 8CF9 B6BD 8CFA B6BE 8CFB B6BF 8CFC B6C0 8CFD B6C1 8CFE B6C2 8D41 B6C3 8D42 B6C4 8D43 B6C5 8D44 B6C6 8D45 B6C7 8D46 B6C8 8D47 B6C9 8D48 B6CA 8D49 B6CB 8D4A B6CC 8D4B B6CD 8D4C B6CE 8D4D B6CF 8D4E B6D0 8D4F B6D1 8D50 B6D2 8D51 B6D3 8D52 B6D5 8D53 B6D6 8D54 B6D7 8D55 B6D8 8D56 B6D9 8D57 B6DA 8D58 B6DB 8D59 B6DC 8D5A B6DD 8D61 B6DE 8D62 B6DF 8D63 B6E0 8D64 B6E1 8D65 B6E2 8D66 B6E3 8D67 B6E4 8D68 B6E5 8D69 B6E6 8D6A B6E7 8D6B B6E8 8D6C B6E9 8D6D B6EA 8D6E B6EB 8D6F B6EC 8D70 B6ED 8D71 B6EE 8D72 B6EF 8D73 B6F1 8D74 B6F2 8D75 B6F3 8D76 B6F5 8D77 B6F6 8D78 B6F7 8D79 B6F9 8D7A B6FA 8D81 B6FB 8D82 B6FC 8D83 B6FD 8D84 B6FE 8D85 B6FF 8D86 B702 8D87 B703 8D88 B704 8D89 B706 8D8A B707 8D8B B708 8D8C B709 8D8D B70A 8D8E B70B 8D8F B70C 8D90 B70D 8D91 B70E 8D92 B70F 8D93 B710 8D94 B711 8D95 B712 8D96 B713 8D97 B714 8D98 B715 8D99 B716 8D9A B717 8D9B B718 8D9C B719 8D9D B71A 8D9E B71B 8D9F B71C 8DA0 B71D 8DA1 B71E 8DA2 B71F 8DA3 B720 8DA4 B721 8DA5 B722 8DA6 B723 8DA7 B724 8DA8 B725 8DA9 B726 8DAA B727 8DAB B72A 8DAC B72B 8DAD B72D 8DAE B72E 8DAF B731 8DB0 B732 8DB1 B733 8DB2 B734 8DB3 B735 8DB4 B736 8DB5 B737 8DB6 B73A 8DB7 B73C 8DB8 B73D 8DB9 B73E 8DBA B73F 8DBB B740 8DBC B741 8DBD B742 8DBE B743 8DBF B745 8DC0 B746 8DC1 B747 8DC2 B749 8DC3 B74A 8DC4 B74B 8DC5 B74D 8DC6 B74E 8DC7 B74F 8DC8 B750 8DC9 B751 8DCA B752 8DCB B753 8DCC B756 8DCD B757 8DCE B758 8DCF B759 8DD0 B75A 8DD1 B75B 8DD2 B75C 8DD3 B75D 8DD4 B75E 8DD5 B75F 8DD6 B761 8DD7 B762 8DD8 B763 8DD9 B765 8DDA B766 8DDB B767 8DDC B769 8DDD B76A 8DDE B76B 8DDF B76C 8DE0 B76D 8DE1 B76E 8DE2 B76F 8DE3 B772 8DE4 B774 8DE5 B776 8DE6 B777 8DE7 B778 8DE8 B779 8DE9 B77A 8DEA B77B 8DEB B77E 8DEC B77F 8DED B781 8DEE B782 8DEF B783 8DF0 B785 8DF1 B786 8DF2 B787 8DF3 B788 8DF4 B789 8DF5 B78A 8DF6 B78B 8DF7 B78E 8DF8 B793 8DF9 B794 8DFA B795 8DFB B79A 8DFC B79B 8DFD B79D 8DFE B79E 8E41 B79F 8E42 B7A1 8E43 B7A2 8E44 B7A3 8E45 B7A4 8E46 B7A5 8E47 B7A6 8E48 B7A7 8E49 B7AA 8E4A B7AE 8E4B B7AF 8E4C B7B0 8E4D B7B1 8E4E B7B2 8E4F B7B3 8E50 B7B6 8E51 B7B7 8E52 B7B9 8E53 B7BA 8E54 B7BB 8E55 B7BC 8E56 B7BD 8E57 B7BE 8E58 B7BF 8E59 B7C0 8E5A B7C1 8E61 B7C2 8E62 B7C3 8E63 B7C4 8E64 B7C5 8E65 B7C6 8E66 B7C8 8E67 B7CA 8E68 B7CB 8E69 B7CC 8E6A B7CD 8E6B B7CE 8E6C B7CF 8E6D B7D0 8E6E B7D1 8E6F B7D2 8E70 B7D3 8E71 B7D4 8E72 B7D5 8E73 B7D6 8E74 B7D7 8E75 B7D8 8E76 B7D9 8E77 B7DA 8E78 B7DB 8E79 B7DC 8E7A B7DD 8E81 B7DE 8E82 B7DF 8E83 B7E0 8E84 B7E1 8E85 B7E2 8E86 B7E3 8E87 B7E4 8E88 B7E5 8E89 B7E6 8E8A B7E7 8E8B B7E8 8E8C B7E9 8E8D B7EA 8E8E B7EB 8E8F B7EE 8E90 B7EF 8E91 B7F1 8E92 B7F2 8E93 B7F3 8E94 B7F5 8E95 B7F6 8E96 B7F7 8E97 B7F8 8E98 B7F9 8E99 B7FA 8E9A B7FB 8E9B B7FE 8E9C B802 8E9D B803 8E9E B804 8E9F B805 8EA0 B806 8EA1 B80A 8EA2 B80B 8EA3 B80D 8EA4 B80E 8EA5 B80F 8EA6 B811 8EA7 B812 8EA8 B813 8EA9 B814 8EAA B815 8EAB B816 8EAC B817 8EAD B81A 8EAE B81C 8EAF B81E 8EB0 B81F 8EB1 B820 8EB2 B821 8EB3 B822 8EB4 B823 8EB5 B826 8EB6 B827 8EB7 B829 8EB8 B82A 8EB9 B82B 8EBA B82D 8EBB B82E 8EBC B82F 8EBD B830 8EBE B831 8EBF B832 8EC0 B833 8EC1 B836 8EC2 B83A 8EC3 B83B 8EC4 B83C 8EC5 B83D 8EC6 B83E 8EC7 B83F 8EC8 B841 8EC9 B842 8ECA B843 8ECB B845 8ECC B846 8ECD B847 8ECE B848 8ECF B849 8ED0 B84A 8ED1 B84B 8ED2 B84C 8ED3 B84D 8ED4 B84E 8ED5 B84F 8ED6 B850 8ED7 B852 8ED8 B854 8ED9 B855 8EDA B856 8EDB B857 8EDC B858 8EDD B859 8EDE B85A 8EDF B85B 8EE0 B85E 8EE1 B85F 8EE2 B861 8EE3 B862 8EE4 B863 8EE5 B865 8EE6 B866 8EE7 B867 8EE8 B868 8EE9 B869 8EEA B86A 8EEB B86B 8EEC B86E 8EED B870 8EEE B872 8EEF B873 8EF0 B874 8EF1 B875 8EF2 B876 8EF3 B877 8EF4 B879 8EF5 B87A 8EF6 B87B 8EF7 B87D 8EF8 B87E 8EF9 B87F 8EFA B880 8EFB B881 8EFC B882 8EFD B883 8EFE B884 8F41 B885 8F42 B886 8F43 B887 8F44 B888 8F45 B889 8F46 B88A 8F47 B88B 8F48 B88C 8F49 B88E 8F4A B88F 8F4B B890 8F4C B891 8F4D B892 8F4E B893 8F4F B894 8F50 B895 8F51 B896 8F52 B897 8F53 B898 8F54 B899 8F55 B89A 8F56 B89B 8F57 B89C 8F58 B89D 8F59 B89E 8F5A B89F 8F61 B8A0 8F62 B8A1 8F63 B8A2 8F64 B8A3 8F65 B8A4 8F66 B8A5 8F67 B8A6 8F68 B8A7 8F69 B8A9 8F6A B8AA 8F6B B8AB 8F6C B8AC 8F6D B8AD 8F6E B8AE 8F6F B8AF 8F70 B8B1 8F71 B8B2 8F72 B8B3 8F73 B8B5 8F74 B8B6 8F75 B8B7 8F76 B8B9 8F77 B8BA 8F78 B8BB 8F79 B8BC 8F7A B8BD 8F81 B8BE 8F82 B8BF 8F83 B8C2 8F84 B8C4 8F85 B8C6 8F86 B8C7 8F87 B8C8 8F88 B8C9 8F89 B8CA 8F8A B8CB 8F8B B8CD 8F8C B8CE 8F8D B8CF 8F8E B8D1 8F8F B8D2 8F90 B8D3 8F91 B8D5 8F92 B8D6 8F93 B8D7 8F94 B8D8 8F95 B8D9 8F96 B8DA 8F97 B8DB 8F98 B8DC 8F99 B8DE 8F9A B8E0 8F9B B8E2 8F9C B8E3 8F9D B8E4 8F9E B8E5 8F9F B8E6 8FA0 B8E7 8FA1 B8EA 8FA2 B8EB 8FA3 B8ED 8FA4 B8EE 8FA5 B8EF 8FA6 B8F1 8FA7 B8F2 8FA8 B8F3 8FA9 B8F4 8FAA B8F5 8FAB B8F6 8FAC B8F7 8FAD B8FA 8FAE B8FC 8FAF B8FE 8FB0 B8FF 8FB1 B900 8FB2 B901 8FB3 B902 8FB4 B903 8FB5 B905 8FB6 B906 8FB7 B907 8FB8 B908 8FB9 B909 8FBA B90A 8FBB B90B 8FBC B90C 8FBD B90D 8FBE B90E 8FBF B90F 8FC0 B910 8FC1 B911 8FC2 B912 8FC3 B913 8FC4 B914 8FC5 B915 8FC6 B916 8FC7 B917 8FC8 B919 8FC9 B91A 8FCA B91B 8FCB B91C 8FCC B91D 8FCD B91E 8FCE B91F 8FCF B921 8FD0 B922 8FD1 B923 8FD2 B924 8FD3 B925 8FD4 B926 8FD5 B927 8FD6 B928 8FD7 B929 8FD8 B92A 8FD9 B92B 8FDA B92C 8FDB B92D 8FDC B92E 8FDD B92F 8FDE B930 8FDF B931 8FE0 B932 8FE1 B933 8FE2 B934 8FE3 B935 8FE4 B936 8FE5 B937 8FE6 B938 8FE7 B939 8FE8 B93A 8FE9 B93B 8FEA B93E 8FEB B93F 8FEC B941 8FED B942 8FEE B943 8FEF B945 8FF0 B946 8FF1 B947 8FF2 B948 8FF3 B949 8FF4 B94A 8FF5 B94B 8FF6 B94D 8FF7 B94E 8FF8 B950 8FF9 B952 8FFA B953 8FFB B954 8FFC B955 8FFD B956 8FFE B957 9041 B95A 9042 B95B 9043 B95D 9044 B95E 9045 B95F 9046 B961 9047 B962 9048 B963 9049 B964 904A B965 904B B966 904C B967 904D B96A 904E B96C 904F B96E 9050 B96F 9051 B970 9052 B971 9053 B972 9054 B973 9055 B976 9056 B977 9057 B979 9058 B97A 9059 B97B 905A B97D 9061 B97E 9062 B97F 9063 B980 9064 B981 9065 B982 9066 B983 9067 B986 9068 B988 9069 B98B 906A B98C 906B B98F 906C B990 906D B991 906E B992 906F B993 9070 B994 9071 B995 9072 B996 9073 B997 9074 B998 9075 B999 9076 B99A 9077 B99B 9078 B99C 9079 B99D 907A B99E 9081 B99F 9082 B9A0 9083 B9A1 9084 B9A2 9085 B9A3 9086 B9A4 9087 B9A5 9088 B9A6 9089 B9A7 908A B9A8 908B B9A9 908C B9AA 908D B9AB 908E B9AE 908F B9AF 9090 B9B1 9091 B9B2 9092 B9B3 9093 B9B5 9094 B9B6 9095 B9B7 9096 B9B8 9097 B9B9 9098 B9BA 9099 B9BB 909A B9BE 909B B9C0 909C B9C2 909D B9C3 909E B9C4 909F B9C5 90A0 B9C6 90A1 B9C7 90A2 B9CA 90A3 B9CB 90A4 B9CD 90A5 B9D3 90A6 B9D4 90A7 B9D5 90A8 B9D6 90A9 B9D7 90AA B9DA 90AB B9DC 90AC B9DF 90AD B9E0 90AE B9E2 90AF B9E6 90B0 B9E7 90B1 B9E9 90B2 B9EA 90B3 B9EB 90B4 B9ED 90B5 B9EE 90B6 B9EF 90B7 B9F0 90B8 B9F1 90B9 B9F2 90BA B9F3 90BB B9F6 90BC B9FB 90BD B9FC 90BE B9FD 90BF B9FE 90C0 B9FF 90C1 BA02 90C2 BA03 90C3 BA04 90C4 BA05 90C5 BA06 90C6 BA07 90C7 BA09 90C8 BA0A 90C9 BA0B 90CA BA0C 90CB BA0D 90CC BA0E 90CD BA0F 90CE BA10 90CF BA11 90D0 BA12 90D1 BA13 90D2 BA14 90D3 BA16 90D4 BA17 90D5 BA18 90D6 BA19 90D7 BA1A 90D8 BA1B 90D9 BA1C 90DA BA1D 90DB BA1E 90DC BA1F 90DD BA20 90DE BA21 90DF BA22 90E0 BA23 90E1 BA24 90E2 BA25 90E3 BA26 90E4 BA27 90E5 BA28 90E6 BA29 90E7 BA2A 90E8 BA2B 90E9 BA2C 90EA BA2D 90EB BA2E 90EC BA2F 90ED BA30 90EE BA31 90EF BA32 90F0 BA33 90F1 BA34 90F2 BA35 90F3 BA36 90F4 BA37 90F5 BA3A 90F6 BA3B 90F7 BA3D 90F8 BA3E 90F9 BA3F 90FA BA41 90FB BA43 90FC BA44 90FD BA45 90FE BA46 9141 BA47 9142 BA4A 9143 BA4C 9144 BA4F 9145 BA50 9146 BA51 9147 BA52 9148 BA56 9149 BA57 914A BA59 914B BA5A 914C BA5B 914D BA5D 914E BA5E 914F BA5F 9150 BA60 9151 BA61 9152 BA62 9153 BA63 9154 BA66 9155 BA6A 9156 BA6B 9157 BA6C 9158 BA6D 9159 BA6E 915A BA6F 9161 BA72 9162 BA73 9163 BA75 9164 BA76 9165 BA77 9166 BA79 9167 BA7A 9168 BA7B 9169 BA7C 916A BA7D 916B BA7E 916C BA7F 916D BA80 916E BA81 916F BA82 9170 BA86 9171 BA88 9172 BA89 9173 BA8A 9174 BA8B 9175 BA8D 9176 BA8E 9177 BA8F 9178 BA90 9179 BA91 917A BA92 9181 BA93 9182 BA94 9183 BA95 9184 BA96 9185 BA97 9186 BA98 9187 BA99 9188 BA9A 9189 BA9B 918A BA9C 918B BA9D 918C BA9E 918D BA9F 918E BAA0 918F BAA1 9190 BAA2 9191 BAA3 9192 BAA4 9193 BAA5 9194 BAA6 9195 BAA7 9196 BAAA 9197 BAAD 9198 BAAE 9199 BAAF 919A BAB1 919B BAB3 919C BAB4 919D BAB5 919E BAB6 919F BAB7 91A0 BABA 91A1 BABC 91A2 BABE 91A3 BABF 91A4 BAC0 91A5 BAC1 91A6 BAC2 91A7 BAC3 91A8 BAC5 91A9 BAC6 91AA BAC7 91AB BAC9 91AC BACA 91AD BACB 91AE BACC 91AF BACD 91B0 BACE 91B1 BACF 91B2 BAD0 91B3 BAD1 91B4 BAD2 91B5 BAD3 91B6 BAD4 91B7 BAD5 91B8 BAD6 91B9 BAD7 91BA BADA 91BB BADB 91BC BADC 91BD BADD 91BE BADE 91BF BADF 91C0 BAE0 91C1 BAE1 91C2 BAE2 91C3 BAE3 91C4 BAE4 91C5 BAE5 91C6 BAE6 91C7 BAE7 91C8 BAE8 91C9 BAE9 91CA BAEA 91CB BAEB 91CC BAEC 91CD BAED 91CE BAEE 91CF BAEF 91D0 BAF0 91D1 BAF1 91D2 BAF2 91D3 BAF3 91D4 BAF4 91D5 BAF5 91D6 BAF6 91D7 BAF7 91D8 BAF8 91D9 BAF9 91DA BAFA 91DB BAFB 91DC BAFD 91DD BAFE 91DE BAFF 91DF BB01 91E0 BB02 91E1 BB03 91E2 BB05 91E3 BB06 91E4 BB07 91E5 BB08 91E6 BB09 91E7 BB0A 91E8 BB0B 91E9 BB0C 91EA BB0E 91EB BB10 91EC BB12 91ED BB13 91EE BB14 91EF BB15 91F0 BB16 91F1 BB17 91F2 BB19 91F3 BB1A 91F4 BB1B 91F5 BB1D 91F6 BB1E 91F7 BB1F 91F8 BB21 91F9 BB22 91FA BB23 91FB BB24 91FC BB25 91FD BB26 91FE BB27 9241 BB28 9242 BB2A 9243 BB2C 9244 BB2D 9245 BB2E 9246 BB2F 9247 BB30 9248 BB31 9249 BB32 924A BB33 924B BB37 924C BB39 924D BB3A 924E BB3F 924F BB40 9250 BB41 9251 BB42 9252 BB43 9253 BB46 9254 BB48 9255 BB4A 9256 BB4B 9257 BB4C 9258 BB4E 9259 BB51 925A BB52 9261 BB53 9262 BB55 9263 BB56 9264 BB57 9265 BB59 9266 BB5A 9267 BB5B 9268 BB5C 9269 BB5D 926A BB5E 926B BB5F 926C BB60 926D BB62 926E BB64 926F BB65 9270 BB66 9271 BB67 9272 BB68 9273 BB69 9274 BB6A 9275 BB6B 9276 BB6D 9277 BB6E 9278 BB6F 9279 BB70 927A BB71 9281 BB72 9282 BB73 9283 BB74 9284 BB75 9285 BB76 9286 BB77 9287 BB78 9288 BB79 9289 BB7A 928A BB7B 928B BB7C 928C BB7D 928D BB7E 928E BB7F 928F BB80 9290 BB81 9291 BB82 9292 BB83 9293 BB84 9294 BB85 9295 BB86 9296 BB87 9297 BB89 9298 BB8A 9299 BB8B 929A BB8D 929B BB8E 929C BB8F 929D BB91 929E BB92 929F BB93 92A0 BB94 92A1 BB95 92A2 BB96 92A3 BB97 92A4 BB98 92A5 BB99 92A6 BB9A 92A7 BB9B 92A8 BB9C 92A9 BB9D 92AA BB9E 92AB BB9F 92AC BBA0 92AD BBA1 92AE BBA2 92AF BBA3 92B0 BBA5 92B1 BBA6 92B2 BBA7 92B3 BBA9 92B4 BBAA 92B5 BBAB 92B6 BBAD 92B7 BBAE 92B8 BBAF 92B9 BBB0 92BA BBB1 92BB BBB2 92BC BBB3 92BD BBB5 92BE BBB6 92BF BBB8 92C0 BBB9 92C1 BBBA 92C2 BBBB 92C3 BBBC 92C4 BBBD 92C5 BBBE 92C6 BBBF 92C7 BBC1 92C8 BBC2 92C9 BBC3 92CA BBC5 92CB BBC6 92CC BBC7 92CD BBC9 92CE BBCA 92CF BBCB 92D0 BBCC 92D1 BBCD 92D2 BBCE 92D3 BBCF 92D4 BBD1 92D5 BBD2 92D6 BBD4 92D7 BBD5 92D8 BBD6 92D9 BBD7 92DA BBD8 92DB BBD9 92DC BBDA 92DD BBDB 92DE BBDC 92DF BBDD 92E0 BBDE 92E1 BBDF 92E2 BBE0 92E3 BBE1 92E4 BBE2 92E5 BBE3 92E6 BBE4 92E7 BBE5 92E8 BBE6 92E9 BBE7 92EA BBE8 92EB BBE9 92EC BBEA 92ED BBEB 92EE BBEC 92EF BBED 92F0 BBEE 92F1 BBEF 92F2 BBF0 92F3 BBF1 92F4 BBF2 92F5 BBF3 92F6 BBF4 92F7 BBF5 92F8 BBF6 92F9 BBF7 92FA BBFA 92FB BBFB 92FC BBFD 92FD BBFE 92FE BC01 9341 BC03 9342 BC04 9343 BC05 9344 BC06 9345 BC07 9346 BC0A 9347 BC0E 9348 BC10 9349 BC12 934A BC13 934B BC19 934C BC1A 934D BC20 934E BC21 934F BC22 9350 BC23 9351 BC26 9352 BC28 9353 BC2A 9354 BC2B 9355 BC2C 9356 BC2E 9357 BC2F 9358 BC32 9359 BC33 935A BC35 9361 BC36 9362 BC37 9363 BC39 9364 BC3A 9365 BC3B 9366 BC3C 9367 BC3D 9368 BC3E 9369 BC3F 936A BC42 936B BC46 936C BC47 936D BC48 936E BC4A 936F BC4B 9370 BC4E 9371 BC4F 9372 BC51 9373 BC52 9374 BC53 9375 BC54 9376 BC55 9377 BC56 9378 BC57 9379 BC58 937A BC59 9381 BC5A 9382 BC5B 9383 BC5C 9384 BC5E 9385 BC5F 9386 BC60 9387 BC61 9388 BC62 9389 BC63 938A BC64 938B BC65 938C BC66 938D BC67 938E BC68 938F BC69 9390 BC6A 9391 BC6B 9392 BC6C 9393 BC6D 9394 BC6E 9395 BC6F 9396 BC70 9397 BC71 9398 BC72 9399 BC73 939A BC74 939B BC75 939C BC76 939D BC77 939E BC78 939F BC79 93A0 BC7A 93A1 BC7B 93A2 BC7C 93A3 BC7D 93A4 BC7E 93A5 BC7F 93A6 BC80 93A7 BC81 93A8 BC82 93A9 BC83 93AA BC86 93AB BC87 93AC BC89 93AD BC8A 93AE BC8D 93AF BC8F 93B0 BC90 93B1 BC91 93B2 BC92 93B3 BC93 93B4 BC96 93B5 BC98 93B6 BC9B 93B7 BC9C 93B8 BC9D 93B9 BC9E 93BA BC9F 93BB BCA2 93BC BCA3 93BD BCA5 93BE BCA6 93BF BCA9 93C0 BCAA 93C1 BCAB 93C2 BCAC 93C3 BCAD 93C4 BCAE 93C5 BCAF 93C6 BCB2 93C7 BCB6 93C8 BCB7 93C9 BCB8 93CA BCB9 93CB BCBA 93CC BCBB 93CD BCBE 93CE BCBF 93CF BCC1 93D0 BCC2 93D1 BCC3 93D2 BCC5 93D3 BCC6 93D4 BCC7 93D5 BCC8 93D6 BCC9 93D7 BCCA 93D8 BCCB 93D9 BCCC 93DA BCCE 93DB BCD2 93DC BCD3 93DD BCD4 93DE BCD6 93DF BCD7 93E0 BCD9 93E1 BCDA 93E2 BCDB 93E3 BCDD 93E4 BCDE 93E5 BCDF 93E6 BCE0 93E7 BCE1 93E8 BCE2 93E9 BCE3 93EA BCE4 93EB BCE5 93EC BCE6 93ED BCE7 93EE BCE8 93EF BCE9 93F0 BCEA 93F1 BCEB 93F2 BCEC 93F3 BCED 93F4 BCEE 93F5 BCEF 93F6 BCF0 93F7 BCF1 93F8 BCF2 93F9 BCF3 93FA BCF7 93FB BCF9 93FC BCFA 93FD BCFB 93FE BCFD 9441 BCFE 9442 BCFF 9443 BD00 9444 BD01 9445 BD02 9446 BD03 9447 BD06 9448 BD08 9449 BD0A 944A BD0B 944B BD0C 944C BD0D 944D BD0E 944E BD0F 944F BD11 9450 BD12 9451 BD13 9452 BD15 9453 BD16 9454 BD17 9455 BD18 9456 BD19 9457 BD1A 9458 BD1B 9459 BD1C 945A BD1D 9461 BD1E 9462 BD1F 9463 BD20 9464 BD21 9465 BD22 9466 BD23 9467 BD25 9468 BD26 9469 BD27 946A BD28 946B BD29 946C BD2A 946D BD2B 946E BD2D 946F BD2E 9470 BD2F 9471 BD30 9472 BD31 9473 BD32 9474 BD33 9475 BD34 9476 BD35 9477 BD36 9478 BD37 9479 BD38 947A BD39 9481 BD3A 9482 BD3B 9483 BD3C 9484 BD3D 9485 BD3E 9486 BD3F 9487 BD41 9488 BD42 9489 BD43 948A BD44 948B BD45 948C BD46 948D BD47 948E BD4A 948F BD4B 9490 BD4D 9491 BD4E 9492 BD4F 9493 BD51 9494 BD52 9495 BD53 9496 BD54 9497 BD55 9498 BD56 9499 BD57 949A BD5A 949B BD5B 949C BD5C 949D BD5D 949E BD5E 949F BD5F 94A0 BD60 94A1 BD61 94A2 BD62 94A3 BD63 94A4 BD65 94A5 BD66 94A6 BD67 94A7 BD69 94A8 BD6A 94A9 BD6B 94AA BD6C 94AB BD6D 94AC BD6E 94AD BD6F 94AE BD70 94AF BD71 94B0 BD72 94B1 BD73 94B2 BD74 94B3 BD75 94B4 BD76 94B5 BD77 94B6 BD78 94B7 BD79 94B8 BD7A 94B9 BD7B 94BA BD7C 94BB BD7D 94BC BD7E 94BD BD7F 94BE BD82 94BF BD83 94C0 BD85 94C1 BD86 94C2 BD8B 94C3 BD8C 94C4 BD8D 94C5 BD8E 94C6 BD8F 94C7 BD92 94C8 BD94 94C9 BD96 94CA BD97 94CB BD98 94CC BD9B 94CD BD9D 94CE BD9E 94CF BD9F 94D0 BDA0 94D1 BDA1 94D2 BDA2 94D3 BDA3 94D4 BDA5 94D5 BDA6 94D6 BDA7 94D7 BDA8 94D8 BDA9 94D9 BDAA 94DA BDAB 94DB BDAC 94DC BDAD 94DD BDAE 94DE BDAF 94DF BDB1 94E0 BDB2 94E1 BDB3 94E2 BDB4 94E3 BDB5 94E4 BDB6 94E5 BDB7 94E6 BDB9 94E7 BDBA 94E8 BDBB 94E9 BDBC 94EA BDBD 94EB BDBE 94EC BDBF 94ED BDC0 94EE BDC1 94EF BDC2 94F0 BDC3 94F1 BDC4 94F2 BDC5 94F3 BDC6 94F4 BDC7 94F5 BDC8 94F6 BDC9 94F7 BDCA 94F8 BDCB 94F9 BDCC 94FA BDCD 94FB BDCE 94FC BDCF 94FD BDD0 94FE BDD1 9541 BDD2 9542 BDD3 9543 BDD6 9544 BDD7 9545 BDD9 9546 BDDA 9547 BDDB 9548 BDDD 9549 BDDE 954A BDDF 954B BDE0 954C BDE1 954D BDE2 954E BDE3 954F BDE4 9550 BDE5 9551 BDE6 9552 BDE7 9553 BDE8 9554 BDEA 9555 BDEB 9556 BDEC 9557 BDED 9558 BDEE 9559 BDEF 955A BDF1 9561 BDF2 9562 BDF3 9563 BDF5 9564 BDF6 9565 BDF7 9566 BDF9 9567 BDFA 9568 BDFB 9569 BDFC 956A BDFD 956B BDFE 956C BDFF 956D BE01 956E BE02 956F BE04 9570 BE06 9571 BE07 9572 BE08 9573 BE09 9574 BE0A 9575 BE0B 9576 BE0E 9577 BE0F 9578 BE11 9579 BE12 957A BE13 9581 BE15 9582 BE16 9583 BE17 9584 BE18 9585 BE19 9586 BE1A 9587 BE1B 9588 BE1E 9589 BE20 958A BE21 958B BE22 958C BE23 958D BE24 958E BE25 958F BE26 9590 BE27 9591 BE28 9592 BE29 9593 BE2A 9594 BE2B 9595 BE2C 9596 BE2D 9597 BE2E 9598 BE2F 9599 BE30 959A BE31 959B BE32 959C BE33 959D BE34 959E BE35 959F BE36 95A0 BE37 95A1 BE38 95A2 BE39 95A3 BE3A 95A4 BE3B 95A5 BE3C 95A6 BE3D 95A7 BE3E 95A8 BE3F 95A9 BE40 95AA BE41 95AB BE42 95AC BE43 95AD BE46 95AE BE47 95AF BE49 95B0 BE4A 95B1 BE4B 95B2 BE4D 95B3 BE4F 95B4 BE50 95B5 BE51 95B6 BE52 95B7 BE53 95B8 BE56 95B9 BE58 95BA BE5C 95BB BE5D 95BC BE5E 95BD BE5F 95BE BE62 95BF BE63 95C0 BE65 95C1 BE66 95C2 BE67 95C3 BE69 95C4 BE6B 95C5 BE6C 95C6 BE6D 95C7 BE6E 95C8 BE6F 95C9 BE72 95CA BE76 95CB BE77 95CC BE78 95CD BE79 95CE BE7A 95CF BE7E 95D0 BE7F 95D1 BE81 95D2 BE82 95D3 BE83 95D4 BE85 95D5 BE86 95D6 BE87 95D7 BE88 95D8 BE89 95D9 BE8A 95DA BE8B 95DB BE8E 95DC BE92 95DD BE93 95DE BE94 95DF BE95 95E0 BE96 95E1 BE97 95E2 BE9A 95E3 BE9B 95E4 BE9C 95E5 BE9D 95E6 BE9E 95E7 BE9F 95E8 BEA0 95E9 BEA1 95EA BEA2 95EB BEA3 95EC BEA4 95ED BEA5 95EE BEA6 95EF BEA7 95F0 BEA9 95F1 BEAA 95F2 BEAB 95F3 BEAC 95F4 BEAD 95F5 BEAE 95F6 BEAF 95F7 BEB0 95F8 BEB1 95F9 BEB2 95FA BEB3 95FB BEB4 95FC BEB5 95FD BEB6 95FE BEB7 9641 BEB8 9642 BEB9 9643 BEBA 9644 BEBB 9645 BEBC 9646 BEBD 9647 BEBE 9648 BEBF 9649 BEC0 964A BEC1 964B BEC2 964C BEC3 964D BEC4 964E BEC5 964F BEC6 9650 BEC7 9651 BEC8 9652 BEC9 9653 BECA 9654 BECB 9655 BECC 9656 BECD 9657 BECE 9658 BECF 9659 BED2 965A BED3 9661 BED5 9662 BED6 9663 BED9 9664 BEDA 9665 BEDB 9666 BEDC 9667 BEDD 9668 BEDE 9669 BEDF 966A BEE1 966B BEE2 966C BEE6 966D BEE7 966E BEE8 966F BEE9 9670 BEEA 9671 BEEB 9672 BEED 9673 BEEE 9674 BEEF 9675 BEF0 9676 BEF1 9677 BEF2 9678 BEF3 9679 BEF4 967A BEF5 9681 BEF6 9682 BEF7 9683 BEF8 9684 BEF9 9685 BEFA 9686 BEFB 9687 BEFC 9688 BEFD 9689 BEFE 968A BEFF 968B BF00 968C BF02 968D BF03 968E BF04 968F BF05 9690 BF06 9691 BF07 9692 BF0A 9693 BF0B 9694 BF0C 9695 BF0D 9696 BF0E 9697 BF0F 9698 BF10 9699 BF11 969A BF12 969B BF13 969C BF14 969D BF15 969E BF16 969F BF17 96A0 BF1A 96A1 BF1E 96A2 BF1F 96A3 BF20 96A4 BF21 96A5 BF22 96A6 BF23 96A7 BF24 96A8 BF25 96A9 BF26 96AA BF27 96AB BF28 96AC BF29 96AD BF2A 96AE BF2B 96AF BF2C 96B0 BF2D 96B1 BF2E 96B2 BF2F 96B3 BF30 96B4 BF31 96B5 BF32 96B6 BF33 96B7 BF34 96B8 BF35 96B9 BF36 96BA BF37 96BB BF38 96BC BF39 96BD BF3A 96BE BF3B 96BF BF3C 96C0 BF3D 96C1 BF3E 96C2 BF3F 96C3 BF42 96C4 BF43 96C5 BF45 96C6 BF46 96C7 BF47 96C8 BF49 96C9 BF4A 96CA BF4B 96CB BF4C 96CC BF4D 96CD BF4E 96CE BF4F 96CF BF52 96D0 BF53 96D1 BF54 96D2 BF56 96D3 BF57 96D4 BF58 96D5 BF59 96D6 BF5A 96D7 BF5B 96D8 BF5C 96D9 BF5D 96DA BF5E 96DB BF5F 96DC BF60 96DD BF61 96DE BF62 96DF BF63 96E0 BF64 96E1 BF65 96E2 BF66 96E3 BF67 96E4 BF68 96E5 BF69 96E6 BF6A 96E7 BF6B 96E8 BF6C 96E9 BF6D 96EA BF6E 96EB BF6F 96EC BF70 96ED BF71 96EE BF72 96EF BF73 96F0 BF74 96F1 BF75 96F2 BF76 96F3 BF77 96F4 BF78 96F5 BF79 96F6 BF7A 96F7 BF7B 96F8 BF7C 96F9 BF7D 96FA BF7E 96FB BF7F 96FC BF80 96FD BF81 96FE BF82 9741 BF83 9742 BF84 9743 BF85 9744 BF86 9745 BF87 9746 BF88 9747 BF89 9748 BF8A 9749 BF8B 974A BF8C 974B BF8D 974C BF8E 974D BF8F 974E BF90 974F BF91 9750 BF92 9751 BF93 9752 BF95 9753 BF96 9754 BF97 9755 BF98 9756 BF99 9757 BF9A 9758 BF9B 9759 BF9C 975A BF9D 9761 BF9E 9762 BF9F 9763 BFA0 9764 BFA1 9765 BFA2 9766 BFA3 9767 BFA4 9768 BFA5 9769 BFA6 976A BFA7 976B BFA8 976C BFA9 976D BFAA 976E BFAB 976F BFAC 9770 BFAD 9771 BFAE 9772 BFAF 9773 BFB1 9774 BFB2 9775 BFB3 9776 BFB4 9777 BFB5 9778 BFB6 9779 BFB7 977A BFB8 9781 BFB9 9782 BFBA 9783 BFBB 9784 BFBC 9785 BFBD 9786 BFBE 9787 BFBF 9788 BFC0 9789 BFC1 978A BFC2 978B BFC3 978C BFC4 978D BFC6 978E BFC7 978F BFC8 9790 BFC9 9791 BFCA 9792 BFCB 9793 BFCE 9794 BFCF 9795 BFD1 9796 BFD2 9797 BFD3 9798 BFD5 9799 BFD6 979A BFD7 979B BFD8 979C BFD9 979D BFDA 979E BFDB 979F BFDD 97A0 BFDE 97A1 BFE0 97A2 BFE2 97A3 BFE3 97A4 BFE4 97A5 BFE5 97A6 BFE6 97A7 BFE7 97A8 BFE8 97A9 BFE9 97AA BFEA 97AB BFEB 97AC BFEC 97AD BFED 97AE BFEE 97AF BFEF 97B0 BFF0 97B1 BFF1 97B2 BFF2 97B3 BFF3 97B4 BFF4 97B5 BFF5 97B6 BFF6 97B7 BFF7 97B8 BFF8 97B9 BFF9 97BA BFFA 97BB BFFB 97BC BFFC 97BD BFFD 97BE BFFE 97BF BFFF 97C0 C000 97C1 C001 97C2 C002 97C3 C003 97C4 C004 97C5 C005 97C6 C006 97C7 C007 97C8 C008 97C9 C009 97CA C00A 97CB C00B 97CC C00C 97CD C00D 97CE C00E 97CF C00F 97D0 C010 97D1 C011 97D2 C012 97D3 C013 97D4 C014 97D5 C015 97D6 C016 97D7 C017 97D8 C018 97D9 C019 97DA C01A 97DB C01B 97DC C01C 97DD C01D 97DE C01E 97DF C01F 97E0 C020 97E1 C021 97E2 C022 97E3 C023 97E4 C024 97E5 C025 97E6 C026 97E7 C027 97E8 C028 97E9 C029 97EA C02A 97EB C02B 97EC C02C 97ED C02D 97EE C02E 97EF C02F 97F0 C030 97F1 C031 97F2 C032 97F3 C033 97F4 C034 97F5 C035 97F6 C036 97F7 C037 97F8 C038 97F9 C039 97FA C03A 97FB C03B 97FC C03D 97FD C03E 97FE C03F 9841 C040 9842 C041 9843 C042 9844 C043 9845 C044 9846 C045 9847 C046 9848 C047 9849 C048 984A C049 984B C04A 984C C04B 984D C04C 984E C04D 984F C04E 9850 C04F 9851 C050 9852 C052 9853 C053 9854 C054 9855 C055 9856 C056 9857 C057 9858 C059 9859 C05A 985A C05B 9861 C05D 9862 C05E 9863 C05F 9864 C061 9865 C062 9866 C063 9867 C064 9868 C065 9869 C066 986A C067 986B C06A 986C C06B 986D C06C 986E C06D 986F C06E 9870 C06F 9871 C070 9872 C071 9873 C072 9874 C073 9875 C074 9876 C075 9877 C076 9878 C077 9879 C078 987A C079 9881 C07A 9882 C07B 9883 C07C 9884 C07D 9885 C07E 9886 C07F 9887 C080 9888 C081 9889 C082 988A C083 988B C084 988C C085 988D C086 988E C087 988F C088 9890 C089 9891 C08A 9892 C08B 9893 C08C 9894 C08D 9895 C08E 9896 C08F 9897 C092 9898 C093 9899 C095 989A C096 989B C097 989C C099 989D C09A 989E C09B 989F C09C 98A0 C09D 98A1 C09E 98A2 C09F 98A3 C0A2 98A4 C0A4 98A5 C0A6 98A6 C0A7 98A7 C0A8 98A8 C0A9 98A9 C0AA 98AA C0AB 98AB C0AE 98AC C0B1 98AD C0B2 98AE C0B7 98AF C0B8 98B0 C0B9 98B1 C0BA 98B2 C0BB 98B3 C0BE 98B4 C0C2 98B5 C0C3 98B6 C0C4 98B7 C0C6 98B8 C0C7 98B9 C0CA 98BA C0CB 98BB C0CD 98BC C0CE 98BD C0CF 98BE C0D1 98BF C0D2 98C0 C0D3 98C1 C0D4 98C2 C0D5 98C3 C0D6 98C4 C0D7 98C5 C0DA 98C6 C0DE 98C7 C0DF 98C8 C0E0 98C9 C0E1 98CA C0E2 98CB C0E3 98CC C0E6 98CD C0E7 98CE C0E9 98CF C0EA 98D0 C0EB 98D1 C0ED 98D2 C0EE 98D3 C0EF 98D4 C0F0 98D5 C0F1 98D6 C0F2 98D7 C0F3 98D8 C0F6 98D9 C0F8 98DA C0FA 98DB C0FB 98DC C0FC 98DD C0FD 98DE C0FE 98DF C0FF 98E0 C101 98E1 C102 98E2 C103 98E3 C105 98E4 C106 98E5 C107 98E6 C109 98E7 C10A 98E8 C10B 98E9 C10C 98EA C10D 98EB C10E 98EC C10F 98ED C111 98EE C112 98EF C113 98F0 C114 98F1 C116 98F2 C117 98F3 C118 98F4 C119 98F5 C11A 98F6 C11B 98F7 C121 98F8 C122 98F9 C125 98FA C128 98FB C129 98FC C12A 98FD C12B 98FE C12E 9941 C132 9942 C133 9943 C134 9944 C135 9945 C137 9946 C13A 9947 C13B 9948 C13D 9949 C13E 994A C13F 994B C141 994C C142 994D C143 994E C144 994F C145 9950 C146 9951 C147 9952 C14A 9953 C14E 9954 C14F 9955 C150 9956 C151 9957 C152 9958 C153 9959 C156 995A C157 9961 C159 9962 C15A 9963 C15B 9964 C15D 9965 C15E 9966 C15F 9967 C160 9968 C161 9969 C162 996A C163 996B C166 996C C16A 996D C16B 996E C16C 996F C16D 9970 C16E 9971 C16F 9972 C171 9973 C172 9974 C173 9975 C175 9976 C176 9977 C177 9978 C179 9979 C17A 997A C17B 9981 C17C 9982 C17D 9983 C17E 9984 C17F 9985 C180 9986 C181 9987 C182 9988 C183 9989 C184 998A C186 998B C187 998C C188 998D C189 998E C18A 998F C18B 9990 C18F 9991 C191 9992 C192 9993 C193 9994 C195 9995 C197 9996 C198 9997 C199 9998 C19A 9999 C19B 999A C19E 999B C1A0 999C C1A2 999D C1A3 999E C1A4 999F C1A6 99A0 C1A7 99A1 C1AA 99A2 C1AB 99A3 C1AD 99A4 C1AE 99A5 C1AF 99A6 C1B1 99A7 C1B2 99A8 C1B3 99A9 C1B4 99AA C1B5 99AB C1B6 99AC C1B7 99AD C1B8 99AE C1B9 99AF C1BA 99B0 C1BB 99B1 C1BC 99B2 C1BE 99B3 C1BF 99B4 C1C0 99B5 C1C1 99B6 C1C2 99B7 C1C3 99B8 C1C5 99B9 C1C6 99BA C1C7 99BB C1C9 99BC C1CA 99BD C1CB 99BE C1CD 99BF C1CE 99C0 C1CF 99C1 C1D0 99C2 C1D1 99C3 C1D2 99C4 C1D3 99C5 C1D5 99C6 C1D6 99C7 C1D9 99C8 C1DA 99C9 C1DB 99CA C1DC 99CB C1DD 99CC C1DE 99CD C1DF 99CE C1E1 99CF C1E2 99D0 C1E3 99D1 C1E5 99D2 C1E6 99D3 C1E7 99D4 C1E9 99D5 C1EA 99D6 C1EB 99D7 C1EC 99D8 C1ED 99D9 C1EE 99DA C1EF 99DB C1F2 99DC C1F4 99DD C1F5 99DE C1F6 99DF C1F7 99E0 C1F8 99E1 C1F9 99E2 C1FA 99E3 C1FB 99E4 C1FE 99E5 C1FF 99E6 C201 99E7 C202 99E8 C203 99E9 C205 99EA C206 99EB C207 99EC C208 99ED C209 99EE C20A 99EF C20B 99F0 C20E 99F1 C210 99F2 C212 99F3 C213 99F4 C214 99F5 C215 99F6 C216 99F7 C217 99F8 C21A 99F9 C21B 99FA C21D 99FB C21E 99FC C221 99FD C222 99FE C223 9A41 C224 9A42 C225 9A43 C226 9A44 C227 9A45 C22A 9A46 C22C 9A47 C22E 9A48 C230 9A49 C233 9A4A C235 9A4B C236 9A4C C237 9A4D C238 9A4E C239 9A4F C23A 9A50 C23B 9A51 C23C 9A52 C23D 9A53 C23E 9A54 C23F 9A55 C240 9A56 C241 9A57 C242 9A58 C243 9A59 C244 9A5A C245 9A61 C246 9A62 C247 9A63 C249 9A64 C24A 9A65 C24B 9A66 C24C 9A67 C24D 9A68 C24E 9A69 C24F 9A6A C252 9A6B C253 9A6C C255 9A6D C256 9A6E C257 9A6F C259 9A70 C25A 9A71 C25B 9A72 C25C 9A73 C25D 9A74 C25E 9A75 C25F 9A76 C261 9A77 C262 9A78 C263 9A79 C264 9A7A C266 9A81 C267 9A82 C268 9A83 C269 9A84 C26A 9A85 C26B 9A86 C26E 9A87 C26F 9A88 C271 9A89 C272 9A8A C273 9A8B C275 9A8C C276 9A8D C277 9A8E C278 9A8F C279 9A90 C27A 9A91 C27B 9A92 C27E 9A93 C280 9A94 C282 9A95 C283 9A96 C284 9A97 C285 9A98 C286 9A99 C287 9A9A C28A 9A9B C28B 9A9C C28C 9A9D C28D 9A9E C28E 9A9F C28F 9AA0 C291 9AA1 C292 9AA2 C293 9AA3 C294 9AA4 C295 9AA5 C296 9AA6 C297 9AA7 C299 9AA8 C29A 9AA9 C29C 9AAA C29E 9AAB C29F 9AAC C2A0 9AAD C2A1 9AAE C2A2 9AAF C2A3 9AB0 C2A6 9AB1 C2A7 9AB2 C2A9 9AB3 C2AA 9AB4 C2AB 9AB5 C2AE 9AB6 C2AF 9AB7 C2B0 9AB8 C2B1 9AB9 C2B2 9ABA C2B3 9ABB C2B6 9ABC C2B8 9ABD C2BA 9ABE C2BB 9ABF C2BC 9AC0 C2BD 9AC1 C2BE 9AC2 C2BF 9AC3 C2C0 9AC4 C2C1 9AC5 C2C2 9AC6 C2C3 9AC7 C2C4 9AC8 C2C5 9AC9 C2C6 9ACA C2C7 9ACB C2C8 9ACC C2C9 9ACD C2CA 9ACE C2CB 9ACF C2CC 9AD0 C2CD 9AD1 C2CE 9AD2 C2CF 9AD3 C2D0 9AD4 C2D1 9AD5 C2D2 9AD6 C2D3 9AD7 C2D4 9AD8 C2D5 9AD9 C2D6 9ADA C2D7 9ADB C2D8 9ADC C2D9 9ADD C2DA 9ADE C2DB 9ADF C2DE 9AE0 C2DF 9AE1 C2E1 9AE2 C2E2 9AE3 C2E5 9AE4 C2E6 9AE5 C2E7 9AE6 C2E8 9AE7 C2E9 9AE8 C2EA 9AE9 C2EE 9AEA C2F0 9AEB C2F2 9AEC C2F3 9AED C2F4 9AEE C2F5 9AEF C2F7 9AF0 C2FA 9AF1 C2FD 9AF2 C2FE 9AF3 C2FF 9AF4 C301 9AF5 C302 9AF6 C303 9AF7 C304 9AF8 C305 9AF9 C306 9AFA C307 9AFB C30A 9AFC C30B 9AFD C30E 9AFE C30F 9B41 C310 9B42 C311 9B43 C312 9B44 C316 9B45 C317 9B46 C319 9B47 C31A 9B48 C31B 9B49 C31D 9B4A C31E 9B4B C31F 9B4C C320 9B4D C321 9B4E C322 9B4F C323 9B50 C326 9B51 C327 9B52 C32A 9B53 C32B 9B54 C32C 9B55 C32D 9B56 C32E 9B57 C32F 9B58 C330 9B59 C331 9B5A C332 9B61 C333 9B62 C334 9B63 C335 9B64 C336 9B65 C337 9B66 C338 9B67 C339 9B68 C33A 9B69 C33B 9B6A C33C 9B6B C33D 9B6C C33E 9B6D C33F 9B6E C340 9B6F C341 9B70 C342 9B71 C343 9B72 C344 9B73 C346 9B74 C347 9B75 C348 9B76 C349 9B77 C34A 9B78 C34B 9B79 C34C 9B7A C34D 9B81 C34E 9B82 C34F 9B83 C350 9B84 C351 9B85 C352 9B86 C353 9B87 C354 9B88 C355 9B89 C356 9B8A C357 9B8B C358 9B8C C359 9B8D C35A 9B8E C35B 9B8F C35C 9B90 C35D 9B91 C35E 9B92 C35F 9B93 C360 9B94 C361 9B95 C362 9B96 C363 9B97 C364 9B98 C365 9B99 C366 9B9A C367 9B9B C36A 9B9C C36B 9B9D C36D 9B9E C36E 9B9F C36F 9BA0 C371 9BA1 C373 9BA2 C374 9BA3 C375 9BA4 C376 9BA5 C377 9BA6 C37A 9BA7 C37B 9BA8 C37E 9BA9 C37F 9BAA C380 9BAB C381 9BAC C382 9BAD C383 9BAE C385 9BAF C386 9BB0 C387 9BB1 C389 9BB2 C38A 9BB3 C38B 9BB4 C38D 9BB5 C38E 9BB6 C38F 9BB7 C390 9BB8 C391 9BB9 C392 9BBA C393 9BBB C394 9BBC C395 9BBD C396 9BBE C397 9BBF C398 9BC0 C399 9BC1 C39A 9BC2 C39B 9BC3 C39C 9BC4 C39D 9BC5 C39E 9BC6 C39F 9BC7 C3A0 9BC8 C3A1 9BC9 C3A2 9BCA C3A3 9BCB C3A4 9BCC C3A5 9BCD C3A6 9BCE C3A7 9BCF C3A8 9BD0 C3A9 9BD1 C3AA 9BD2 C3AB 9BD3 C3AC 9BD4 C3AD 9BD5 C3AE 9BD6 C3AF 9BD7 C3B0 9BD8 C3B1 9BD9 C3B2 9BDA C3B3 9BDB C3B4 9BDC C3B5 9BDD C3B6 9BDE C3B7 9BDF C3B8 9BE0 C3B9 9BE1 C3BA 9BE2 C3BB 9BE3 C3BC 9BE4 C3BD 9BE5 C3BE 9BE6 C3BF 9BE7 C3C1 9BE8 C3C2 9BE9 C3C3 9BEA C3C4 9BEB C3C5 9BEC C3C6 9BED C3C7 9BEE C3C8 9BEF C3C9 9BF0 C3CA 9BF1 C3CB 9BF2 C3CC 9BF3 C3CD 9BF4 C3CE 9BF5 C3CF 9BF6 C3D0 9BF7 C3D1 9BF8 C3D2 9BF9 C3D3 9BFA C3D4 9BFB C3D5 9BFC C3D6 9BFD C3D7 9BFE C3DA 9C41 C3DB 9C42 C3DD 9C43 C3DE 9C44 C3E1 9C45 C3E3 9C46 C3E4 9C47 C3E5 9C48 C3E6 9C49 C3E7 9C4A C3EA 9C4B C3EB 9C4C C3EC 9C4D C3EE 9C4E C3EF 9C4F C3F0 9C50 C3F1 9C51 C3F2 9C52 C3F3 9C53 C3F6 9C54 C3F7 9C55 C3F9 9C56 C3FA 9C57 C3FB 9C58 C3FC 9C59 C3FD 9C5A C3FE 9C61 C3FF 9C62 C400 9C63 C401 9C64 C402 9C65 C403 9C66 C404 9C67 C405 9C68 C406 9C69 C407 9C6A C409 9C6B C40A 9C6C C40B 9C6D C40C 9C6E C40D 9C6F C40E 9C70 C40F 9C71 C411 9C72 C412 9C73 C413 9C74 C414 9C75 C415 9C76 C416 9C77 C417 9C78 C418 9C79 C419 9C7A C41A 9C81 C41B 9C82 C41C 9C83 C41D 9C84 C41E 9C85 C41F 9C86 C420 9C87 C421 9C88 C422 9C89 C423 9C8A C425 9C8B C426 9C8C C427 9C8D C428 9C8E C429 9C8F C42A 9C90 C42B 9C91 C42D 9C92 C42E 9C93 C42F 9C94 C431 9C95 C432 9C96 C433 9C97 C435 9C98 C436 9C99 C437 9C9A C438 9C9B C439 9C9C C43A 9C9D C43B 9C9E C43E 9C9F C43F 9CA0 C440 9CA1 C441 9CA2 C442 9CA3 C443 9CA4 C444 9CA5 C445 9CA6 C446 9CA7 C447 9CA8 C449 9CA9 C44A 9CAA C44B 9CAB C44C 9CAC C44D 9CAD C44E 9CAE C44F 9CAF C450 9CB0 C451 9CB1 C452 9CB2 C453 9CB3 C454 9CB4 C455 9CB5 C456 9CB6 C457 9CB7 C458 9CB8 C459 9CB9 C45A 9CBA C45B 9CBB C45C 9CBC C45D 9CBD C45E 9CBE C45F 9CBF C460 9CC0 C461 9CC1 C462 9CC2 C463 9CC3 C466 9CC4 C467 9CC5 C469 9CC6 C46A 9CC7 C46B 9CC8 C46D 9CC9 C46E 9CCA C46F 9CCB C470 9CCC C471 9CCD C472 9CCE C473 9CCF C476 9CD0 C477 9CD1 C478 9CD2 C47A 9CD3 C47B 9CD4 C47C 9CD5 C47D 9CD6 C47E 9CD7 C47F 9CD8 C481 9CD9 C482 9CDA C483 9CDB C484 9CDC C485 9CDD C486 9CDE C487 9CDF C488 9CE0 C489 9CE1 C48A 9CE2 C48B 9CE3 C48C 9CE4 C48D 9CE5 C48E 9CE6 C48F 9CE7 C490 9CE8 C491 9CE9 C492 9CEA C493 9CEB C495 9CEC C496 9CED C497 9CEE C498 9CEF C499 9CF0 C49A 9CF1 C49B 9CF2 C49D 9CF3 C49E 9CF4 C49F 9CF5 C4A0 9CF6 C4A1 9CF7 C4A2 9CF8 C4A3 9CF9 C4A4 9CFA C4A5 9CFB C4A6 9CFC C4A7 9CFD C4A8 9CFE C4A9 9D41 C4AA 9D42 C4AB 9D43 C4AC 9D44 C4AD 9D45 C4AE 9D46 C4AF 9D47 C4B0 9D48 C4B1 9D49 C4B2 9D4A C4B3 9D4B C4B4 9D4C C4B5 9D4D C4B6 9D4E C4B7 9D4F C4B9 9D50 C4BA 9D51 C4BB 9D52 C4BD 9D53 C4BE 9D54 C4BF 9D55 C4C0 9D56 C4C1 9D57 C4C2 9D58 C4C3 9D59 C4C4 9D5A C4C5 9D61 C4C6 9D62 C4C7 9D63 C4C8 9D64 C4C9 9D65 C4CA 9D66 C4CB 9D67 C4CC 9D68 C4CD 9D69 C4CE 9D6A C4CF 9D6B C4D0 9D6C C4D1 9D6D C4D2 9D6E C4D3 9D6F C4D4 9D70 C4D5 9D71 C4D6 9D72 C4D7 9D73 C4D8 9D74 C4D9 9D75 C4DA 9D76 C4DB 9D77 C4DC 9D78 C4DD 9D79 C4DE 9D7A C4DF 9D81 C4E0 9D82 C4E1 9D83 C4E2 9D84 C4E3 9D85 C4E4 9D86 C4E5 9D87 C4E6 9D88 C4E7 9D89 C4E8 9D8A C4EA 9D8B C4EB 9D8C C4EC 9D8D C4ED 9D8E C4EE 9D8F C4EF 9D90 C4F2 9D91 C4F3 9D92 C4F5 9D93 C4F6 9D94 C4F7 9D95 C4F9 9D96 C4FB 9D97 C4FC 9D98 C4FD 9D99 C4FE 9D9A C502 9D9B C503 9D9C C504 9D9D C505 9D9E C506 9D9F C507 9DA0 C508 9DA1 C509 9DA2 C50A 9DA3 C50B 9DA4 C50D 9DA5 C50E 9DA6 C50F 9DA7 C511 9DA8 C512 9DA9 C513 9DAA C515 9DAB C516 9DAC C517 9DAD C518 9DAE C519 9DAF C51A 9DB0 C51B 9DB1 C51D 9DB2 C51E 9DB3 C51F 9DB4 C520 9DB5 C521 9DB6 C522 9DB7 C523 9DB8 C524 9DB9 C525 9DBA C526 9DBB C527 9DBC C52A 9DBD C52B 9DBE C52D 9DBF C52E 9DC0 C52F 9DC1 C531 9DC2 C532 9DC3 C533 9DC4 C534 9DC5 C535 9DC6 C536 9DC7 C537 9DC8 C53A 9DC9 C53C 9DCA C53E 9DCB C53F 9DCC C540 9DCD C541 9DCE C542 9DCF C543 9DD0 C546 9DD1 C547 9DD2 C54B 9DD3 C54F 9DD4 C550 9DD5 C551 9DD6 C552 9DD7 C556 9DD8 C55A 9DD9 C55B 9DDA C55C 9DDB C55F 9DDC C562 9DDD C563 9DDE C565 9DDF C566 9DE0 C567 9DE1 C569 9DE2 C56A 9DE3 C56B 9DE4 C56C 9DE5 C56D 9DE6 C56E 9DE7 C56F 9DE8 C572 9DE9 C576 9DEA C577 9DEB C578 9DEC C579 9DED C57A 9DEE C57B 9DEF C57E 9DF0 C57F 9DF1 C581 9DF2 C582 9DF3 C583 9DF4 C585 9DF5 C586 9DF6 C588 9DF7 C589 9DF8 C58A 9DF9 C58B 9DFA C58E 9DFB C590 9DFC C592 9DFD C593 9DFE C594 9E41 C596 9E42 C599 9E43 C59A 9E44 C59B 9E45 C59D 9E46 C59E 9E47 C59F 9E48 C5A1 9E49 C5A2 9E4A C5A3 9E4B C5A4 9E4C C5A5 9E4D C5A6 9E4E C5A7 9E4F C5A8 9E50 C5AA 9E51 C5AB 9E52 C5AC 9E53 C5AD 9E54 C5AE 9E55 C5AF 9E56 C5B0 9E57 C5B1 9E58 C5B2 9E59 C5B3 9E5A C5B6 9E61 C5B7 9E62 C5BA 9E63 C5BF 9E64 C5C0 9E65 C5C1 9E66 C5C2 9E67 C5C3 9E68 C5CB 9E69 C5CD 9E6A C5CF 9E6B C5D2 9E6C C5D3 9E6D C5D5 9E6E C5D6 9E6F C5D7 9E70 C5D9 9E71 C5DA 9E72 C5DB 9E73 C5DC 9E74 C5DD 9E75 C5DE 9E76 C5DF 9E77 C5E2 9E78 C5E4 9E79 C5E6 9E7A C5E7 9E81 C5E8 9E82 C5E9 9E83 C5EA 9E84 C5EB 9E85 C5EF 9E86 C5F1 9E87 C5F2 9E88 C5F3 9E89 C5F5 9E8A C5F8 9E8B C5F9 9E8C C5FA 9E8D C5FB 9E8E C602 9E8F C603 9E90 C604 9E91 C609 9E92 C60A 9E93 C60B 9E94 C60D 9E95 C60E 9E96 C60F 9E97 C611 9E98 C612 9E99 C613 9E9A C614 9E9B C615 9E9C C616 9E9D C617 9E9E C61A 9E9F C61D 9EA0 C61E 9EA1 C61F 9EA2 C620 9EA3 C621 9EA4 C622 9EA5 C623 9EA6 C626 9EA7 C627 9EA8 C629 9EA9 C62A 9EAA C62B 9EAB C62F 9EAC C631 9EAD C632 9EAE C636 9EAF C638 9EB0 C63A 9EB1 C63C 9EB2 C63D 9EB3 C63E 9EB4 C63F 9EB5 C642 9EB6 C643 9EB7 C645 9EB8 C646 9EB9 C647 9EBA C649 9EBB C64A 9EBC C64B 9EBD C64C 9EBE C64D 9EBF C64E 9EC0 C64F 9EC1 C652 9EC2 C656 9EC3 C657 9EC4 C658 9EC5 C659 9EC6 C65A 9EC7 C65B 9EC8 C65E 9EC9 C65F 9ECA C661 9ECB C662 9ECC C663 9ECD C664 9ECE C665 9ECF C666 9ED0 C667 9ED1 C668 9ED2 C669 9ED3 C66A 9ED4 C66B 9ED5 C66D 9ED6 C66E 9ED7 C670 9ED8 C672 9ED9 C673 9EDA C674 9EDB C675 9EDC C676 9EDD C677 9EDE C67A 9EDF C67B 9EE0 C67D 9EE1 C67E 9EE2 C67F 9EE3 C681 9EE4 C682 9EE5 C683 9EE6 C684 9EE7 C685 9EE8 C686 9EE9 C687 9EEA C68A 9EEB C68C 9EEC C68E 9EED C68F 9EEE C690 9EEF C691 9EF0 C692 9EF1 C693 9EF2 C696 9EF3 C697 9EF4 C699 9EF5 C69A 9EF6 C69B 9EF7 C69D 9EF8 C69E 9EF9 C69F 9EFA C6A0 9EFB C6A1 9EFC C6A2 9EFD C6A3 9EFE C6A6 9F41 C6A8 9F42 C6AA 9F43 C6AB 9F44 C6AC 9F45 C6AD 9F46 C6AE 9F47 C6AF 9F48 C6B2 9F49 C6B3 9F4A C6B5 9F4B C6B6 9F4C C6B7 9F4D C6BB 9F4E C6BC 9F4F C6BD 9F50 C6BE 9F51 C6BF 9F52 C6C2 9F53 C6C4 9F54 C6C6 9F55 C6C7 9F56 C6C8 9F57 C6C9 9F58 C6CA 9F59 C6CB 9F5A C6CE 9F61 C6CF 9F62 C6D1 9F63 C6D2 9F64 C6D3 9F65 C6D5 9F66 C6D6 9F67 C6D7 9F68 C6D8 9F69 C6D9 9F6A C6DA 9F6B C6DB 9F6C C6DE 9F6D C6DF 9F6E C6E2 9F6F C6E3 9F70 C6E4 9F71 C6E5 9F72 C6E6 9F73 C6E7 9F74 C6EA 9F75 C6EB 9F76 C6ED 9F77 C6EE 9F78 C6EF 9F79 C6F1 9F7A C6F2 9F81 C6F3 9F82 C6F4 9F83 C6F5 9F84 C6F6 9F85 C6F7 9F86 C6FA 9F87 C6FB 9F88 C6FC 9F89 C6FE 9F8A C6FF 9F8B C700 9F8C C701 9F8D C702 9F8E C703 9F8F C706 9F90 C707 9F91 C709 9F92 C70A 9F93 C70B 9F94 C70D 9F95 C70E 9F96 C70F 9F97 C710 9F98 C711 9F99 C712 9F9A C713 9F9B C716 9F9C C718 9F9D C71A 9F9E C71B 9F9F C71C 9FA0 C71D 9FA1 C71E 9FA2 C71F 9FA3 C722 9FA4 C723 9FA5 C725 9FA6 C726 9FA7 C727 9FA8 C729 9FA9 C72A 9FAA C72B 9FAB C72C 9FAC C72D 9FAD C72E 9FAE C72F 9FAF C732 9FB0 C734 9FB1 C736 9FB2 C738 9FB3 C739 9FB4 C73A 9FB5 C73B 9FB6 C73E 9FB7 C73F 9FB8 C741 9FB9 C742 9FBA C743 9FBB C745 9FBC C746 9FBD C747 9FBE C748 9FBF C749 9FC0 C74B 9FC1 C74E 9FC2 C750 9FC3 C759 9FC4 C75A 9FC5 C75B 9FC6 C75D 9FC7 C75E 9FC8 C75F 9FC9 C761 9FCA C762 9FCB C763 9FCC C764 9FCD C765 9FCE C766 9FCF C767 9FD0 C769 9FD1 C76A 9FD2 C76C 9FD3 C76D 9FD4 C76E 9FD5 C76F 9FD6 C770 9FD7 C771 9FD8 C772 9FD9 C773 9FDA C776 9FDB C777 9FDC C779 9FDD C77A 9FDE C77B 9FDF C77F 9FE0 C780 9FE1 C781 9FE2 C782 9FE3 C786 9FE4 C78B 9FE5 C78C 9FE6 C78D 9FE7 C78F 9FE8 C792 9FE9 C793 9FEA C795 9FEB C799 9FEC C79B 9FED C79C 9FEE C79D 9FEF C79E 9FF0 C79F 9FF1 C7A2 9FF2 C7A7 9FF3 C7A8 9FF4 C7A9 9FF5 C7AA 9FF6 C7AB 9FF7 C7AE 9FF8 C7AF 9FF9 C7B1 9FFA C7B2 9FFB C7B3 9FFC C7B5 9FFD C7B6 9FFE C7B7 A041 C7B8 A042 C7B9 A043 C7BA A044 C7BB A045 C7BE A046 C7C2 A047 C7C3 A048 C7C4 A049 C7C5 A04A C7C6 A04B C7C7 A04C C7CA A04D C7CB A04E C7CD A04F C7CF A050 C7D1 A051 C7D2 A052 C7D3 A053 C7D4 A054 C7D5 A055 C7D6 A056 C7D7 A057 C7D9 A058 C7DA A059 C7DB A05A C7DC A061 C7DE A062 C7DF A063 C7E0 A064 C7E1 A065 C7E2 A066 C7E3 A067 C7E5 A068 C7E6 A069 C7E7 A06A C7E9 A06B C7EA A06C C7EB A06D C7ED A06E C7EE A06F C7EF A070 C7F0 A071 C7F1 A072 C7F2 A073 C7F3 A074 C7F4 A075 C7F5 A076 C7F6 A077 C7F7 A078 C7F8 A079 C7F9 A07A C7FA A081 C7FB A082 C7FC A083 C7FD A084 C7FE A085 C7FF A086 C802 A087 C803 A088 C805 A089 C806 A08A C807 A08B C809 A08C C80B A08D C80C A08E C80D A08F C80E A090 C80F A091 C812 A092 C814 A093 C817 A094 C818 A095 C819 A096 C81A A097 C81B A098 C81E A099 C81F A09A C821 A09B C822 A09C C823 A09D C825 A09E C826 A09F C827 A0A0 C828 A0A1 C829 A0A2 C82A A0A3 C82B A0A4 C82E A0A5 C830 A0A6 C832 A0A7 C833 A0A8 C834 A0A9 C835 A0AA C836 A0AB C837 A0AC C839 A0AD C83A A0AE C83B A0AF C83D A0B0 C83E A0B1 C83F A0B2 C841 A0B3 C842 A0B4 C843 A0B5 C844 A0B6 C845 A0B7 C846 A0B8 C847 A0B9 C84A A0BA C84B A0BB C84E A0BC C84F A0BD C850 A0BE C851 A0BF C852 A0C0 C853 A0C1 C855 A0C2 C856 A0C3 C857 A0C4 C858 A0C5 C859 A0C6 C85A A0C7 C85B A0C8 C85C A0C9 C85D A0CA C85E A0CB C85F A0CC C860 A0CD C861 A0CE C862 A0CF C863 A0D0 C864 A0D1 C865 A0D2 C866 A0D3 C867 A0D4 C868 A0D5 C869 A0D6 C86A A0D7 C86B A0D8 C86C A0D9 C86D A0DA C86E A0DB C86F A0DC C872 A0DD C873 A0DE C875 A0DF C876 A0E0 C877 A0E1 C879 A0E2 C87B A0E3 C87C A0E4 C87D A0E5 C87E A0E6 C87F A0E7 C882 A0E8 C884 A0E9 C888 A0EA C889 A0EB C88A A0EC C88E A0ED C88F A0EE C890 A0EF C891 A0F0 C892 A0F1 C893 A0F2 C895 A0F3 C896 A0F4 C897 A0F5 C898 A0F6 C899 A0F7 C89A A0F8 C89B A0F9 C89C A0FA C89E A0FB C8A0 A0FC C8A2 A0FD C8A3 A0FE C8A4 A141 C8A5 A142 C8A6 A143 C8A7 A144 C8A9 A145 C8AA A146 C8AB A147 C8AC A148 C8AD A149 C8AE A14A C8AF A14B C8B0 A14C C8B1 A14D C8B2 A14E C8B3 A14F C8B4 A150 C8B5 A151 C8B6 A152 C8B7 A153 C8B8 A154 C8B9 A155 C8BA A156 C8BB A157 C8BE A158 C8BF A159 C8C0 A15A C8C1 A161 C8C2 A162 C8C3 A163 C8C5 A164 C8C6 A165 C8C7 A166 C8C9 A167 C8CA A168 C8CB A169 C8CD A16A C8CE A16B C8CF A16C C8D0 A16D C8D1 A16E C8D2 A16F C8D3 A170 C8D6 A171 C8D8 A172 C8DA A173 C8DB A174 C8DC A175 C8DD A176 C8DE A177 C8DF A178 C8E2 A179 C8E3 A17A C8E5 A181 C8E6 A182 C8E7 A183 C8E8 A184 C8E9 A185 C8EA A186 C8EB A187 C8EC A188 C8ED A189 C8EE A18A C8EF A18B C8F0 A18C C8F1 A18D C8F2 A18E C8F3 A18F C8F4 A190 C8F6 A191 C8F7 A192 C8F8 A193 C8F9 A194 C8FA A195 C8FB A196 C8FE A197 C8FF A198 C901 A199 C902 A19A C903 A19B C907 A19C C908 A19D C909 A19E C90A A19F C90B A1A0 C90E A1A1 3000 A1A2 3001 A1A3 3002 A1A4 00B7 A1A5 2025 A1A6 2026 A1A7 00A8 A1A8 3003 A1A9 00AD A1AA 2015 A1AB 2225 A1AC FF3C A1AD 223C A1AE 2018 A1AF 2019 A1B0 201C A1B1 201D A1B2 3014 A1B3 3015 A1B4 3008 A1B5 3009 A1B6 300A A1B7 300B A1B8 300C A1B9 300D A1BA 300E A1BB 300F A1BC 3010 A1BD 3011 A1BE 00B1 A1BF 00D7 A1C0 00F7 A1C1 2260 A1C2 2264 A1C3 2265 A1C4 221E A1C5 2234 A1C6 00B0 A1C7 2032 A1C8 2033 A1C9 2103 A1CA 212B A1CB FFE0 A1CC FFE1 A1CD FFE5 A1CE 2642 A1CF 2640 A1D0 2220 A1D1 22A5 A1D2 2312 A1D3 2202 A1D4 2207 A1D5 2261 A1D6 2252 A1D7 00A7 A1D8 203B A1D9 2606 A1DA 2605 A1DB 25CB A1DC 25CF A1DD 25CE A1DE 25C7 A1DF 25C6 A1E0 25A1 A1E1 25A0 A1E2 25B3 A1E3 25B2 A1E4 25BD A1E5 25BC A1E6 2192 A1E7 2190 A1E8 2191 A1E9 2193 A1EA 2194 A1EB 3013 A1EC 226A A1ED 226B A1EE 221A A1EF 223D A1F0 221D A1F1 2235 A1F2 222B A1F3 222C A1F4 2208 A1F5 220B A1F6 2286 A1F7 2287 A1F8 2282 A1F9 2283 A1FA 222A A1FB 2229 A1FC 2227 A1FD 2228 A1FE FFE2 A241 C910 A242 C912 A243 C913 A244 C914 A245 C915 A246 C916 A247 C917 A248 C919 A249 C91A A24A C91B A24B C91C A24C C91D A24D C91E A24E C91F A24F C920 A250 C921 A251 C922 A252 C923 A253 C924 A254 C925 A255 C926 A256 C927 A257 C928 A258 C929 A259 C92A A25A C92B A261 C92D A262 C92E A263 C92F A264 C930 A265 C931 A266 C932 A267 C933 A268 C935 A269 C936 A26A C937 A26B C938 A26C C939 A26D C93A A26E C93B A26F C93C A270 C93D A271 C93E A272 C93F A273 C940 A274 C941 A275 C942 A276 C943 A277 C944 A278 C945 A279 C946 A27A C947 A281 C948 A282 C949 A283 C94A A284 C94B A285 C94C A286 C94D A287 C94E A288 C94F A289 C952 A28A C953 A28B C955 A28C C956 A28D C957 A28E C959 A28F C95A A290 C95B A291 C95C A292 C95D A293 C95E A294 C95F A295 C962 A296 C964 A297 C965 A298 C966 A299 C967 A29A C968 A29B C969 A29C C96A A29D C96B A29E C96D A29F C96E A2A0 C96F A2A1 21D2 A2A2 21D4 A2A3 2200 A2A4 2203 A2A5 00B4 A2A6 FF5E A2A7 02C7 A2A8 02D8 A2A9 02DD A2AA 02DA A2AB 02D9 A2AC 00B8 A2AD 02DB A2AE 00A1 A2AF 00BF A2B0 02D0 A2B1 222E A2B2 2211 A2B3 220F A2B4 00A4 A2B5 2109 A2B6 2030 A2B7 25C1 A2B8 25C0 A2B9 25B7 A2BA 25B6 A2BB 2664 A2BC 2660 A2BD 2661 A2BE 2665 A2BF 2667 A2C0 2663 A2C1 2299 A2C2 25C8 A2C3 25A3 A2C4 25D0 A2C5 25D1 A2C6 2592 A2C7 25A4 A2C8 25A5 A2C9 25A8 A2CA 25A7 A2CB 25A6 A2CC 25A9 A2CD 2668 A2CE 260F A2CF 260E A2D0 261C A2D1 261E A2D2 00B6 A2D3 2020 A2D4 2021 A2D5 2195 A2D6 2197 A2D7 2199 A2D8 2196 A2D9 2198 A2DA 266D A2DB 2669 A2DC 266A A2DD 266C A2DE 327F A2DF 321C A2E0 2116 A2E1 33C7 A2E2 2122 A2E3 33C2 A2E4 33D8 A2E5 2121 A2E6 20AC A2E7 00AE A341 C971 A342 C972 A343 C973 A344 C975 A345 C976 A346 C977 A347 C978 A348 C979 A349 C97A A34A C97B A34B C97D A34C C97E A34D C97F A34E C980 A34F C981 A350 C982 A351 C983 A352 C984 A353 C985 A354 C986 A355 C987 A356 C98A A357 C98B A358 C98D A359 C98E A35A C98F A361 C991 A362 C992 A363 C993 A364 C994 A365 C995 A366 C996 A367 C997 A368 C99A A369 C99C A36A C99E A36B C99F A36C C9A0 A36D C9A1 A36E C9A2 A36F C9A3 A370 C9A4 A371 C9A5 A372 C9A6 A373 C9A7 A374 C9A8 A375 C9A9 A376 C9AA A377 C9AB A378 C9AC A379 C9AD A37A C9AE A381 C9AF A382 C9B0 A383 C9B1 A384 C9B2 A385 C9B3 A386 C9B4 A387 C9B5 A388 C9B6 A389 C9B7 A38A C9B8 A38B C9B9 A38C C9BA A38D C9BB A38E C9BC A38F C9BD A390 C9BE A391 C9BF A392 C9C2 A393 C9C3 A394 C9C5 A395 C9C6 A396 C9C9 A397 C9CB A398 C9CC A399 C9CD A39A C9CE A39B C9CF A39C C9D2 A39D C9D4 A39E C9D7 A39F C9D8 A3A0 C9DB A3A1 FF01 A3A2 FF02 A3A3 FF03 A3A4 FF04 A3A5 FF05 A3A6 FF06 A3A7 FF07 A3A8 FF08 A3A9 FF09 A3AA FF0A A3AB FF0B A3AC FF0C A3AD FF0D A3AE FF0E A3AF FF0F A3B0 FF10 A3B1 FF11 A3B2 FF12 A3B3 FF13 A3B4 FF14 A3B5 FF15 A3B6 FF16 A3B7 FF17 A3B8 FF18 A3B9 FF19 A3BA FF1A A3BB FF1B A3BC FF1C A3BD FF1D A3BE FF1E A3BF FF1F A3C0 FF20 A3C1 FF21 A3C2 FF22 A3C3 FF23 A3C4 FF24 A3C5 FF25 A3C6 FF26 A3C7 FF27 A3C8 FF28 A3C9 FF29 A3CA FF2A A3CB FF2B A3CC FF2C A3CD FF2D A3CE FF2E A3CF FF2F A3D0 FF30 A3D1 FF31 A3D2 FF32 A3D3 FF33 A3D4 FF34 A3D5 FF35 A3D6 FF36 A3D7 FF37 A3D8 FF38 A3D9 FF39 A3DA FF3A A3DB FF3B A3DC FFE6 A3DD FF3D A3DE FF3E A3DF FF3F A3E0 FF40 A3E1 FF41 A3E2 FF42 A3E3 FF43 A3E4 FF44 A3E5 FF45 A3E6 FF46 A3E7 FF47 A3E8 FF48 A3E9 FF49 A3EA FF4A A3EB FF4B A3EC FF4C A3ED FF4D A3EE FF4E A3EF FF4F A3F0 FF50 A3F1 FF51 A3F2 FF52 A3F3 FF53 A3F4 FF54 A3F5 FF55 A3F6 FF56 A3F7 FF57 A3F8 FF58 A3F9 FF59 A3FA FF5A A3FB FF5B A3FC FF5C A3FD FF5D A3FE FFE3 A441 C9DE A442 C9DF A443 C9E1 A444 C9E3 A445 C9E5 A446 C9E6 A447 C9E8 A448 C9E9 A449 C9EA A44A C9EB A44B C9EE A44C C9F2 A44D C9F3 A44E C9F4 A44F C9F5 A450 C9F6 A451 C9F7 A452 C9FA A453 C9FB A454 C9FD A455 C9FE A456 C9FF A457 CA01 A458 CA02 A459 CA03 A45A CA04 A461 CA05 A462 CA06 A463 CA07 A464 CA0A A465 CA0E A466 CA0F A467 CA10 A468 CA11 A469 CA12 A46A CA13 A46B CA15 A46C CA16 A46D CA17 A46E CA19 A46F CA1A A470 CA1B A471 CA1C A472 CA1D A473 CA1E A474 CA1F A475 CA20 A476 CA21 A477 CA22 A478 CA23 A479 CA24 A47A CA25 A481 CA26 A482 CA27 A483 CA28 A484 CA2A A485 CA2B A486 CA2C A487 CA2D A488 CA2E A489 CA2F A48A CA30 A48B CA31 A48C CA32 A48D CA33 A48E CA34 A48F CA35 A490 CA36 A491 CA37 A492 CA38 A493 CA39 A494 CA3A A495 CA3B A496 CA3C A497 CA3D A498 CA3E A499 CA3F A49A CA40 A49B CA41 A49C CA42 A49D CA43 A49E CA44 A49F CA45 A4A0 CA46 A4A1 3131 A4A2 3132 A4A3 3133 A4A4 3134 A4A5 3135 A4A6 3136 A4A7 3137 A4A8 3138 A4A9 3139 A4AA 313A A4AB 313B A4AC 313C A4AD 313D A4AE 313E A4AF 313F A4B0 3140 A4B1 3141 A4B2 3142 A4B3 3143 A4B4 3144 A4B5 3145 A4B6 3146 A4B7 3147 A4B8 3148 A4B9 3149 A4BA 314A A4BB 314B A4BC 314C A4BD 314D A4BE 314E A4BF 314F A4C0 3150 A4C1 3151 A4C2 3152 A4C3 3153 A4C4 3154 A4C5 3155 A4C6 3156 A4C7 3157 A4C8 3158 A4C9 3159 A4CA 315A A4CB 315B A4CC 315C A4CD 315D A4CE 315E A4CF 315F A4D0 3160 A4D1 3161 A4D2 3162 A4D3 3163 A4D4 3164 A4D5 3165 A4D6 3166 A4D7 3167 A4D8 3168 A4D9 3169 A4DA 316A A4DB 316B A4DC 316C A4DD 316D A4DE 316E A4DF 316F A4E0 3170 A4E1 3171 A4E2 3172 A4E3 3173 A4E4 3174 A4E5 3175 A4E6 3176 A4E7 3177 A4E8 3178 A4E9 3179 A4EA 317A A4EB 317B A4EC 317C A4ED 317D A4EE 317E A4EF 317F A4F0 3180 A4F1 3181 A4F2 3182 A4F3 3183 A4F4 3184 A4F5 3185 A4F6 3186 A4F7 3187 A4F8 3188 A4F9 3189 A4FA 318A A4FB 318B A4FC 318C A4FD 318D A4FE 318E A541 CA47 A542 CA48 A543 CA49 A544 CA4A A545 CA4B A546 CA4E A547 CA4F A548 CA51 A549 CA52 A54A CA53 A54B CA55 A54C CA56 A54D CA57 A54E CA58 A54F CA59 A550 CA5A A551 CA5B A552 CA5E A553 CA62 A554 CA63 A555 CA64 A556 CA65 A557 CA66 A558 CA67 A559 CA69 A55A CA6A A561 CA6B A562 CA6C A563 CA6D A564 CA6E A565 CA6F A566 CA70 A567 CA71 A568 CA72 A569 CA73 A56A CA74 A56B CA75 A56C CA76 A56D CA77 A56E CA78 A56F CA79 A570 CA7A A571 CA7B A572 CA7C A573 CA7E A574 CA7F A575 CA80 A576 CA81 A577 CA82 A578 CA83 A579 CA85 A57A CA86 A581 CA87 A582 CA88 A583 CA89 A584 CA8A A585 CA8B A586 CA8C A587 CA8D A588 CA8E A589 CA8F A58A CA90 A58B CA91 A58C CA92 A58D CA93 A58E CA94 A58F CA95 A590 CA96 A591 CA97 A592 CA99 A593 CA9A A594 CA9B A595 CA9C A596 CA9D A597 CA9E A598 CA9F A599 CAA0 A59A CAA1 A59B CAA2 A59C CAA3 A59D CAA4 A59E CAA5 A59F CAA6 A5A0 CAA7 A5A1 2170 A5A2 2171 A5A3 2172 A5A4 2173 A5A5 2174 A5A6 2175 A5A7 2176 A5A8 2177 A5A9 2178 A5AA 2179 A5B0 2160 A5B1 2161 A5B2 2162 A5B3 2163 A5B4 2164 A5B5 2165 A5B6 2166 A5B7 2167 A5B8 2168 A5B9 2169 A5C1 0391 A5C2 0392 A5C3 0393 A5C4 0394 A5C5 0395 A5C6 0396 A5C7 0397 A5C8 0398 A5C9 0399 A5CA 039A A5CB 039B A5CC 039C A5CD 039D A5CE 039E A5CF 039F A5D0 03A0 A5D1 03A1 A5D2 03A3 A5D3 03A4 A5D4 03A5 A5D5 03A6 A5D6 03A7 A5D7 03A8 A5D8 03A9 A5E1 03B1 A5E2 03B2 A5E3 03B3 A5E4 03B4 A5E5 03B5 A5E6 03B6 A5E7 03B7 A5E8 03B8 A5E9 03B9 A5EA 03BA A5EB 03BB A5EC 03BC A5ED 03BD A5EE 03BE A5EF 03BF A5F0 03C0 A5F1 03C1 A5F2 03C3 A5F3 03C4 A5F4 03C5 A5F5 03C6 A5F6 03C7 A5F7 03C8 A5F8 03C9 A641 CAA8 A642 CAA9 A643 CAAA A644 CAAB A645 CAAC A646 CAAD A647 CAAE A648 CAAF A649 CAB0 A64A CAB1 A64B CAB2 A64C CAB3 A64D CAB4 A64E CAB5 A64F CAB6 A650 CAB7 A651 CAB8 A652 CAB9 A653 CABA A654 CABB A655 CABE A656 CABF A657 CAC1 A658 CAC2 A659 CAC3 A65A CAC5 A661 CAC6 A662 CAC7 A663 CAC8 A664 CAC9 A665 CACA A666 CACB A667 CACE A668 CAD0 A669 CAD2 A66A CAD4 A66B CAD5 A66C CAD6 A66D CAD7 A66E CADA A66F CADB A670 CADC A671 CADD A672 CADE A673 CADF A674 CAE1 A675 CAE2 A676 CAE3 A677 CAE4 A678 CAE5 A679 CAE6 A67A CAE7 A681 CAE8 A682 CAE9 A683 CAEA A684 CAEB A685 CAED A686 CAEE A687 CAEF A688 CAF0 A689 CAF1 A68A CAF2 A68B CAF3 A68C CAF5 A68D CAF6 A68E CAF7 A68F CAF8 A690 CAF9 A691 CAFA A692 CAFB A693 CAFC A694 CAFD A695 CAFE A696 CAFF A697 CB00 A698 CB01 A699 CB02 A69A CB03 A69B CB04 A69C CB05 A69D CB06 A69E CB07 A69F CB09 A6A0 CB0A A6A1 2500 A6A2 2502 A6A3 250C A6A4 2510 A6A5 2518 A6A6 2514 A6A7 251C A6A8 252C A6A9 2524 A6AA 2534 A6AB 253C A6AC 2501 A6AD 2503 A6AE 250F A6AF 2513 A6B0 251B A6B1 2517 A6B2 2523 A6B3 2533 A6B4 252B A6B5 253B A6B6 254B A6B7 2520 A6B8 252F A6B9 2528 A6BA 2537 A6BB 253F A6BC 251D A6BD 2530 A6BE 2525 A6BF 2538 A6C0 2542 A6C1 2512 A6C2 2511 A6C3 251A A6C4 2519 A6C5 2516 A6C6 2515 A6C7 250E A6C8 250D A6C9 251E A6CA 251F A6CB 2521 A6CC 2522 A6CD 2526 A6CE 2527 A6CF 2529 A6D0 252A A6D1 252D A6D2 252E A6D3 2531 A6D4 2532 A6D5 2535 A6D6 2536 A6D7 2539 A6D8 253A A6D9 253D A6DA 253E A6DB 2540 A6DC 2541 A6DD 2543 A6DE 2544 A6DF 2545 A6E0 2546 A6E1 2547 A6E2 2548 A6E3 2549 A6E4 254A A741 CB0B A742 CB0C A743 CB0D A744 CB0E A745 CB0F A746 CB11 A747 CB12 A748 CB13 A749 CB15 A74A CB16 A74B CB17 A74C CB19 A74D CB1A A74E CB1B A74F CB1C A750 CB1D A751 CB1E A752 CB1F A753 CB22 A754 CB23 A755 CB24 A756 CB25 A757 CB26 A758 CB27 A759 CB28 A75A CB29 A761 CB2A A762 CB2B A763 CB2C A764 CB2D A765 CB2E A766 CB2F A767 CB30 A768 CB31 A769 CB32 A76A CB33 A76B CB34 A76C CB35 A76D CB36 A76E CB37 A76F CB38 A770 CB39 A771 CB3A A772 CB3B A773 CB3C A774 CB3D A775 CB3E A776 CB3F A777 CB40 A778 CB42 A779 CB43 A77A CB44 A781 CB45 A782 CB46 A783 CB47 A784 CB4A A785 CB4B A786 CB4D A787 CB4E A788 CB4F A789 CB51 A78A CB52 A78B CB53 A78C CB54 A78D CB55 A78E CB56 A78F CB57 A790 CB5A A791 CB5B A792 CB5C A793 CB5E A794 CB5F A795 CB60 A796 CB61 A797 CB62 A798 CB63 A799 CB65 A79A CB66 A79B CB67 A79C CB68 A79D CB69 A79E CB6A A79F CB6B A7A0 CB6C A7A1 3395 A7A2 3396 A7A3 3397 A7A4 2113 A7A5 3398 A7A6 33C4 A7A7 33A3 A7A8 33A4 A7A9 33A5 A7AA 33A6 A7AB 3399 A7AC 339A A7AD 339B A7AE 339C A7AF 339D A7B0 339E A7B1 339F A7B2 33A0 A7B3 33A1 A7B4 33A2 A7B5 33CA A7B6 338D A7B7 338E A7B8 338F A7B9 33CF A7BA 3388 A7BB 3389 A7BC 33C8 A7BD 33A7 A7BE 33A8 A7BF 33B0 A7C0 33B1 A7C1 33B2 A7C2 33B3 A7C3 33B4 A7C4 33B5 A7C5 33B6 A7C6 33B7 A7C7 33B8 A7C8 33B9 A7C9 3380 A7CA 3381 A7CB 3382 A7CC 3383 A7CD 3384 A7CE 33BA A7CF 33BB A7D0 33BC A7D1 33BD A7D2 33BE A7D3 33BF A7D4 3390 A7D5 3391 A7D6 3392 A7D7 3393 A7D8 3394 A7D9 2126 A7DA 33C0 A7DB 33C1 A7DC 338A A7DD 338B A7DE 338C A7DF 33D6 A7E0 33C5 A7E1 33AD A7E2 33AE A7E3 33AF A7E4 33DB A7E5 33A9 A7E6 33AA A7E7 33AB A7E8 33AC A7E9 33DD A7EA 33D0 A7EB 33D3 A7EC 33C3 A7ED 33C9 A7EE 33DC A7EF 33C6 A841 CB6D A842 CB6E A843 CB6F A844 CB70 A845 CB71 A846 CB72 A847 CB73 A848 CB74 A849 CB75 A84A CB76 A84B CB77 A84C CB7A A84D CB7B A84E CB7C A84F CB7D A850 CB7E A851 CB7F A852 CB80 A853 CB81 A854 CB82 A855 CB83 A856 CB84 A857 CB85 A858 CB86 A859 CB87 A85A CB88 A861 CB89 A862 CB8A A863 CB8B A864 CB8C A865 CB8D A866 CB8E A867 CB8F A868 CB90 A869 CB91 A86A CB92 A86B CB93 A86C CB94 A86D CB95 A86E CB96 A86F CB97 A870 CB98 A871 CB99 A872 CB9A A873 CB9B A874 CB9D A875 CB9E A876 CB9F A877 CBA0 A878 CBA1 A879 CBA2 A87A CBA3 A881 CBA4 A882 CBA5 A883 CBA6 A884 CBA7 A885 CBA8 A886 CBA9 A887 CBAA A888 CBAB A889 CBAC A88A CBAD A88B CBAE A88C CBAF A88D CBB0 A88E CBB1 A88F CBB2 A890 CBB3 A891 CBB4 A892 CBB5 A893 CBB6 A894 CBB7 A895 CBB9 A896 CBBA A897 CBBB A898 CBBC A899 CBBD A89A CBBE A89B CBBF A89C CBC0 A89D CBC1 A89E CBC2 A89F CBC3 A8A0 CBC4 A8A1 00C6 A8A2 00D0 A8A3 00AA A8A4 0126 A8A6 0132 A8A8 013F A8A9 0141 A8AA 00D8 A8AB 0152 A8AC 00BA A8AD 00DE A8AE 0166 A8AF 014A A8B1 3260 A8B2 3261 A8B3 3262 A8B4 3263 A8B5 3264 A8B6 3265 A8B7 3266 A8B8 3267 A8B9 3268 A8BA 3269 A8BB 326A A8BC 326B A8BD 326C A8BE 326D A8BF 326E A8C0 326F A8C1 3270 A8C2 3271 A8C3 3272 A8C4 3273 A8C5 3274 A8C6 3275 A8C7 3276 A8C8 3277 A8C9 3278 A8CA 3279 A8CB 327A A8CC 327B A8CD 24D0 A8CE 24D1 A8CF 24D2 A8D0 24D3 A8D1 24D4 A8D2 24D5 A8D3 24D6 A8D4 24D7 A8D5 24D8 A8D6 24D9 A8D7 24DA A8D8 24DB A8D9 24DC A8DA 24DD A8DB 24DE A8DC 24DF A8DD 24E0 A8DE 24E1 A8DF 24E2 A8E0 24E3 A8E1 24E4 A8E2 24E5 A8E3 24E6 A8E4 24E7 A8E5 24E8 A8E6 24E9 A8E7 2460 A8E8 2461 A8E9 2462 A8EA 2463 A8EB 2464 A8EC 2465 A8ED 2466 A8EE 2467 A8EF 2468 A8F0 2469 A8F1 246A A8F2 246B A8F3 246C A8F4 246D A8F5 246E A8F6 00BD A8F7 2153 A8F8 2154 A8F9 00BC A8FA 00BE A8FB 215B A8FC 215C A8FD 215D A8FE 215E A941 CBC5 A942 CBC6 A943 CBC7 A944 CBC8 A945 CBC9 A946 CBCA A947 CBCB A948 CBCC A949 CBCD A94A CBCE A94B CBCF A94C CBD0 A94D CBD1 A94E CBD2 A94F CBD3 A950 CBD5 A951 CBD6 A952 CBD7 A953 CBD8 A954 CBD9 A955 CBDA A956 CBDB A957 CBDC A958 CBDD A959 CBDE A95A CBDF A961 CBE0 A962 CBE1 A963 CBE2 A964 CBE3 A965 CBE5 A966 CBE6 A967 CBE8 A968 CBEA A969 CBEB A96A CBEC A96B CBED A96C CBEE A96D CBEF A96E CBF0 A96F CBF1 A970 CBF2 A971 CBF3 A972 CBF4 A973 CBF5 A974 CBF6 A975 CBF7 A976 CBF8 A977 CBF9 A978 CBFA A979 CBFB A97A CBFC A981 CBFD A982 CBFE A983 CBFF A984 CC00 A985 CC01 A986 CC02 A987 CC03 A988 CC04 A989 CC05 A98A CC06 A98B CC07 A98C CC08 A98D CC09 A98E CC0A A98F CC0B A990 CC0E A991 CC0F A992 CC11 A993 CC12 A994 CC13 A995 CC15 A996 CC16 A997 CC17 A998 CC18 A999 CC19 A99A CC1A A99B CC1B A99C CC1E A99D CC1F A99E CC20 A99F CC23 A9A0 CC24 A9A1 00E6 A9A2 0111 A9A3 00F0 A9A4 0127 A9A5 0131 A9A6 0133 A9A7 0138 A9A8 0140 A9A9 0142 A9AA 00F8 A9AB 0153 A9AC 00DF A9AD 00FE A9AE 0167 A9AF 014B A9B0 0149 A9B1 3200 A9B2 3201 A9B3 3202 A9B4 3203 A9B5 3204 A9B6 3205 A9B7 3206 A9B8 3207 A9B9 3208 A9BA 3209 A9BB 320A A9BC 320B A9BD 320C A9BE 320D A9BF 320E A9C0 320F A9C1 3210 A9C2 3211 A9C3 3212 A9C4 3213 A9C5 3214 A9C6 3215 A9C7 3216 A9C8 3217 A9C9 3218 A9CA 3219 A9CB 321A A9CC 321B A9CD 249C A9CE 249D A9CF 249E A9D0 249F A9D1 24A0 A9D2 24A1 A9D3 24A2 A9D4 24A3 A9D5 24A4 A9D6 24A5 A9D7 24A6 A9D8 24A7 A9D9 24A8 A9DA 24A9 A9DB 24AA A9DC 24AB A9DD 24AC A9DE 24AD A9DF 24AE A9E0 24AF A9E1 24B0 A9E2 24B1 A9E3 24B2 A9E4 24B3 A9E5 24B4 A9E6 24B5 A9E7 2474 A9E8 2475 A9E9 2476 A9EA 2477 A9EB 2478 A9EC 2479 A9ED 247A A9EE 247B A9EF 247C A9F0 247D A9F1 247E A9F2 247F A9F3 2480 A9F4 2481 A9F5 2482 A9F6 00B9 A9F7 00B2 A9F8 00B3 A9F9 2074 A9FA 207F A9FB 2081 A9FC 2082 A9FD 2083 A9FE 2084 AA41 CC25 AA42 CC26 AA43 CC2A AA44 CC2B AA45 CC2D AA46 CC2F AA47 CC31 AA48 CC32 AA49 CC33 AA4A CC34 AA4B CC35 AA4C CC36 AA4D CC37 AA4E CC3A AA4F CC3F AA50 CC40 AA51 CC41 AA52 CC42 AA53 CC43 AA54 CC46 AA55 CC47 AA56 CC49 AA57 CC4A AA58 CC4B AA59 CC4D AA5A CC4E AA61 CC4F AA62 CC50 AA63 CC51 AA64 CC52 AA65 CC53 AA66 CC56 AA67 CC5A AA68 CC5B AA69 CC5C AA6A CC5D AA6B CC5E AA6C CC5F AA6D CC61 AA6E CC62 AA6F CC63 AA70 CC65 AA71 CC67 AA72 CC69 AA73 CC6A AA74 CC6B AA75 CC6C AA76 CC6D AA77 CC6E AA78 CC6F AA79 CC71 AA7A CC72 AA81 CC73 AA82 CC74 AA83 CC76 AA84 CC77 AA85 CC78 AA86 CC79 AA87 CC7A AA88 CC7B AA89 CC7C AA8A CC7D AA8B CC7E AA8C CC7F AA8D CC80 AA8E CC81 AA8F CC82 AA90 CC83 AA91 CC84 AA92 CC85 AA93 CC86 AA94 CC87 AA95 CC88 AA96 CC89 AA97 CC8A AA98 CC8B AA99 CC8C AA9A CC8D AA9B CC8E AA9C CC8F AA9D CC90 AA9E CC91 AA9F CC92 AAA0 CC93 AAA1 3041 AAA2 3042 AAA3 3043 AAA4 3044 AAA5 3045 AAA6 3046 AAA7 3047 AAA8 3048 AAA9 3049 AAAA 304A AAAB 304B AAAC 304C AAAD 304D AAAE 304E AAAF 304F AAB0 3050 AAB1 3051 AAB2 3052 AAB3 3053 AAB4 3054 AAB5 3055 AAB6 3056 AAB7 3057 AAB8 3058 AAB9 3059 AABA 305A AABB 305B AABC 305C AABD 305D AABE 305E AABF 305F AAC0 3060 AAC1 3061 AAC2 3062 AAC3 3063 AAC4 3064 AAC5 3065 AAC6 3066 AAC7 3067 AAC8 3068 AAC9 3069 AACA 306A AACB 306B AACC 306C AACD 306D AACE 306E AACF 306F AAD0 3070 AAD1 3071 AAD2 3072 AAD3 3073 AAD4 3074 AAD5 3075 AAD6 3076 AAD7 3077 AAD8 3078 AAD9 3079 AADA 307A AADB 307B AADC 307C AADD 307D AADE 307E AADF 307F AAE0 3080 AAE1 3081 AAE2 3082 AAE3 3083 AAE4 3084 AAE5 3085 AAE6 3086 AAE7 3087 AAE8 3088 AAE9 3089 AAEA 308A AAEB 308B AAEC 308C AAED 308D AAEE 308E AAEF 308F AAF0 3090 AAF1 3091 AAF2 3092 AAF3 3093 AB41 CC94 AB42 CC95 AB43 CC96 AB44 CC97 AB45 CC9A AB46 CC9B AB47 CC9D AB48 CC9E AB49 CC9F AB4A CCA1 AB4B CCA2 AB4C CCA3 AB4D CCA4 AB4E CCA5 AB4F CCA6 AB50 CCA7 AB51 CCAA AB52 CCAE AB53 CCAF AB54 CCB0 AB55 CCB1 AB56 CCB2 AB57 CCB3 AB58 CCB6 AB59 CCB7 AB5A CCB9 AB61 CCBA AB62 CCBB AB63 CCBD AB64 CCBE AB65 CCBF AB66 CCC0 AB67 CCC1 AB68 CCC2 AB69 CCC3 AB6A CCC6 AB6B CCC8 AB6C CCCA AB6D CCCB AB6E CCCC AB6F CCCD AB70 CCCE AB71 CCCF AB72 CCD1 AB73 CCD2 AB74 CCD3 AB75 CCD5 AB76 CCD6 AB77 CCD7 AB78 CCD8 AB79 CCD9 AB7A CCDA AB81 CCDB AB82 CCDC AB83 CCDD AB84 CCDE AB85 CCDF AB86 CCE0 AB87 CCE1 AB88 CCE2 AB89 CCE3 AB8A CCE5 AB8B CCE6 AB8C CCE7 AB8D CCE8 AB8E CCE9 AB8F CCEA AB90 CCEB AB91 CCED AB92 CCEE AB93 CCEF AB94 CCF1 AB95 CCF2 AB96 CCF3 AB97 CCF4 AB98 CCF5 AB99 CCF6 AB9A CCF7 AB9B CCF8 AB9C CCF9 AB9D CCFA AB9E CCFB AB9F CCFC ABA0 CCFD ABA1 30A1 ABA2 30A2 ABA3 30A3 ABA4 30A4 ABA5 30A5 ABA6 30A6 ABA7 30A7 ABA8 30A8 ABA9 30A9 ABAA 30AA ABAB 30AB ABAC 30AC ABAD 30AD ABAE 30AE ABAF 30AF ABB0 30B0 ABB1 30B1 ABB2 30B2 ABB3 30B3 ABB4 30B4 ABB5 30B5 ABB6 30B6 ABB7 30B7 ABB8 30B8 ABB9 30B9 ABBA 30BA ABBB 30BB ABBC 30BC ABBD 30BD ABBE 30BE ABBF 30BF ABC0 30C0 ABC1 30C1 ABC2 30C2 ABC3 30C3 ABC4 30C4 ABC5 30C5 ABC6 30C6 ABC7 30C7 ABC8 30C8 ABC9 30C9 ABCA 30CA ABCB 30CB ABCC 30CC ABCD 30CD ABCE 30CE ABCF 30CF ABD0 30D0 ABD1 30D1 ABD2 30D2 ABD3 30D3 ABD4 30D4 ABD5 30D5 ABD6 30D6 ABD7 30D7 ABD8 30D8 ABD9 30D9 ABDA 30DA ABDB 30DB ABDC 30DC ABDD 30DD ABDE 30DE ABDF 30DF ABE0 30E0 ABE1 30E1 ABE2 30E2 ABE3 30E3 ABE4 30E4 ABE5 30E5 ABE6 30E6 ABE7 30E7 ABE8 30E8 ABE9 30E9 ABEA 30EA ABEB 30EB ABEC 30EC ABED 30ED ABEE 30EE ABEF 30EF ABF0 30F0 ABF1 30F1 ABF2 30F2 ABF3 30F3 ABF4 30F4 ABF5 30F5 ABF6 30F6 AC41 CCFE AC42 CCFF AC43 CD00 AC44 CD02 AC45 CD03 AC46 CD04 AC47 CD05 AC48 CD06 AC49 CD07 AC4A CD0A AC4B CD0B AC4C CD0D AC4D CD0E AC4E CD0F AC4F CD11 AC50 CD12 AC51 CD13 AC52 CD14 AC53 CD15 AC54 CD16 AC55 CD17 AC56 CD1A AC57 CD1C AC58 CD1E AC59 CD1F AC5A CD20 AC61 CD21 AC62 CD22 AC63 CD23 AC64 CD25 AC65 CD26 AC66 CD27 AC67 CD29 AC68 CD2A AC69 CD2B AC6A CD2D AC6B CD2E AC6C CD2F AC6D CD30 AC6E CD31 AC6F CD32 AC70 CD33 AC71 CD34 AC72 CD35 AC73 CD36 AC74 CD37 AC75 CD38 AC76 CD3A AC77 CD3B AC78 CD3C AC79 CD3D AC7A CD3E AC81 CD3F AC82 CD40 AC83 CD41 AC84 CD42 AC85 CD43 AC86 CD44 AC87 CD45 AC88 CD46 AC89 CD47 AC8A CD48 AC8B CD49 AC8C CD4A AC8D CD4B AC8E CD4C AC8F CD4D AC90 CD4E AC91 CD4F AC92 CD50 AC93 CD51 AC94 CD52 AC95 CD53 AC96 CD54 AC97 CD55 AC98 CD56 AC99 CD57 AC9A CD58 AC9B CD59 AC9C CD5A AC9D CD5B AC9E CD5D AC9F CD5E ACA0 CD5F ACA1 0410 ACA2 0411 ACA3 0412 ACA4 0413 ACA5 0414 ACA6 0415 ACA7 0401 ACA8 0416 ACA9 0417 ACAA 0418 ACAB 0419 ACAC 041A ACAD 041B ACAE 041C ACAF 041D ACB0 041E ACB1 041F ACB2 0420 ACB3 0421 ACB4 0422 ACB5 0423 ACB6 0424 ACB7 0425 ACB8 0426 ACB9 0427 ACBA 0428 ACBB 0429 ACBC 042A ACBD 042B ACBE 042C ACBF 042D ACC0 042E ACC1 042F ACD1 0430 ACD2 0431 ACD3 0432 ACD4 0433 ACD5 0434 ACD6 0435 ACD7 0451 ACD8 0436 ACD9 0437 ACDA 0438 ACDB 0439 ACDC 043A ACDD 043B ACDE 043C ACDF 043D ACE0 043E ACE1 043F ACE2 0440 ACE3 0441 ACE4 0442 ACE5 0443 ACE6 0444 ACE7 0445 ACE8 0446 ACE9 0447 ACEA 0448 ACEB 0449 ACEC 044A ACED 044B ACEE 044C ACEF 044D ACF0 044E ACF1 044F AD41 CD61 AD42 CD62 AD43 CD63 AD44 CD65 AD45 CD66 AD46 CD67 AD47 CD68 AD48 CD69 AD49 CD6A AD4A CD6B AD4B CD6E AD4C CD70 AD4D CD72 AD4E CD73 AD4F CD74 AD50 CD75 AD51 CD76 AD52 CD77 AD53 CD79 AD54 CD7A AD55 CD7B AD56 CD7C AD57 CD7D AD58 CD7E AD59 CD7F AD5A CD80 AD61 CD81 AD62 CD82 AD63 CD83 AD64 CD84 AD65 CD85 AD66 CD86 AD67 CD87 AD68 CD89 AD69 CD8A AD6A CD8B AD6B CD8C AD6C CD8D AD6D CD8E AD6E CD8F AD6F CD90 AD70 CD91 AD71 CD92 AD72 CD93 AD73 CD96 AD74 CD97 AD75 CD99 AD76 CD9A AD77 CD9B AD78 CD9D AD79 CD9E AD7A CD9F AD81 CDA0 AD82 CDA1 AD83 CDA2 AD84 CDA3 AD85 CDA6 AD86 CDA8 AD87 CDAA AD88 CDAB AD89 CDAC AD8A CDAD AD8B CDAE AD8C CDAF AD8D CDB1 AD8E CDB2 AD8F CDB3 AD90 CDB4 AD91 CDB5 AD92 CDB6 AD93 CDB7 AD94 CDB8 AD95 CDB9 AD96 CDBA AD97 CDBB AD98 CDBC AD99 CDBD AD9A CDBE AD9B CDBF AD9C CDC0 AD9D CDC1 AD9E CDC2 AD9F CDC3 ADA0 CDC5 AE41 CDC6 AE42 CDC7 AE43 CDC8 AE44 CDC9 AE45 CDCA AE46 CDCB AE47 CDCD AE48 CDCE AE49 CDCF AE4A CDD1 AE4B CDD2 AE4C CDD3 AE4D CDD4 AE4E CDD5 AE4F CDD6 AE50 CDD7 AE51 CDD8 AE52 CDD9 AE53 CDDA AE54 CDDB AE55 CDDC AE56 CDDD AE57 CDDE AE58 CDDF AE59 CDE0 AE5A CDE1 AE61 CDE2 AE62 CDE3 AE63 CDE4 AE64 CDE5 AE65 CDE6 AE66 CDE7 AE67 CDE9 AE68 CDEA AE69 CDEB AE6A CDED AE6B CDEE AE6C CDEF AE6D CDF1 AE6E CDF2 AE6F CDF3 AE70 CDF4 AE71 CDF5 AE72 CDF6 AE73 CDF7 AE74 CDFA AE75 CDFC AE76 CDFE AE77 CDFF AE78 CE00 AE79 CE01 AE7A CE02 AE81 CE03 AE82 CE05 AE83 CE06 AE84 CE07 AE85 CE09 AE86 CE0A AE87 CE0B AE88 CE0D AE89 CE0E AE8A CE0F AE8B CE10 AE8C CE11 AE8D CE12 AE8E CE13 AE8F CE15 AE90 CE16 AE91 CE17 AE92 CE18 AE93 CE1A AE94 CE1B AE95 CE1C AE96 CE1D AE97 CE1E AE98 CE1F AE99 CE22 AE9A CE23 AE9B CE25 AE9C CE26 AE9D CE27 AE9E CE29 AE9F CE2A AEA0 CE2B AF41 CE2C AF42 CE2D AF43 CE2E AF44 CE2F AF45 CE32 AF46 CE34 AF47 CE36 AF48 CE37 AF49 CE38 AF4A CE39 AF4B CE3A AF4C CE3B AF4D CE3C AF4E CE3D AF4F CE3E AF50 CE3F AF51 CE40 AF52 CE41 AF53 CE42 AF54 CE43 AF55 CE44 AF56 CE45 AF57 CE46 AF58 CE47 AF59 CE48 AF5A CE49 AF61 CE4A AF62 CE4B AF63 CE4C AF64 CE4D AF65 CE4E AF66 CE4F AF67 CE50 AF68 CE51 AF69 CE52 AF6A CE53 AF6B CE54 AF6C CE55 AF6D CE56 AF6E CE57 AF6F CE5A AF70 CE5B AF71 CE5D AF72 CE5E AF73 CE62 AF74 CE63 AF75 CE64 AF76 CE65 AF77 CE66 AF78 CE67 AF79 CE6A AF7A CE6C AF81 CE6E AF82 CE6F AF83 CE70 AF84 CE71 AF85 CE72 AF86 CE73 AF87 CE76 AF88 CE77 AF89 CE79 AF8A CE7A AF8B CE7B AF8C CE7D AF8D CE7E AF8E CE7F AF8F CE80 AF90 CE81 AF91 CE82 AF92 CE83 AF93 CE86 AF94 CE88 AF95 CE8A AF96 CE8B AF97 CE8C AF98 CE8D AF99 CE8E AF9A CE8F AF9B CE92 AF9C CE93 AF9D CE95 AF9E CE96 AF9F CE97 AFA0 CE99 B041 CE9A B042 CE9B B043 CE9C B044 CE9D B045 CE9E B046 CE9F B047 CEA2 B048 CEA6 B049 CEA7 B04A CEA8 B04B CEA9 B04C CEAA B04D CEAB B04E CEAE B04F CEAF B050 CEB0 B051 CEB1 B052 CEB2 B053 CEB3 B054 CEB4 B055 CEB5 B056 CEB6 B057 CEB7 B058 CEB8 B059 CEB9 B05A CEBA B061 CEBB B062 CEBC B063 CEBD B064 CEBE B065 CEBF B066 CEC0 B067 CEC2 B068 CEC3 B069 CEC4 B06A CEC5 B06B CEC6 B06C CEC7 B06D CEC8 B06E CEC9 B06F CECA B070 CECB B071 CECC B072 CECD B073 CECE B074 CECF B075 CED0 B076 CED1 B077 CED2 B078 CED3 B079 CED4 B07A CED5 B081 CED6 B082 CED7 B083 CED8 B084 CED9 B085 CEDA B086 CEDB B087 CEDC B088 CEDD B089 CEDE B08A CEDF B08B CEE0 B08C CEE1 B08D CEE2 B08E CEE3 B08F CEE6 B090 CEE7 B091 CEE9 B092 CEEA B093 CEED B094 CEEE B095 CEEF B096 CEF0 B097 CEF1 B098 CEF2 B099 CEF3 B09A CEF6 B09B CEFA B09C CEFB B09D CEFC B09E CEFD B09F CEFE B0A0 CEFF B0A1 AC00 B0A2 AC01 B0A3 AC04 B0A4 AC07 B0A5 AC08 B0A6 AC09 B0A7 AC0A B0A8 AC10 B0A9 AC11 B0AA AC12 B0AB AC13 B0AC AC14 B0AD AC15 B0AE AC16 B0AF AC17 B0B0 AC19 B0B1 AC1A B0B2 AC1B B0B3 AC1C B0B4 AC1D B0B5 AC20 B0B6 AC24 B0B7 AC2C B0B8 AC2D B0B9 AC2F B0BA AC30 B0BB AC31 B0BC AC38 B0BD AC39 B0BE AC3C B0BF AC40 B0C0 AC4B B0C1 AC4D B0C2 AC54 B0C3 AC58 B0C4 AC5C B0C5 AC70 B0C6 AC71 B0C7 AC74 B0C8 AC77 B0C9 AC78 B0CA AC7A B0CB AC80 B0CC AC81 B0CD AC83 B0CE AC84 B0CF AC85 B0D0 AC86 B0D1 AC89 B0D2 AC8A B0D3 AC8B B0D4 AC8C B0D5 AC90 B0D6 AC94 B0D7 AC9C B0D8 AC9D B0D9 AC9F B0DA ACA0 B0DB ACA1 B0DC ACA8 B0DD ACA9 B0DE ACAA B0DF ACAC B0E0 ACAF B0E1 ACB0 B0E2 ACB8 B0E3 ACB9 B0E4 ACBB B0E5 ACBC B0E6 ACBD B0E7 ACC1 B0E8 ACC4 B0E9 ACC8 B0EA ACCC B0EB ACD5 B0EC ACD7 B0ED ACE0 B0EE ACE1 B0EF ACE4 B0F0 ACE7 B0F1 ACE8 B0F2 ACEA B0F3 ACEC B0F4 ACEF B0F5 ACF0 B0F6 ACF1 B0F7 ACF3 B0F8 ACF5 B0F9 ACF6 B0FA ACFC B0FB ACFD B0FC AD00 B0FD AD04 B0FE AD06 B141 CF02 B142 CF03 B143 CF05 B144 CF06 B145 CF07 B146 CF09 B147 CF0A B148 CF0B B149 CF0C B14A CF0D B14B CF0E B14C CF0F B14D CF12 B14E CF14 B14F CF16 B150 CF17 B151 CF18 B152 CF19 B153 CF1A B154 CF1B B155 CF1D B156 CF1E B157 CF1F B158 CF21 B159 CF22 B15A CF23 B161 CF25 B162 CF26 B163 CF27 B164 CF28 B165 CF29 B166 CF2A B167 CF2B B168 CF2E B169 CF32 B16A CF33 B16B CF34 B16C CF35 B16D CF36 B16E CF37 B16F CF39 B170 CF3A B171 CF3B B172 CF3C B173 CF3D B174 CF3E B175 CF3F B176 CF40 B177 CF41 B178 CF42 B179 CF43 B17A CF44 B181 CF45 B182 CF46 B183 CF47 B184 CF48 B185 CF49 B186 CF4A B187 CF4B B188 CF4C B189 CF4D B18A CF4E B18B CF4F B18C CF50 B18D CF51 B18E CF52 B18F CF53 B190 CF56 B191 CF57 B192 CF59 B193 CF5A B194 CF5B B195 CF5D B196 CF5E B197 CF5F B198 CF60 B199 CF61 B19A CF62 B19B CF63 B19C CF66 B19D CF68 B19E CF6A B19F CF6B B1A0 CF6C B1A1 AD0C B1A2 AD0D B1A3 AD0F B1A4 AD11 B1A5 AD18 B1A6 AD1C B1A7 AD20 B1A8 AD29 B1A9 AD2C B1AA AD2D B1AB AD34 B1AC AD35 B1AD AD38 B1AE AD3C B1AF AD44 B1B0 AD45 B1B1 AD47 B1B2 AD49 B1B3 AD50 B1B4 AD54 B1B5 AD58 B1B6 AD61 B1B7 AD63 B1B8 AD6C B1B9 AD6D B1BA AD70 B1BB AD73 B1BC AD74 B1BD AD75 B1BE AD76 B1BF AD7B B1C0 AD7C B1C1 AD7D B1C2 AD7F B1C3 AD81 B1C4 AD82 B1C5 AD88 B1C6 AD89 B1C7 AD8C B1C8 AD90 B1C9 AD9C B1CA AD9D B1CB ADA4 B1CC ADB7 B1CD ADC0 B1CE ADC1 B1CF ADC4 B1D0 ADC8 B1D1 ADD0 B1D2 ADD1 B1D3 ADD3 B1D4 ADDC B1D5 ADE0 B1D6 ADE4 B1D7 ADF8 B1D8 ADF9 B1D9 ADFC B1DA ADFF B1DB AE00 B1DC AE01 B1DD AE08 B1DE AE09 B1DF AE0B B1E0 AE0D B1E1 AE14 B1E2 AE30 B1E3 AE31 B1E4 AE34 B1E5 AE37 B1E6 AE38 B1E7 AE3A B1E8 AE40 B1E9 AE41 B1EA AE43 B1EB AE45 B1EC AE46 B1ED AE4A B1EE AE4C B1EF AE4D B1F0 AE4E B1F1 AE50 B1F2 AE54 B1F3 AE56 B1F4 AE5C B1F5 AE5D B1F6 AE5F B1F7 AE60 B1F8 AE61 B1F9 AE65 B1FA AE68 B1FB AE69 B1FC AE6C B1FD AE70 B1FE AE78 B241 CF6D B242 CF6E B243 CF6F B244 CF72 B245 CF73 B246 CF75 B247 CF76 B248 CF77 B249 CF79 B24A CF7A B24B CF7B B24C CF7C B24D CF7D B24E CF7E B24F CF7F B250 CF81 B251 CF82 B252 CF83 B253 CF84 B254 CF86 B255 CF87 B256 CF88 B257 CF89 B258 CF8A B259 CF8B B25A CF8D B261 CF8E B262 CF8F B263 CF90 B264 CF91 B265 CF92 B266 CF93 B267 CF94 B268 CF95 B269 CF96 B26A CF97 B26B CF98 B26C CF99 B26D CF9A B26E CF9B B26F CF9C B270 CF9D B271 CF9E B272 CF9F B273 CFA0 B274 CFA2 B275 CFA3 B276 CFA4 B277 CFA5 B278 CFA6 B279 CFA7 B27A CFA9 B281 CFAA B282 CFAB B283 CFAC B284 CFAD B285 CFAE B286 CFAF B287 CFB1 B288 CFB2 B289 CFB3 B28A CFB4 B28B CFB5 B28C CFB6 B28D CFB7 B28E CFB8 B28F CFB9 B290 CFBA B291 CFBB B292 CFBC B293 CFBD B294 CFBE B295 CFBF B296 CFC0 B297 CFC1 B298 CFC2 B299 CFC3 B29A CFC5 B29B CFC6 B29C CFC7 B29D CFC8 B29E CFC9 B29F CFCA B2A0 CFCB B2A1 AE79 B2A2 AE7B B2A3 AE7C B2A4 AE7D B2A5 AE84 B2A6 AE85 B2A7 AE8C B2A8 AEBC B2A9 AEBD B2AA AEBE B2AB AEC0 B2AC AEC4 B2AD AECC B2AE AECD B2AF AECF B2B0 AED0 B2B1 AED1 B2B2 AED8 B2B3 AED9 B2B4 AEDC B2B5 AEE8 B2B6 AEEB B2B7 AEED B2B8 AEF4 B2B9 AEF8 B2BA AEFC B2BB AF07 B2BC AF08 B2BD AF0D B2BE AF10 B2BF AF2C B2C0 AF2D B2C1 AF30 B2C2 AF32 B2C3 AF34 B2C4 AF3C B2C5 AF3D B2C6 AF3F B2C7 AF41 B2C8 AF42 B2C9 AF43 B2CA AF48 B2CB AF49 B2CC AF50 B2CD AF5C B2CE AF5D B2CF AF64 B2D0 AF65 B2D1 AF79 B2D2 AF80 B2D3 AF84 B2D4 AF88 B2D5 AF90 B2D6 AF91 B2D7 AF95 B2D8 AF9C B2D9 AFB8 B2DA AFB9 B2DB AFBC B2DC AFC0 B2DD AFC7 B2DE AFC8 B2DF AFC9 B2E0 AFCB B2E1 AFCD B2E2 AFCE B2E3 AFD4 B2E4 AFDC B2E5 AFE8 B2E6 AFE9 B2E7 AFF0 B2E8 AFF1 B2E9 AFF4 B2EA AFF8 B2EB B000 B2EC B001 B2ED B004 B2EE B00C B2EF B010 B2F0 B014 B2F1 B01C B2F2 B01D B2F3 B028 B2F4 B044 B2F5 B045 B2F6 B048 B2F7 B04A B2F8 B04C B2F9 B04E B2FA B053 B2FB B054 B2FC B055 B2FD B057 B2FE B059 B341 CFCC B342 CFCD B343 CFCE B344 CFCF B345 CFD0 B346 CFD1 B347 CFD2 B348 CFD3 B349 CFD4 B34A CFD5 B34B CFD6 B34C CFD7 B34D CFD8 B34E CFD9 B34F CFDA B350 CFDB B351 CFDC B352 CFDD B353 CFDE B354 CFDF B355 CFE2 B356 CFE3 B357 CFE5 B358 CFE6 B359 CFE7 B35A CFE9 B361 CFEA B362 CFEB B363 CFEC B364 CFED B365 CFEE B366 CFEF B367 CFF2 B368 CFF4 B369 CFF6 B36A CFF7 B36B CFF8 B36C CFF9 B36D CFFA B36E CFFB B36F CFFD B370 CFFE B371 CFFF B372 D001 B373 D002 B374 D003 B375 D005 B376 D006 B377 D007 B378 D008 B379 D009 B37A D00A B381 D00B B382 D00C B383 D00D B384 D00E B385 D00F B386 D010 B387 D012 B388 D013 B389 D014 B38A D015 B38B D016 B38C D017 B38D D019 B38E D01A B38F D01B B390 D01C B391 D01D B392 D01E B393 D01F B394 D020 B395 D021 B396 D022 B397 D023 B398 D024 B399 D025 B39A D026 B39B D027 B39C D028 B39D D029 B39E D02A B39F D02B B3A0 D02C B3A1 B05D B3A2 B07C B3A3 B07D B3A4 B080 B3A5 B084 B3A6 B08C B3A7 B08D B3A8 B08F B3A9 B091 B3AA B098 B3AB B099 B3AC B09A B3AD B09C B3AE B09F B3AF B0A0 B3B0 B0A1 B3B1 B0A2 B3B2 B0A8 B3B3 B0A9 B3B4 B0AB B3B5 B0AC B3B6 B0AD B3B7 B0AE B3B8 B0AF B3B9 B0B1 B3BA B0B3 B3BB B0B4 B3BC B0B5 B3BD B0B8 B3BE B0BC B3BF B0C4 B3C0 B0C5 B3C1 B0C7 B3C2 B0C8 B3C3 B0C9 B3C4 B0D0 B3C5 B0D1 B3C6 B0D4 B3C7 B0D8 B3C8 B0E0 B3C9 B0E5 B3CA B108 B3CB B109 B3CC B10B B3CD B10C B3CE B110 B3CF B112 B3D0 B113 B3D1 B118 B3D2 B119 B3D3 B11B B3D4 B11C B3D5 B11D B3D6 B123 B3D7 B124 B3D8 B125 B3D9 B128 B3DA B12C B3DB B134 B3DC B135 B3DD B137 B3DE B138 B3DF B139 B3E0 B140 B3E1 B141 B3E2 B144 B3E3 B148 B3E4 B150 B3E5 B151 B3E6 B154 B3E7 B155 B3E8 B158 B3E9 B15C B3EA B160 B3EB B178 B3EC B179 B3ED B17C B3EE B180 B3EF B182 B3F0 B188 B3F1 B189 B3F2 B18B B3F3 B18D B3F4 B192 B3F5 B193 B3F6 B194 B3F7 B198 B3F8 B19C B3F9 B1A8 B3FA B1CC B3FB B1D0 B3FC B1D4 B3FD B1DC B3FE B1DD B441 D02E B442 D02F B443 D030 B444 D031 B445 D032 B446 D033 B447 D036 B448 D037 B449 D039 B44A D03A B44B D03B B44C D03D B44D D03E B44E D03F B44F D040 B450 D041 B451 D042 B452 D043 B453 D046 B454 D048 B455 D04A B456 D04B B457 D04C B458 D04D B459 D04E B45A D04F B461 D051 B462 D052 B463 D053 B464 D055 B465 D056 B466 D057 B467 D059 B468 D05A B469 D05B B46A D05C B46B D05D B46C D05E B46D D05F B46E D061 B46F D062 B470 D063 B471 D064 B472 D065 B473 D066 B474 D067 B475 D068 B476 D069 B477 D06A B478 D06B B479 D06E B47A D06F B481 D071 B482 D072 B483 D073 B484 D075 B485 D076 B486 D077 B487 D078 B488 D079 B489 D07A B48A D07B B48B D07E B48C D07F B48D D080 B48E D082 B48F D083 B490 D084 B491 D085 B492 D086 B493 D087 B494 D088 B495 D089 B496 D08A B497 D08B B498 D08C B499 D08D B49A D08E B49B D08F B49C D090 B49D D091 B49E D092 B49F D093 B4A0 D094 B4A1 B1DF B4A2 B1E8 B4A3 B1E9 B4A4 B1EC B4A5 B1F0 B4A6 B1F9 B4A7 B1FB B4A8 B1FD B4A9 B204 B4AA B205 B4AB B208 B4AC B20B B4AD B20C B4AE B214 B4AF B215 B4B0 B217 B4B1 B219 B4B2 B220 B4B3 B234 B4B4 B23C B4B5 B258 B4B6 B25C B4B7 B260 B4B8 B268 B4B9 B269 B4BA B274 B4BB B275 B4BC B27C B4BD B284 B4BE B285 B4BF B289 B4C0 B290 B4C1 B291 B4C2 B294 B4C3 B298 B4C4 B299 B4C5 B29A B4C6 B2A0 B4C7 B2A1 B4C8 B2A3 B4C9 B2A5 B4CA B2A6 B4CB B2AA B4CC B2AC B4CD B2B0 B4CE B2B4 B4CF B2C8 B4D0 B2C9 B4D1 B2CC B4D2 B2D0 B4D3 B2D2 B4D4 B2D8 B4D5 B2D9 B4D6 B2DB B4D7 B2DD B4D8 B2E2 B4D9 B2E4 B4DA B2E5 B4DB B2E6 B4DC B2E8 B4DD B2EB B4DE B2EC B4DF B2ED B4E0 B2EE B4E1 B2EF B4E2 B2F3 B4E3 B2F4 B4E4 B2F5 B4E5 B2F7 B4E6 B2F8 B4E7 B2F9 B4E8 B2FA B4E9 B2FB B4EA B2FF B4EB B300 B4EC B301 B4ED B304 B4EE B308 B4EF B310 B4F0 B311 B4F1 B313 B4F2 B314 B4F3 B315 B4F4 B31C B4F5 B354 B4F6 B355 B4F7 B356 B4F8 B358 B4F9 B35B B4FA B35C B4FB B35E B4FC B35F B4FD B364 B4FE B365 B541 D095 B542 D096 B543 D097 B544 D098 B545 D099 B546 D09A B547 D09B B548 D09C B549 D09D B54A D09E B54B D09F B54C D0A0 B54D D0A1 B54E D0A2 B54F D0A3 B550 D0A6 B551 D0A7 B552 D0A9 B553 D0AA B554 D0AB B555 D0AD B556 D0AE B557 D0AF B558 D0B0 B559 D0B1 B55A D0B2 B561 D0B3 B562 D0B6 B563 D0B8 B564 D0BA B565 D0BB B566 D0BC B567 D0BD B568 D0BE B569 D0BF B56A D0C2 B56B D0C3 B56C D0C5 B56D D0C6 B56E D0C7 B56F D0CA B570 D0CB B571 D0CC B572 D0CD B573 D0CE B574 D0CF B575 D0D2 B576 D0D6 B577 D0D7 B578 D0D8 B579 D0D9 B57A D0DA B581 D0DB B582 D0DE B583 D0DF B584 D0E1 B585 D0E2 B586 D0E3 B587 D0E5 B588 D0E6 B589 D0E7 B58A D0E8 B58B D0E9 B58C D0EA B58D D0EB B58E D0EE B58F D0F2 B590 D0F3 B591 D0F4 B592 D0F5 B593 D0F6 B594 D0F7 B595 D0F9 B596 D0FA B597 D0FB B598 D0FC B599 D0FD B59A D0FE B59B D0FF B59C D100 B59D D101 B59E D102 B59F D103 B5A0 D104 B5A1 B367 B5A2 B369 B5A3 B36B B5A4 B36E B5A5 B370 B5A6 B371 B5A7 B374 B5A8 B378 B5A9 B380 B5AA B381 B5AB B383 B5AC B384 B5AD B385 B5AE B38C B5AF B390 B5B0 B394 B5B1 B3A0 B5B2 B3A1 B5B3 B3A8 B5B4 B3AC B5B5 B3C4 B5B6 B3C5 B5B7 B3C8 B5B8 B3CB B5B9 B3CC B5BA B3CE B5BB B3D0 B5BC B3D4 B5BD B3D5 B5BE B3D7 B5BF B3D9 B5C0 B3DB B5C1 B3DD B5C2 B3E0 B5C3 B3E4 B5C4 B3E8 B5C5 B3FC B5C6 B410 B5C7 B418 B5C8 B41C B5C9 B420 B5CA B428 B5CB B429 B5CC B42B B5CD B434 B5CE B450 B5CF B451 B5D0 B454 B5D1 B458 B5D2 B460 B5D3 B461 B5D4 B463 B5D5 B465 B5D6 B46C B5D7 B480 B5D8 B488 B5D9 B49D B5DA B4A4 B5DB B4A8 B5DC B4AC B5DD B4B5 B5DE B4B7 B5DF B4B9 B5E0 B4C0 B5E1 B4C4 B5E2 B4C8 B5E3 B4D0 B5E4 B4D5 B5E5 B4DC B5E6 B4DD B5E7 B4E0 B5E8 B4E3 B5E9 B4E4 B5EA B4E6 B5EB B4EC B5EC B4ED B5ED B4EF B5EE B4F1 B5EF B4F8 B5F0 B514 B5F1 B515 B5F2 B518 B5F3 B51B B5F4 B51C B5F5 B524 B5F6 B525 B5F7 B527 B5F8 B528 B5F9 B529 B5FA B52A B5FB B530 B5FC B531 B5FD B534 B5FE B538 B641 D105 B642 D106 B643 D107 B644 D108 B645 D109 B646 D10A B647 D10B B648 D10C B649 D10E B64A D10F B64B D110 B64C D111 B64D D112 B64E D113 B64F D114 B650 D115 B651 D116 B652 D117 B653 D118 B654 D119 B655 D11A B656 D11B B657 D11C B658 D11D B659 D11E B65A D11F B661 D120 B662 D121 B663 D122 B664 D123 B665 D124 B666 D125 B667 D126 B668 D127 B669 D128 B66A D129 B66B D12A B66C D12B B66D D12C B66E D12D B66F D12E B670 D12F B671 D132 B672 D133 B673 D135 B674 D136 B675 D137 B676 D139 B677 D13B B678 D13C B679 D13D B67A D13E B681 D13F B682 D142 B683 D146 B684 D147 B685 D148 B686 D149 B687 D14A B688 D14B B689 D14E B68A D14F B68B D151 B68C D152 B68D D153 B68E D155 B68F D156 B690 D157 B691 D158 B692 D159 B693 D15A B694 D15B B695 D15E B696 D160 B697 D162 B698 D163 B699 D164 B69A D165 B69B D166 B69C D167 B69D D169 B69E D16A B69F D16B B6A0 D16D B6A1 B540 B6A2 B541 B6A3 B543 B6A4 B544 B6A5 B545 B6A6 B54B B6A7 B54C B6A8 B54D B6A9 B550 B6AA B554 B6AB B55C B6AC B55D B6AD B55F B6AE B560 B6AF B561 B6B0 B5A0 B6B1 B5A1 B6B2 B5A4 B6B3 B5A8 B6B4 B5AA B6B5 B5AB B6B6 B5B0 B6B7 B5B1 B6B8 B5B3 B6B9 B5B4 B6BA B5B5 B6BB B5BB B6BC B5BC B6BD B5BD B6BE B5C0 B6BF B5C4 B6C0 B5CC B6C1 B5CD B6C2 B5CF B6C3 B5D0 B6C4 B5D1 B6C5 B5D8 B6C6 B5EC B6C7 B610 B6C8 B611 B6C9 B614 B6CA B618 B6CB B625 B6CC B62C B6CD B634 B6CE B648 B6CF B664 B6D0 B668 B6D1 B69C B6D2 B69D B6D3 B6A0 B6D4 B6A4 B6D5 B6AB B6D6 B6AC B6D7 B6B1 B6D8 B6D4 B6D9 B6F0 B6DA B6F4 B6DB B6F8 B6DC B700 B6DD B701 B6DE B705 B6DF B728 B6E0 B729 B6E1 B72C B6E2 B72F B6E3 B730 B6E4 B738 B6E5 B739 B6E6 B73B B6E7 B744 B6E8 B748 B6E9 B74C B6EA B754 B6EB B755 B6EC B760 B6ED B764 B6EE B768 B6EF B770 B6F0 B771 B6F1 B773 B6F2 B775 B6F3 B77C B6F4 B77D B6F5 B780 B6F6 B784 B6F7 B78C B6F8 B78D B6F9 B78F B6FA B790 B6FB B791 B6FC B792 B6FD B796 B6FE B797 B741 D16E B742 D16F B743 D170 B744 D171 B745 D172 B746 D173 B747 D174 B748 D175 B749 D176 B74A D177 B74B D178 B74C D179 B74D D17A B74E D17B B74F D17D B750 D17E B751 D17F B752 D180 B753 D181 B754 D182 B755 D183 B756 D185 B757 D186 B758 D187 B759 D189 B75A D18A B761 D18B B762 D18C B763 D18D B764 D18E B765 D18F B766 D190 B767 D191 B768 D192 B769 D193 B76A D194 B76B D195 B76C D196 B76D D197 B76E D198 B76F D199 B770 D19A B771 D19B B772 D19C B773 D19D B774 D19E B775 D19F B776 D1A2 B777 D1A3 B778 D1A5 B779 D1A6 B77A D1A7 B781 D1A9 B782 D1AA B783 D1AB B784 D1AC B785 D1AD B786 D1AE B787 D1AF B788 D1B2 B789 D1B4 B78A D1B6 B78B D1B7 B78C D1B8 B78D D1B9 B78E D1BB B78F D1BD B790 D1BE B791 D1BF B792 D1C1 B793 D1C2 B794 D1C3 B795 D1C4 B796 D1C5 B797 D1C6 B798 D1C7 B799 D1C8 B79A D1C9 B79B D1CA B79C D1CB B79D D1CC B79E D1CD B79F D1CE B7A0 D1CF B7A1 B798 B7A2 B799 B7A3 B79C B7A4 B7A0 B7A5 B7A8 B7A6 B7A9 B7A7 B7AB B7A8 B7AC B7A9 B7AD B7AA B7B4 B7AB B7B5 B7AC B7B8 B7AD B7C7 B7AE B7C9 B7AF B7EC B7B0 B7ED B7B1 B7F0 B7B2 B7F4 B7B3 B7FC B7B4 B7FD B7B5 B7FF B7B6 B800 B7B7 B801 B7B8 B807 B7B9 B808 B7BA B809 B7BB B80C B7BC B810 B7BD B818 B7BE B819 B7BF B81B B7C0 B81D B7C1 B824 B7C2 B825 B7C3 B828 B7C4 B82C B7C5 B834 B7C6 B835 B7C7 B837 B7C8 B838 B7C9 B839 B7CA B840 B7CB B844 B7CC B851 B7CD B853 B7CE B85C B7CF B85D B7D0 B860 B7D1 B864 B7D2 B86C B7D3 B86D B7D4 B86F B7D5 B871 B7D6 B878 B7D7 B87C B7D8 B88D B7D9 B8A8 B7DA B8B0 B7DB B8B4 B7DC B8B8 B7DD B8C0 B7DE B8C1 B7DF B8C3 B7E0 B8C5 B7E1 B8CC B7E2 B8D0 B7E3 B8D4 B7E4 B8DD B7E5 B8DF B7E6 B8E1 B7E7 B8E8 B7E8 B8E9 B7E9 B8EC B7EA B8F0 B7EB B8F8 B7EC B8F9 B7ED B8FB B7EE B8FD B7EF B904 B7F0 B918 B7F1 B920 B7F2 B93C B7F3 B93D B7F4 B940 B7F5 B944 B7F6 B94C B7F7 B94F B7F8 B951 B7F9 B958 B7FA B959 B7FB B95C B7FC B960 B7FD B968 B7FE B969 B841 D1D0 B842 D1D1 B843 D1D2 B844 D1D3 B845 D1D4 B846 D1D5 B847 D1D6 B848 D1D7 B849 D1D9 B84A D1DA B84B D1DB B84C D1DC B84D D1DD B84E D1DE B84F D1DF B850 D1E0 B851 D1E1 B852 D1E2 B853 D1E3 B854 D1E4 B855 D1E5 B856 D1E6 B857 D1E7 B858 D1E8 B859 D1E9 B85A D1EA B861 D1EB B862 D1EC B863 D1ED B864 D1EE B865 D1EF B866 D1F0 B867 D1F1 B868 D1F2 B869 D1F3 B86A D1F5 B86B D1F6 B86C D1F7 B86D D1F9 B86E D1FA B86F D1FB B870 D1FC B871 D1FD B872 D1FE B873 D1FF B874 D200 B875 D201 B876 D202 B877 D203 B878 D204 B879 D205 B87A D206 B881 D208 B882 D20A B883 D20B B884 D20C B885 D20D B886 D20E B887 D20F B888 D211 B889 D212 B88A D213 B88B D214 B88C D215 B88D D216 B88E D217 B88F D218 B890 D219 B891 D21A B892 D21B B893 D21C B894 D21D B895 D21E B896 D21F B897 D220 B898 D221 B899 D222 B89A D223 B89B D224 B89C D225 B89D D226 B89E D227 B89F D228 B8A0 D229 B8A1 B96B B8A2 B96D B8A3 B974 B8A4 B975 B8A5 B978 B8A6 B97C B8A7 B984 B8A8 B985 B8A9 B987 B8AA B989 B8AB B98A B8AC B98D B8AD B98E B8AE B9AC B8AF B9AD B8B0 B9B0 B8B1 B9B4 B8B2 B9BC B8B3 B9BD B8B4 B9BF B8B5 B9C1 B8B6 B9C8 B8B7 B9C9 B8B8 B9CC B8B9 B9CE B8BA B9CF B8BB B9D0 B8BC B9D1 B8BD B9D2 B8BE B9D8 B8BF B9D9 B8C0 B9DB B8C1 B9DD B8C2 B9DE B8C3 B9E1 B8C4 B9E3 B8C5 B9E4 B8C6 B9E5 B8C7 B9E8 B8C8 B9EC B8C9 B9F4 B8CA B9F5 B8CB B9F7 B8CC B9F8 B8CD B9F9 B8CE B9FA B8CF BA00 B8D0 BA01 B8D1 BA08 B8D2 BA15 B8D3 BA38 B8D4 BA39 B8D5 BA3C B8D6 BA40 B8D7 BA42 B8D8 BA48 B8D9 BA49 B8DA BA4B B8DB BA4D B8DC BA4E B8DD BA53 B8DE BA54 B8DF BA55 B8E0 BA58 B8E1 BA5C B8E2 BA64 B8E3 BA65 B8E4 BA67 B8E5 BA68 B8E6 BA69 B8E7 BA70 B8E8 BA71 B8E9 BA74 B8EA BA78 B8EB BA83 B8EC BA84 B8ED BA85 B8EE BA87 B8EF BA8C B8F0 BAA8 B8F1 BAA9 B8F2 BAAB B8F3 BAAC B8F4 BAB0 B8F5 BAB2 B8F6 BAB8 B8F7 BAB9 B8F8 BABB B8F9 BABD B8FA BAC4 B8FB BAC8 B8FC BAD8 B8FD BAD9 B8FE BAFC B941 D22A B942 D22B B943 D22E B944 D22F B945 D231 B946 D232 B947 D233 B948 D235 B949 D236 B94A D237 B94B D238 B94C D239 B94D D23A B94E D23B B94F D23E B950 D240 B951 D242 B952 D243 B953 D244 B954 D245 B955 D246 B956 D247 B957 D249 B958 D24A B959 D24B B95A D24C B961 D24D B962 D24E B963 D24F B964 D250 B965 D251 B966 D252 B967 D253 B968 D254 B969 D255 B96A D256 B96B D257 B96C D258 B96D D259 B96E D25A B96F D25B B970 D25D B971 D25E B972 D25F B973 D260 B974 D261 B975 D262 B976 D263 B977 D265 B978 D266 B979 D267 B97A D268 B981 D269 B982 D26A B983 D26B B984 D26C B985 D26D B986 D26E B987 D26F B988 D270 B989 D271 B98A D272 B98B D273 B98C D274 B98D D275 B98E D276 B98F D277 B990 D278 B991 D279 B992 D27A B993 D27B B994 D27C B995 D27D B996 D27E B997 D27F B998 D282 B999 D283 B99A D285 B99B D286 B99C D287 B99D D289 B99E D28A B99F D28B B9A0 D28C B9A1 BB00 B9A2 BB04 B9A3 BB0D B9A4 BB0F B9A5 BB11 B9A6 BB18 B9A7 BB1C B9A8 BB20 B9A9 BB29 B9AA BB2B B9AB BB34 B9AC BB35 B9AD BB36 B9AE BB38 B9AF BB3B B9B0 BB3C B9B1 BB3D B9B2 BB3E B9B3 BB44 B9B4 BB45 B9B5 BB47 B9B6 BB49 B9B7 BB4D B9B8 BB4F B9B9 BB50 B9BA BB54 B9BB BB58 B9BC BB61 B9BD BB63 B9BE BB6C B9BF BB88 B9C0 BB8C B9C1 BB90 B9C2 BBA4 B9C3 BBA8 B9C4 BBAC B9C5 BBB4 B9C6 BBB7 B9C7 BBC0 B9C8 BBC4 B9C9 BBC8 B9CA BBD0 B9CB BBD3 B9CC BBF8 B9CD BBF9 B9CE BBFC B9CF BBFF B9D0 BC00 B9D1 BC02 B9D2 BC08 B9D3 BC09 B9D4 BC0B B9D5 BC0C B9D6 BC0D B9D7 BC0F B9D8 BC11 B9D9 BC14 B9DA BC15 B9DB BC16 B9DC BC17 B9DD BC18 B9DE BC1B B9DF BC1C B9E0 BC1D B9E1 BC1E B9E2 BC1F B9E3 BC24 B9E4 BC25 B9E5 BC27 B9E6 BC29 B9E7 BC2D B9E8 BC30 B9E9 BC31 B9EA BC34 B9EB BC38 B9EC BC40 B9ED BC41 B9EE BC43 B9EF BC44 B9F0 BC45 B9F1 BC49 B9F2 BC4C B9F3 BC4D B9F4 BC50 B9F5 BC5D B9F6 BC84 B9F7 BC85 B9F8 BC88 B9F9 BC8B B9FA BC8C B9FB BC8E B9FC BC94 B9FD BC95 B9FE BC97 BA41 D28D BA42 D28E BA43 D28F BA44 D292 BA45 D293 BA46 D294 BA47 D296 BA48 D297 BA49 D298 BA4A D299 BA4B D29A BA4C D29B BA4D D29D BA4E D29E BA4F D29F BA50 D2A1 BA51 D2A2 BA52 D2A3 BA53 D2A5 BA54 D2A6 BA55 D2A7 BA56 D2A8 BA57 D2A9 BA58 D2AA BA59 D2AB BA5A D2AD BA61 D2AE BA62 D2AF BA63 D2B0 BA64 D2B2 BA65 D2B3 BA66 D2B4 BA67 D2B5 BA68 D2B6 BA69 D2B7 BA6A D2BA BA6B D2BB BA6C D2BD BA6D D2BE BA6E D2C1 BA6F D2C3 BA70 D2C4 BA71 D2C5 BA72 D2C6 BA73 D2C7 BA74 D2CA BA75 D2CC BA76 D2CD BA77 D2CE BA78 D2CF BA79 D2D0 BA7A D2D1 BA81 D2D2 BA82 D2D3 BA83 D2D5 BA84 D2D6 BA85 D2D7 BA86 D2D9 BA87 D2DA BA88 D2DB BA89 D2DD BA8A D2DE BA8B D2DF BA8C D2E0 BA8D D2E1 BA8E D2E2 BA8F D2E3 BA90 D2E6 BA91 D2E7 BA92 D2E8 BA93 D2E9 BA94 D2EA BA95 D2EB BA96 D2EC BA97 D2ED BA98 D2EE BA99 D2EF BA9A D2F2 BA9B D2F3 BA9C D2F5 BA9D D2F6 BA9E D2F7 BA9F D2F9 BAA0 D2FA BAA1 BC99 BAA2 BC9A BAA3 BCA0 BAA4 BCA1 BAA5 BCA4 BAA6 BCA7 BAA7 BCA8 BAA8 BCB0 BAA9 BCB1 BAAA BCB3 BAAB BCB4 BAAC BCB5 BAAD BCBC BAAE BCBD BAAF BCC0 BAB0 BCC4 BAB1 BCCD BAB2 BCCF BAB3 BCD0 BAB4 BCD1 BAB5 BCD5 BAB6 BCD8 BAB7 BCDC BAB8 BCF4 BAB9 BCF5 BABA BCF6 BABB BCF8 BABC BCFC BABD BD04 BABE BD05 BABF BD07 BAC0 BD09 BAC1 BD10 BAC2 BD14 BAC3 BD24 BAC4 BD2C BAC5 BD40 BAC6 BD48 BAC7 BD49 BAC8 BD4C BAC9 BD50 BACA BD58 BACB BD59 BACC BD64 BACD BD68 BACE BD80 BACF BD81 BAD0 BD84 BAD1 BD87 BAD2 BD88 BAD3 BD89 BAD4 BD8A BAD5 BD90 BAD6 BD91 BAD7 BD93 BAD8 BD95 BAD9 BD99 BADA BD9A BADB BD9C BADC BDA4 BADD BDB0 BADE BDB8 BADF BDD4 BAE0 BDD5 BAE1 BDD8 BAE2 BDDC BAE3 BDE9 BAE4 BDF0 BAE5 BDF4 BAE6 BDF8 BAE7 BE00 BAE8 BE03 BAE9 BE05 BAEA BE0C BAEB BE0D BAEC BE10 BAED BE14 BAEE BE1C BAEF BE1D BAF0 BE1F BAF1 BE44 BAF2 BE45 BAF3 BE48 BAF4 BE4C BAF5 BE4E BAF6 BE54 BAF7 BE55 BAF8 BE57 BAF9 BE59 BAFA BE5A BAFB BE5B BAFC BE60 BAFD BE61 BAFE BE64 BB41 D2FB BB42 D2FC BB43 D2FD BB44 D2FE BB45 D2FF BB46 D302 BB47 D304 BB48 D306 BB49 D307 BB4A D308 BB4B D309 BB4C D30A BB4D D30B BB4E D30F BB4F D311 BB50 D312 BB51 D313 BB52 D315 BB53 D317 BB54 D318 BB55 D319 BB56 D31A BB57 D31B BB58 D31E BB59 D322 BB5A D323 BB61 D324 BB62 D326 BB63 D327 BB64 D32A BB65 D32B BB66 D32D BB67 D32E BB68 D32F BB69 D331 BB6A D332 BB6B D333 BB6C D334 BB6D D335 BB6E D336 BB6F D337 BB70 D33A BB71 D33E BB72 D33F BB73 D340 BB74 D341 BB75 D342 BB76 D343 BB77 D346 BB78 D347 BB79 D348 BB7A D349 BB81 D34A BB82 D34B BB83 D34C BB84 D34D BB85 D34E BB86 D34F BB87 D350 BB88 D351 BB89 D352 BB8A D353 BB8B D354 BB8C D355 BB8D D356 BB8E D357 BB8F D358 BB90 D359 BB91 D35A BB92 D35B BB93 D35C BB94 D35D BB95 D35E BB96 D35F BB97 D360 BB98 D361 BB99 D362 BB9A D363 BB9B D364 BB9C D365 BB9D D366 BB9E D367 BB9F D368 BBA0 D369 BBA1 BE68 BBA2 BE6A BBA3 BE70 BBA4 BE71 BBA5 BE73 BBA6 BE74 BBA7 BE75 BBA8 BE7B BBA9 BE7C BBAA BE7D BBAB BE80 BBAC BE84 BBAD BE8C BBAE BE8D BBAF BE8F BBB0 BE90 BBB1 BE91 BBB2 BE98 BBB3 BE99 BBB4 BEA8 BBB5 BED0 BBB6 BED1 BBB7 BED4 BBB8 BED7 BBB9 BED8 BBBA BEE0 BBBB BEE3 BBBC BEE4 BBBD BEE5 BBBE BEEC BBBF BF01 BBC0 BF08 BBC1 BF09 BBC2 BF18 BBC3 BF19 BBC4 BF1B BBC5 BF1C BBC6 BF1D BBC7 BF40 BBC8 BF41 BBC9 BF44 BBCA BF48 BBCB BF50 BBCC BF51 BBCD BF55 BBCE BF94 BBCF BFB0 BBD0 BFC5 BBD1 BFCC BBD2 BFCD BBD3 BFD0 BBD4 BFD4 BBD5 BFDC BBD6 BFDF BBD7 BFE1 BBD8 C03C BBD9 C051 BBDA C058 BBDB C05C BBDC C060 BBDD C068 BBDE C069 BBDF C090 BBE0 C091 BBE1 C094 BBE2 C098 BBE3 C0A0 BBE4 C0A1 BBE5 C0A3 BBE6 C0A5 BBE7 C0AC BBE8 C0AD BBE9 C0AF BBEA C0B0 BBEB C0B3 BBEC C0B4 BBED C0B5 BBEE C0B6 BBEF C0BC BBF0 C0BD BBF1 C0BF BBF2 C0C0 BBF3 C0C1 BBF4 C0C5 BBF5 C0C8 BBF6 C0C9 BBF7 C0CC BBF8 C0D0 BBF9 C0D8 BBFA C0D9 BBFB C0DB BBFC C0DC BBFD C0DD BBFE C0E4 BC41 D36A BC42 D36B BC43 D36C BC44 D36D BC45 D36E BC46 D36F BC47 D370 BC48 D371 BC49 D372 BC4A D373 BC4B D374 BC4C D375 BC4D D376 BC4E D377 BC4F D378 BC50 D379 BC51 D37A BC52 D37B BC53 D37E BC54 D37F BC55 D381 BC56 D382 BC57 D383 BC58 D385 BC59 D386 BC5A D387 BC61 D388 BC62 D389 BC63 D38A BC64 D38B BC65 D38E BC66 D392 BC67 D393 BC68 D394 BC69 D395 BC6A D396 BC6B D397 BC6C D39A BC6D D39B BC6E D39D BC6F D39E BC70 D39F BC71 D3A1 BC72 D3A2 BC73 D3A3 BC74 D3A4 BC75 D3A5 BC76 D3A6 BC77 D3A7 BC78 D3AA BC79 D3AC BC7A D3AE BC81 D3AF BC82 D3B0 BC83 D3B1 BC84 D3B2 BC85 D3B3 BC86 D3B5 BC87 D3B6 BC88 D3B7 BC89 D3B9 BC8A D3BA BC8B D3BB BC8C D3BD BC8D D3BE BC8E D3BF BC8F D3C0 BC90 D3C1 BC91 D3C2 BC92 D3C3 BC93 D3C6 BC94 D3C7 BC95 D3CA BC96 D3CB BC97 D3CC BC98 D3CD BC99 D3CE BC9A D3CF BC9B D3D1 BC9C D3D2 BC9D D3D3 BC9E D3D4 BC9F D3D5 BCA0 D3D6 BCA1 C0E5 BCA2 C0E8 BCA3 C0EC BCA4 C0F4 BCA5 C0F5 BCA6 C0F7 BCA7 C0F9 BCA8 C100 BCA9 C104 BCAA C108 BCAB C110 BCAC C115 BCAD C11C BCAE C11D BCAF C11E BCB0 C11F BCB1 C120 BCB2 C123 BCB3 C124 BCB4 C126 BCB5 C127 BCB6 C12C BCB7 C12D BCB8 C12F BCB9 C130 BCBA C131 BCBB C136 BCBC C138 BCBD C139 BCBE C13C BCBF C140 BCC0 C148 BCC1 C149 BCC2 C14B BCC3 C14C BCC4 C14D BCC5 C154 BCC6 C155 BCC7 C158 BCC8 C15C BCC9 C164 BCCA C165 BCCB C167 BCCC C168 BCCD C169 BCCE C170 BCCF C174 BCD0 C178 BCD1 C185 BCD2 C18C BCD3 C18D BCD4 C18E BCD5 C190 BCD6 C194 BCD7 C196 BCD8 C19C BCD9 C19D BCDA C19F BCDB C1A1 BCDC C1A5 BCDD C1A8 BCDE C1A9 BCDF C1AC BCE0 C1B0 BCE1 C1BD BCE2 C1C4 BCE3 C1C8 BCE4 C1CC BCE5 C1D4 BCE6 C1D7 BCE7 C1D8 BCE8 C1E0 BCE9 C1E4 BCEA C1E8 BCEB C1F0 BCEC C1F1 BCED C1F3 BCEE C1FC BCEF C1FD BCF0 C200 BCF1 C204 BCF2 C20C BCF3 C20D BCF4 C20F BCF5 C211 BCF6 C218 BCF7 C219 BCF8 C21C BCF9 C21F BCFA C220 BCFB C228 BCFC C229 BCFD C22B BCFE C22D BD41 D3D7 BD42 D3D9 BD43 D3DA BD44 D3DB BD45 D3DC BD46 D3DD BD47 D3DE BD48 D3DF BD49 D3E0 BD4A D3E2 BD4B D3E4 BD4C D3E5 BD4D D3E6 BD4E D3E7 BD4F D3E8 BD50 D3E9 BD51 D3EA BD52 D3EB BD53 D3EE BD54 D3EF BD55 D3F1 BD56 D3F2 BD57 D3F3 BD58 D3F5 BD59 D3F6 BD5A D3F7 BD61 D3F8 BD62 D3F9 BD63 D3FA BD64 D3FB BD65 D3FE BD66 D400 BD67 D402 BD68 D403 BD69 D404 BD6A D405 BD6B D406 BD6C D407 BD6D D409 BD6E D40A BD6F D40B BD70 D40C BD71 D40D BD72 D40E BD73 D40F BD74 D410 BD75 D411 BD76 D412 BD77 D413 BD78 D414 BD79 D415 BD7A D416 BD81 D417 BD82 D418 BD83 D419 BD84 D41A BD85 D41B BD86 D41C BD87 D41E BD88 D41F BD89 D420 BD8A D421 BD8B D422 BD8C D423 BD8D D424 BD8E D425 BD8F D426 BD90 D427 BD91 D428 BD92 D429 BD93 D42A BD94 D42B BD95 D42C BD96 D42D BD97 D42E BD98 D42F BD99 D430 BD9A D431 BD9B D432 BD9C D433 BD9D D434 BD9E D435 BD9F D436 BDA0 D437 BDA1 C22F BDA2 C231 BDA3 C232 BDA4 C234 BDA5 C248 BDA6 C250 BDA7 C251 BDA8 C254 BDA9 C258 BDAA C260 BDAB C265 BDAC C26C BDAD C26D BDAE C270 BDAF C274 BDB0 C27C BDB1 C27D BDB2 C27F BDB3 C281 BDB4 C288 BDB5 C289 BDB6 C290 BDB7 C298 BDB8 C29B BDB9 C29D BDBA C2A4 BDBB C2A5 BDBC C2A8 BDBD C2AC BDBE C2AD BDBF C2B4 BDC0 C2B5 BDC1 C2B7 BDC2 C2B9 BDC3 C2DC BDC4 C2DD BDC5 C2E0 BDC6 C2E3 BDC7 C2E4 BDC8 C2EB BDC9 C2EC BDCA C2ED BDCB C2EF BDCC C2F1 BDCD C2F6 BDCE C2F8 BDCF C2F9 BDD0 C2FB BDD1 C2FC BDD2 C300 BDD3 C308 BDD4 C309 BDD5 C30C BDD6 C30D BDD7 C313 BDD8 C314 BDD9 C315 BDDA C318 BDDB C31C BDDC C324 BDDD C325 BDDE C328 BDDF C329 BDE0 C345 BDE1 C368 BDE2 C369 BDE3 C36C BDE4 C370 BDE5 C372 BDE6 C378 BDE7 C379 BDE8 C37C BDE9 C37D BDEA C384 BDEB C388 BDEC C38C BDED C3C0 BDEE C3D8 BDEF C3D9 BDF0 C3DC BDF1 C3DF BDF2 C3E0 BDF3 C3E2 BDF4 C3E8 BDF5 C3E9 BDF6 C3ED BDF7 C3F4 BDF8 C3F5 BDF9 C3F8 BDFA C408 BDFB C410 BDFC C424 BDFD C42C BDFE C430 BE41 D438 BE42 D439 BE43 D43A BE44 D43B BE45 D43C BE46 D43D BE47 D43E BE48 D43F BE49 D441 BE4A D442 BE4B D443 BE4C D445 BE4D D446 BE4E D447 BE4F D448 BE50 D449 BE51 D44A BE52 D44B BE53 D44C BE54 D44D BE55 D44E BE56 D44F BE57 D450 BE58 D451 BE59 D452 BE5A D453 BE61 D454 BE62 D455 BE63 D456 BE64 D457 BE65 D458 BE66 D459 BE67 D45A BE68 D45B BE69 D45D BE6A D45E BE6B D45F BE6C D461 BE6D D462 BE6E D463 BE6F D465 BE70 D466 BE71 D467 BE72 D468 BE73 D469 BE74 D46A BE75 D46B BE76 D46C BE77 D46E BE78 D470 BE79 D471 BE7A D472 BE81 D473 BE82 D474 BE83 D475 BE84 D476 BE85 D477 BE86 D47A BE87 D47B BE88 D47D BE89 D47E BE8A D481 BE8B D483 BE8C D484 BE8D D485 BE8E D486 BE8F D487 BE90 D48A BE91 D48C BE92 D48E BE93 D48F BE94 D490 BE95 D491 BE96 D492 BE97 D493 BE98 D495 BE99 D496 BE9A D497 BE9B D498 BE9C D499 BE9D D49A BE9E D49B BE9F D49C BEA0 D49D BEA1 C434 BEA2 C43C BEA3 C43D BEA4 C448 BEA5 C464 BEA6 C465 BEA7 C468 BEA8 C46C BEA9 C474 BEAA C475 BEAB C479 BEAC C480 BEAD C494 BEAE C49C BEAF C4B8 BEB0 C4BC BEB1 C4E9 BEB2 C4F0 BEB3 C4F1 BEB4 C4F4 BEB5 C4F8 BEB6 C4FA BEB7 C4FF BEB8 C500 BEB9 C501 BEBA C50C BEBB C510 BEBC C514 BEBD C51C BEBE C528 BEBF C529 BEC0 C52C BEC1 C530 BEC2 C538 BEC3 C539 BEC4 C53B BEC5 C53D BEC6 C544 BEC7 C545 BEC8 C548 BEC9 C549 BECA C54A BECB C54C BECC C54D BECD C54E BECE C553 BECF C554 BED0 C555 BED1 C557 BED2 C558 BED3 C559 BED4 C55D BED5 C55E BED6 C560 BED7 C561 BED8 C564 BED9 C568 BEDA C570 BEDB C571 BEDC C573 BEDD C574 BEDE C575 BEDF C57C BEE0 C57D BEE1 C580 BEE2 C584 BEE3 C587 BEE4 C58C BEE5 C58D BEE6 C58F BEE7 C591 BEE8 C595 BEE9 C597 BEEA C598 BEEB C59C BEEC C5A0 BEED C5A9 BEEE C5B4 BEEF C5B5 BEF0 C5B8 BEF1 C5B9 BEF2 C5BB BEF3 C5BC BEF4 C5BD BEF5 C5BE BEF6 C5C4 BEF7 C5C5 BEF8 C5C6 BEF9 C5C7 BEFA C5C8 BEFB C5C9 BEFC C5CA BEFD C5CC BEFE C5CE BF41 D49E BF42 D49F BF43 D4A0 BF44 D4A1 BF45 D4A2 BF46 D4A3 BF47 D4A4 BF48 D4A5 BF49 D4A6 BF4A D4A7 BF4B D4A8 BF4C D4AA BF4D D4AB BF4E D4AC BF4F D4AD BF50 D4AE BF51 D4AF BF52 D4B0 BF53 D4B1 BF54 D4B2 BF55 D4B3 BF56 D4B4 BF57 D4B5 BF58 D4B6 BF59 D4B7 BF5A D4B8 BF61 D4B9 BF62 D4BA BF63 D4BB BF64 D4BC BF65 D4BD BF66 D4BE BF67 D4BF BF68 D4C0 BF69 D4C1 BF6A D4C2 BF6B D4C3 BF6C D4C4 BF6D D4C5 BF6E D4C6 BF6F D4C7 BF70 D4C8 BF71 D4C9 BF72 D4CA BF73 D4CB BF74 D4CD BF75 D4CE BF76 D4CF BF77 D4D1 BF78 D4D2 BF79 D4D3 BF7A D4D5 BF81 D4D6 BF82 D4D7 BF83 D4D8 BF84 D4D9 BF85 D4DA BF86 D4DB BF87 D4DD BF88 D4DE BF89 D4E0 BF8A D4E1 BF8B D4E2 BF8C D4E3 BF8D D4E4 BF8E D4E5 BF8F D4E6 BF90 D4E7 BF91 D4E9 BF92 D4EA BF93 D4EB BF94 D4ED BF95 D4EE BF96 D4EF BF97 D4F1 BF98 D4F2 BF99 D4F3 BF9A D4F4 BF9B D4F5 BF9C D4F6 BF9D D4F7 BF9E D4F9 BF9F D4FA BFA0 D4FC BFA1 C5D0 BFA2 C5D1 BFA3 C5D4 BFA4 C5D8 BFA5 C5E0 BFA6 C5E1 BFA7 C5E3 BFA8 C5E5 BFA9 C5EC BFAA C5ED BFAB C5EE BFAC C5F0 BFAD C5F4 BFAE C5F6 BFAF C5F7 BFB0 C5FC BFB1 C5FD BFB2 C5FE BFB3 C5FF BFB4 C600 BFB5 C601 BFB6 C605 BFB7 C606 BFB8 C607 BFB9 C608 BFBA C60C BFBB C610 BFBC C618 BFBD C619 BFBE C61B BFBF C61C BFC0 C624 BFC1 C625 BFC2 C628 BFC3 C62C BFC4 C62D BFC5 C62E BFC6 C630 BFC7 C633 BFC8 C634 BFC9 C635 BFCA C637 BFCB C639 BFCC C63B BFCD C640 BFCE C641 BFCF C644 BFD0 C648 BFD1 C650 BFD2 C651 BFD3 C653 BFD4 C654 BFD5 C655 BFD6 C65C BFD7 C65D BFD8 C660 BFD9 C66C BFDA C66F BFDB C671 BFDC C678 BFDD C679 BFDE C67C BFDF C680 BFE0 C688 BFE1 C689 BFE2 C68B BFE3 C68D BFE4 C694 BFE5 C695 BFE6 C698 BFE7 C69C BFE8 C6A4 BFE9 C6A5 BFEA C6A7 BFEB C6A9 BFEC C6B0 BFED C6B1 BFEE C6B4 BFEF C6B8 BFF0 C6B9 BFF1 C6BA BFF2 C6C0 BFF3 C6C1 BFF4 C6C3 BFF5 C6C5 BFF6 C6CC BFF7 C6CD BFF8 C6D0 BFF9 C6D4 BFFA C6DC BFFB C6DD BFFC C6E0 BFFD C6E1 BFFE C6E8 C041 D4FE C042 D4FF C043 D500 C044 D501 C045 D502 C046 D503 C047 D505 C048 D506 C049 D507 C04A D509 C04B D50A C04C D50B C04D D50D C04E D50E C04F D50F C050 D510 C051 D511 C052 D512 C053 D513 C054 D516 C055 D518 C056 D519 C057 D51A C058 D51B C059 D51C C05A D51D C061 D51E C062 D51F C063 D520 C064 D521 C065 D522 C066 D523 C067 D524 C068 D525 C069 D526 C06A D527 C06B D528 C06C D529 C06D D52A C06E D52B C06F D52C C070 D52D C071 D52E C072 D52F C073 D530 C074 D531 C075 D532 C076 D533 C077 D534 C078 D535 C079 D536 C07A D537 C081 D538 C082 D539 C083 D53A C084 D53B C085 D53E C086 D53F C087 D541 C088 D542 C089 D543 C08A D545 C08B D546 C08C D547 C08D D548 C08E D549 C08F D54A C090 D54B C091 D54E C092 D550 C093 D552 C094 D553 C095 D554 C096 D555 C097 D556 C098 D557 C099 D55A C09A D55B C09B D55D C09C D55E C09D D55F C09E D561 C09F D562 C0A0 D563 C0A1 C6E9 C0A2 C6EC C0A3 C6F0 C0A4 C6F8 C0A5 C6F9 C0A6 C6FD C0A7 C704 C0A8 C705 C0A9 C708 C0AA C70C C0AB C714 C0AC C715 C0AD C717 C0AE C719 C0AF C720 C0B0 C721 C0B1 C724 C0B2 C728 C0B3 C730 C0B4 C731 C0B5 C733 C0B6 C735 C0B7 C737 C0B8 C73C C0B9 C73D C0BA C740 C0BB C744 C0BC C74A C0BD C74C C0BE C74D C0BF C74F C0C0 C751 C0C1 C752 C0C2 C753 C0C3 C754 C0C4 C755 C0C5 C756 C0C6 C757 C0C7 C758 C0C8 C75C C0C9 C760 C0CA C768 C0CB C76B C0CC C774 C0CD C775 C0CE C778 C0CF C77C C0D0 C77D C0D1 C77E C0D2 C783 C0D3 C784 C0D4 C785 C0D5 C787 C0D6 C788 C0D7 C789 C0D8 C78A C0D9 C78E C0DA C790 C0DB C791 C0DC C794 C0DD C796 C0DE C797 C0DF C798 C0E0 C79A C0E1 C7A0 C0E2 C7A1 C0E3 C7A3 C0E4 C7A4 C0E5 C7A5 C0E6 C7A6 C0E7 C7AC C0E8 C7AD C0E9 C7B0 C0EA C7B4 C0EB C7BC C0EC C7BD C0ED C7BF C0EE C7C0 C0EF C7C1 C0F0 C7C8 C0F1 C7C9 C0F2 C7CC C0F3 C7CE C0F4 C7D0 C0F5 C7D8 C0F6 C7DD C0F7 C7E4 C0F8 C7E8 C0F9 C7EC C0FA C800 C0FB C801 C0FC C804 C0FD C808 C0FE C80A C141 D564 C142 D566 C143 D567 C144 D56A C145 D56C C146 D56E C147 D56F C148 D570 C149 D571 C14A D572 C14B D573 C14C D576 C14D D577 C14E D579 C14F D57A C150 D57B C151 D57D C152 D57E C153 D57F C154 D580 C155 D581 C156 D582 C157 D583 C158 D586 C159 D58A C15A D58B C161 D58C C162 D58D C163 D58E C164 D58F C165 D591 C166 D592 C167 D593 C168 D594 C169 D595 C16A D596 C16B D597 C16C D598 C16D D599 C16E D59A C16F D59B C170 D59C C171 D59D C172 D59E C173 D59F C174 D5A0 C175 D5A1 C176 D5A2 C177 D5A3 C178 D5A4 C179 D5A6 C17A D5A7 C181 D5A8 C182 D5A9 C183 D5AA C184 D5AB C185 D5AC C186 D5AD C187 D5AE C188 D5AF C189 D5B0 C18A D5B1 C18B D5B2 C18C D5B3 C18D D5B4 C18E D5B5 C18F D5B6 C190 D5B7 C191 D5B8 C192 D5B9 C193 D5BA C194 D5BB C195 D5BC C196 D5BD C197 D5BE C198 D5BF C199 D5C0 C19A D5C1 C19B D5C2 C19C D5C3 C19D D5C4 C19E D5C5 C19F D5C6 C1A0 D5C7 C1A1 C810 C1A2 C811 C1A3 C813 C1A4 C815 C1A5 C816 C1A6 C81C C1A7 C81D C1A8 C820 C1A9 C824 C1AA C82C C1AB C82D C1AC C82F C1AD C831 C1AE C838 C1AF C83C C1B0 C840 C1B1 C848 C1B2 C849 C1B3 C84C C1B4 C84D C1B5 C854 C1B6 C870 C1B7 C871 C1B8 C874 C1B9 C878 C1BA C87A C1BB C880 C1BC C881 C1BD C883 C1BE C885 C1BF C886 C1C0 C887 C1C1 C88B C1C2 C88C C1C3 C88D C1C4 C894 C1C5 C89D C1C6 C89F C1C7 C8A1 C1C8 C8A8 C1C9 C8BC C1CA C8BD C1CB C8C4 C1CC C8C8 C1CD C8CC C1CE C8D4 C1CF C8D5 C1D0 C8D7 C1D1 C8D9 C1D2 C8E0 C1D3 C8E1 C1D4 C8E4 C1D5 C8F5 C1D6 C8FC C1D7 C8FD C1D8 C900 C1D9 C904 C1DA C905 C1DB C906 C1DC C90C C1DD C90D C1DE C90F C1DF C911 C1E0 C918 C1E1 C92C C1E2 C934 C1E3 C950 C1E4 C951 C1E5 C954 C1E6 C958 C1E7 C960 C1E8 C961 C1E9 C963 C1EA C96C C1EB C970 C1EC C974 C1ED C97C C1EE C988 C1EF C989 C1F0 C98C C1F1 C990 C1F2 C998 C1F3 C999 C1F4 C99B C1F5 C99D C1F6 C9C0 C1F7 C9C1 C1F8 C9C4 C1F9 C9C7 C1FA C9C8 C1FB C9CA C1FC C9D0 C1FD C9D1 C1FE C9D3 C241 D5CA C242 D5CB C243 D5CD C244 D5CE C245 D5CF C246 D5D1 C247 D5D3 C248 D5D4 C249 D5D5 C24A D5D6 C24B D5D7 C24C D5DA C24D D5DC C24E D5DE C24F D5DF C250 D5E0 C251 D5E1 C252 D5E2 C253 D5E3 C254 D5E6 C255 D5E7 C256 D5E9 C257 D5EA C258 D5EB C259 D5ED C25A D5EE C261 D5EF C262 D5F0 C263 D5F1 C264 D5F2 C265 D5F3 C266 D5F6 C267 D5F8 C268 D5FA C269 D5FB C26A D5FC C26B D5FD C26C D5FE C26D D5FF C26E D602 C26F D603 C270 D605 C271 D606 C272 D607 C273 D609 C274 D60A C275 D60B C276 D60C C277 D60D C278 D60E C279 D60F C27A D612 C281 D616 C282 D617 C283 D618 C284 D619 C285 D61A C286 D61B C287 D61D C288 D61E C289 D61F C28A D621 C28B D622 C28C D623 C28D D625 C28E D626 C28F D627 C290 D628 C291 D629 C292 D62A C293 D62B C294 D62C C295 D62E C296 D62F C297 D630 C298 D631 C299 D632 C29A D633 C29B D634 C29C D635 C29D D636 C29E D637 C29F D63A C2A0 D63B C2A1 C9D5 C2A2 C9D6 C2A3 C9D9 C2A4 C9DA C2A5 C9DC C2A6 C9DD C2A7 C9E0 C2A8 C9E2 C2A9 C9E4 C2AA C9E7 C2AB C9EC C2AC C9ED C2AD C9EF C2AE C9F0 C2AF C9F1 C2B0 C9F8 C2B1 C9F9 C2B2 C9FC C2B3 CA00 C2B4 CA08 C2B5 CA09 C2B6 CA0B C2B7 CA0C C2B8 CA0D C2B9 CA14 C2BA CA18 C2BB CA29 C2BC CA4C C2BD CA4D C2BE CA50 C2BF CA54 C2C0 CA5C C2C1 CA5D C2C2 CA5F C2C3 CA60 C2C4 CA61 C2C5 CA68 C2C6 CA7D C2C7 CA84 C2C8 CA98 C2C9 CABC C2CA CABD C2CB CAC0 C2CC CAC4 C2CD CACC C2CE CACD C2CF CACF C2D0 CAD1 C2D1 CAD3 C2D2 CAD8 C2D3 CAD9 C2D4 CAE0 C2D5 CAEC C2D6 CAF4 C2D7 CB08 C2D8 CB10 C2D9 CB14 C2DA CB18 C2DB CB20 C2DC CB21 C2DD CB41 C2DE CB48 C2DF CB49 C2E0 CB4C C2E1 CB50 C2E2 CB58 C2E3 CB59 C2E4 CB5D C2E5 CB64 C2E6 CB78 C2E7 CB79 C2E8 CB9C C2E9 CBB8 C2EA CBD4 C2EB CBE4 C2EC CBE7 C2ED CBE9 C2EE CC0C C2EF CC0D C2F0 CC10 C2F1 CC14 C2F2 CC1C C2F3 CC1D C2F4 CC21 C2F5 CC22 C2F6 CC27 C2F7 CC28 C2F8 CC29 C2F9 CC2C C2FA CC2E C2FB CC30 C2FC CC38 C2FD CC39 C2FE CC3B C341 D63D C342 D63E C343 D63F C344 D641 C345 D642 C346 D643 C347 D644 C348 D646 C349 D647 C34A D64A C34B D64C C34C D64E C34D D64F C34E D650 C34F D652 C350 D653 C351 D656 C352 D657 C353 D659 C354 D65A C355 D65B C356 D65D C357 D65E C358 D65F C359 D660 C35A D661 C361 D662 C362 D663 C363 D664 C364 D665 C365 D666 C366 D668 C367 D66A C368 D66B C369 D66C C36A D66D C36B D66E C36C D66F C36D D672 C36E D673 C36F D675 C370 D676 C371 D677 C372 D678 C373 D679 C374 D67A C375 D67B C376 D67C C377 D67D C378 D67E C379 D67F C37A D680 C381 D681 C382 D682 C383 D684 C384 D686 C385 D687 C386 D688 C387 D689 C388 D68A C389 D68B C38A D68E C38B D68F C38C D691 C38D D692 C38E D693 C38F D695 C390 D696 C391 D697 C392 D698 C393 D699 C394 D69A C395 D69B C396 D69C C397 D69E C398 D6A0 C399 D6A2 C39A D6A3 C39B D6A4 C39C D6A5 C39D D6A6 C39E D6A7 C39F D6A9 C3A0 D6AA C3A1 CC3C C3A2 CC3D C3A3 CC3E C3A4 CC44 C3A5 CC45 C3A6 CC48 C3A7 CC4C C3A8 CC54 C3A9 CC55 C3AA CC57 C3AB CC58 C3AC CC59 C3AD CC60 C3AE CC64 C3AF CC66 C3B0 CC68 C3B1 CC70 C3B2 CC75 C3B3 CC98 C3B4 CC99 C3B5 CC9C C3B6 CCA0 C3B7 CCA8 C3B8 CCA9 C3B9 CCAB C3BA CCAC C3BB CCAD C3BC CCB4 C3BD CCB5 C3BE CCB8 C3BF CCBC C3C0 CCC4 C3C1 CCC5 C3C2 CCC7 C3C3 CCC9 C3C4 CCD0 C3C5 CCD4 C3C6 CCE4 C3C7 CCEC C3C8 CCF0 C3C9 CD01 C3CA CD08 C3CB CD09 C3CC CD0C C3CD CD10 C3CE CD18 C3CF CD19 C3D0 CD1B C3D1 CD1D C3D2 CD24 C3D3 CD28 C3D4 CD2C C3D5 CD39 C3D6 CD5C C3D7 CD60 C3D8 CD64 C3D9 CD6C C3DA CD6D C3DB CD6F C3DC CD71 C3DD CD78 C3DE CD88 C3DF CD94 C3E0 CD95 C3E1 CD98 C3E2 CD9C C3E3 CDA4 C3E4 CDA5 C3E5 CDA7 C3E6 CDA9 C3E7 CDB0 C3E8 CDC4 C3E9 CDCC C3EA CDD0 C3EB CDE8 C3EC CDEC C3ED CDF0 C3EE CDF8 C3EF CDF9 C3F0 CDFB C3F1 CDFD C3F2 CE04 C3F3 CE08 C3F4 CE0C C3F5 CE14 C3F6 CE19 C3F7 CE20 C3F8 CE21 C3F9 CE24 C3FA CE28 C3FB CE30 C3FC CE31 C3FD CE33 C3FE CE35 C441 D6AB C442 D6AD C443 D6AE C444 D6AF C445 D6B1 C446 D6B2 C447 D6B3 C448 D6B4 C449 D6B5 C44A D6B6 C44B D6B7 C44C D6B8 C44D D6BA C44E D6BC C44F D6BD C450 D6BE C451 D6BF C452 D6C0 C453 D6C1 C454 D6C2 C455 D6C3 C456 D6C6 C457 D6C7 C458 D6C9 C459 D6CA C45A D6CB C461 D6CD C462 D6CE C463 D6CF C464 D6D0 C465 D6D2 C466 D6D3 C467 D6D5 C468 D6D6 C469 D6D8 C46A D6DA C46B D6DB C46C D6DC C46D D6DD C46E D6DE C46F D6DF C470 D6E1 C471 D6E2 C472 D6E3 C473 D6E5 C474 D6E6 C475 D6E7 C476 D6E9 C477 D6EA C478 D6EB C479 D6EC C47A D6ED C481 D6EE C482 D6EF C483 D6F1 C484 D6F2 C485 D6F3 C486 D6F4 C487 D6F6 C488 D6F7 C489 D6F8 C48A D6F9 C48B D6FA C48C D6FB C48D D6FE C48E D6FF C48F D701 C490 D702 C491 D703 C492 D705 C493 D706 C494 D707 C495 D708 C496 D709 C497 D70A C498 D70B C499 D70C C49A D70D C49B D70E C49C D70F C49D D710 C49E D712 C49F D713 C4A0 D714 C4A1 CE58 C4A2 CE59 C4A3 CE5C C4A4 CE5F C4A5 CE60 C4A6 CE61 C4A7 CE68 C4A8 CE69 C4A9 CE6B C4AA CE6D C4AB CE74 C4AC CE75 C4AD CE78 C4AE CE7C C4AF CE84 C4B0 CE85 C4B1 CE87 C4B2 CE89 C4B3 CE90 C4B4 CE91 C4B5 CE94 C4B6 CE98 C4B7 CEA0 C4B8 CEA1 C4B9 CEA3 C4BA CEA4 C4BB CEA5 C4BC CEAC C4BD CEAD C4BE CEC1 C4BF CEE4 C4C0 CEE5 C4C1 CEE8 C4C2 CEEB C4C3 CEEC C4C4 CEF4 C4C5 CEF5 C4C6 CEF7 C4C7 CEF8 C4C8 CEF9 C4C9 CF00 C4CA CF01 C4CB CF04 C4CC CF08 C4CD CF10 C4CE CF11 C4CF CF13 C4D0 CF15 C4D1 CF1C C4D2 CF20 C4D3 CF24 C4D4 CF2C C4D5 CF2D C4D6 CF2F C4D7 CF30 C4D8 CF31 C4D9 CF38 C4DA CF54 C4DB CF55 C4DC CF58 C4DD CF5C C4DE CF64 C4DF CF65 C4E0 CF67 C4E1 CF69 C4E2 CF70 C4E3 CF71 C4E4 CF74 C4E5 CF78 C4E6 CF80 C4E7 CF85 C4E8 CF8C C4E9 CFA1 C4EA CFA8 C4EB CFB0 C4EC CFC4 C4ED CFE0 C4EE CFE1 C4EF CFE4 C4F0 CFE8 C4F1 CFF0 C4F2 CFF1 C4F3 CFF3 C4F4 CFF5 C4F5 CFFC C4F6 D000 C4F7 D004 C4F8 D011 C4F9 D018 C4FA D02D C4FB D034 C4FC D035 C4FD D038 C4FE D03C C541 D715 C542 D716 C543 D717 C544 D71A C545 D71B C546 D71D C547 D71E C548 D71F C549 D721 C54A D722 C54B D723 C54C D724 C54D D725 C54E D726 C54F D727 C550 D72A C551 D72C C552 D72E C553 D72F C554 D730 C555 D731 C556 D732 C557 D733 C558 D736 C559 D737 C55A D739 C561 D73A C562 D73B C563 D73D C564 D73E C565 D73F C566 D740 C567 D741 C568 D742 C569 D743 C56A D745 C56B D746 C56C D748 C56D D74A C56E D74B C56F D74C C570 D74D C571 D74E C572 D74F C573 D752 C574 D753 C575 D755 C576 D75A C577 D75B C578 D75C C579 D75D C57A D75E C581 D75F C582 D762 C583 D764 C584 D766 C585 D767 C586 D768 C587 D76A C588 D76B C589 D76D C58A D76E C58B D76F C58C D771 C58D D772 C58E D773 C58F D775 C590 D776 C591 D777 C592 D778 C593 D779 C594 D77A C595 D77B C596 D77E C597 D77F C598 D780 C599 D782 C59A D783 C59B D784 C59C D785 C59D D786 C59E D787 C59F D78A C5A0 D78B C5A1 D044 C5A2 D045 C5A3 D047 C5A4 D049 C5A5 D050 C5A6 D054 C5A7 D058 C5A8 D060 C5A9 D06C C5AA D06D C5AB D070 C5AC D074 C5AD D07C C5AE D07D C5AF D081 C5B0 D0A4 C5B1 D0A5 C5B2 D0A8 C5B3 D0AC C5B4 D0B4 C5B5 D0B5 C5B6 D0B7 C5B7 D0B9 C5B8 D0C0 C5B9 D0C1 C5BA D0C4 C5BB D0C8 C5BC D0C9 C5BD D0D0 C5BE D0D1 C5BF D0D3 C5C0 D0D4 C5C1 D0D5 C5C2 D0DC C5C3 D0DD C5C4 D0E0 C5C5 D0E4 C5C6 D0EC C5C7 D0ED C5C8 D0EF C5C9 D0F0 C5CA D0F1 C5CB D0F8 C5CC D10D C5CD D130 C5CE D131 C5CF D134 C5D0 D138 C5D1 D13A C5D2 D140 C5D3 D141 C5D4 D143 C5D5 D144 C5D6 D145 C5D7 D14C C5D8 D14D C5D9 D150 C5DA D154 C5DB D15C C5DC D15D C5DD D15F C5DE D161 C5DF D168 C5E0 D16C C5E1 D17C C5E2 D184 C5E3 D188 C5E4 D1A0 C5E5 D1A1 C5E6 D1A4 C5E7 D1A8 C5E8 D1B0 C5E9 D1B1 C5EA D1B3 C5EB D1B5 C5EC D1BA C5ED D1BC C5EE D1C0 C5EF D1D8 C5F0 D1F4 C5F1 D1F8 C5F2 D207 C5F3 D209 C5F4 D210 C5F5 D22C C5F6 D22D C5F7 D230 C5F8 D234 C5F9 D23C C5FA D23D C5FB D23F C5FC D241 C5FD D248 C5FE D25C C641 D78D C642 D78E C643 D78F C644 D791 C645 D792 C646 D793 C647 D794 C648 D795 C649 D796 C64A D797 C64B D79A C64C D79C C64D D79E C64E D79F C64F D7A0 C650 D7A1 C651 D7A2 C652 D7A3 C6A1 D264 C6A2 D280 C6A3 D281 C6A4 D284 C6A5 D288 C6A6 D290 C6A7 D291 C6A8 D295 C6A9 D29C C6AA D2A0 C6AB D2A4 C6AC D2AC C6AD D2B1 C6AE D2B8 C6AF D2B9 C6B0 D2BC C6B1 D2BF C6B2 D2C0 C6B3 D2C2 C6B4 D2C8 C6B5 D2C9 C6B6 D2CB C6B7 D2D4 C6B8 D2D8 C6B9 D2DC C6BA D2E4 C6BB D2E5 C6BC D2F0 C6BD D2F1 C6BE D2F4 C6BF D2F8 C6C0 D300 C6C1 D301 C6C2 D303 C6C3 D305 C6C4 D30C C6C5 D30D C6C6 D30E C6C7 D310 C6C8 D314 C6C9 D316 C6CA D31C C6CB D31D C6CC D31F C6CD D320 C6CE D321 C6CF D325 C6D0 D328 C6D1 D329 C6D2 D32C C6D3 D330 C6D4 D338 C6D5 D339 C6D6 D33B C6D7 D33C C6D8 D33D C6D9 D344 C6DA D345 C6DB D37C C6DC D37D C6DD D380 C6DE D384 C6DF D38C C6E0 D38D C6E1 D38F C6E2 D390 C6E3 D391 C6E4 D398 C6E5 D399 C6E6 D39C C6E7 D3A0 C6E8 D3A8 C6E9 D3A9 C6EA D3AB C6EB D3AD C6EC D3B4 C6ED D3B8 C6EE D3BC C6EF D3C4 C6F0 D3C5 C6F1 D3C8 C6F2 D3C9 C6F3 D3D0 C6F4 D3D8 C6F5 D3E1 C6F6 D3E3 C6F7 D3EC C6F8 D3ED C6F9 D3F0 C6FA D3F4 C6FB D3FC C6FC D3FD C6FD D3FF C6FE D401 C7A1 D408 C7A2 D41D C7A3 D440 C7A4 D444 C7A5 D45C C7A6 D460 C7A7 D464 C7A8 D46D C7A9 D46F C7AA D478 C7AB D479 C7AC D47C C7AD D47F C7AE D480 C7AF D482 C7B0 D488 C7B1 D489 C7B2 D48B C7B3 D48D C7B4 D494 C7B5 D4A9 C7B6 D4CC C7B7 D4D0 C7B8 D4D4 C7B9 D4DC C7BA D4DF C7BB D4E8 C7BC D4EC C7BD D4F0 C7BE D4F8 C7BF D4FB C7C0 D4FD C7C1 D504 C7C2 D508 C7C3 D50C C7C4 D514 C7C5 D515 C7C6 D517 C7C7 D53C C7C8 D53D C7C9 D540 C7CA D544 C7CB D54C C7CC D54D C7CD D54F C7CE D551 C7CF D558 C7D0 D559 C7D1 D55C C7D2 D560 C7D3 D565 C7D4 D568 C7D5 D569 C7D6 D56B C7D7 D56D C7D8 D574 C7D9 D575 C7DA D578 C7DB D57C C7DC D584 C7DD D585 C7DE D587 C7DF D588 C7E0 D589 C7E1 D590 C7E2 D5A5 C7E3 D5C8 C7E4 D5C9 C7E5 D5CC C7E6 D5D0 C7E7 D5D2 C7E8 D5D8 C7E9 D5D9 C7EA D5DB C7EB D5DD C7EC D5E4 C7ED D5E5 C7EE D5E8 C7EF D5EC C7F0 D5F4 C7F1 D5F5 C7F2 D5F7 C7F3 D5F9 C7F4 D600 C7F5 D601 C7F6 D604 C7F7 D608 C7F8 D610 C7F9 D611 C7FA D613 C7FB D614 C7FC D615 C7FD D61C C7FE D620 C8A1 D624 C8A2 D62D C8A3 D638 C8A4 D639 C8A5 D63C C8A6 D640 C8A7 D645 C8A8 D648 C8A9 D649 C8AA D64B C8AB D64D C8AC D651 C8AD D654 C8AE D655 C8AF D658 C8B0 D65C C8B1 D667 C8B2 D669 C8B3 D670 C8B4 D671 C8B5 D674 C8B6 D683 C8B7 D685 C8B8 D68C C8B9 D68D C8BA D690 C8BB D694 C8BC D69D C8BD D69F C8BE D6A1 C8BF D6A8 C8C0 D6AC C8C1 D6B0 C8C2 D6B9 C8C3 D6BB C8C4 D6C4 C8C5 D6C5 C8C6 D6C8 C8C7 D6CC C8C8 D6D1 C8C9 D6D4 C8CA D6D7 C8CB D6D9 C8CC D6E0 C8CD D6E4 C8CE D6E8 C8CF D6F0 C8D0 D6F5 C8D1 D6FC C8D2 D6FD C8D3 D700 C8D4 D704 C8D5 D711 C8D6 D718 C8D7 D719 C8D8 D71C C8D9 D720 C8DA D728 C8DB D729 C8DC D72B C8DD D72D C8DE D734 C8DF D735 C8E0 D738 C8E1 D73C C8E2 D744 C8E3 D747 C8E4 D749 C8E5 D750 C8E6 D751 C8E7 D754 C8E8 D756 C8E9 D757 C8EA D758 C8EB D759 C8EC D760 C8ED D761 C8EE D763 C8EF D765 C8F0 D769 C8F1 D76C C8F2 D770 C8F3 D774 C8F4 D77C C8F5 D77D C8F6 D781 C8F7 D788 C8F8 D789 C8F9 D78C C8FA D790 C8FB D798 C8FC D799 C8FD D79B C8FE D79D CAA1 4F3D CAA2 4F73 CAA3 5047 CAA4 50F9 CAA5 52A0 CAA6 53EF CAA7 5475 CAA8 54E5 CAA9 5609 CAAA 5AC1 CAAB 5BB6 CAAC 6687 CAAD 67B6 CAAE 67B7 CAAF 67EF CAB0 6B4C CAB1 73C2 CAB2 75C2 CAB3 7A3C CAB4 82DB CAB5 8304 CAB6 8857 CAB7 8888 CAB8 8A36 CAB9 8CC8 CABA 8DCF CABB 8EFB CABC 8FE6 CABD 99D5 CABE 523B CABF 5374 CAC0 5404 CAC1 606A CAC2 6164 CAC3 6BBC CAC4 73CF CAC5 811A CAC6 89BA CAC7 89D2 CAC8 95A3 CAC9 4F83 CACA 520A CACB 58BE CACC 5978 CACD 59E6 CACE 5E72 CACF 5E79 CAD0 61C7 CAD1 63C0 CAD2 6746 CAD3 67EC CAD4 687F CAD5 6F97 CAD6 764E CAD7 770B CAD8 78F5 CAD9 7A08 CADA 7AFF CADB 7C21 CADC 809D CADD 826E CADE 8271 CADF 8AEB CAE0 9593 CAE1 4E6B CAE2 559D CAE3 66F7 CAE4 6E34 CAE5 78A3 CAE6 7AED CAE7 845B CAE8 8910 CAE9 874E CAEA 97A8 CAEB 52D8 CAEC 574E CAED 582A CAEE 5D4C CAEF 611F CAF0 61BE CAF1 6221 CAF2 6562 CAF3 67D1 CAF4 6A44 CAF5 6E1B CAF6 7518 CAF7 75B3 CAF8 76E3 CAF9 77B0 CAFA 7D3A CAFB 90AF CAFC 9451 CAFD 9452 CAFE 9F95 CBA1 5323 CBA2 5CAC CBA3 7532 CBA4 80DB CBA5 9240 CBA6 9598 CBA7 525B CBA8 5808 CBA9 59DC CBAA 5CA1 CBAB 5D17 CBAC 5EB7 CBAD 5F3A CBAE 5F4A CBAF 6177 CBB0 6C5F CBB1 757A CBB2 7586 CBB3 7CE0 CBB4 7D73 CBB5 7DB1 CBB6 7F8C CBB7 8154 CBB8 8221 CBB9 8591 CBBA 8941 CBBB 8B1B CBBC 92FC CBBD 964D CBBE 9C47 CBBF 4ECB CBC0 4EF7 CBC1 500B CBC2 51F1 CBC3 584F CBC4 6137 CBC5 613E CBC6 6168 CBC7 6539 CBC8 69EA CBC9 6F11 CBCA 75A5 CBCB 7686 CBCC 76D6 CBCD 7B87 CBCE 82A5 CBCF 84CB CBD0 F900 CBD1 93A7 CBD2 958B CBD3 5580 CBD4 5BA2 CBD5 5751 CBD6 F901 CBD7 7CB3 CBD8 7FB9 CBD9 91B5 CBDA 5028 CBDB 53BB CBDC 5C45 CBDD 5DE8 CBDE 62D2 CBDF 636E CBE0 64DA CBE1 64E7 CBE2 6E20 CBE3 70AC CBE4 795B CBE5 8DDD CBE6 8E1E CBE7 F902 CBE8 907D CBE9 9245 CBEA 92F8 CBEB 4E7E CBEC 4EF6 CBED 5065 CBEE 5DFE CBEF 5EFA CBF0 6106 CBF1 6957 CBF2 8171 CBF3 8654 CBF4 8E47 CBF5 9375 CBF6 9A2B CBF7 4E5E CBF8 5091 CBF9 6770 CBFA 6840 CBFB 5109 CBFC 528D CBFD 5292 CBFE 6AA2 CCA1 77BC CCA2 9210 CCA3 9ED4 CCA4 52AB CCA5 602F CCA6 8FF2 CCA7 5048 CCA8 61A9 CCA9 63ED CCAA 64CA CCAB 683C CCAC 6A84 CCAD 6FC0 CCAE 8188 CCAF 89A1 CCB0 9694 CCB1 5805 CCB2 727D CCB3 72AC CCB4 7504 CCB5 7D79 CCB6 7E6D CCB7 80A9 CCB8 898B CCB9 8B74 CCBA 9063 CCBB 9D51 CCBC 6289 CCBD 6C7A CCBE 6F54 CCBF 7D50 CCC0 7F3A CCC1 8A23 CCC2 517C CCC3 614A CCC4 7B9D CCC5 8B19 CCC6 9257 CCC7 938C CCC8 4EAC CCC9 4FD3 CCCA 501E CCCB 50BE CCCC 5106 CCCD 52C1 CCCE 52CD CCCF 537F CCD0 5770 CCD1 5883 CCD2 5E9A CCD3 5F91 CCD4 6176 CCD5 61AC CCD6 64CE CCD7 656C CCD8 666F CCD9 66BB CCDA 66F4 CCDB 6897 CCDC 6D87 CCDD 7085 CCDE 70F1 CCDF 749F CCE0 74A5 CCE1 74CA CCE2 75D9 CCE3 786C CCE4 78EC CCE5 7ADF CCE6 7AF6 CCE7 7D45 CCE8 7D93 CCE9 8015 CCEA 803F CCEB 811B CCEC 8396 CCED 8B66 CCEE 8F15 CCEF 9015 CCF0 93E1 CCF1 9803 CCF2 9838 CCF3 9A5A CCF4 9BE8 CCF5 4FC2 CCF6 5553 CCF7 583A CCF8 5951 CCF9 5B63 CCFA 5C46 CCFB 60B8 CCFC 6212 CCFD 6842 CCFE 68B0 CDA1 68E8 CDA2 6EAA CDA3 754C CDA4 7678 CDA5 78CE CDA6 7A3D CDA7 7CFB CDA8 7E6B CDA9 7E7C CDAA 8A08 CDAB 8AA1 CDAC 8C3F CDAD 968E CDAE 9DC4 CDAF 53E4 CDB0 53E9 CDB1 544A CDB2 5471 CDB3 56FA CDB4 59D1 CDB5 5B64 CDB6 5C3B CDB7 5EAB CDB8 62F7 CDB9 6537 CDBA 6545 CDBB 6572 CDBC 66A0 CDBD 67AF CDBE 69C1 CDBF 6CBD CDC0 75FC CDC1 7690 CDC2 777E CDC3 7A3F CDC4 7F94 CDC5 8003 CDC6 80A1 CDC7 818F CDC8 82E6 CDC9 82FD CDCA 83F0 CDCB 85C1 CDCC 8831 CDCD 88B4 CDCE 8AA5 CDCF F903 CDD0 8F9C CDD1 932E CDD2 96C7 CDD3 9867 CDD4 9AD8 CDD5 9F13 CDD6 54ED CDD7 659B CDD8 66F2 CDD9 688F CDDA 7A40 CDDB 8C37 CDDC 9D60 CDDD 56F0 CDDE 5764 CDDF 5D11 CDE0 6606 CDE1 68B1 CDE2 68CD CDE3 6EFE CDE4 7428 CDE5 889E CDE6 9BE4 CDE7 6C68 CDE8 F904 CDE9 9AA8 CDEA 4F9B CDEB 516C CDEC 5171 CDED 529F CDEE 5B54 CDEF 5DE5 CDF0 6050 CDF1 606D CDF2 62F1 CDF3 63A7 CDF4 653B CDF5 73D9 CDF6 7A7A CDF7 86A3 CDF8 8CA2 CDF9 978F CDFA 4E32 CDFB 5BE1 CDFC 6208 CDFD 679C CDFE 74DC CEA1 79D1 CEA2 83D3 CEA3 8A87 CEA4 8AB2 CEA5 8DE8 CEA6 904E CEA7 934B CEA8 9846 CEA9 5ED3 CEAA 69E8 CEAB 85FF CEAC 90ED CEAD F905 CEAE 51A0 CEAF 5B98 CEB0 5BEC CEB1 6163 CEB2 68FA CEB3 6B3E CEB4 704C CEB5 742F CEB6 74D8 CEB7 7BA1 CEB8 7F50 CEB9 83C5 CEBA 89C0 CEBB 8CAB CEBC 95DC CEBD 9928 CEBE 522E CEBF 605D CEC0 62EC CEC1 9002 CEC2 4F8A CEC3 5149 CEC4 5321 CEC5 58D9 CEC6 5EE3 CEC7 66E0 CEC8 6D38 CEC9 709A CECA 72C2 CECB 73D6 CECC 7B50 CECD 80F1 CECE 945B CECF 5366 CED0 639B CED1 7F6B CED2 4E56 CED3 5080 CED4 584A CED5 58DE CED6 602A CED7 6127 CED8 62D0 CED9 69D0 CEDA 9B41 CEDB 5B8F CEDC 7D18 CEDD 80B1 CEDE 8F5F CEDF 4EA4 CEE0 50D1 CEE1 54AC CEE2 55AC CEE3 5B0C CEE4 5DA0 CEE5 5DE7 CEE6 652A CEE7 654E CEE8 6821 CEE9 6A4B CEEA 72E1 CEEB 768E CEEC 77EF CEED 7D5E CEEE 7FF9 CEEF 81A0 CEF0 854E CEF1 86DF CEF2 8F03 CEF3 8F4E CEF4 90CA CEF5 9903 CEF6 9A55 CEF7 9BAB CEF8 4E18 CEF9 4E45 CEFA 4E5D CEFB 4EC7 CEFC 4FF1 CEFD 5177 CEFE 52FE CFA1 5340 CFA2 53E3 CFA3 53E5 CFA4 548E CFA5 5614 CFA6 5775 CFA7 57A2 CFA8 5BC7 CFA9 5D87 CFAA 5ED0 CFAB 61FC CFAC 62D8 CFAD 6551 CFAE 67B8 CFAF 67E9 CFB0 69CB CFB1 6B50 CFB2 6BC6 CFB3 6BEC CFB4 6C42 CFB5 6E9D CFB6 7078 CFB7 72D7 CFB8 7396 CFB9 7403 CFBA 77BF CFBB 77E9 CFBC 7A76 CFBD 7D7F CFBE 8009 CFBF 81FC CFC0 8205 CFC1 820A CFC2 82DF CFC3 8862 CFC4 8B33 CFC5 8CFC CFC6 8EC0 CFC7 9011 CFC8 90B1 CFC9 9264 CFCA 92B6 CFCB 99D2 CFCC 9A45 CFCD 9CE9 CFCE 9DD7 CFCF 9F9C CFD0 570B CFD1 5C40 CFD2 83CA CFD3 97A0 CFD4 97AB CFD5 9EB4 CFD6 541B CFD7 7A98 CFD8 7FA4 CFD9 88D9 CFDA 8ECD CFDB 90E1 CFDC 5800 CFDD 5C48 CFDE 6398 CFDF 7A9F CFE0 5BAE CFE1 5F13 CFE2 7A79 CFE3 7AAE CFE4 828E CFE5 8EAC CFE6 5026 CFE7 5238 CFE8 52F8 CFE9 5377 CFEA 5708 CFEB 62F3 CFEC 6372 CFED 6B0A CFEE 6DC3 CFEF 7737 CFF0 53A5 CFF1 7357 CFF2 8568 CFF3 8E76 CFF4 95D5 CFF5 673A CFF6 6AC3 CFF7 6F70 CFF8 8A6D CFF9 8ECC CFFA 994B CFFB F906 CFFC 6677 CFFD 6B78 CFFE 8CB4 D0A1 9B3C D0A2 F907 D0A3 53EB D0A4 572D D0A5 594E D0A6 63C6 D0A7 69FB D0A8 73EA D0A9 7845 D0AA 7ABA D0AB 7AC5 D0AC 7CFE D0AD 8475 D0AE 898F D0AF 8D73 D0B0 9035 D0B1 95A8 D0B2 52FB D0B3 5747 D0B4 7547 D0B5 7B60 D0B6 83CC D0B7 921E D0B8 F908 D0B9 6A58 D0BA 514B D0BB 524B D0BC 5287 D0BD 621F D0BE 68D8 D0BF 6975 D0C0 9699 D0C1 50C5 D0C2 52A4 D0C3 52E4 D0C4 61C3 D0C5 65A4 D0C6 6839 D0C7 69FF D0C8 747E D0C9 7B4B D0CA 82B9 D0CB 83EB D0CC 89B2 D0CD 8B39 D0CE 8FD1 D0CF 9949 D0D0 F909 D0D1 4ECA D0D2 5997 D0D3 64D2 D0D4 6611 D0D5 6A8E D0D6 7434 D0D7 7981 D0D8 79BD D0D9 82A9 D0DA 887E D0DB 887F D0DC 895F D0DD F90A D0DE 9326 D0DF 4F0B D0E0 53CA D0E1 6025 D0E2 6271 D0E3 6C72 D0E4 7D1A D0E5 7D66 D0E6 4E98 D0E7 5162 D0E8 77DC D0E9 80AF D0EA 4F01 D0EB 4F0E D0EC 5176 D0ED 5180 D0EE 55DC D0EF 5668 D0F0 573B D0F1 57FA D0F2 57FC D0F3 5914 D0F4 5947 D0F5 5993 D0F6 5BC4 D0F7 5C90 D0F8 5D0E D0F9 5DF1 D0FA 5E7E D0FB 5FCC D0FC 6280 D0FD 65D7 D0FE 65E3 D1A1 671E D1A2 671F D1A3 675E D1A4 68CB D1A5 68C4 D1A6 6A5F D1A7 6B3A D1A8 6C23 D1A9 6C7D D1AA 6C82 D1AB 6DC7 D1AC 7398 D1AD 7426 D1AE 742A D1AF 7482 D1B0 74A3 D1B1 7578 D1B2 757F D1B3 7881 D1B4 78EF D1B5 7941 D1B6 7947 D1B7 7948 D1B8 797A D1B9 7B95 D1BA 7D00 D1BB 7DBA D1BC 7F88 D1BD 8006 D1BE 802D D1BF 808C D1C0 8A18 D1C1 8B4F D1C2 8C48 D1C3 8D77 D1C4 9321 D1C5 9324 D1C6 98E2 D1C7 9951 D1C8 9A0E D1C9 9A0F D1CA 9A65 D1CB 9E92 D1CC 7DCA D1CD 4F76 D1CE 5409 D1CF 62EE D1D0 6854 D1D1 91D1 D1D2 55AB D1D3 513A D1D4 F90B D1D5 F90C D1D6 5A1C D1D7 61E6 D1D8 F90D D1D9 62CF D1DA 62FF D1DB F90E D1DC F90F D1DD F910 D1DE F911 D1DF F912 D1E0 F913 D1E1 90A3 D1E2 F914 D1E3 F915 D1E4 F916 D1E5 F917 D1E6 F918 D1E7 8AFE D1E8 F919 D1E9 F91A D1EA F91B D1EB F91C D1EC 6696 D1ED F91D D1EE 7156 D1EF F91E D1F0 F91F D1F1 96E3 D1F2 F920 D1F3 634F D1F4 637A D1F5 5357 D1F6 F921 D1F7 678F D1F8 6960 D1F9 6E73 D1FA F922 D1FB 7537 D1FC F923 D1FD F924 D1FE F925 D2A1 7D0D D2A2 F926 D2A3 F927 D2A4 8872 D2A5 56CA D2A6 5A18 D2A7 F928 D2A8 F929 D2A9 F92A D2AA F92B D2AB F92C D2AC 4E43 D2AD F92D D2AE 5167 D2AF 5948 D2B0 67F0 D2B1 8010 D2B2 F92E D2B3 5973 D2B4 5E74 D2B5 649A D2B6 79CA D2B7 5FF5 D2B8 606C D2B9 62C8 D2BA 637B D2BB 5BE7 D2BC 5BD7 D2BD 52AA D2BE F92F D2BF 5974 D2C0 5F29 D2C1 6012 D2C2 F930 D2C3 F931 D2C4 F932 D2C5 7459 D2C6 F933 D2C7 F934 D2C8 F935 D2C9 F936 D2CA F937 D2CB F938 D2CC 99D1 D2CD F939 D2CE F93A D2CF F93B D2D0 F93C D2D1 F93D D2D2 F93E D2D3 F93F D2D4 F940 D2D5 F941 D2D6 F942 D2D7 F943 D2D8 6FC3 D2D9 F944 D2DA F945 D2DB 81BF D2DC 8FB2 D2DD 60F1 D2DE F946 D2DF F947 D2E0 8166 D2E1 F948 D2E2 F949 D2E3 5C3F D2E4 F94A D2E5 F94B D2E6 F94C D2E7 F94D D2E8 F94E D2E9 F94F D2EA F950 D2EB F951 D2EC 5AE9 D2ED 8A25 D2EE 677B D2EF 7D10 D2F0 F952 D2F1 F953 D2F2 F954 D2F3 F955 D2F4 F956 D2F5 F957 D2F6 80FD D2F7 F958 D2F8 F959 D2F9 5C3C D2FA 6CE5 D2FB 533F D2FC 6EBA D2FD 591A D2FE 8336 D3A1 4E39 D3A2 4EB6 D3A3 4F46 D3A4 55AE D3A5 5718 D3A6 58C7 D3A7 5F56 D3A8 65B7 D3A9 65E6 D3AA 6A80 D3AB 6BB5 D3AC 6E4D D3AD 77ED D3AE 7AEF D3AF 7C1E D3B0 7DDE D3B1 86CB D3B2 8892 D3B3 9132 D3B4 935B D3B5 64BB D3B6 6FBE D3B7 737A D3B8 75B8 D3B9 9054 D3BA 5556 D3BB 574D D3BC 61BA D3BD 64D4 D3BE 66C7 D3BF 6DE1 D3C0 6E5B D3C1 6F6D D3C2 6FB9 D3C3 75F0 D3C4 8043 D3C5 81BD D3C6 8541 D3C7 8983 D3C8 8AC7 D3C9 8B5A D3CA 931F D3CB 6C93 D3CC 7553 D3CD 7B54 D3CE 8E0F D3CF 905D D3D0 5510 D3D1 5802 D3D2 5858 D3D3 5E62 D3D4 6207 D3D5 649E D3D6 68E0 D3D7 7576 D3D8 7CD6 D3D9 87B3 D3DA 9EE8 D3DB 4EE3 D3DC 5788 D3DD 576E D3DE 5927 D3DF 5C0D D3E0 5CB1 D3E1 5E36 D3E2 5F85 D3E3 6234 D3E4 64E1 D3E5 73B3 D3E6 81FA D3E7 888B D3E8 8CB8 D3E9 968A D3EA 9EDB D3EB 5B85 D3EC 5FB7 D3ED 60B3 D3EE 5012 D3EF 5200 D3F0 5230 D3F1 5716 D3F2 5835 D3F3 5857 D3F4 5C0E D3F5 5C60 D3F6 5CF6 D3F7 5D8B D3F8 5EA6 D3F9 5F92 D3FA 60BC D3FB 6311 D3FC 6389 D3FD 6417 D3FE 6843 D4A1 68F9 D4A2 6AC2 D4A3 6DD8 D4A4 6E21 D4A5 6ED4 D4A6 6FE4 D4A7 71FE D4A8 76DC D4A9 7779 D4AA 79B1 D4AB 7A3B D4AC 8404 D4AD 89A9 D4AE 8CED D4AF 8DF3 D4B0 8E48 D4B1 9003 D4B2 9014 D4B3 9053 D4B4 90FD D4B5 934D D4B6 9676 D4B7 97DC D4B8 6BD2 D4B9 7006 D4BA 7258 D4BB 72A2 D4BC 7368 D4BD 7763 D4BE 79BF D4BF 7BE4 D4C0 7E9B D4C1 8B80 D4C2 58A9 D4C3 60C7 D4C4 6566 D4C5 65FD D4C6 66BE D4C7 6C8C D4C8 711E D4C9 71C9 D4CA 8C5A D4CB 9813 D4CC 4E6D D4CD 7A81 D4CE 4EDD D4CF 51AC D4D0 51CD D4D1 52D5 D4D2 540C D4D3 61A7 D4D4 6771 D4D5 6850 D4D6 68DF D4D7 6D1E D4D8 6F7C D4D9 75BC D4DA 77B3 D4DB 7AE5 D4DC 80F4 D4DD 8463 D4DE 9285 D4DF 515C D4E0 6597 D4E1 675C D4E2 6793 D4E3 75D8 D4E4 7AC7 D4E5 8373 D4E6 F95A D4E7 8C46 D4E8 9017 D4E9 982D D4EA 5C6F D4EB 81C0 D4EC 829A D4ED 9041 D4EE 906F D4EF 920D D4F0 5F97 D4F1 5D9D D4F2 6A59 D4F3 71C8 D4F4 767B D4F5 7B49 D4F6 85E4 D4F7 8B04 D4F8 9127 D4F9 9A30 D4FA 5587 D4FB 61F6 D4FC F95B D4FD 7669 D4FE 7F85 D5A1 863F D5A2 87BA D5A3 88F8 D5A4 908F D5A5 F95C D5A6 6D1B D5A7 70D9 D5A8 73DE D5A9 7D61 D5AA 843D D5AB F95D D5AC 916A D5AD 99F1 D5AE F95E D5AF 4E82 D5B0 5375 D5B1 6B04 D5B2 6B12 D5B3 703E D5B4 721B D5B5 862D D5B6 9E1E D5B7 524C D5B8 8FA3 D5B9 5D50 D5BA 64E5 D5BB 652C D5BC 6B16 D5BD 6FEB D5BE 7C43 D5BF 7E9C D5C0 85CD D5C1 8964 D5C2 89BD D5C3 62C9 D5C4 81D8 D5C5 881F D5C6 5ECA D5C7 6717 D5C8 6D6A D5C9 72FC D5CA 7405 D5CB 746F D5CC 8782 D5CD 90DE D5CE 4F86 D5CF 5D0D D5D0 5FA0 D5D1 840A D5D2 51B7 D5D3 63A0 D5D4 7565 D5D5 4EAE D5D6 5006 D5D7 5169 D5D8 51C9 D5D9 6881 D5DA 6A11 D5DB 7CAE D5DC 7CB1 D5DD 7CE7 D5DE 826F D5DF 8AD2 D5E0 8F1B D5E1 91CF D5E2 4FB6 D5E3 5137 D5E4 52F5 D5E5 5442 D5E6 5EEC D5E7 616E D5E8 623E D5E9 65C5 D5EA 6ADA D5EB 6FFE D5EC 792A D5ED 85DC D5EE 8823 D5EF 95AD D5F0 9A62 D5F1 9A6A D5F2 9E97 D5F3 9ECE D5F4 529B D5F5 66C6 D5F6 6B77 D5F7 701D D5F8 792B D5F9 8F62 D5FA 9742 D5FB 6190 D5FC 6200 D5FD 6523 D5FE 6F23 D6A1 7149 D6A2 7489 D6A3 7DF4 D6A4 806F D6A5 84EE D6A6 8F26 D6A7 9023 D6A8 934A D6A9 51BD D6AA 5217 D6AB 52A3 D6AC 6D0C D6AD 70C8 D6AE 88C2 D6AF 5EC9 D6B0 6582 D6B1 6BAE D6B2 6FC2 D6B3 7C3E D6B4 7375 D6B5 4EE4 D6B6 4F36 D6B7 56F9 D6B8 F95F D6B9 5CBA D6BA 5DBA D6BB 601C D6BC 73B2 D6BD 7B2D D6BE 7F9A D6BF 7FCE D6C0 8046 D6C1 901E D6C2 9234 D6C3 96F6 D6C4 9748 D6C5 9818 D6C6 9F61 D6C7 4F8B D6C8 6FA7 D6C9 79AE D6CA 91B4 D6CB 96B7 D6CC 52DE D6CD F960 D6CE 6488 D6CF 64C4 D6D0 6AD3 D6D1 6F5E D6D2 7018 D6D3 7210 D6D4 76E7 D6D5 8001 D6D6 8606 D6D7 865C D6D8 8DEF D6D9 8F05 D6DA 9732 D6DB 9B6F D6DC 9DFA D6DD 9E75 D6DE 788C D6DF 797F D6E0 7DA0 D6E1 83C9 D6E2 9304 D6E3 9E7F D6E4 9E93 D6E5 8AD6 D6E6 58DF D6E7 5F04 D6E8 6727 D6E9 7027 D6EA 74CF D6EB 7C60 D6EC 807E D6ED 5121 D6EE 7028 D6EF 7262 D6F0 78CA D6F1 8CC2 D6F2 8CDA D6F3 8CF4 D6F4 96F7 D6F5 4E86 D6F6 50DA D6F7 5BEE D6F8 5ED6 D6F9 6599 D6FA 71CE D6FB 7642 D6FC 77AD D6FD 804A D6FE 84FC D7A1 907C D7A2 9B27 D7A3 9F8D D7A4 58D8 D7A5 5A41 D7A6 5C62 D7A7 6A13 D7A8 6DDA D7A9 6F0F D7AA 763B D7AB 7D2F D7AC 7E37 D7AD 851E D7AE 8938 D7AF 93E4 D7B0 964B D7B1 5289 D7B2 65D2 D7B3 67F3 D7B4 69B4 D7B5 6D41 D7B6 6E9C D7B7 700F D7B8 7409 D7B9 7460 D7BA 7559 D7BB 7624 D7BC 786B D7BD 8B2C D7BE 985E D7BF 516D D7C0 622E D7C1 9678 D7C2 4F96 D7C3 502B D7C4 5D19 D7C5 6DEA D7C6 7DB8 D7C7 8F2A D7C8 5F8B D7C9 6144 D7CA 6817 D7CB F961 D7CC 9686 D7CD 52D2 D7CE 808B D7CF 51DC D7D0 51CC D7D1 695E D7D2 7A1C D7D3 7DBE D7D4 83F1 D7D5 9675 D7D6 4FDA D7D7 5229 D7D8 5398 D7D9 540F D7DA 550E D7DB 5C65 D7DC 60A7 D7DD 674E D7DE 68A8 D7DF 6D6C D7E0 7281 D7E1 72F8 D7E2 7406 D7E3 7483 D7E4 F962 D7E5 75E2 D7E6 7C6C D7E7 7F79 D7E8 7FB8 D7E9 8389 D7EA 88CF D7EB 88E1 D7EC 91CC D7ED 91D0 D7EE 96E2 D7EF 9BC9 D7F0 541D D7F1 6F7E D7F2 71D0 D7F3 7498 D7F4 85FA D7F5 8EAA D7F6 96A3 D7F7 9C57 D7F8 9E9F D7F9 6797 D7FA 6DCB D7FB 7433 D7FC 81E8 D7FD 9716 D7FE 782C D8A1 7ACB D8A2 7B20 D8A3 7C92 D8A4 6469 D8A5 746A D8A6 75F2 D8A7 78BC D8A8 78E8 D8A9 99AC D8AA 9B54 D8AB 9EBB D8AC 5BDE D8AD 5E55 D8AE 6F20 D8AF 819C D8B0 83AB D8B1 9088 D8B2 4E07 D8B3 534D D8B4 5A29 D8B5 5DD2 D8B6 5F4E D8B7 6162 D8B8 633D D8B9 6669 D8BA 66FC D8BB 6EFF D8BC 6F2B D8BD 7063 D8BE 779E D8BF 842C D8C0 8513 D8C1 883B D8C2 8F13 D8C3 9945 D8C4 9C3B D8C5 551C D8C6 62B9 D8C7 672B D8C8 6CAB D8C9 8309 D8CA 896A D8CB 977A D8CC 4EA1 D8CD 5984 D8CE 5FD8 D8CF 5FD9 D8D0 671B D8D1 7DB2 D8D2 7F54 D8D3 8292 D8D4 832B D8D5 83BD D8D6 8F1E D8D7 9099 D8D8 57CB D8D9 59B9 D8DA 5A92 D8DB 5BD0 D8DC 6627 D8DD 679A D8DE 6885 D8DF 6BCF D8E0 7164 D8E1 7F75 D8E2 8CB7 D8E3 8CE3 D8E4 9081 D8E5 9B45 D8E6 8108 D8E7 8C8A D8E8 964C D8E9 9A40 D8EA 9EA5 D8EB 5B5F D8EC 6C13 D8ED 731B D8EE 76F2 D8EF 76DF D8F0 840C D8F1 51AA D8F2 8993 D8F3 514D D8F4 5195 D8F5 52C9 D8F6 68C9 D8F7 6C94 D8F8 7704 D8F9 7720 D8FA 7DBF D8FB 7DEC D8FC 9762 D8FD 9EB5 D8FE 6EC5 D9A1 8511 D9A2 51A5 D9A3 540D D9A4 547D D9A5 660E D9A6 669D D9A7 6927 D9A8 6E9F D9A9 76BF D9AA 7791 D9AB 8317 D9AC 84C2 D9AD 879F D9AE 9169 D9AF 9298 D9B0 9CF4 D9B1 8882 D9B2 4FAE D9B3 5192 D9B4 52DF D9B5 59C6 D9B6 5E3D D9B7 6155 D9B8 6478 D9B9 6479 D9BA 66AE D9BB 67D0 D9BC 6A21 D9BD 6BCD D9BE 6BDB D9BF 725F D9C0 7261 D9C1 7441 D9C2 7738 D9C3 77DB D9C4 8017 D9C5 82BC D9C6 8305 D9C7 8B00 D9C8 8B28 D9C9 8C8C D9CA 6728 D9CB 6C90 D9CC 7267 D9CD 76EE D9CE 7766 D9CF 7A46 D9D0 9DA9 D9D1 6B7F D9D2 6C92 D9D3 5922 D9D4 6726 D9D5 8499 D9D6 536F D9D7 5893 D9D8 5999 D9D9 5EDF D9DA 63CF D9DB 6634 D9DC 6773 D9DD 6E3A D9DE 732B D9DF 7AD7 D9E0 82D7 D9E1 9328 D9E2 52D9 D9E3 5DEB D9E4 61AE D9E5 61CB D9E6 620A D9E7 62C7 D9E8 64AB D9E9 65E0 D9EA 6959 D9EB 6B66 D9EC 6BCB D9ED 7121 D9EE 73F7 D9EF 755D D9F0 7E46 D9F1 821E D9F2 8302 D9F3 856A D9F4 8AA3 D9F5 8CBF D9F6 9727 D9F7 9D61 D9F8 58A8 D9F9 9ED8 D9FA 5011 D9FB 520E D9FC 543B D9FD 554F D9FE 6587 DAA1 6C76 DAA2 7D0A DAA3 7D0B DAA4 805E DAA5 868A DAA6 9580 DAA7 96EF DAA8 52FF DAA9 6C95 DAAA 7269 DAAB 5473 DAAC 5A9A DAAD 5C3E DAAE 5D4B DAAF 5F4C DAB0 5FAE DAB1 672A DAB2 68B6 DAB3 6963 DAB4 6E3C DAB5 6E44 DAB6 7709 DAB7 7C73 DAB8 7F8E DAB9 8587 DABA 8B0E DABB 8FF7 DABC 9761 DABD 9EF4 DABE 5CB7 DABF 60B6 DAC0 610D DAC1 61AB DAC2 654F DAC3 65FB DAC4 65FC DAC5 6C11 DAC6 6CEF DAC7 739F DAC8 73C9 DAC9 7DE1 DACA 9594 DACB 5BC6 DACC 871C DACD 8B10 DACE 525D DACF 535A DAD0 62CD DAD1 640F DAD2 64B2 DAD3 6734 DAD4 6A38 DAD5 6CCA DAD6 73C0 DAD7 749E DAD8 7B94 DAD9 7C95 DADA 7E1B DADB 818A DADC 8236 DADD 8584 DADE 8FEB DADF 96F9 DAE0 99C1 DAE1 4F34 DAE2 534A DAE3 53CD DAE4 53DB DAE5 62CC DAE6 642C DAE7 6500 DAE8 6591 DAE9 69C3 DAEA 6CEE DAEB 6F58 DAEC 73ED DAED 7554 DAEE 7622 DAEF 76E4 DAF0 76FC DAF1 78D0 DAF2 78FB DAF3 792C DAF4 7D46 DAF5 822C DAF6 87E0 DAF7 8FD4 DAF8 9812 DAF9 98EF DAFA 52C3 DAFB 62D4 DAFC 64A5 DAFD 6E24 DAFE 6F51 DBA1 767C DBA2 8DCB DBA3 91B1 DBA4 9262 DBA5 9AEE DBA6 9B43 DBA7 5023 DBA8 508D DBA9 574A DBAA 59A8 DBAB 5C28 DBAC 5E47 DBAD 5F77 DBAE 623F DBAF 653E DBB0 65B9 DBB1 65C1 DBB2 6609 DBB3 678B DBB4 699C DBB5 6EC2 DBB6 78C5 DBB7 7D21 DBB8 80AA DBB9 8180 DBBA 822B DBBB 82B3 DBBC 84A1 DBBD 868C DBBE 8A2A DBBF 8B17 DBC0 90A6 DBC1 9632 DBC2 9F90 DBC3 500D DBC4 4FF3 DBC5 F963 DBC6 57F9 DBC7 5F98 DBC8 62DC DBC9 6392 DBCA 676F DBCB 6E43 DBCC 7119 DBCD 76C3 DBCE 80CC DBCF 80DA DBD0 88F4 DBD1 88F5 DBD2 8919 DBD3 8CE0 DBD4 8F29 DBD5 914D DBD6 966A DBD7 4F2F DBD8 4F70 DBD9 5E1B DBDA 67CF DBDB 6822 DBDC 767D DBDD 767E DBDE 9B44 DBDF 5E61 DBE0 6A0A DBE1 7169 DBE2 71D4 DBE3 756A DBE4 F964 DBE5 7E41 DBE6 8543 DBE7 85E9 DBE8 98DC DBE9 4F10 DBEA 7B4F DBEB 7F70 DBEC 95A5 DBED 51E1 DBEE 5E06 DBEF 68B5 DBF0 6C3E DBF1 6C4E DBF2 6CDB DBF3 72AF DBF4 7BC4 DBF5 8303 DBF6 6CD5 DBF7 743A DBF8 50FB DBF9 5288 DBFA 58C1 DBFB 64D8 DBFC 6A97 DBFD 74A7 DBFE 7656 DCA1 78A7 DCA2 8617 DCA3 95E2 DCA4 9739 DCA5 F965 DCA6 535E DCA7 5F01 DCA8 8B8A DCA9 8FA8 DCAA 8FAF DCAB 908A DCAC 5225 DCAD 77A5 DCAE 9C49 DCAF 9F08 DCB0 4E19 DCB1 5002 DCB2 5175 DCB3 5C5B DCB4 5E77 DCB5 661E DCB6 663A DCB7 67C4 DCB8 68C5 DCB9 70B3 DCBA 7501 DCBB 75C5 DCBC 79C9 DCBD 7ADD DCBE 8F27 DCBF 9920 DCC0 9A08 DCC1 4FDD DCC2 5821 DCC3 5831 DCC4 5BF6 DCC5 666E DCC6 6B65 DCC7 6D11 DCC8 6E7A DCC9 6F7D DCCA 73E4 DCCB 752B DCCC 83E9 DCCD 88DC DCCE 8913 DCCF 8B5C DCD0 8F14 DCD1 4F0F DCD2 50D5 DCD3 5310 DCD4 535C DCD5 5B93 DCD6 5FA9 DCD7 670D DCD8 798F DCD9 8179 DCDA 832F DCDB 8514 DCDC 8907 DCDD 8986 DCDE 8F39 DCDF 8F3B DCE0 99A5 DCE1 9C12 DCE2 672C DCE3 4E76 DCE4 4FF8 DCE5 5949 DCE6 5C01 DCE7 5CEF DCE8 5CF0 DCE9 6367 DCEA 68D2 DCEB 70FD DCEC 71A2 DCED 742B DCEE 7E2B DCEF 84EC DCF0 8702 DCF1 9022 DCF2 92D2 DCF3 9CF3 DCF4 4E0D DCF5 4ED8 DCF6 4FEF DCF7 5085 DCF8 5256 DCF9 526F DCFA 5426 DCFB 5490 DCFC 57E0 DCFD 592B DCFE 5A66 DDA1 5B5A DDA2 5B75 DDA3 5BCC DDA4 5E9C DDA5 F966 DDA6 6276 DDA7 6577 DDA8 65A7 DDA9 6D6E DDAA 6EA5 DDAB 7236 DDAC 7B26 DDAD 7C3F DDAE 7F36 DDAF 8150 DDB0 8151 DDB1 819A DDB2 8240 DDB3 8299 DDB4 83A9 DDB5 8A03 DDB6 8CA0 DDB7 8CE6 DDB8 8CFB DDB9 8D74 DDBA 8DBA DDBB 90E8 DDBC 91DC DDBD 961C DDBE 9644 DDBF 99D9 DDC0 9CE7 DDC1 5317 DDC2 5206 DDC3 5429 DDC4 5674 DDC5 58B3 DDC6 5954 DDC7 596E DDC8 5FFF DDC9 61A4 DDCA 626E DDCB 6610 DDCC 6C7E DDCD 711A DDCE 76C6 DDCF 7C89 DDD0 7CDE DDD1 7D1B DDD2 82AC DDD3 8CC1 DDD4 96F0 DDD5 F967 DDD6 4F5B DDD7 5F17 DDD8 5F7F DDD9 62C2 DDDA 5D29 DDDB 670B DDDC 68DA DDDD 787C DDDE 7E43 DDDF 9D6C DDE0 4E15 DDE1 5099 DDE2 5315 DDE3 532A DDE4 5351 DDE5 5983 DDE6 5A62 DDE7 5E87 DDE8 60B2 DDE9 618A DDEA 6249 DDEB 6279 DDEC 6590 DDED 6787 DDEE 69A7 DDEF 6BD4 DDF0 6BD6 DDF1 6BD7 DDF2 6BD8 DDF3 6CB8 DDF4 F968 DDF5 7435 DDF6 75FA DDF7 7812 DDF8 7891 DDF9 79D5 DDFA 79D8 DDFB 7C83 DDFC 7DCB DDFD 7FE1 DDFE 80A5 DEA1 813E DEA2 81C2 DEA3 83F2 DEA4 871A DEA5 88E8 DEA6 8AB9 DEA7 8B6C DEA8 8CBB DEA9 9119 DEAA 975E DEAB 98DB DEAC 9F3B DEAD 56AC DEAE 5B2A DEAF 5F6C DEB0 658C DEB1 6AB3 DEB2 6BAF DEB3 6D5C DEB4 6FF1 DEB5 7015 DEB6 725D DEB7 73AD DEB8 8CA7 DEB9 8CD3 DEBA 983B DEBB 6191 DEBC 6C37 DEBD 8058 DEBE 9A01 DEBF 4E4D DEC0 4E8B DEC1 4E9B DEC2 4ED5 DEC3 4F3A DEC4 4F3C DEC5 4F7F DEC6 4FDF DEC7 50FF DEC8 53F2 DEC9 53F8 DECA 5506 DECB 55E3 DECC 56DB DECD 58EB DECE 5962 DECF 5A11 DED0 5BEB DED1 5BFA DED2 5C04 DED3 5DF3 DED4 5E2B DED5 5F99 DED6 601D DED7 6368 DED8 659C DED9 65AF DEDA 67F6 DEDB 67FB DEDC 68AD DEDD 6B7B DEDE 6C99 DEDF 6CD7 DEE0 6E23 DEE1 7009 DEE2 7345 DEE3 7802 DEE4 793E DEE5 7940 DEE6 7960 DEE7 79C1 DEE8 7BE9 DEE9 7D17 DEEA 7D72 DEEB 8086 DEEC 820D DEED 838E DEEE 84D1 DEEF 86C7 DEF0 88DF DEF1 8A50 DEF2 8A5E DEF3 8B1D DEF4 8CDC DEF5 8D66 DEF6 8FAD DEF7 90AA DEF8 98FC DEF9 99DF DEFA 9E9D DEFB 524A DEFC F969 DEFD 6714 DEFE F96A DFA1 5098 DFA2 522A DFA3 5C71 DFA4 6563 DFA5 6C55 DFA6 73CA DFA7 7523 DFA8 759D DFA9 7B97 DFAA 849C DFAB 9178 DFAC 9730 DFAD 4E77 DFAE 6492 DFAF 6BBA DFB0 715E DFB1 85A9 DFB2 4E09 DFB3 F96B DFB4 6749 DFB5 68EE DFB6 6E17 DFB7 829F DFB8 8518 DFB9 886B DFBA 63F7 DFBB 6F81 DFBC 9212 DFBD 98AF DFBE 4E0A DFBF 50B7 DFC0 50CF DFC1 511F DFC2 5546 DFC3 55AA DFC4 5617 DFC5 5B40 DFC6 5C19 DFC7 5CE0 DFC8 5E38 DFC9 5E8A DFCA 5EA0 DFCB 5EC2 DFCC 60F3 DFCD 6851 DFCE 6A61 DFCF 6E58 DFD0 723D DFD1 7240 DFD2 72C0 DFD3 76F8 DFD4 7965 DFD5 7BB1 DFD6 7FD4 DFD7 88F3 DFD8 89F4 DFD9 8A73 DFDA 8C61 DFDB 8CDE DFDC 971C DFDD 585E DFDE 74BD DFDF 8CFD DFE0 55C7 DFE1 F96C DFE2 7A61 DFE3 7D22 DFE4 8272 DFE5 7272 DFE6 751F DFE7 7525 DFE8 F96D DFE9 7B19 DFEA 5885 DFEB 58FB DFEC 5DBC DFED 5E8F DFEE 5EB6 DFEF 5F90 DFF0 6055 DFF1 6292 DFF2 637F DFF3 654D DFF4 6691 DFF5 66D9 DFF6 66F8 DFF7 6816 DFF8 68F2 DFF9 7280 DFFA 745E DFFB 7B6E DFFC 7D6E DFFD 7DD6 DFFE 7F72 E0A1 80E5 E0A2 8212 E0A3 85AF E0A4 897F E0A5 8A93 E0A6 901D E0A7 92E4 E0A8 9ECD E0A9 9F20 E0AA 5915 E0AB 596D E0AC 5E2D E0AD 60DC E0AE 6614 E0AF 6673 E0B0 6790 E0B1 6C50 E0B2 6DC5 E0B3 6F5F E0B4 77F3 E0B5 78A9 E0B6 84C6 E0B7 91CB E0B8 932B E0B9 4ED9 E0BA 50CA E0BB 5148 E0BC 5584 E0BD 5B0B E0BE 5BA3 E0BF 6247 E0C0 657E E0C1 65CB E0C2 6E32 E0C3 717D E0C4 7401 E0C5 7444 E0C6 7487 E0C7 74BF E0C8 766C E0C9 79AA E0CA 7DDA E0CB 7E55 E0CC 7FA8 E0CD 817A E0CE 81B3 E0CF 8239 E0D0 861A E0D1 87EC E0D2 8A75 E0D3 8DE3 E0D4 9078 E0D5 9291 E0D6 9425 E0D7 994D E0D8 9BAE E0D9 5368 E0DA 5C51 E0DB 6954 E0DC 6CC4 E0DD 6D29 E0DE 6E2B E0DF 820C E0E0 859B E0E1 893B E0E2 8A2D E0E3 8AAA E0E4 96EA E0E5 9F67 E0E6 5261 E0E7 66B9 E0E8 6BB2 E0E9 7E96 E0EA 87FE E0EB 8D0D E0EC 9583 E0ED 965D E0EE 651D E0EF 6D89 E0F0 71EE E0F1 F96E E0F2 57CE E0F3 59D3 E0F4 5BAC E0F5 6027 E0F6 60FA E0F7 6210 E0F8 661F E0F9 665F E0FA 7329 E0FB 73F9 E0FC 76DB E0FD 7701 E0FE 7B6C E1A1 8056 E1A2 8072 E1A3 8165 E1A4 8AA0 E1A5 9192 E1A6 4E16 E1A7 52E2 E1A8 6B72 E1A9 6D17 E1AA 7A05 E1AB 7B39 E1AC 7D30 E1AD F96F E1AE 8CB0 E1AF 53EC E1B0 562F E1B1 5851 E1B2 5BB5 E1B3 5C0F E1B4 5C11 E1B5 5DE2 E1B6 6240 E1B7 6383 E1B8 6414 E1B9 662D E1BA 68B3 E1BB 6CBC E1BC 6D88 E1BD 6EAF E1BE 701F E1BF 70A4 E1C0 71D2 E1C1 7526 E1C2 758F E1C3 758E E1C4 7619 E1C5 7B11 E1C6 7BE0 E1C7 7C2B E1C8 7D20 E1C9 7D39 E1CA 852C E1CB 856D E1CC 8607 E1CD 8A34 E1CE 900D E1CF 9061 E1D0 90B5 E1D1 92B7 E1D2 97F6 E1D3 9A37 E1D4 4FD7 E1D5 5C6C E1D6 675F E1D7 6D91 E1D8 7C9F E1D9 7E8C E1DA 8B16 E1DB 8D16 E1DC 901F E1DD 5B6B E1DE 5DFD E1DF 640D E1E0 84C0 E1E1 905C E1E2 98E1 E1E3 7387 E1E4 5B8B E1E5 609A E1E6 677E E1E7 6DDE E1E8 8A1F E1E9 8AA6 E1EA 9001 E1EB 980C E1EC 5237 E1ED F970 E1EE 7051 E1EF 788E E1F0 9396 E1F1 8870 E1F2 91D7 E1F3 4FEE E1F4 53D7 E1F5 55FD E1F6 56DA E1F7 5782 E1F8 58FD E1F9 5AC2 E1FA 5B88 E1FB 5CAB E1FC 5CC0 E1FD 5E25 E1FE 6101 E2A1 620D E2A2 624B E2A3 6388 E2A4 641C E2A5 6536 E2A6 6578 E2A7 6A39 E2A8 6B8A E2A9 6C34 E2AA 6D19 E2AB 6F31 E2AC 71E7 E2AD 72E9 E2AE 7378 E2AF 7407 E2B0 74B2 E2B1 7626 E2B2 7761 E2B3 79C0 E2B4 7A57 E2B5 7AEA E2B6 7CB9 E2B7 7D8F E2B8 7DAC E2B9 7E61 E2BA 7F9E E2BB 8129 E2BC 8331 E2BD 8490 E2BE 84DA E2BF 85EA E2C0 8896 E2C1 8AB0 E2C2 8B90 E2C3 8F38 E2C4 9042 E2C5 9083 E2C6 916C E2C7 9296 E2C8 92B9 E2C9 968B E2CA 96A7 E2CB 96A8 E2CC 96D6 E2CD 9700 E2CE 9808 E2CF 9996 E2D0 9AD3 E2D1 9B1A E2D2 53D4 E2D3 587E E2D4 5919 E2D5 5B70 E2D6 5BBF E2D7 6DD1 E2D8 6F5A E2D9 719F E2DA 7421 E2DB 74B9 E2DC 8085 E2DD 83FD E2DE 5DE1 E2DF 5F87 E2E0 5FAA E2E1 6042 E2E2 65EC E2E3 6812 E2E4 696F E2E5 6A53 E2E6 6B89 E2E7 6D35 E2E8 6DF3 E2E9 73E3 E2EA 76FE E2EB 77AC E2EC 7B4D E2ED 7D14 E2EE 8123 E2EF 821C E2F0 8340 E2F1 84F4 E2F2 8563 E2F3 8A62 E2F4 8AC4 E2F5 9187 E2F6 931E E2F7 9806 E2F8 99B4 E2F9 620C E2FA 8853 E2FB 8FF0 E2FC 9265 E2FD 5D07 E2FE 5D27 E3A1 5D69 E3A2 745F E3A3 819D E3A4 8768 E3A5 6FD5 E3A6 62FE E3A7 7FD2 E3A8 8936 E3A9 8972 E3AA 4E1E E3AB 4E58 E3AC 50E7 E3AD 52DD E3AE 5347 E3AF 627F E3B0 6607 E3B1 7E69 E3B2 8805 E3B3 965E E3B4 4F8D E3B5 5319 E3B6 5636 E3B7 59CB E3B8 5AA4 E3B9 5C38 E3BA 5C4E E3BB 5C4D E3BC 5E02 E3BD 5F11 E3BE 6043 E3BF 65BD E3C0 662F E3C1 6642 E3C2 67BE E3C3 67F4 E3C4 731C E3C5 77E2 E3C6 793A E3C7 7FC5 E3C8 8494 E3C9 84CD E3CA 8996 E3CB 8A66 E3CC 8A69 E3CD 8AE1 E3CE 8C55 E3CF 8C7A E3D0 57F4 E3D1 5BD4 E3D2 5F0F E3D3 606F E3D4 62ED E3D5 690D E3D6 6B96 E3D7 6E5C E3D8 7184 E3D9 7BD2 E3DA 8755 E3DB 8B58 E3DC 8EFE E3DD 98DF E3DE 98FE E3DF 4F38 E3E0 4F81 E3E1 4FE1 E3E2 547B E3E3 5A20 E3E4 5BB8 E3E5 613C E3E6 65B0 E3E7 6668 E3E8 71FC E3E9 7533 E3EA 795E E3EB 7D33 E3EC 814E E3ED 81E3 E3EE 8398 E3EF 85AA E3F0 85CE E3F1 8703 E3F2 8A0A E3F3 8EAB E3F4 8F9B E3F5 F971 E3F6 8FC5 E3F7 5931 E3F8 5BA4 E3F9 5BE6 E3FA 6089 E3FB 5BE9 E3FC 5C0B E3FD 5FC3 E3FE 6C81 E4A1 F972 E4A2 6DF1 E4A3 700B E4A4 751A E4A5 82AF E4A6 8AF6 E4A7 4EC0 E4A8 5341 E4A9 F973 E4AA 96D9 E4AB 6C0F E4AC 4E9E E4AD 4FC4 E4AE 5152 E4AF 555E E4B0 5A25 E4B1 5CE8 E4B2 6211 E4B3 7259 E4B4 82BD E4B5 83AA E4B6 86FE E4B7 8859 E4B8 8A1D E4B9 963F E4BA 96C5 E4BB 9913 E4BC 9D09 E4BD 9D5D E4BE 580A E4BF 5CB3 E4C0 5DBD E4C1 5E44 E4C2 60E1 E4C3 6115 E4C4 63E1 E4C5 6A02 E4C6 6E25 E4C7 9102 E4C8 9354 E4C9 984E E4CA 9C10 E4CB 9F77 E4CC 5B89 E4CD 5CB8 E4CE 6309 E4CF 664F E4D0 6848 E4D1 773C E4D2 96C1 E4D3 978D E4D4 9854 E4D5 9B9F E4D6 65A1 E4D7 8B01 E4D8 8ECB E4D9 95BC E4DA 5535 E4DB 5CA9 E4DC 5DD6 E4DD 5EB5 E4DE 6697 E4DF 764C E4E0 83F4 E4E1 95C7 E4E2 58D3 E4E3 62BC E4E4 72CE E4E5 9D28 E4E6 4EF0 E4E7 592E E4E8 600F E4E9 663B E4EA 6B83 E4EB 79E7 E4EC 9D26 E4ED 5393 E4EE 54C0 E4EF 57C3 E4F0 5D16 E4F1 611B E4F2 66D6 E4F3 6DAF E4F4 788D E4F5 827E E4F6 9698 E4F7 9744 E4F8 5384 E4F9 627C E4FA 6396 E4FB 6DB2 E4FC 7E0A E4FD 814B E4FE 984D E5A1 6AFB E5A2 7F4C E5A3 9DAF E5A4 9E1A E5A5 4E5F E5A6 503B E5A7 51B6 E5A8 591C E5A9 60F9 E5AA 63F6 E5AB 6930 E5AC 723A E5AD 8036 E5AE F974 E5AF 91CE E5B0 5F31 E5B1 F975 E5B2 F976 E5B3 7D04 E5B4 82E5 E5B5 846F E5B6 84BB E5B7 85E5 E5B8 8E8D E5B9 F977 E5BA 4F6F E5BB F978 E5BC F979 E5BD 58E4 E5BE 5B43 E5BF 6059 E5C0 63DA E5C1 6518 E5C2 656D E5C3 6698 E5C4 F97A E5C5 694A E5C6 6A23 E5C7 6D0B E5C8 7001 E5C9 716C E5CA 75D2 E5CB 760D E5CC 79B3 E5CD 7A70 E5CE F97B E5CF 7F8A E5D0 F97C E5D1 8944 E5D2 F97D E5D3 8B93 E5D4 91C0 E5D5 967D E5D6 F97E E5D7 990A E5D8 5704 E5D9 5FA1 E5DA 65BC E5DB 6F01 E5DC 7600 E5DD 79A6 E5DE 8A9E E5DF 99AD E5E0 9B5A E5E1 9F6C E5E2 5104 E5E3 61B6 E5E4 6291 E5E5 6A8D E5E6 81C6 E5E7 5043 E5E8 5830 E5E9 5F66 E5EA 7109 E5EB 8A00 E5EC 8AFA E5ED 5B7C E5EE 8616 E5EF 4FFA E5F0 513C E5F1 56B4 E5F2 5944 E5F3 63A9 E5F4 6DF9 E5F5 5DAA E5F6 696D E5F7 5186 E5F8 4E88 E5F9 4F59 E5FA F97F E5FB F980 E5FC F981 E5FD 5982 E5FE F982 E6A1 F983 E6A2 6B5F E6A3 6C5D E6A4 F984 E6A5 74B5 E6A6 7916 E6A7 F985 E6A8 8207 E6A9 8245 E6AA 8339 E6AB 8F3F E6AC 8F5D E6AD F986 E6AE 9918 E6AF F987 E6B0 F988 E6B1 F989 E6B2 4EA6 E6B3 F98A E6B4 57DF E6B5 5F79 E6B6 6613 E6B7 F98B E6B8 F98C E6B9 75AB E6BA 7E79 E6BB 8B6F E6BC F98D E6BD 9006 E6BE 9A5B E6BF 56A5 E6C0 5827 E6C1 59F8 E6C2 5A1F E6C3 5BB4 E6C4 F98E E6C5 5EF6 E6C6 F98F E6C7 F990 E6C8 6350 E6C9 633B E6CA F991 E6CB 693D E6CC 6C87 E6CD 6CBF E6CE 6D8E E6CF 6D93 E6D0 6DF5 E6D1 6F14 E6D2 F992 E6D3 70DF E6D4 7136 E6D5 7159 E6D6 F993 E6D7 71C3 E6D8 71D5 E6D9 F994 E6DA 784F E6DB 786F E6DC F995 E6DD 7B75 E6DE 7DE3 E6DF F996 E6E0 7E2F E6E1 F997 E6E2 884D E6E3 8EDF E6E4 F998 E6E5 F999 E6E6 F99A E6E7 925B E6E8 F99B E6E9 9CF6 E6EA F99C E6EB F99D E6EC F99E E6ED 6085 E6EE 6D85 E6EF F99F E6F0 71B1 E6F1 F9A0 E6F2 F9A1 E6F3 95B1 E6F4 53AD E6F5 F9A2 E6F6 F9A3 E6F7 F9A4 E6F8 67D3 E6F9 F9A5 E6FA 708E E6FB 7130 E6FC 7430 E6FD 8276 E6FE 82D2 E7A1 F9A6 E7A2 95BB E7A3 9AE5 E7A4 9E7D E7A5 66C4 E7A6 F9A7 E7A7 71C1 E7A8 8449 E7A9 F9A8 E7AA F9A9 E7AB 584B E7AC F9AA E7AD F9AB E7AE 5DB8 E7AF 5F71 E7B0 F9AC E7B1 6620 E7B2 668E E7B3 6979 E7B4 69AE E7B5 6C38 E7B6 6CF3 E7B7 6E36 E7B8 6F41 E7B9 6FDA E7BA 701B E7BB 702F E7BC 7150 E7BD 71DF E7BE 7370 E7BF F9AD E7C0 745B E7C1 F9AE E7C2 74D4 E7C3 76C8 E7C4 7A4E E7C5 7E93 E7C6 F9AF E7C7 F9B0 E7C8 82F1 E7C9 8A60 E7CA 8FCE E7CB F9B1 E7CC 9348 E7CD F9B2 E7CE 9719 E7CF F9B3 E7D0 F9B4 E7D1 4E42 E7D2 502A E7D3 F9B5 E7D4 5208 E7D5 53E1 E7D6 66F3 E7D7 6C6D E7D8 6FCA E7D9 730A E7DA 777F E7DB 7A62 E7DC 82AE E7DD 85DD E7DE 8602 E7DF F9B6 E7E0 88D4 E7E1 8A63 E7E2 8B7D E7E3 8C6B E7E4 F9B7 E7E5 92B3 E7E6 F9B8 E7E7 9713 E7E8 9810 E7E9 4E94 E7EA 4F0D E7EB 4FC9 E7EC 50B2 E7ED 5348 E7EE 543E E7EF 5433 E7F0 55DA E7F1 5862 E7F2 58BA E7F3 5967 E7F4 5A1B E7F5 5BE4 E7F6 609F E7F7 F9B9 E7F8 61CA E7F9 6556 E7FA 65FF E7FB 6664 E7FC 68A7 E7FD 6C5A E7FE 6FB3 E8A1 70CF E8A2 71AC E8A3 7352 E8A4 7B7D E8A5 8708 E8A6 8AA4 E8A7 9C32 E8A8 9F07 E8A9 5C4B E8AA 6C83 E8AB 7344 E8AC 7389 E8AD 923A E8AE 6EAB E8AF 7465 E8B0 761F E8B1 7A69 E8B2 7E15 E8B3 860A E8B4 5140 E8B5 58C5 E8B6 64C1 E8B7 74EE E8B8 7515 E8B9 7670 E8BA 7FC1 E8BB 9095 E8BC 96CD E8BD 9954 E8BE 6E26 E8BF 74E6 E8C0 7AA9 E8C1 7AAA E8C2 81E5 E8C3 86D9 E8C4 8778 E8C5 8A1B E8C6 5A49 E8C7 5B8C E8C8 5B9B E8C9 68A1 E8CA 6900 E8CB 6D63 E8CC 73A9 E8CD 7413 E8CE 742C E8CF 7897 E8D0 7DE9 E8D1 7FEB E8D2 8118 E8D3 8155 E8D4 839E E8D5 8C4C E8D6 962E E8D7 9811 E8D8 66F0 E8D9 5F80 E8DA 65FA E8DB 6789 E8DC 6C6A E8DD 738B E8DE 502D E8DF 5A03 E8E0 6B6A E8E1 77EE E8E2 5916 E8E3 5D6C E8E4 5DCD E8E5 7325 E8E6 754F E8E7 F9BA E8E8 F9BB E8E9 50E5 E8EA 51F9 E8EB 582F E8EC 592D E8ED 5996 E8EE 59DA E8EF 5BE5 E8F0 F9BC E8F1 F9BD E8F2 5DA2 E8F3 62D7 E8F4 6416 E8F5 6493 E8F6 64FE E8F7 F9BE E8F8 66DC E8F9 F9BF E8FA 6A48 E8FB F9C0 E8FC 71FF E8FD 7464 E8FE F9C1 E9A1 7A88 E9A2 7AAF E9A3 7E47 E9A4 7E5E E9A5 8000 E9A6 8170 E9A7 F9C2 E9A8 87EF E9A9 8981 E9AA 8B20 E9AB 9059 E9AC F9C3 E9AD 9080 E9AE 9952 E9AF 617E E9B0 6B32 E9B1 6D74 E9B2 7E1F E9B3 8925 E9B4 8FB1 E9B5 4FD1 E9B6 50AD E9B7 5197 E9B8 52C7 E9B9 57C7 E9BA 5889 E9BB 5BB9 E9BC 5EB8 E9BD 6142 E9BE 6995 E9BF 6D8C E9C0 6E67 E9C1 6EB6 E9C2 7194 E9C3 7462 E9C4 7528 E9C5 752C E9C6 8073 E9C7 8338 E9C8 84C9 E9C9 8E0A E9CA 9394 E9CB 93DE E9CC F9C4 E9CD 4E8E E9CE 4F51 E9CF 5076 E9D0 512A E9D1 53C8 E9D2 53CB E9D3 53F3 E9D4 5B87 E9D5 5BD3 E9D6 5C24 E9D7 611A E9D8 6182 E9D9 65F4 E9DA 725B E9DB 7397 E9DC 7440 E9DD 76C2 E9DE 7950 E9DF 7991 E9E0 79B9 E9E1 7D06 E9E2 7FBD E9E3 828B E9E4 85D5 E9E5 865E E9E6 8FC2 E9E7 9047 E9E8 90F5 E9E9 91EA E9EA 9685 E9EB 96E8 E9EC 96E9 E9ED 52D6 E9EE 5F67 E9EF 65ED E9F0 6631 E9F1 682F E9F2 715C E9F3 7A36 E9F4 90C1 E9F5 980A E9F6 4E91 E9F7 F9C5 E9F8 6A52 E9F9 6B9E E9FA 6F90 E9FB 7189 E9FC 8018 E9FD 82B8 E9FE 8553 EAA1 904B EAA2 9695 EAA3 96F2 EAA4 97FB EAA5 851A EAA6 9B31 EAA7 4E90 EAA8 718A EAA9 96C4 EAAA 5143 EAAB 539F EAAC 54E1 EAAD 5713 EAAE 5712 EAAF 57A3 EAB0 5A9B EAB1 5AC4 EAB2 5BC3 EAB3 6028 EAB4 613F EAB5 63F4 EAB6 6C85 EAB7 6D39 EAB8 6E72 EAB9 6E90 EABA 7230 EABB 733F EABC 7457 EABD 82D1 EABE 8881 EABF 8F45 EAC0 9060 EAC1 F9C6 EAC2 9662 EAC3 9858 EAC4 9D1B EAC5 6708 EAC6 8D8A EAC7 925E EAC8 4F4D EAC9 5049 EACA 50DE EACB 5371 EACC 570D EACD 59D4 EACE 5A01 EACF 5C09 EAD0 6170 EAD1 6690 EAD2 6E2D EAD3 7232 EAD4 744B EAD5 7DEF EAD6 80C3 EAD7 840E EAD8 8466 EAD9 853F EADA 875F EADB 885B EADC 8918 EADD 8B02 EADE 9055 EADF 97CB EAE0 9B4F EAE1 4E73 EAE2 4F91 EAE3 5112 EAE4 516A EAE5 F9C7 EAE6 552F EAE7 55A9 EAE8 5B7A EAE9 5BA5 EAEA 5E7C EAEB 5E7D EAEC 5EBE EAED 60A0 EAEE 60DF EAEF 6108 EAF0 6109 EAF1 63C4 EAF2 6538 EAF3 6709 EAF4 F9C8 EAF5 67D4 EAF6 67DA EAF7 F9C9 EAF8 6961 EAF9 6962 EAFA 6CB9 EAFB 6D27 EAFC F9CA EAFD 6E38 EAFE F9CB EBA1 6FE1 EBA2 7336 EBA3 7337 EBA4 F9CC EBA5 745C EBA6 7531 EBA7 F9CD EBA8 7652 EBA9 F9CE EBAA F9CF EBAB 7DAD EBAC 81FE EBAD 8438 EBAE 88D5 EBAF 8A98 EBB0 8ADB EBB1 8AED EBB2 8E30 EBB3 8E42 EBB4 904A EBB5 903E EBB6 907A EBB7 9149 EBB8 91C9 EBB9 936E EBBA F9D0 EBBB F9D1 EBBC 5809 EBBD F9D2 EBBE 6BD3 EBBF 8089 EBC0 80B2 EBC1 F9D3 EBC2 F9D4 EBC3 5141 EBC4 596B EBC5 5C39 EBC6 F9D5 EBC7 F9D6 EBC8 6F64 EBC9 73A7 EBCA 80E4 EBCB 8D07 EBCC F9D7 EBCD 9217 EBCE 958F EBCF F9D8 EBD0 F9D9 EBD1 F9DA EBD2 F9DB EBD3 807F EBD4 620E EBD5 701C EBD6 7D68 EBD7 878D EBD8 F9DC EBD9 57A0 EBDA 6069 EBDB 6147 EBDC 6BB7 EBDD 8ABE EBDE 9280 EBDF 96B1 EBE0 4E59 EBE1 541F EBE2 6DEB EBE3 852D EBE4 9670 EBE5 97F3 EBE6 98EE EBE7 63D6 EBE8 6CE3 EBE9 9091 EBEA 51DD EBEB 61C9 EBEC 81BA EBED 9DF9 EBEE 4F9D EBEF 501A EBF0 5100 EBF1 5B9C EBF2 610F EBF3 61FF EBF4 64EC EBF5 6905 EBF6 6BC5 EBF7 7591 EBF8 77E3 EBF9 7FA9 EBFA 8264 EBFB 858F EBFC 87FB EBFD 8863 EBFE 8ABC ECA1 8B70 ECA2 91AB ECA3 4E8C ECA4 4EE5 ECA5 4F0A ECA6 F9DD ECA7 F9DE ECA8 5937 ECA9 59E8 ECAA F9DF ECAB 5DF2 ECAC 5F1B ECAD 5F5B ECAE 6021 ECAF F9E0 ECB0 F9E1 ECB1 F9E2 ECB2 F9E3 ECB3 723E ECB4 73E5 ECB5 F9E4 ECB6 7570 ECB7 75CD ECB8 F9E5 ECB9 79FB ECBA F9E6 ECBB 800C ECBC 8033 ECBD 8084 ECBE 82E1 ECBF 8351 ECC0 F9E7 ECC1 F9E8 ECC2 8CBD ECC3 8CB3 ECC4 9087 ECC5 F9E9 ECC6 F9EA ECC7 98F4 ECC8 990C ECC9 F9EB ECCA F9EC ECCB 7037 ECCC 76CA ECCD 7FCA ECCE 7FCC ECCF 7FFC ECD0 8B1A ECD1 4EBA ECD2 4EC1 ECD3 5203 ECD4 5370 ECD5 F9ED ECD6 54BD ECD7 56E0 ECD8 59FB ECD9 5BC5 ECDA 5F15 ECDB 5FCD ECDC 6E6E ECDD F9EE ECDE F9EF ECDF 7D6A ECE0 8335 ECE1 F9F0 ECE2 8693 ECE3 8A8D ECE4 F9F1 ECE5 976D ECE6 9777 ECE7 F9F2 ECE8 F9F3 ECE9 4E00 ECEA 4F5A ECEB 4F7E ECEC 58F9 ECED 65E5 ECEE 6EA2 ECEF 9038 ECF0 93B0 ECF1 99B9 ECF2 4EFB ECF3 58EC ECF4 598A ECF5 59D9 ECF6 6041 ECF7 F9F4 ECF8 F9F5 ECF9 7A14 ECFA F9F6 ECFB 834F ECFC 8CC3 ECFD 5165 ECFE 5344 EDA1 F9F7 EDA2 F9F8 EDA3 F9F9 EDA4 4ECD EDA5 5269 EDA6 5B55 EDA7 82BF EDA8 4ED4 EDA9 523A EDAA 54A8 EDAB 59C9 EDAC 59FF EDAD 5B50 EDAE 5B57 EDAF 5B5C EDB0 6063 EDB1 6148 EDB2 6ECB EDB3 7099 EDB4 716E EDB5 7386 EDB6 74F7 EDB7 75B5 EDB8 78C1 EDB9 7D2B EDBA 8005 EDBB 81EA EDBC 8328 EDBD 8517 EDBE 85C9 EDBF 8AEE EDC0 8CC7 EDC1 96CC EDC2 4F5C EDC3 52FA EDC4 56BC EDC5 65AB EDC6 6628 EDC7 707C EDC8 70B8 EDC9 7235 EDCA 7DBD EDCB 828D EDCC 914C EDCD 96C0 EDCE 9D72 EDCF 5B71 EDD0 68E7 EDD1 6B98 EDD2 6F7A EDD3 76DE EDD4 5C91 EDD5 66AB EDD6 6F5B EDD7 7BB4 EDD8 7C2A EDD9 8836 EDDA 96DC EDDB 4E08 EDDC 4ED7 EDDD 5320 EDDE 5834 EDDF 58BB EDE0 58EF EDE1 596C EDE2 5C07 EDE3 5E33 EDE4 5E84 EDE5 5F35 EDE6 638C EDE7 66B2 EDE8 6756 EDE9 6A1F EDEA 6AA3 EDEB 6B0C EDEC 6F3F EDED 7246 EDEE F9FA EDEF 7350 EDF0 748B EDF1 7AE0 EDF2 7CA7 EDF3 8178 EDF4 81DF EDF5 81E7 EDF6 838A EDF7 846C EDF8 8523 EDF9 8594 EDFA 85CF EDFB 88DD EDFC 8D13 EDFD 91AC EDFE 9577 EEA1 969C EEA2 518D EEA3 54C9 EEA4 5728 EEA5 5BB0 EEA6 624D EEA7 6750 EEA8 683D EEA9 6893 EEAA 6E3D EEAB 6ED3 EEAC 707D EEAD 7E21 EEAE 88C1 EEAF 8CA1 EEB0 8F09 EEB1 9F4B EEB2 9F4E EEB3 722D EEB4 7B8F EEB5 8ACD EEB6 931A EEB7 4F47 EEB8 4F4E EEB9 5132 EEBA 5480 EEBB 59D0 EEBC 5E95 EEBD 62B5 EEBE 6775 EEBF 696E EEC0 6A17 EEC1 6CAE EEC2 6E1A EEC3 72D9 EEC4 732A EEC5 75BD EEC6 7BB8 EEC7 7D35 EEC8 82E7 EEC9 83F9 EECA 8457 EECB 85F7 EECC 8A5B EECD 8CAF EECE 8E87 EECF 9019 EED0 90B8 EED1 96CE EED2 9F5F EED3 52E3 EED4 540A EED5 5AE1 EED6 5BC2 EED7 6458 EED8 6575 EED9 6EF4 EEDA 72C4 EEDB F9FB EEDC 7684 EEDD 7A4D EEDE 7B1B EEDF 7C4D EEE0 7E3E EEE1 7FDF EEE2 837B EEE3 8B2B EEE4 8CCA EEE5 8D64 EEE6 8DE1 EEE7 8E5F EEE8 8FEA EEE9 8FF9 EEEA 9069 EEEB 93D1 EEEC 4F43 EEED 4F7A EEEE 50B3 EEEF 5168 EEF0 5178 EEF1 524D EEF2 526A EEF3 5861 EEF4 587C EEF5 5960 EEF6 5C08 EEF7 5C55 EEF8 5EDB EEF9 609B EEFA 6230 EEFB 6813 EEFC 6BBF EEFD 6C08 EEFE 6FB1 EFA1 714E EFA2 7420 EFA3 7530 EFA4 7538 EFA5 7551 EFA6 7672 EFA7 7B4C EFA8 7B8B EFA9 7BAD EFAA 7BC6 EFAB 7E8F EFAC 8A6E EFAD 8F3E EFAE 8F49 EFAF 923F EFB0 9293 EFB1 9322 EFB2 942B EFB3 96FB EFB4 985A EFB5 986B EFB6 991E EFB7 5207 EFB8 622A EFB9 6298 EFBA 6D59 EFBB 7664 EFBC 7ACA EFBD 7BC0 EFBE 7D76 EFBF 5360 EFC0 5CBE EFC1 5E97 EFC2 6F38 EFC3 70B9 EFC4 7C98 EFC5 9711 EFC6 9B8E EFC7 9EDE EFC8 63A5 EFC9 647A EFCA 8776 EFCB 4E01 EFCC 4E95 EFCD 4EAD EFCE 505C EFCF 5075 EFD0 5448 EFD1 59C3 EFD2 5B9A EFD3 5E40 EFD4 5EAD EFD5 5EF7 EFD6 5F81 EFD7 60C5 EFD8 633A EFD9 653F EFDA 6574 EFDB 65CC EFDC 6676 EFDD 6678 EFDE 67FE EFDF 6968 EFE0 6A89 EFE1 6B63 EFE2 6C40 EFE3 6DC0 EFE4 6DE8 EFE5 6E1F EFE6 6E5E EFE7 701E EFE8 70A1 EFE9 738E EFEA 73FD EFEB 753A EFEC 775B EFED 7887 EFEE 798E EFEF 7A0B EFF0 7A7D EFF1 7CBE EFF2 7D8E EFF3 8247 EFF4 8A02 EFF5 8AEA EFF6 8C9E EFF7 912D EFF8 914A EFF9 91D8 EFFA 9266 EFFB 92CC EFFC 9320 EFFD 9706 EFFE 9756 F0A1 975C F0A2 9802 F0A3 9F0E F0A4 5236 F0A5 5291 F0A6 557C F0A7 5824 F0A8 5E1D F0A9 5F1F F0AA 608C F0AB 63D0 F0AC 68AF F0AD 6FDF F0AE 796D F0AF 7B2C F0B0 81CD F0B1 85BA F0B2 88FD F0B3 8AF8 F0B4 8E44 F0B5 918D F0B6 9664 F0B7 969B F0B8 973D F0B9 984C F0BA 9F4A F0BB 4FCE F0BC 5146 F0BD 51CB F0BE 52A9 F0BF 5632 F0C0 5F14 F0C1 5F6B F0C2 63AA F0C3 64CD F0C4 65E9 F0C5 6641 F0C6 66FA F0C7 66F9 F0C8 671D F0C9 689D F0CA 68D7 F0CB 69FD F0CC 6F15 F0CD 6F6E F0CE 7167 F0CF 71E5 F0D0 722A F0D1 74AA F0D2 773A F0D3 7956 F0D4 795A F0D5 79DF F0D6 7A20 F0D7 7A95 F0D8 7C97 F0D9 7CDF F0DA 7D44 F0DB 7E70 F0DC 8087 F0DD 85FB F0DE 86A4 F0DF 8A54 F0E0 8ABF F0E1 8D99 F0E2 8E81 F0E3 9020 F0E4 906D F0E5 91E3 F0E6 963B F0E7 96D5 F0E8 9CE5 F0E9 65CF F0EA 7C07 F0EB 8DB3 F0EC 93C3 F0ED 5B58 F0EE 5C0A F0EF 5352 F0F0 62D9 F0F1 731D F0F2 5027 F0F3 5B97 F0F4 5F9E F0F5 60B0 F0F6 616B F0F7 68D5 F0F8 6DD9 F0F9 742E F0FA 7A2E F0FB 7D42 F0FC 7D9C F0FD 7E31 F0FE 816B F1A1 8E2A F1A2 8E35 F1A3 937E F1A4 9418 F1A5 4F50 F1A6 5750 F1A7 5DE6 F1A8 5EA7 F1A9 632B F1AA 7F6A F1AB 4E3B F1AC 4F4F F1AD 4F8F F1AE 505A F1AF 59DD F1B0 80C4 F1B1 546A F1B2 5468 F1B3 55FE F1B4 594F F1B5 5B99 F1B6 5DDE F1B7 5EDA F1B8 665D F1B9 6731 F1BA 67F1 F1BB 682A F1BC 6CE8 F1BD 6D32 F1BE 6E4A F1BF 6F8D F1C0 70B7 F1C1 73E0 F1C2 7587 F1C3 7C4C F1C4 7D02 F1C5 7D2C F1C6 7DA2 F1C7 821F F1C8 86DB F1C9 8A3B F1CA 8A85 F1CB 8D70 F1CC 8E8A F1CD 8F33 F1CE 9031 F1CF 914E F1D0 9152 F1D1 9444 F1D2 99D0 F1D3 7AF9 F1D4 7CA5 F1D5 4FCA F1D6 5101 F1D7 51C6 F1D8 57C8 F1D9 5BEF F1DA 5CFB F1DB 6659 F1DC 6A3D F1DD 6D5A F1DE 6E96 F1DF 6FEC F1E0 710C F1E1 756F F1E2 7AE3 F1E3 8822 F1E4 9021 F1E5 9075 F1E6 96CB F1E7 99FF F1E8 8301 F1E9 4E2D F1EA 4EF2 F1EB 8846 F1EC 91CD F1ED 537D F1EE 6ADB F1EF 696B F1F0 6C41 F1F1 847A F1F2 589E F1F3 618E F1F4 66FE F1F5 62EF F1F6 70DD F1F7 7511 F1F8 75C7 F1F9 7E52 F1FA 84B8 F1FB 8B49 F1FC 8D08 F1FD 4E4B F1FE 53EA F2A1 54AB F2A2 5730 F2A3 5740 F2A4 5FD7 F2A5 6301 F2A6 6307 F2A7 646F F2A8 652F F2A9 65E8 F2AA 667A F2AB 679D F2AC 67B3 F2AD 6B62 F2AE 6C60 F2AF 6C9A F2B0 6F2C F2B1 77E5 F2B2 7825 F2B3 7949 F2B4 7957 F2B5 7D19 F2B6 80A2 F2B7 8102 F2B8 81F3 F2B9 829D F2BA 82B7 F2BB 8718 F2BC 8A8C F2BD F9FC F2BE 8D04 F2BF 8DBE F2C0 9072 F2C1 76F4 F2C2 7A19 F2C3 7A37 F2C4 7E54 F2C5 8077 F2C6 5507 F2C7 55D4 F2C8 5875 F2C9 632F F2CA 6422 F2CB 6649 F2CC 664B F2CD 686D F2CE 699B F2CF 6B84 F2D0 6D25 F2D1 6EB1 F2D2 73CD F2D3 7468 F2D4 74A1 F2D5 755B F2D6 75B9 F2D7 76E1 F2D8 771E F2D9 778B F2DA 79E6 F2DB 7E09 F2DC 7E1D F2DD 81FB F2DE 852F F2DF 8897 F2E0 8A3A F2E1 8CD1 F2E2 8EEB F2E3 8FB0 F2E4 9032 F2E5 93AD F2E6 9663 F2E7 9673 F2E8 9707 F2E9 4F84 F2EA 53F1 F2EB 59EA F2EC 5AC9 F2ED 5E19 F2EE 684E F2EF 74C6 F2F0 75BE F2F1 79E9 F2F2 7A92 F2F3 81A3 F2F4 86ED F2F5 8CEA F2F6 8DCC F2F7 8FED F2F8 659F F2F9 6715 F2FA F9FD F2FB 57F7 F2FC 6F57 F2FD 7DDD F2FE 8F2F F3A1 93F6 F3A2 96C6 F3A3 5FB5 F3A4 61F2 F3A5 6F84 F3A6 4E14 F3A7 4F98 F3A8 501F F3A9 53C9 F3AA 55DF F3AB 5D6F F3AC 5DEE F3AD 6B21 F3AE 6B64 F3AF 78CB F3B0 7B9A F3B1 F9FE F3B2 8E49 F3B3 8ECA F3B4 906E F3B5 6349 F3B6 643E F3B7 7740 F3B8 7A84 F3B9 932F F3BA 947F F3BB 9F6A F3BC 64B0 F3BD 6FAF F3BE 71E6 F3BF 74A8 F3C0 74DA F3C1 7AC4 F3C2 7C12 F3C3 7E82 F3C4 7CB2 F3C5 7E98 F3C6 8B9A F3C7 8D0A F3C8 947D F3C9 9910 F3CA 994C F3CB 5239 F3CC 5BDF F3CD 64E6 F3CE 672D F3CF 7D2E F3D0 50ED F3D1 53C3 F3D2 5879 F3D3 6158 F3D4 6159 F3D5 61FA F3D6 65AC F3D7 7AD9 F3D8 8B92 F3D9 8B96 F3DA 5009 F3DB 5021 F3DC 5275 F3DD 5531 F3DE 5A3C F3DF 5EE0 F3E0 5F70 F3E1 6134 F3E2 655E F3E3 660C F3E4 6636 F3E5 66A2 F3E6 69CD F3E7 6EC4 F3E8 6F32 F3E9 7316 F3EA 7621 F3EB 7A93 F3EC 8139 F3ED 8259 F3EE 83D6 F3EF 84BC F3F0 50B5 F3F1 57F0 F3F2 5BC0 F3F3 5BE8 F3F4 5F69 F3F5 63A1 F3F6 7826 F3F7 7DB5 F3F8 83DC F3F9 8521 F3FA 91C7 F3FB 91F5 F3FC 518A F3FD 67F5 F3FE 7B56 F4A1 8CAC F4A2 51C4 F4A3 59BB F4A4 60BD F4A5 8655 F4A6 501C F4A7 F9FF F4A8 5254 F4A9 5C3A F4AA 617D F4AB 621A F4AC 62D3 F4AD 64F2 F4AE 65A5 F4AF 6ECC F4B0 7620 F4B1 810A F4B2 8E60 F4B3 965F F4B4 96BB F4B5 4EDF F4B6 5343 F4B7 5598 F4B8 5929 F4B9 5DDD F4BA 64C5 F4BB 6CC9 F4BC 6DFA F4BD 7394 F4BE 7A7F F4BF 821B F4C0 85A6 F4C1 8CE4 F4C2 8E10 F4C3 9077 F4C4 91E7 F4C5 95E1 F4C6 9621 F4C7 97C6 F4C8 51F8 F4C9 54F2 F4CA 5586 F4CB 5FB9 F4CC 64A4 F4CD 6F88 F4CE 7DB4 F4CF 8F1F F4D0 8F4D F4D1 9435 F4D2 50C9 F4D3 5C16 F4D4 6CBE F4D5 6DFB F4D6 751B F4D7 77BB F4D8 7C3D F4D9 7C64 F4DA 8A79 F4DB 8AC2 F4DC 581E F4DD 59BE F4DE 5E16 F4DF 6377 F4E0 7252 F4E1 758A F4E2 776B F4E3 8ADC F4E4 8CBC F4E5 8F12 F4E6 5EF3 F4E7 6674 F4E8 6DF8 F4E9 807D F4EA 83C1 F4EB 8ACB F4EC 9751 F4ED 9BD6 F4EE FA00 F4EF 5243 F4F0 66FF F4F1 6D95 F4F2 6EEF F4F3 7DE0 F4F4 8AE6 F4F5 902E F4F6 905E F4F7 9AD4 F4F8 521D F4F9 527F F4FA 54E8 F4FB 6194 F4FC 6284 F4FD 62DB F4FE 68A2 F5A1 6912 F5A2 695A F5A3 6A35 F5A4 7092 F5A5 7126 F5A6 785D F5A7 7901 F5A8 790E F5A9 79D2 F5AA 7A0D F5AB 8096 F5AC 8278 F5AD 82D5 F5AE 8349 F5AF 8549 F5B0 8C82 F5B1 8D85 F5B2 9162 F5B3 918B F5B4 91AE F5B5 4FC3 F5B6 56D1 F5B7 71ED F5B8 77D7 F5B9 8700 F5BA 89F8 F5BB 5BF8 F5BC 5FD6 F5BD 6751 F5BE 90A8 F5BF 53E2 F5C0 585A F5C1 5BF5 F5C2 60A4 F5C3 6181 F5C4 6460 F5C5 7E3D F5C6 8070 F5C7 8525 F5C8 9283 F5C9 64AE F5CA 50AC F5CB 5D14 F5CC 6700 F5CD 589C F5CE 62BD F5CF 63A8 F5D0 690E F5D1 6978 F5D2 6A1E F5D3 6E6B F5D4 76BA F5D5 79CB F5D6 82BB F5D7 8429 F5D8 8ACF F5D9 8DA8 F5DA 8FFD F5DB 9112 F5DC 914B F5DD 919C F5DE 9310 F5DF 9318 F5E0 939A F5E1 96DB F5E2 9A36 F5E3 9C0D F5E4 4E11 F5E5 755C F5E6 795D F5E7 7AFA F5E8 7B51 F5E9 7BC9 F5EA 7E2E F5EB 84C4 F5EC 8E59 F5ED 8E74 F5EE 8EF8 F5EF 9010 F5F0 6625 F5F1 693F F5F2 7443 F5F3 51FA F5F4 672E F5F5 9EDC F5F6 5145 F5F7 5FE0 F5F8 6C96 F5F9 87F2 F5FA 885D F5FB 8877 F5FC 60B4 F5FD 81B5 F5FE 8403 F6A1 8D05 F6A2 53D6 F6A3 5439 F6A4 5634 F6A5 5A36 F6A6 5C31 F6A7 708A F6A8 7FE0 F6A9 805A F6AA 8106 F6AB 81ED F6AC 8DA3 F6AD 9189 F6AE 9A5F F6AF 9DF2 F6B0 5074 F6B1 4EC4 F6B2 53A0 F6B3 60FB F6B4 6E2C F6B5 5C64 F6B6 4F88 F6B7 5024 F6B8 55E4 F6B9 5CD9 F6BA 5E5F F6BB 6065 F6BC 6894 F6BD 6CBB F6BE 6DC4 F6BF 71BE F6C0 75D4 F6C1 75F4 F6C2 7661 F6C3 7A1A F6C4 7A49 F6C5 7DC7 F6C6 7DFB F6C7 7F6E F6C8 81F4 F6C9 86A9 F6CA 8F1C F6CB 96C9 F6CC 99B3 F6CD 9F52 F6CE 5247 F6CF 52C5 F6D0 98ED F6D1 89AA F6D2 4E03 F6D3 67D2 F6D4 6F06 F6D5 4FB5 F6D6 5BE2 F6D7 6795 F6D8 6C88 F6D9 6D78 F6DA 741B F6DB 7827 F6DC 91DD F6DD 937C F6DE 87C4 F6DF 79E4 F6E0 7A31 F6E1 5FEB F6E2 4ED6 F6E3 54A4 F6E4 553E F6E5 58AE F6E6 59A5 F6E7 60F0 F6E8 6253 F6E9 62D6 F6EA 6736 F6EB 6955 F6EC 8235 F6ED 9640 F6EE 99B1 F6EF 99DD F6F0 502C F6F1 5353 F6F2 5544 F6F3 577C F6F4 FA01 F6F5 6258 F6F6 FA02 F6F7 64E2 F6F8 666B F6F9 67DD F6FA 6FC1 F6FB 6FEF F6FC 7422 F6FD 7438 F6FE 8A17 F7A1 9438 F7A2 5451 F7A3 5606 F7A4 5766 F7A5 5F48 F7A6 619A F7A7 6B4E F7A8 7058 F7A9 70AD F7AA 7DBB F7AB 8A95 F7AC 596A F7AD 812B F7AE 63A2 F7AF 7708 F7B0 803D F7B1 8CAA F7B2 5854 F7B3 642D F7B4 69BB F7B5 5B95 F7B6 5E11 F7B7 6E6F F7B8 FA03 F7B9 8569 F7BA 514C F7BB 53F0 F7BC 592A F7BD 6020 F7BE 614B F7BF 6B86 F7C0 6C70 F7C1 6CF0 F7C2 7B1E F7C3 80CE F7C4 82D4 F7C5 8DC6 F7C6 90B0 F7C7 98B1 F7C8 FA04 F7C9 64C7 F7CA 6FA4 F7CB 6491 F7CC 6504 F7CD 514E F7CE 5410 F7CF 571F F7D0 8A0E F7D1 615F F7D2 6876 F7D3 FA05 F7D4 75DB F7D5 7B52 F7D6 7D71 F7D7 901A F7D8 5806 F7D9 69CC F7DA 817F F7DB 892A F7DC 9000 F7DD 9839 F7DE 5078 F7DF 5957 F7E0 59AC F7E1 6295 F7E2 900F F7E3 9B2A F7E4 615D F7E5 7279 F7E6 95D6 F7E7 5761 F7E8 5A46 F7E9 5DF4 F7EA 628A F7EB 64AD F7EC 64FA F7ED 6777 F7EE 6CE2 F7EF 6D3E F7F0 722C F7F1 7436 F7F2 7834 F7F3 7F77 F7F4 82AD F7F5 8DDB F7F6 9817 F7F7 5224 F7F8 5742 F7F9 677F F7FA 7248 F7FB 74E3 F7FC 8CA9 F7FD 8FA6 F7FE 9211 F8A1 962A F8A2 516B F8A3 53ED F8A4 634C F8A5 4F69 F8A6 5504 F8A7 6096 F8A8 6557 F8A9 6C9B F8AA 6D7F F8AB 724C F8AC 72FD F8AD 7A17 F8AE 8987 F8AF 8C9D F8B0 5F6D F8B1 6F8E F8B2 70F9 F8B3 81A8 F8B4 610E F8B5 4FBF F8B6 504F F8B7 6241 F8B8 7247 F8B9 7BC7 F8BA 7DE8 F8BB 7FE9 F8BC 904D F8BD 97AD F8BE 9A19 F8BF 8CB6 F8C0 576A F8C1 5E73 F8C2 67B0 F8C3 840D F8C4 8A55 F8C5 5420 F8C6 5B16 F8C7 5E63 F8C8 5EE2 F8C9 5F0A F8CA 6583 F8CB 80BA F8CC 853D F8CD 9589 F8CE 965B F8CF 4F48 F8D0 5305 F8D1 530D F8D2 530F F8D3 5486 F8D4 54FA F8D5 5703 F8D6 5E03 F8D7 6016 F8D8 629B F8D9 62B1 F8DA 6355 F8DB FA06 F8DC 6CE1 F8DD 6D66 F8DE 75B1 F8DF 7832 F8E0 80DE F8E1 812F F8E2 82DE F8E3 8461 F8E4 84B2 F8E5 888D F8E6 8912 F8E7 900B F8E8 92EA F8E9 98FD F8EA 9B91 F8EB 5E45 F8EC 66B4 F8ED 66DD F8EE 7011 F8EF 7206 F8F0 FA07 F8F1 4FF5 F8F2 527D F8F3 5F6A F8F4 6153 F8F5 6753 F8F6 6A19 F8F7 6F02 F8F8 74E2 F8F9 7968 F8FA 8868 F8FB 8C79 F8FC 98C7 F8FD 98C4 F8FE 9A43 F9A1 54C1 F9A2 7A1F F9A3 6953 F9A4 8AF7 F9A5 8C4A F9A6 98A8 F9A7 99AE F9A8 5F7C F9A9 62AB F9AA 75B2 F9AB 76AE F9AC 88AB F9AD 907F F9AE 9642 F9AF 5339 F9B0 5F3C F9B1 5FC5 F9B2 6CCC F9B3 73CC F9B4 7562 F9B5 758B F9B6 7B46 F9B7 82FE F9B8 999D F9B9 4E4F F9BA 903C F9BB 4E0B F9BC 4F55 F9BD 53A6 F9BE 590F F9BF 5EC8 F9C0 6630 F9C1 6CB3 F9C2 7455 F9C3 8377 F9C4 8766 F9C5 8CC0 F9C6 9050 F9C7 971E F9C8 9C15 F9C9 58D1 F9CA 5B78 F9CB 8650 F9CC 8B14 F9CD 9DB4 F9CE 5BD2 F9CF 6068 F9D0 608D F9D1 65F1 F9D2 6C57 F9D3 6F22 F9D4 6FA3 F9D5 701A F9D6 7F55 F9D7 7FF0 F9D8 9591 F9D9 9592 F9DA 9650 F9DB 97D3 F9DC 5272 F9DD 8F44 F9DE 51FD F9DF 542B F9E0 54B8 F9E1 5563 F9E2 558A F9E3 6ABB F9E4 6DB5 F9E5 7DD8 F9E6 8266 F9E7 929C F9E8 9677 F9E9 9E79 F9EA 5408 F9EB 54C8 F9EC 76D2 F9ED 86E4 F9EE 95A4 F9EF 95D4 F9F0 965C F9F1 4EA2 F9F2 4F09 F9F3 59EE F9F4 5AE6 F9F5 5DF7 F9F6 6052 F9F7 6297 F9F8 676D F9F9 6841 F9FA 6C86 F9FB 6E2F F9FC 7F38 F9FD 809B F9FE 822A FAA1 FA08 FAA2 FA09 FAA3 9805 FAA4 4EA5 FAA5 5055 FAA6 54B3 FAA7 5793 FAA8 595A FAA9 5B69 FAAA 5BB3 FAAB 61C8 FAAC 6977 FAAD 6D77 FAAE 7023 FAAF 87F9 FAB0 89E3 FAB1 8A72 FAB2 8AE7 FAB3 9082 FAB4 99ED FAB5 9AB8 FAB6 52BE FAB7 6838 FAB8 5016 FAB9 5E78 FABA 674F FABB 8347 FABC 884C FABD 4EAB FABE 5411 FABF 56AE FAC0 73E6 FAC1 9115 FAC2 97FF FAC3 9909 FAC4 9957 FAC5 9999 FAC6 5653 FAC7 589F FAC8 865B FAC9 8A31 FACA 61B2 FACB 6AF6 FACC 737B FACD 8ED2 FACE 6B47 FACF 96AA FAD0 9A57 FAD1 5955 FAD2 7200 FAD3 8D6B FAD4 9769 FAD5 4FD4 FAD6 5CF4 FAD7 5F26 FAD8 61F8 FAD9 665B FADA 6CEB FADB 70AB FADC 7384 FADD 73B9 FADE 73FE FADF 7729 FAE0 774D FAE1 7D43 FAE2 7D62 FAE3 7E23 FAE4 8237 FAE5 8852 FAE6 FA0A FAE7 8CE2 FAE8 9249 FAE9 986F FAEA 5B51 FAEB 7A74 FAEC 8840 FAED 9801 FAEE 5ACC FAEF 4FE0 FAF0 5354 FAF1 593E FAF2 5CFD FAF3 633E FAF4 6D79 FAF5 72F9 FAF6 8105 FAF7 8107 FAF8 83A2 FAF9 92CF FAFA 9830 FAFB 4EA8 FAFC 5144 FAFD 5211 FAFE 578B FBA1 5F62 FBA2 6CC2 FBA3 6ECE FBA4 7005 FBA5 7050 FBA6 70AF FBA7 7192 FBA8 73E9 FBA9 7469 FBAA 834A FBAB 87A2 FBAC 8861 FBAD 9008 FBAE 90A2 FBAF 93A3 FBB0 99A8 FBB1 516E FBB2 5F57 FBB3 60E0 FBB4 6167 FBB5 66B3 FBB6 8559 FBB7 8E4A FBB8 91AF FBB9 978B FBBA 4E4E FBBB 4E92 FBBC 547C FBBD 58D5 FBBE 58FA FBBF 597D FBC0 5CB5 FBC1 5F27 FBC2 6236 FBC3 6248 FBC4 660A FBC5 6667 FBC6 6BEB FBC7 6D69 FBC8 6DCF FBC9 6E56 FBCA 6EF8 FBCB 6F94 FBCC 6FE0 FBCD 6FE9 FBCE 705D FBCF 72D0 FBD0 7425 FBD1 745A FBD2 74E0 FBD3 7693 FBD4 795C FBD5 7CCA FBD6 7E1E FBD7 80E1 FBD8 82A6 FBD9 846B FBDA 84BF FBDB 864E FBDC 865F FBDD 8774 FBDE 8B77 FBDF 8C6A FBE0 93AC FBE1 9800 FBE2 9865 FBE3 60D1 FBE4 6216 FBE5 9177 FBE6 5A5A FBE7 660F FBE8 6DF7 FBE9 6E3E FBEA 743F FBEB 9B42 FBEC 5FFD FBED 60DA FBEE 7B0F FBEF 54C4 FBF0 5F18 FBF1 6C5E FBF2 6CD3 FBF3 6D2A FBF4 70D8 FBF5 7D05 FBF6 8679 FBF7 8A0C FBF8 9D3B FBF9 5316 FBFA 548C FBFB 5B05 FBFC 6A3A FBFD 706B FBFE 7575 FCA1 798D FCA2 79BE FCA3 82B1 FCA4 83EF FCA5 8A71 FCA6 8B41 FCA7 8CA8 FCA8 9774 FCA9 FA0B FCAA 64F4 FCAB 652B FCAC 78BA FCAD 78BB FCAE 7A6B FCAF 4E38 FCB0 559A FCB1 5950 FCB2 5BA6 FCB3 5E7B FCB4 60A3 FCB5 63DB FCB6 6B61 FCB7 6665 FCB8 6853 FCB9 6E19 FCBA 7165 FCBB 74B0 FCBC 7D08 FCBD 9084 FCBE 9A69 FCBF 9C25 FCC0 6D3B FCC1 6ED1 FCC2 733E FCC3 8C41 FCC4 95CA FCC5 51F0 FCC6 5E4C FCC7 5FA8 FCC8 604D FCC9 60F6 FCCA 6130 FCCB 614C FCCC 6643 FCCD 6644 FCCE 69A5 FCCF 6CC1 FCD0 6E5F FCD1 6EC9 FCD2 6F62 FCD3 714C FCD4 749C FCD5 7687 FCD6 7BC1 FCD7 7C27 FCD8 8352 FCD9 8757 FCDA 9051 FCDB 968D FCDC 9EC3 FCDD 532F FCDE 56DE FCDF 5EFB FCE0 5F8A FCE1 6062 FCE2 6094 FCE3 61F7 FCE4 6666 FCE5 6703 FCE6 6A9C FCE7 6DEE FCE8 6FAE FCE9 7070 FCEA 736A FCEB 7E6A FCEC 81BE FCED 8334 FCEE 86D4 FCEF 8AA8 FCF0 8CC4 FCF1 5283 FCF2 7372 FCF3 5B96 FCF4 6A6B FCF5 9404 FCF6 54EE FCF7 5686 FCF8 5B5D FCF9 6548 FCFA 6585 FCFB 66C9 FCFC 689F FCFD 6D8D FCFE 6DC6 FDA1 723B FDA2 80B4 FDA3 9175 FDA4 9A4D FDA5 4FAF FDA6 5019 FDA7 539A FDA8 540E FDA9 543C FDAA 5589 FDAB 55C5 FDAC 5E3F FDAD 5F8C FDAE 673D FDAF 7166 FDB0 73DD FDB1 9005 FDB2 52DB FDB3 52F3 FDB4 5864 FDB5 58CE FDB6 7104 FDB7 718F FDB8 71FB FDB9 85B0 FDBA 8A13 FDBB 6688 FDBC 85A8 FDBD 55A7 FDBE 6684 FDBF 714A FDC0 8431 FDC1 5349 FDC2 5599 FDC3 6BC1 FDC4 5F59 FDC5 5FBD FDC6 63EE FDC7 6689 FDC8 7147 FDC9 8AF1 FDCA 8F1D FDCB 9EBE FDCC 4F11 FDCD 643A FDCE 70CB FDCF 7566 FDD0 8667 FDD1 6064 FDD2 8B4E FDD3 9DF8 FDD4 5147 FDD5 51F6 FDD6 5308 FDD7 6D36 FDD8 80F8 FDD9 9ED1 FDDA 6615 FDDB 6B23 FDDC 7098 FDDD 75D5 FDDE 5403 FDDF 5C79 FDE0 7D07 FDE1 8A16 FDE2 6B20 FDE3 6B3D FDE4 6B46 FDE5 5438 FDE6 6070 FDE7 6D3D FDE8 7FD5 FDE9 8208 FDEA 50D6 FDEB 51DE FDEC 559C FDED 566B FDEE 56CD FDEF 59EC FDF0 5B09 FDF1 5E0C FDF2 6199 FDF3 6198 FDF4 6231 FDF5 665E FDF6 66E6 FDF7 7199 FDF8 71B9 FDF9 71BA FDFA 72A7 FDFB 79A7 FDFC 7A00 FDFD 7FB2 FDFE 8A70
172,364
17,323
jart/cosmopolitan
false