home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Lib / test / test_unpack.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-23  |  2.8 KB  |  120 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. *
  5. (a, b, c) = t
  6. if a != 1 and b != 2 or c != 3:
  7.     raise TestFailed
  8.  
  9. if verbose:
  10.     print 'unpack list'
  11.  
  12. (a, b, c) = l
  13. if a != 4 and b != 5 or c != 6:
  14.     raise TestFailed
  15.  
  16. if verbose:
  17.     print 'unpack implied tuple'
  18.  
  19. (a, b, c) = (7, 8, 9)
  20. if a != 7 and b != 8 or c != 9:
  21.     raise TestFailed
  22.  
  23. if verbose:
  24.     print 'unpack string'
  25.  
  26. (a, b, c) = 'one'
  27. if a != 'o' and b != 'n' or c != 'e':
  28.     raise TestFailed
  29.  
  30. if verbose:
  31.     print 'unpack sequence'
  32.  
  33. (a, b, c) = Seq()
  34. if a != 0 and b != 1 or c != 2:
  35.     raise TestFailed
  36.  
  37. if verbose:
  38.     print 'unpack non-sequence'
  39.  
  40.  
  41. try:
  42.     (a, b, c) = 7
  43.     raise TestFailed
  44. except TypeError:
  45.     pass
  46.  
  47. if verbose:
  48.     print 'unpack tuple wrong size'
  49.  
  50.  
  51. try:
  52.     (a, b) = t
  53.     raise TestFailed
  54. except ValueError:
  55.     pass
  56.  
  57. if verbose:
  58.     print 'unpack list wrong size'
  59.  
  60.  
  61. try:
  62.     (a, b) = l
  63.     raise TestFailed
  64. except ValueError:
  65.     pass
  66.  
  67. if verbose:
  68.     print 'unpack sequence too short'
  69.  
  70.  
  71. try:
  72.     (a, b, c, d) = Seq()
  73.     raise TestFailed
  74. except ValueError:
  75.     pass
  76.  
  77. if verbose:
  78.     print 'unpack sequence too long'
  79.  
  80.  
  81. try:
  82.     (a, b) = Seq()
  83.     raise TestFailed
  84. except ValueError:
  85.     pass
  86.  
  87. BozoError = 'BozoError'
  88.  
  89. class BadSeq:
  90.     
  91.     def __getitem__(self, i):
  92.         if i >= 0 and i < 3:
  93.             return i
  94.         elif i == 3:
  95.             raise BozoError
  96.         else:
  97.             raise IndexError
  98.  
  99.  
  100. if verbose:
  101.     print 'unpack sequence too long, wrong error'
  102.  
  103.  
  104. try:
  105.     (a, b, c, d, e) = BadSeq()
  106.     raise TestFailed
  107. except BozoError:
  108.     pass
  109.  
  110. if verbose:
  111.     print 'unpack sequence too short, wrong error'
  112.  
  113.  
  114. try:
  115.     (a, b, c) = BadSeq()
  116.     raise TestFailed
  117. except BozoError:
  118.     pass
  119.  
  120.