summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_b2.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-23 17:22:08 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-23 17:22:08 (GMT)
commit004d5e6880940ddbb38460986ac62ee0f1bae97d (patch)
tree682e75e743f5c22206a65ac0262c03ce37e4fbee /Lib/test/test_b2.py
parent2e6d25c5bbf3e2d4f18191c0836b5ed8f94dc850 (diff)
downloadcpython-004d5e6880940ddbb38460986ac62ee0f1bae97d.zip
cpython-004d5e6880940ddbb38460986ac62ee0f1bae97d.tar.gz
cpython-004d5e6880940ddbb38460986ac62ee0f1bae97d.tar.bz2
Make reindent.py happy (convert everything to 4-space indents!).
Diffstat (limited to 'Lib/test/test_b2.py')
-rw-r--r--Lib/test/test_b2.py164
1 files changed, 82 insertions, 82 deletions
diff --git a/Lib/test/test_b2.py b/Lib/test/test_b2.py
index 8ee4a03..ec6ae50 100644
--- a/Lib/test/test_b2.py
+++ b/Lib/test/test_b2.py
@@ -6,35 +6,35 @@ print 'oct'
if oct(100) != '0144': raise TestFailed, 'oct(100)'
if oct(100L) != '0144L': raise TestFailed, 'oct(100L)'
if oct(-100) not in ('037777777634', '01777777777777777777634'):
- raise TestFailed, 'oct(-100)'
+ raise TestFailed, 'oct(-100)'
if oct(-100L) != '-0144L': raise TestFailed, 'oct(-100L)'
print 'open'
# NB the first 4 lines are also used to test input and raw_input, below
fp = open(TESTFN, 'w')
try:
- fp.write('1+1\n')
- fp.write('1+1\n')
- fp.write('The quick brown fox jumps over the lazy dog')
- fp.write('.\n')
- fp.write('Dear John\n')
- fp.write('XXX'*100)
- fp.write('YYY'*100)
+ fp.write('1+1\n')
+ fp.write('1+1\n')
+ fp.write('The quick brown fox jumps over the lazy dog')
+ fp.write('.\n')
+ fp.write('Dear John\n')
+ fp.write('XXX'*100)
+ fp.write('YYY'*100)
finally:
- fp.close()
+ fp.close()
#
fp = open(TESTFN, 'r')
try:
- if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact'
- if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact'
- if fp.readline() <> 'The quick brown fox jumps over the lazy dog.\n':
- raise TestFailed, 'readline() # default'
- if fp.readline(4) <> 'Dear': raise TestFailed, 'readline(4) # short'
- if fp.readline(100) <> ' John\n': raise TestFailed, 'readline(100)'
- if fp.read(300) <> 'XXX'*100: raise TestFailed, 'read(300)'
- if fp.read(1000) <> 'YYY'*100: raise TestFailed, 'read(1000) # truncate'
+ if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact'
+ if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact'
+ if fp.readline() <> 'The quick brown fox jumps over the lazy dog.\n':
+ raise TestFailed, 'readline() # default'
+ if fp.readline(4) <> 'Dear': raise TestFailed, 'readline(4) # short'
+ if fp.readline(100) <> ' John\n': raise TestFailed, 'readline(100)'
+ if fp.read(300) <> 'XXX'*100: raise TestFailed, 'read(300)'
+ if fp.read(1000) <> 'YYY'*100: raise TestFailed, 'read(1000) # truncate'
finally:
- fp.close()
+ fp.close()
print 'ord'
if ord(' ') <> 32: raise TestFailed, 'ord(\' \')'
@@ -89,10 +89,10 @@ if fcmp(pow(2.,30), 1024.*1024.*1024.): raise TestFailed, 'pow(2.,30)'
#if fcmp(pow(-2.,3), -8.): raise TestFailed, 'pow(-2.,3)'
#
for x in 2, 2L, 2.0:
- for y in 10, 10L, 10.0:
- for z in 1000, 1000L, 1000.0:
- if fcmp(pow(x, y, z), 24.0):
- raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z)
+ for y in 10, 10L, 10.0:
+ for z in 1000, 1000L, 1000.0:
+ if fcmp(pow(x, y, z), 24.0):
+ raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z)
print 'range'
if range(3) <> [0, 1, 2]: raise TestFailed, 'range(3)'
@@ -107,45 +107,45 @@ import sys
fp = open(TESTFN, 'r')
savestdin = sys.stdin
try:
- sys.stdin = fp
- if input() <> 2: raise TestFailed, 'input()'
- if input('testing\n') <> 2: raise TestFailed, 'input()'
- if raw_input() <> 'The quick brown fox jumps over the lazy dog.':
- raise TestFailed, 'raw_input()'
- if raw_input('testing\n') <> 'Dear John':
- raise TestFailed, 'raw_input(\'testing\\n\')'
+ sys.stdin = fp
+ if input() <> 2: raise TestFailed, 'input()'
+ if input('testing\n') <> 2: raise TestFailed, 'input()'
+ if raw_input() <> 'The quick brown fox jumps over the lazy dog.':
+ raise TestFailed, 'raw_input()'
+ if raw_input('testing\n') <> 'Dear John':
+ raise TestFailed, 'raw_input(\'testing\\n\')'
finally:
- sys.stdin = savestdin
- fp.close()
+ sys.stdin = savestdin
+ fp.close()
print 'reduce'
if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') <> 'abc':
- raise TestFailed, 'reduce(): implode a string'
+ raise TestFailed, 'reduce(): implode a string'
if reduce(lambda x, y: x+y,
- [['a', 'c'], [], ['d', 'w']], []) <> ['a','c','d','w']:
- raise TestFailed, 'reduce(): append'
+ [['a', 'c'], [], ['d', 'w']], []) <> ['a','c','d','w']:
+ raise TestFailed, 'reduce(): append'
if reduce(lambda x, y: x*y, range(2,8), 1) <> 5040:
- raise TestFailed, 'reduce(): compute 7!'
+ raise TestFailed, 'reduce(): compute 7!'
if reduce(lambda x, y: x*y, range(2,21), 1L) <> 2432902008176640000L:
- raise TestFailed, 'reduce(): compute 20!, use long'
+ raise TestFailed, 'reduce(): compute 20!, use long'
class Squares:
- def __init__(self, max):
- self.max = max
- self.sofar = []
- def __len__(self): return len(self.sofar)
- def __getitem__(self, i):
- if not 0 <= i < self.max: raise IndexError
- n = len(self.sofar)
- while n <= i:
- self.sofar.append(n*n)
- n = n+1
- return self.sofar[i]
+ def __init__(self, max):
+ self.max = max
+ self.sofar = []
+ def __len__(self): return len(self.sofar)
+ def __getitem__(self, i):
+ if not 0 <= i < self.max: raise IndexError
+ n = len(self.sofar)
+ while n <= i:
+ self.sofar.append(n*n)
+ n = n+1
+ return self.sofar[i]
if reduce(lambda x, y: x+y, Squares(10)) != 285:
- raise TestFailed, 'reduce(<+>, Squares(10))'
+ raise TestFailed, 'reduce(<+>, Squares(10))'
if reduce(lambda x, y: x+y, Squares(10), 0) != 285:
- raise TestFailed, 'reduce(<+>, Squares(10), 0)'
+ raise TestFailed, 'reduce(<+>, Squares(10), 0)'
if reduce(lambda x, y: x+y, Squares(0), 0) != 0:
- raise TestFailed, 'reduce(<+>, Squares(0), 0)'
+ raise TestFailed, 'reduce(<+>, Squares(0), 0)'
print 'reload'
@@ -171,35 +171,35 @@ if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)'
if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)'
if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)'
if round(1000000000.0) <> 1000000000.0:
- raise TestFailed, 'round(1000000000.0)'
+ raise TestFailed, 'round(1000000000.0)'
if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)'
if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)'
if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)'
if round(-1000000000.0) <> -1000000000.0:
- raise TestFailed, 'round(-1000000000.0)'
+ raise TestFailed, 'round(-1000000000.0)'
if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)'
if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)'
if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)'
if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)'
if round(1000000000.1) <> 1000000000.0:
- raise TestFailed, 'round(1000000000.0)'
+ raise TestFailed, 'round(1000000000.0)'
if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)'
if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)'
if round(-1000000000.1) <> -1000000000.0:
- raise TestFailed, 'round(-1000000000.0)'
+ raise TestFailed, 'round(-1000000000.0)'
if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)'
if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)'
if round(999999999.9) <> 1000000000.0:
- raise TestFailed, 'round(999999999.9)'
+ raise TestFailed, 'round(999999999.9)'
if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)'
if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)'
if round(-999999999.9) <> -1000000000.0:
- raise TestFailed, 'round(-999999999.9)'
+ raise TestFailed, 'round(-999999999.9)'
print 'setattr'
import sys
@@ -224,7 +224,7 @@ if tuple('spam') <> ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')"
print 'type'
if type('') <> type('123') or type('') == type(()):
- raise TestFailed, 'type()'
+ raise TestFailed, 'type()'
print 'vars'
a = b = None
@@ -240,20 +240,20 @@ a.sort()
b.sort()
if a <> b: raise TestFailed, 'vars(sys)'
def f0():
- if vars() != {}: raise TestFailed, 'vars() in f0()'
+ if vars() != {}: raise TestFailed, 'vars() in f0()'
f0()
def f2():
- f0()
- a = 1
- b = 2
- if vars() != {'a': a, 'b': b}: raise TestFailed, 'vars() in f2()'
+ f0()
+ a = 1
+ b = 2
+ if vars() != {'a': a, 'b': b}: raise TestFailed, 'vars() in f2()'
f2()
print 'xrange'
if tuple(xrange(10)) <> tuple(range(10)): raise TestFailed, 'xrange(10)'
if tuple(xrange(5,10)) <> tuple(range(5,10)): raise TestFailed, 'xrange(5,10)'
if tuple(xrange(0,10,2)) <> tuple(range(0,10,2)):
- raise TestFailed, 'xrange(0,10,2)'
+ raise TestFailed, 'xrange(0,10,2)'
print 'zip'
a = (1, 2, 3)
@@ -265,43 +265,43 @@ if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, tuple/list'
b = (4, 5, 6, 7)
if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - b is longer'
class I:
- def __getitem__(self, i):
- if i < 0 or i > 2: raise IndexError
- return i + 4
+ def __getitem__(self, i):
+ if i < 0 or i > 2: raise IndexError
+ return i + 4
if zip(a, I()) <> t: raise TestFailed, 'zip(a, b) - b is instance'
exc = 0
try:
- zip()
+ zip()
except TypeError:
- exc = 1
+ exc = 1
except:
- e = sys.exc_info()[0]
- raise TestFailed, 'zip() - no args, expected TypeError, got %s' % e
+ e = sys.exc_info()[0]
+ raise TestFailed, 'zip() - no args, expected TypeError, got %s' % e
if not exc:
- raise TestFailed, 'zip() - no args, missing expected TypeError'
+ raise TestFailed, 'zip() - no args, missing expected TypeError'
exc = 0
try:
- zip(None)
+ zip(None)
except TypeError:
- exc = 1
+ exc = 1
except:
- e = sys.exc_info()[0]
- raise TestFailed, 'zip(None) - expected TypeError, got %s' % e
+ e = sys.exc_info()[0]
+ raise TestFailed, 'zip(None) - expected TypeError, got %s' % e
if not exc:
- raise TestFailed, 'zip(None) - missing expected TypeError'
+ raise TestFailed, 'zip(None) - missing expected TypeError'
class G:
- pass
+ pass
exc = 0
try:
- zip(a, G())
+ zip(a, G())
except AttributeError:
- exc = 1
+ exc = 1
except:
- e = sys.exc_info()[0]
- raise TestFailed, 'zip(a, b) - b instance w/o __getitem__'
+ e = sys.exc_info()[0]
+ raise TestFailed, 'zip(a, b) - b instance w/o __getitem__'
if not exc:
- raise TestFailed, 'zip(a, b) - missing expected AttributeError'
+ raise TestFailed, 'zip(a, b) - missing expected AttributeError'
# Epilogue -- unlink the temp file