[pypy-commit] pypy py3k: merge heads
bdkearns
noreply at buildbot.pypy.org
Thu Mar 7 22:12:09 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch: py3k
Changeset: r62186:46a5efb3dae1
Date: 2013-03-07 16:11 -0500
http://bitbucket.org/pypy/pypy/changeset/46a5efb3dae1/
Log: merge heads
diff --git a/pypy/module/__builtin__/test/test_filter.py b/pypy/module/__builtin__/test/test_filter.py
--- a/pypy/module/__builtin__/test/test_filter.py
+++ b/pypy/module/__builtin__/test/test_filter.py
@@ -1,4 +1,4 @@
-# trivial functions for testing
+# trivial functions for testing
class AppTestFilter:
def test_filter_no_arguments(self):
diff --git a/pypy/module/__builtin__/test/test_functional.py b/pypy/module/__builtin__/test/test_functional.py
--- a/pypy/module/__builtin__/test/test_functional.py
+++ b/pypy/module/__builtin__/test/test_functional.py
@@ -1,70 +1,70 @@
class AppTestMap:
- def test_trivial_map_one_seq(self):
- assert list(map(lambda x: x+2, [1, 2, 3, 4])) == [3, 4, 5, 6]
+ def test_trivial_map_one_seq(self):
+ assert list(map(lambda x: x+2, [1, 2, 3, 4])) == [3, 4, 5, 6]
- def test_trivial_map_one_seq_2(self):
- assert list(map(str, [1, 2, 3, 4])) == ['1', '2', '3', '4']
+ def test_trivial_map_one_seq_2(self):
+ assert list(map(str, [1, 2, 3, 4])) == ['1', '2', '3', '4']
- def test_trivial_map_two_seq(self):
- assert list(map(lambda x,y: x+y,
- [1, 2, 3, 4],[1, 2, 3, 4])) == (
- [2, 4, 6, 8])
+ def test_trivial_map_two_seq(self):
+ assert list(map(lambda x,y: x+y,
+ [1, 2, 3, 4],[1, 2, 3, 4])) == (
+ [2, 4, 6, 8])
- def test_trivial_map_sizes_dont_match(self):
- assert list(map(lambda x,y: x+y, [1, 2, 3, 4], [1, 2, 3])) == (
- [2, 4, 6])
+ def test_trivial_map_sizes_dont_match(self):
+ assert list(map(lambda x,y: x+y, [1, 2, 3, 4], [1, 2, 3])) == (
+ [2, 4, 6])
- def test_trivial_map_no_arguments(self):
- raises(TypeError, map)
+ def test_trivial_map_no_arguments(self):
+ raises(TypeError, map)
- def test_trivial_map_no_function_no_seq(self):
- raises(TypeError, map, None)
+ def test_trivial_map_no_function_no_seq(self):
+ raises(TypeError, map, None)
- def test_trivial_map_no_fuction(self):
- m = map(None, [1, 2, 3]) # Don't crash here...
- raises(TypeError, next, m) # ...but only on first item.
+ def test_trivial_map_no_fuction(self):
+ m = map(None, [1, 2, 3]) # Don't crash here...
+ raises(TypeError, next, m) # ...but only on first item.
- def test_map_identity1(self):
- a = ['1', 2, 3, 'b', None]
- b = a[:]
- assert list(map(lambda x: x, a)) == a
- assert a == b
+ def test_map_identity1(self):
+ a = ['1', 2, 3, 'b', None]
+ b = a[:]
+ assert list(map(lambda x: x, a)) == a
+ assert a == b
- def test_map_badoperation(self):
- a = ['1', 2, 3, 'b', None]
- raises(TypeError, list, map, lambda x: x+1, a)
+ def test_map_badoperation(self):
+ a = ['1', 2, 3, 'b', None]
+ raises(TypeError, list, map, lambda x: x+1, a)
- def test_map_add(self):
- a = [1, 2, 3, 4]
- b = [0, 1, 1, 1]
- assert list(map(lambda x, y: x+y, a, b)) == [1, 3, 4, 5]
+ def test_map_add(self):
+ a = [1, 2, 3, 4]
+ b = [0, 1, 1, 1]
+ assert list(map(lambda x, y: x+y, a, b)) == [1, 3, 4, 5]
- def test_map_first_item(self):
- a = [1, 2, 3, 4, 5]
- b = [6, 7, 8, 9, 10]
- assert list(map(lambda x, y: x, a, b)) == a
+ def test_map_first_item(self):
+ a = [1, 2, 3, 4, 5]
+ b = [6, 7, 8, 9, 10]
+ assert list(map(lambda x, y: x, a, b)) == a
- def test_map_iterables(self):
- class A(object):
- def __init__(self, n):
- self.n = n
- def __iter__(self):
- return B(self.n)
- class B(object):
- def __init__(self, n):
- self.n = n
- def __next__(self):
- self.n -= 1
- if self.n == 0: raise StopIteration
- return self.n
- result = map(lambda *x:x, A(3), A(8))
- # this also checks that B.next() is not called any more after it
- # raised StopIteration once
- assert list(result) == [(2, 7), (1, 6)]
+ def test_map_iterables(self):
+ class A(object):
+ def __init__(self, n):
+ self.n = n
+ def __iter__(self):
+ return B(self.n)
+ class B(object):
+ def __init__(self, n):
+ self.n = n
+ def __next__(self):
+ self.n -= 1
+ if self.n == 0: raise StopIteration
+ return self.n
+ result = map(lambda *x:x, A(3), A(8))
+ # this also checks that B.next() is not called any more after it
+ # raised StopIteration once
+ assert list(result) == [(2, 7), (1, 6)]
- def test_repr(self):
- assert repr(map(1, [2])).startswith('<map object ')
+ def test_repr(self):
+ assert repr(map(1, [2])).startswith('<map object ')
class AppTestMap2:
@@ -106,37 +106,37 @@
raises(TypeError, map, 42)
class AppTestZip:
- def test_one_list(self):
- assert list(zip([1,2,3])) == [(1,), (2,), (3,)]
+ def test_one_list(self):
+ assert list(zip([1,2,3])) == [(1,), (2,), (3,)]
- def test_three_lists(self):
- assert list(zip([1,2,3], [1,2], [1,2,3])) == [(1,1,1), (2,2,2)]
+ def test_three_lists(self):
+ assert list(zip([1,2,3], [1,2], [1,2,3])) == [(1,1,1), (2,2,2)]
- def test_bad_length_hint(self):
- class Foo(object):
- def __length_hint__(self):
- return NotImplemented
- def __iter__(self):
- if False:
- yield None
- assert list(zip(Foo())) == []
+ def test_bad_length_hint(self):
+ class Foo(object):
+ def __length_hint__(self):
+ return NotImplemented
+ def __iter__(self):
+ if False:
+ yield None
+ assert list(zip(Foo())) == []
- def test_repr(self):
- assert repr(zip([1,2,3], [1,2], [1,2,3])).startswith('<zip object ')
+ def test_repr(self):
+ assert repr(zip([1,2,3], [1,2], [1,2,3])).startswith('<zip object ')
class AppTestFilter:
- def test_None(self):
- assert list(filter(None, ['a', 'b', 1, 0, None])) == ['a', 'b', 1]
+ def test_None(self):
+ assert list(filter(None, ['a', 'b', 1, 0, None])) == ['a', 'b', 1]
- def test_return_type(self):
- txt = "This is a test text"
- assert list(filter(None, txt)) == list(txt)
- tup = ("a", None, 0, [], 1)
- assert list(filter(None, tup)) == ["a", 1]
+ def test_return_type(self):
+ txt = "This is a test text"
+ assert list(filter(None, txt)) == list(txt)
+ tup = ("a", None, 0, [], 1)
+ assert list(filter(None, tup)) == ["a", 1]
- def test_function(self):
- assert list(filter(lambda x: x != "a", "a small text")) == list(" smll text")
- assert list(filter(lambda x: x < 20, [3, 33, 5, 55])) == [3, 5]
+ def test_function(self):
+ assert list(filter(lambda x: x != "a", "a small text")) == list(" smll text")
+ assert list(filter(lambda x: x < 20, [3, 33, 5, 55])) == [3, 5]
class AppTestFilter2:
def test_filter(self):
@@ -164,225 +164,225 @@
class AppTestRange:
- def test_range(self):
- x = range(2, 9, 3)
- assert x[1] == 5
- assert len(x) == 3
- assert list(x) == [2, 5, 8]
- # test again, to make sure that range() is not its own iterator
- assert list(x) == [2, 5, 8]
+ def test_range(self):
+ x = range(2, 9, 3)
+ assert x[1] == 5
+ assert len(x) == 3
+ assert list(x) == [2, 5, 8]
+ # test again, to make sure that range() is not its own iterator
+ assert list(x) == [2, 5, 8]
- def test_range_toofew(self):
- raises(TypeError, range)
+ def test_range_toofew(self):
+ raises(TypeError, range)
- def test_range_toomany(self):
- raises(TypeError, range, 1, 2, 3, 4)
+ def test_range_toomany(self):
+ raises(TypeError, range, 1, 2, 3, 4)
- def test_range_one(self):
- assert list(range(1)) == [0]
+ def test_range_one(self):
+ assert list(range(1)) == [0]
- def test_range_posstartisstop(self):
- assert list(range(1, 1)) == []
+ def test_range_posstartisstop(self):
+ assert list(range(1, 1)) == []
- def test_range_negstartisstop(self):
- assert list(range(-1, -1)) == []
+ def test_range_negstartisstop(self):
+ assert list(range(-1, -1)) == []
- def test_range_zero(self):
- assert list(range(0)) == []
+ def test_range_zero(self):
+ assert list(range(0)) == []
- def test_range_twoargs(self):
- assert list(range(1, 2)) == [1]
+ def test_range_twoargs(self):
+ assert list(range(1, 2)) == [1]
- def test_range_decreasingtwoargs(self):
- assert list(range(3, 1)) == []
+ def test_range_decreasingtwoargs(self):
+ assert list(range(3, 1)) == []
- def test_range_negatives(self):
- assert list(range(-3)) == []
+ def test_range_negatives(self):
+ assert list(range(-3)) == []
- def test_range_decreasing_negativestep(self):
- assert list(range(5, -2, -1)) == [5, 4, 3, 2, 1, 0 , -1]
+ def test_range_decreasing_negativestep(self):
+ assert list(range(5, -2, -1)) == [5, 4, 3, 2, 1, 0 , -1]
- def test_range_posfencepost1(self):
- assert list(range(1, 10, 3)) == [1, 4, 7]
+ def test_range_posfencepost1(self):
+ assert list(range(1, 10, 3)) == [1, 4, 7]
- def test_range_posfencepost2(self):
- assert list(range(1, 11, 3)) == [1, 4, 7, 10]
+ def test_range_posfencepost2(self):
+ assert list(range(1, 11, 3)) == [1, 4, 7, 10]
- def test_range_posfencepost3(self):
- assert list(range(1, 12, 3)) == [1, 4, 7, 10]
+ def test_range_posfencepost3(self):
+ assert list(range(1, 12, 3)) == [1, 4, 7, 10]
- def test_range_negfencepost1(self):
- assert list(range(-1, -10, -3)) == [-1, -4, -7]
+ def test_range_negfencepost1(self):
+ assert list(range(-1, -10, -3)) == [-1, -4, -7]
- def test_range_negfencepost2(self):
- assert list(range(-1, -11, -3)) == [-1, -4, -7, -10]
+ def test_range_negfencepost2(self):
+ assert list(range(-1, -11, -3)) == [-1, -4, -7, -10]
- def test_range_negfencepost3(self):
- assert list(range(-1, -12, -3)) == [-1, -4, -7, -10]
+ def test_range_negfencepost3(self):
+ assert list(range(-1, -12, -3)) == [-1, -4, -7, -10]
- def test_range_decreasing_negativelargestep(self):
- assert list(range(5, -2, -3)) == [5, 2, -1]
+ def test_range_decreasing_negativelargestep(self):
+ assert list(range(5, -2, -3)) == [5, 2, -1]
- def test_range_increasing_positivelargestep(self):
- assert list(range(-5, 2, 3)) == [-5, -2, 1]
+ def test_range_increasing_positivelargestep(self):
+ assert list(range(-5, 2, 3)) == [-5, -2, 1]
- def test_range_zerostep(self):
- raises(ValueError, range, 1, 5, 0)
+ def test_range_zerostep(self):
+ raises(ValueError, range, 1, 5, 0)
- def test_range_wrong_type(self):
- raises(TypeError, range, "42")
+ def test_range_wrong_type(self):
+ raises(TypeError, range, "42")
- def test_range_iter(self):
- x = range(2, 9, 3)
- it = iter(x)
- assert iter(it) is it
- assert it.__next__() == 2
- assert it.__next__() == 5
- assert it.__next__() == 8
- raises(StopIteration, it.__next__)
- # test again, to make sure that range() is not its own iterator
- assert iter(x).__next__() == 2
+ def test_range_iter(self):
+ x = range(2, 9, 3)
+ it = iter(x)
+ assert iter(it) is it
+ assert it.__next__() == 2
+ assert it.__next__() == 5
+ assert it.__next__() == 8
+ raises(StopIteration, it.__next__)
+ # test again, to make sure that range() is not its own iterator
+ assert iter(x).__next__() == 2
- def test_range_object_with___index__(self):
- class A(object):
- def __index__(self):
- return 5
+ def test_range_object_with___index__(self):
+ class A(object):
+ def __index__(self):
+ return 5
- assert list(range(A())) == [0, 1, 2, 3, 4]
- assert list(range(0, A())) == [0, 1, 2, 3, 4]
- assert list(range(0, 10, A())) == [0, 5]
+ assert list(range(A())) == [0, 1, 2, 3, 4]
+ assert list(range(0, A())) == [0, 1, 2, 3, 4]
+ assert list(range(0, 10, A())) == [0, 5]
- class A2(object):
- def __index__(self):
- return 'quux'
- raises(TypeError, range, A2())
+ class A2(object):
+ def __index__(self):
+ return 'quux'
+ raises(TypeError, range, A2())
- def test_range_float(self):
- raises(TypeError, range, 0.1)
- raises(TypeError, range, 0.1, 0)
- raises(TypeError, range, 0, 0.1)
- raises(TypeError, range, 0.1, 0, 0)
- raises(TypeError, range, 0, 0.1, 0)
- raises(TypeError, range, 0, 0, 0.1)
- raises(TypeError, range, 0.1, 2.0, 1.1)
+ def test_range_float(self):
+ raises(TypeError, range, 0.1)
+ raises(TypeError, range, 0.1, 0)
+ raises(TypeError, range, 0, 0.1)
+ raises(TypeError, range, 0.1, 0, 0)
+ raises(TypeError, range, 0, 0.1, 0)
+ raises(TypeError, range, 0, 0, 0.1)
+ raises(TypeError, range, 0.1, 2.0, 1.1)
- def test_range_long(self):
- import sys
- assert list(range(-2**100)) == []
- assert list(range(0, -2**100)) == []
- assert list(range(0, 2**100, -1)) == []
- assert list(range(0, 2**100, -1)) == []
+ def test_range_long(self):
+ import sys
+ assert list(range(-2**100)) == []
+ assert list(range(0, -2**100)) == []
+ assert list(range(0, 2**100, -1)) == []
+ assert list(range(0, 2**100, -1)) == []
- a = 10 * sys.maxsize
- assert range(a)[-1] == a-1
- assert range(0, a)[-1] == a-1
- assert range(0, 1, a)[-1] == 0
- assert list(range(a, a+2)) == [a, a+1]
- assert list(range(a+2, a, -1)) == [a+2, a+1]
- assert list(range(a+4, a, -2)) == [a+4, a+2]
- assert list(range(a, a*5, a)) == [a, 2*a, 3*a, 4*a]
+ a = 10 * sys.maxsize
+ assert range(a)[-1] == a-1
+ assert range(0, a)[-1] == a-1
+ assert range(0, 1, a)[-1] == 0
+ assert list(range(a, a+2)) == [a, a+1]
+ assert list(range(a+2, a, -1)) == [a+2, a+1]
+ assert list(range(a+4, a, -2)) == [a+4, a+2]
+ assert list(range(a, a*5, a)) == [a, 2*a, 3*a, 4*a]
- def test_range_cases(self):
- import sys
- for start in [10, 10 * sys.maxsize]:
- for stop in [start-4, start-1, start, start+1, start+4]:
- for step in [1, 2, 3, 4]:
- lst = list(range(start, stop, step))
- expected = []
- a = start
- while a < stop:
- expected.append(a)
- a += step
- assert lst == expected
- for step in [-1, -2, -3, -4]:
- lst = list(range(start, stop, step))
- expected = []
- a = start
- while a > stop:
- expected.append(a)
- a += step
- assert lst == expected
+ def test_range_cases(self):
+ import sys
+ for start in [10, 10 * sys.maxsize]:
+ for stop in [start-4, start-1, start, start+1, start+4]:
+ for step in [1, 2, 3, 4]:
+ lst = list(range(start, stop, step))
+ expected = []
+ a = start
+ while a < stop:
+ expected.append(a)
+ a += step
+ assert lst == expected
+ for step in [-1, -2, -3, -4]:
+ lst = list(range(start, stop, step))
+ expected = []
+ a = start
+ while a > stop:
+ expected.append(a)
+ a += step
+ assert lst == expected
- def test_range_contains(self):
- assert 3 in range(5)
- assert 3 not in range(3)
- assert 3 not in range(4, 5)
- assert 3 in range(1, 5, 2)
- assert 3 not in range(0, 5, 2)
- assert '3' not in range(5)
+ def test_range_contains(self):
+ assert 3 in range(5)
+ assert 3 not in range(3)
+ assert 3 not in range(4, 5)
+ assert 3 in range(1, 5, 2)
+ assert 3 not in range(0, 5, 2)
+ assert '3' not in range(5)
- def test_range_count(self):
- assert range(5).count(3) == 1
- assert type(range(5).count(3)) is int
- assert range(0, 5, 2).count(3) == 0
- assert range(5).count(3.0) == 1
- assert range(5).count('3') == 0
+ def test_range_count(self):
+ assert range(5).count(3) == 1
+ assert type(range(5).count(3)) is int
+ assert range(0, 5, 2).count(3) == 0
+ assert range(5).count(3.0) == 1
+ assert range(5).count('3') == 0
- def test_range_getitem(self):
- assert range(6)[3] == 3
- assert range(6)[-1] == 5
- raises(IndexError, range(6).__getitem__, 6)
+ def test_range_getitem(self):
+ assert range(6)[3] == 3
+ assert range(6)[-1] == 5
+ raises(IndexError, range(6).__getitem__, 6)
- def test_range_slice(self):
- # range objects don't implement equality in 3.2, use the repr
- assert repr(range(6)[2:5]) == 'range(2, 5)'
- assert repr(range(6)[-1:-3:-2]) == 'range(5, 3, -2)'
+ def test_range_slice(self):
+ # range objects don't implement equality in 3.2, use the repr
+ assert repr(range(6)[2:5]) == 'range(2, 5)'
+ assert repr(range(6)[-1:-3:-2]) == 'range(5, 3, -2)'
- def test_large_range(self):
- import sys
- def _range_len(x):
- try:
- length = len(x)
- except OverflowError:
- step = x[1] - x[0]
- length = 1 + ((x[-1] - x[0]) // step)
- return length
- a = -sys.maxsize
- b = sys.maxsize
- expected_len = b - a
- x = range(a, b)
- assert a in x
- assert b not in x
- raises(OverflowError, len, x)
- assert _range_len(x) == expected_len
+ def test_large_range(self):
+ import sys
+ def _range_len(x):
+ try:
+ length = len(x)
+ except OverflowError:
+ step = x[1] - x[0]
+ length = 1 + ((x[-1] - x[0]) // step)
+ return length
+ a = -sys.maxsize
+ b = sys.maxsize
+ expected_len = b - a
+ x = range(a, b)
+ assert a in x
+ assert b not in x
+ raises(OverflowError, len, x)
+ assert _range_len(x) == expected_len
- def test_range_reduce(self):
- x = range(2, 9, 3)
- callable, args = x.__reduce__()
- y = callable(*args)
- assert list(y) == list(x)
+ def test_range_reduce(self):
+ x = range(2, 9, 3)
+ callable, args = x.__reduce__()
+ y = callable(*args)
+ assert list(y) == list(x)
- def test_range_iter_reduce(self):
- x = iter(range(2, 9, 3))
- next(x)
- callable, args = x.__reduce__()
- y = callable(*args)
- assert list(y) == list(x)
+ def test_range_iter_reduce(self):
+ x = iter(range(2, 9, 3))
+ next(x)
+ callable, args = x.__reduce__()
+ y = callable(*args)
+ assert list(y) == list(x)
- def test_range_iter_reduce_one(self):
- x = iter(range(2, 9))
- next(x)
- callable, args = x.__reduce__()
- y = callable(*args)
- assert list(y) == list(x)
+ def test_range_iter_reduce_one(self):
+ x = iter(range(2, 9))
+ next(x)
+ callable, args = x.__reduce__()
+ y = callable(*args)
+ assert list(y) == list(x)
- def test_lib_python_range_optimization(self):
- x = range(1)
- assert type(reversed(x)) == type(iter(x))
+ def test_lib_python_range_optimization(self):
+ x = range(1)
+ assert type(reversed(x)) == type(iter(x))
class AppTestReversed:
- def test_reversed(self):
- r = reversed("hello")
- assert iter(r) is r
- assert r.__next__() == "o"
- assert r.__next__() == "l"
- assert r.__next__() == "l"
- assert r.__next__() == "e"
- assert r.__next__() == "h"
- raises(StopIteration, r.__next__)
- assert list(reversed(list(reversed("hello")))) == ['h','e','l','l','o']
- raises(TypeError, reversed, reversed("hello"))
+ def test_reversed(self):
+ r = reversed("hello")
+ assert iter(r) is r
+ assert r.__next__() == "o"
+ assert r.__next__() == "l"
+ assert r.__next__() == "l"
+ assert r.__next__() == "e"
+ assert r.__next__() == "h"
+ raises(StopIteration, r.__next__)
+ assert list(reversed(list(reversed("hello")))) == ['h','e','l','l','o']
+ raises(TypeError, reversed, reversed("hello"))
class AppTestAllAny:
"""
@@ -434,16 +434,16 @@
assert any([x > 42 for x in S]) == False
class AppTestMinMax:
- def test_min(self):
- assert min(1, 2) == 1
- assert min(1, 2, key=lambda x: -x) == 2
- assert min([1, 2, 3]) == 1
- raises(TypeError, min, 1, 2, bar=2)
- raises(TypeError, min, 1, 2, key=lambda x: x, bar=2)
+ def test_min(self):
+ assert min(1, 2) == 1
+ assert min(1, 2, key=lambda x: -x) == 2
+ assert min([1, 2, 3]) == 1
+ raises(TypeError, min, 1, 2, bar=2)
+ raises(TypeError, min, 1, 2, key=lambda x: x, bar=2)
- def test_max(self):
- assert max(1, 2) == 2
- assert max(1, 2, key=lambda x: -x) == 1
- assert max([1, 2, 3]) == 3
- raises(TypeError, max, 1, 2, bar=2)
- raises(TypeError, max, 1, 2, key=lambda x: x, bar=2)
+ def test_max(self):
+ assert max(1, 2) == 2
+ assert max(1, 2, key=lambda x: -x) == 1
+ assert max([1, 2, 3]) == 3
+ raises(TypeError, max, 1, 2, bar=2)
+ raises(TypeError, max, 1, 2, key=lambda x: x, bar=2)
diff --git a/pypy/module/__builtin__/test/test_minmax.py b/pypy/module/__builtin__/test/test_minmax.py
--- a/pypy/module/__builtin__/test/test_minmax.py
+++ b/pypy/module/__builtin__/test/test_minmax.py
@@ -1,73 +1,73 @@
class AppTestMin:
- def test_min_notseq(self):
- raises(TypeError, min, 1)
+ def test_min_notseq(self):
+ raises(TypeError, min, 1)
- def test_min_usual(self):
- assert min(1, 2, 3) == 1
+ def test_min_usual(self):
+ assert min(1, 2, 3) == 1
- def test_min_floats(self):
- assert min(0.1, 2.7, 14.7) == 0.1
+ def test_min_floats(self):
+ assert min(0.1, 2.7, 14.7) == 0.1
- def test_min_chars(self):
- assert min('a', 'b', 'c') == 'a'
+ def test_min_chars(self):
+ assert min('a', 'b', 'c') == 'a'
- def test_min_strings(self):
- assert min('aaa', 'bbb', 'c') == 'aaa'
+ def test_min_strings(self):
+ assert min('aaa', 'bbb', 'c') == 'aaa'
- def test_min_noargs(self):
- raises(TypeError, min)
+ def test_min_noargs(self):
+ raises(TypeError, min)
- def test_min_empty(self):
- raises(ValueError, min, [])
+ def test_min_empty(self):
+ raises(ValueError, min, [])
class AppTestMax:
- def test_max_notseq(self):
- raises(TypeError, max, 1)
+ def test_max_notseq(self):
+ raises(TypeError, max, 1)
- def test_max_usual(self):
- assert max(1, 2, 3) == 3
+ def test_max_usual(self):
+ assert max(1, 2, 3) == 3
- def test_max_floats(self):
- assert max(0.1, 2.7, 14.7) == 14.7
+ def test_max_floats(self):
+ assert max(0.1, 2.7, 14.7) == 14.7
- def test_max_chars(self):
- assert max('a', 'b', 'c') == 'c'
+ def test_max_chars(self):
+ assert max('a', 'b', 'c') == 'c'
- def test_max_strings(self):
- assert max('aaa', 'bbb', 'c') == 'c'
+ def test_max_strings(self):
+ assert max('aaa', 'bbb', 'c') == 'c'
- def test_max_noargs(self):
- raises(TypeError, max)
+ def test_max_noargs(self):
+ raises(TypeError, max)
- def test_max_empty(self):
- raises(ValueError, max, [])
+ def test_max_empty(self):
+ raises(ValueError, max, [])
class AppTestMaxTuple:
- def test_max_usual(self):
- assert max((1, 2, 3)) == 3
+ def test_max_usual(self):
+ assert max((1, 2, 3)) == 3
- def test_max_floats(self):
- assert max((0.1, 2.7, 14.7)) == 14.7
+ def test_max_floats(self):
+ assert max((0.1, 2.7, 14.7)) == 14.7
- def test_max_chars(self):
- assert max(('a', 'b', 'c')) == 'c'
+ def test_max_chars(self):
+ assert max(('a', 'b', 'c')) == 'c'
- def test_max_strings(self):
- assert max(('aaa', 'bbb', 'c')) == 'c'
+ def test_max_strings(self):
+ assert max(('aaa', 'bbb', 'c')) == 'c'
class AppTestMinList:
- def test_min_usual(self):
- assert min([1, 2, 3]) == 1
+ def test_min_usual(self):
+ assert min([1, 2, 3]) == 1
- def test_min_floats(self):
- assert min([0.1, 2.7, 14.7]) == 0.1
+ def test_min_floats(self):
+ assert min([0.1, 2.7, 14.7]) == 0.1
- def test_min_chars(self):
- assert min(['a', 'b', 'c']) == 'a'
+ def test_min_chars(self):
+ assert min(['a', 'b', 'c']) == 'a'
- def test_min_strings(self):
- assert min(['aaa', 'bbb', 'c']) == 'aaa'
+ def test_min_strings(self):
+ assert min(['aaa', 'bbb', 'c']) == 'aaa'
diff --git a/pypy/module/__builtin__/test/test_zip.py b/pypy/module/__builtin__/test/test_zip.py
--- a/pypy/module/__builtin__/test/test_zip.py
+++ b/pypy/module/__builtin__/test/test_zip.py
@@ -1,39 +1,39 @@
class AppTestZip:
- def test_zip_no_arguments(self):
- import sys
- if sys.version_info < (2,4):
- # Test 2.3 behaviour
- raises(TypeError, zip)
- else:
- # Test 2.4 behaviour
- assert list(zip()) == []
- assert list(zip(*[])) == []
-
- def test_one_list(self):
- assert list(zip([1, 2, 3])) == [(1,), (2,), (3,)]
+ def test_zip_no_arguments(self):
+ import sys
+ if sys.version_info < (2,4):
+ # Test 2.3 behaviour
+ raises(TypeError, zip)
+ else:
+ # Test 2.4 behaviour
+ assert list(zip()) == []
+ assert list(zip(*[])) == []
- def test_three_lists_same_size(self):
- assert list(zip([1, 2, 3], [3, 4, 5], [6, 7, 8])) == (
- [(1, 3, 6), (2, 4, 7), (3, 5, 8)])
+ def test_one_list(self):
+ assert list(zip([1, 2, 3])) == [(1,), (2,), (3,)]
- def test_three_lists_different_sizes(self):
- assert list(zip([1, 2], [3, 4, 5, 6], [6, 7, 8])) == (
- [(1, 3, 6), (2, 4, 7)])
+ def test_three_lists_same_size(self):
+ assert list(zip([1, 2, 3], [3, 4, 5], [6, 7, 8])) == (
+ [(1, 3, 6), (2, 4, 7), (3, 5, 8)])
- def test_tuples(self):
- assert list(zip((1, 2, 3))) == [(1,), (2,), (3,)]
+ def test_three_lists_different_sizes(self):
+ assert list(zip([1, 2], [3, 4, 5, 6], [6, 7, 8])) == (
+ [(1, 3, 6), (2, 4, 7)])
- def test_string(self):
- assert list(zip('hello')) == [('h',), ('e',), ('l',), ('l',), ('o',)]
+ def test_tuples(self):
+ assert list(zip((1, 2, 3))) == [(1,), (2,), (3,)]
- def test_strings(self):
- assert list(zip('hello', 'bye')) == (
- [('h', 'b'), ('e', 'y'), ('l', 'e')])
+ def test_string(self):
+ assert list(zip('hello')) == [('h',), ('e',), ('l',), ('l',), ('o',)]
- def test_mixed_types(self):
- assert list(zip('hello', [1,2,3,4], (7,8,9,10))) == (
- [('h', 1, 7), ('e', 2, 8), ('l', 3, 9), ('l', 4, 10)])
+ def test_strings(self):
+ assert list(zip('hello', 'bye')) == (
+ [('h', 'b'), ('e', 'y'), ('l', 'e')])
+
+ def test_mixed_types(self):
+ assert list(zip('hello', [1,2,3,4], (7,8,9,10))) == (
+ [('h', 1, 7), ('e', 2, 8), ('l', 3, 9), ('l', 4, 10)])
class AppTestZip2:
def test_zip(self):
@@ -45,11 +45,11 @@
for x in obj_list:
assert next(it) == (x, )
raises(StopIteration, next, it)
-
+
it = zip([1, 2, 3], [4], [5, 6])
assert next(it) == (1, 4, 5)
raises(StopIteration, next, it)
-
+
it = zip([], [], [1], [])
raises(StopIteration, next, it)
@@ -78,4 +78,3 @@
assert str(e).find("#" + str(x + 1) + " ") >= 0
else:
fail("TypeError expected")
-
More information about the pypy-commit
mailing list