1. Pypy
  2. Untitled project
  3. pypy

Commits

Philip Jenvey  committed 9b6d55d

reindent this sillyness

  • Participants
  • Parent commits 8ce8657
  • Branches default

Comments (0)

Files changed (8)

File pypy/module/__builtin__/test/test_apply.py

View file
  • Ignore whitespace
 # This is a very trivial series of tests.  If apply is subtlely broken,
 # we will have to find out some other way.
-  
+
 class AppTestApply:
 
-   def test_trivial_listonly(self):
-      def mymin(*args):
-           return min(list(args))
+    def test_trivial_listonly(self):
+        def mymin(*args):
+            return min(list(args))
 
-      assert apply(mymin, [-1,-2,-3,-4]) == -4
+        assert apply(mymin, [-1,-2,-3,-4]) == -4
 
-   def test_trivial_dictonly(self):
-      def mymin(*arr, **kwargs):
-           return min(list(arr) + kwargs.values())
-      assert apply(mymin,
-                             [], {'null' : 0, 'one': 1, 'two' : 2}) == (
-                             0)
-   def test_trivial(self):
-      def mymin(*arr, **kwargs):
-           return min(list(arr) + kwargs.values())
-      assert apply(mymin,
-                             [-1,-2,-3,-4],
-                             {'null' : 0, 'one': 1, 'two' : 2}) == (
-                             (-4))
+    def test_trivial_dictonly(self):
+        def mymin(*arr, **kwargs):
+            return min(list(arr) + kwargs.values())
+        assert apply(mymin,
+                               [], {'null' : 0, 'one': 1, 'two' : 2}) == (
+                               0)
+    def test_trivial(self):
+        def mymin(*arr, **kwargs):
+            return min(list(arr) + kwargs.values())
+        assert apply(mymin,
+                               [-1,-2,-3,-4],
+                               {'null' : 0, 'one': 1, 'two' : 2}) == (
+                               (-4))

File pypy/module/__builtin__/test/test_classobj.py

View file
  • Ignore whitespace
     def test_unary_method(self):
         class A:
             def __pos__(self):
-                 return -1
+                return -1
         a = A()
         assert +a == -1
 
     def test_cmp(self):
         class A:
             def __lt__(self, other):
-                 return True
+                return True
         a = A()
         b = A()
         assert a < b
             def __add__(self, other):
                 return 1 + other
             def __coerce__(self, other):
-                 return self, int(other)
+                return self, int(other)
 
         a = A()
         assert a + 1 == 2
         l = []
         class A:
             def __coerce__(self, other):
-                 l.append(other)
+                l.append(other)
 
         a = A()
         raises(TypeError, "a + 1")
             def __init__(self):
                 self.l = []
             def __iadd__(self, other):
-                 self.l.append(other)
-                 return self
+                self.l.append(other)
+                return self
         a1 = a = A()
         a += 1
         assert a is a1
         a = A()
         raises(TypeError, hash, a)
         bigint = sys.maxint + 1
-        class A: # can return long 
+        class A: # can return long
             def __hash__(self):
                 return long(bigint)
         a = A()
-        assert hash(a) == -bigint 
+        assert hash(a) == -bigint
 
     def test_index(self):
         import sys
         class X:
             def __iter__(self):
                 return Y()
-         
+
         class Y:
             def next(self):
                 return 3
-         
+
         for i in X():
             assert i == 3
             break
             skip("assignment to __del__ doesn't give a warning in CPython")
 
         import warnings
-        
+
         warnings.simplefilter('error', RuntimeWarning)
         try:
             class X:
         a = A()
         assert a.x == 42
         assert self.has_mapdict(a)
-

File pypy/module/__builtin__/test/test_filter.py

View file
  • Ignore whitespace
-# trivial functions for testing 
+# trivial functions for testing
 
 class AppTestFilter:
     def test_filter_no_arguments(self):
         raises(TypeError, filter)
-      
+
     def test_filter_no_function_no_seq(self):
         raises(TypeError, filter, None)
 
         raises(TypeError, filter, lambda x: x>3, [1], [2])
 
     def test_filter_no_function_list(self):
-      assert filter(None, [1, 2, 3]) == [1, 2, 3]
+        assert filter(None, [1, 2, 3]) == [1, 2, 3]
 
     def test_filter_no_function_tuple(self):
-      assert filter(None, (1, 2, 3)) == (1, 2, 3)
+        assert filter(None, (1, 2, 3)) == (1, 2, 3)
 
     def test_filter_no_function_string(self):
-      assert filter(None, 'mystring') == 'mystring'
+        assert filter(None, 'mystring') == 'mystring'
 
     def test_filter_no_function_with_bools(self):
-      assert filter(None, (True, False, True)) == (True, True)
-      
+        assert filter(None, (True, False, True)) == (True, True)
+
     def test_filter_list(self):
-      assert filter(lambda x: x>3, [1, 2, 3, 4, 5]) == [4, 5]
+        assert filter(lambda x: x>3, [1, 2, 3, 4, 5]) == [4, 5]
 
     def test_filter_tuple(self):
-      assert filter(lambda x: x>3, (1, 2, 3, 4, 5)) == (4, 5)
+        assert filter(lambda x: x>3, (1, 2, 3, 4, 5)) == (4, 5)
 
     def test_filter_string(self):
-      assert filter(lambda x: x>'a', 'xyzabcd') == 'xyzbcd'
+        assert filter(lambda x: x>'a', 'xyzabcd') == 'xyzbcd'

File pypy/module/__builtin__/test/test_functional.py

View file
  • Ignore whitespace
 class AppTestMap:
 
-   def test_trivial_map_one_seq(self):
-      assert map(lambda x: x+2, [1, 2, 3, 4]) == [3, 4, 5, 6]
+    def test_trivial_map_one_seq(self):
+        assert map(lambda x: x+2, [1, 2, 3, 4]) == [3, 4, 5, 6]
 
-   def test_trivial_map_one_seq_2(self):
-      assert map(str, [1, 2, 3, 4]) == ['1', '2', '3', '4']
+    def test_trivial_map_one_seq_2(self):
+        assert map(str, [1, 2, 3, 4]) == ['1', '2', '3', '4']
 
-   def test_trivial_map_two_seq(self):
-      assert 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 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_and_should(self):
-      raises(TypeError, map, lambda x,y: x+y, [1, 2, 3, 4], [1, 2, 3])
+    def test_trivial_map_sizes_dont_match_and_should(self):
+        raises(TypeError, map, lambda x,y: x+y, [1, 2, 3, 4], [1, 2, 3])
 
-   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_one_seq(self):
-      assert map(None, [1, 2, 3]) == [1, 2, 3]
+    def test_trivial_map_no_fuction_one_seq(self):
+        assert map(None, [1, 2, 3]) == [1, 2, 3]
 
-   def test_trivial_map_no_function(self):
-      assert map(None, [1,2,3], [4,5,6], [7,8], [1]) == (
-                       [(1, 4, 7, 1), (2, 5, 8, None), (3, 6, None, None)])
+    def test_trivial_map_no_function(self):
+        assert map(None, [1,2,3], [4,5,6], [7,8], [1]) == (
+                         [(1, 4, 7, 1), (2, 5, 8, None), (3, 6, None, None)])
 
-   def test_map_identity1(self):
-      a = ['1', 2, 3, 'b', None]
-      b = a[:]
-      assert map(lambda x: x, a) == a
-      assert a == b
+    def test_map_identity1(self):
+        a = ['1', 2, 3, 'b', None]
+        b = a[:]
+        assert map(lambda x: x, a) == a
+        assert a == b
 
-   def test_map_None(self):
-      a = ['1', 2, 3, 'b', None]
-      b = a[:]
-      assert map(None, a) == a
-      assert a == b
+    def test_map_None(self):
+        a = ['1', 2, 3, 'b', None]
+        b = a[:]
+        assert map(None, a) == a
+        assert a == b
 
-   def test_map_badoperation(self):
-      a = ['1', 2, 3, 'b', None]
-      raises(TypeError, map, lambda x: x+1, a)
+    def test_map_badoperation(self):
+        a = ['1', 2, 3, 'b', None]
+        raises(TypeError, map, lambda x: x+1, a)
 
-   def test_map_multiply_identity(self):
-      a = ['1', 2, 3, 'b', None]
-      b = [ 2, 3, 4, 5, 6]
-      assert map(None, a, b) == [('1', 2), (2, 3), (3, 4), ('b', 5), (None, 6)]
+    def test_map_multiply_identity(self):
+        a = ['1', 2, 3, 'b', None]
+        b = [ 2, 3, 4, 5, 6]
+        assert map(None, a, b) == [('1', 2), (2, 3), (3, 4), ('b', 5), (None, 6)]
 
-   def test_map_add(self):
-      a = [1, 2, 3, 4]
-      b = [0, 1, 1, 1]
-      assert 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 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 = []
-      assert map(lambda x, y: x, a, b) == a
+    def test_map_first_item(self):
+        a = [1, 2, 3, 4, 5]
+        b = []
+        assert 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(None, A(3), A(8))
-      # this also checks that B.next() is not called any more after it
-      # raised StopIteration once
-      assert result == [(2, 7), (1, 6), (None, 5), (None, 4),
-                        (None, 3), (None, 2), (None, 1)]
+    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(None, A(3), A(8))
+        # this also checks that B.next() is not called any more after it
+        # raised StopIteration once
+        assert result == [(2, 7), (1, 6), (None, 5), (None, 4),
+                          (None, 3), (None, 2), (None, 1)]
 
 class AppTestZip:
-   def test_one_list(self):
-      assert zip([1,2,3]) == [(1,), (2,), (3,)]
+    def test_one_list(self):
+        assert zip([1,2,3]) == [(1,), (2,), (3,)]
 
-   def test_three_lists(self):
-      assert zip([1,2,3], [1,2], [1,2,3]) == [(1,1,1), (2,2,2)]
+    def test_three_lists(self):
+        assert 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 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 zip(Foo()) == []
 
 class AppTestReduce:
-   def test_None(self):
-       raises(TypeError, reduce, lambda x, y: x+y, [1,2,3], None)
+    def test_None(self):
+        raises(TypeError, reduce, lambda x, y: x+y, [1,2,3], None)
 
-   def test_sum(self):
-       assert reduce(lambda x, y: x+y, [1,2,3,4], 0) == 10
-       assert reduce(lambda x, y: x+y, [1,2,3,4]) == 10
+    def test_sum(self):
+        assert reduce(lambda x, y: x+y, [1,2,3,4], 0) == 10
+        assert reduce(lambda x, y: x+y, [1,2,3,4]) == 10
 
-   def test_minus(self):
-       assert reduce(lambda x, y: x-y, [10, 2, 8]) == 0
-       assert reduce(lambda x, y: x-y, [2, 8], 10) == 0
+    def test_minus(self):
+        assert reduce(lambda x, y: x-y, [10, 2, 8]) == 0
+        assert reduce(lambda x, y: x-y, [2, 8], 10) == 0
 
 class AppTestFilter:
-   def test_None(self):
-       assert filter(None, ['a', 'b', 1, 0, None]) == ['a', 'b', 1]
+    def test_None(self):
+        assert filter(None, ['a', 'b', 1, 0, None]) == ['a', 'b', 1]
 
-   def test_return_type(self):
-       txt = "This is a test text"
-       assert filter(None, txt) == txt
-       tup = ("a", None, 0, [], 1)
-       assert filter(None, tup) == ("a", 1)
+    def test_return_type(self):
+        txt = "This is a test text"
+        assert filter(None, txt) == txt
+        tup = ("a", None, 0, [], 1)
+        assert filter(None, tup) == ("a", 1)
 
-   def test_function(self):
-       assert filter(lambda x: x != "a", "a small text") == " smll text"
-       assert filter(lambda x: x < 20, [3, 33, 5, 55]) == [3, 5]
+    def test_function(self):
+        assert filter(lambda x: x != "a", "a small text") == " smll text"
+        assert filter(lambda x: x < 20, [3, 33, 5, 55]) == [3, 5]
 
-   def test_filter_tuple_calls_getitem(self):
-       class T(tuple):
-           def __getitem__(self, i):
-               return i * 10
-       assert filter(lambda x: x != 20, T("abcd")) == (0, 10, 30)
+    def test_filter_tuple_calls_getitem(self):
+        class T(tuple):
+            def __getitem__(self, i):
+                return i * 10
+        assert filter(lambda x: x != 20, T("abcd")) == (0, 10, 30)
 
 class AppTestXRange:
-   def test_xrange(self):
-      x = xrange(2, 9, 3)
-      assert x[1] == 5
-      assert len(x) == 3
-      assert list(x) == [2, 5, 8]
-      # test again, to make sure that xrange() is not its own iterator
-      assert list(x) == [2, 5, 8]
+    def test_xrange(self):
+        x = xrange(2, 9, 3)
+        assert x[1] == 5
+        assert len(x) == 3
+        assert list(x) == [2, 5, 8]
+        # test again, to make sure that xrange() is not its own iterator
+        assert list(x) == [2, 5, 8]
 
-   def test_xrange_iter(self):
-      x = xrange(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 xrange() is not its own iterator
-      assert iter(x).next() == 2
+    def test_xrange_iter(self):
+        x = xrange(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 xrange() is not its own iterator
+        assert iter(x).next() == 2
 
-   def test_xrange_object_with___int__(self):
-       class A(object):
-          def __int__(self):
-             return 5
+    def test_xrange_object_with___int__(self):
+        class A(object):
+            def __int__(self):
+                return 5
 
-       assert list(xrange(A())) == [0, 1, 2, 3, 4]
-       assert list(xrange(0, A())) == [0, 1, 2, 3, 4]
-       assert list(xrange(0, 10, A())) == [0, 5]
+        assert list(xrange(A())) == [0, 1, 2, 3, 4]
+        assert list(xrange(0, A())) == [0, 1, 2, 3, 4]
+        assert list(xrange(0, 10, A())) == [0, 5]
 
-   def test_xrange_float(self):
-      assert list(xrange(0.1, 2.0, 1.1)) == [0, 1]
+    def test_xrange_float(self):
+        assert list(xrange(0.1, 2.0, 1.1)) == [0, 1]
 
-   def test_xrange_long(self):
-       import sys
-       a = long(10 * sys.maxint)
-       raises(OverflowError, xrange, a)
-       raises(OverflowError, xrange, 0, a)
-       raises(OverflowError, xrange, 0, 1, a)
+    def test_xrange_long(self):
+        import sys
+        a = long(10 * sys.maxint)
+        raises(OverflowError, xrange, a)
+        raises(OverflowError, xrange, 0, a)
+        raises(OverflowError, xrange, 0, 1, a)
 
-   def test_xrange_reduce(self):
-      x = xrange(2, 9, 3)
-      callable, args = x.__reduce__()
-      y = callable(*args)
-      assert list(y) == list(x)
+    def test_xrange_reduce(self):
+        x = xrange(2, 9, 3)
+        callable, args = x.__reduce__()
+        y = callable(*args)
+        assert list(y) == list(x)
 
-   def test_xrange_iter_reduce(self):
-      x = iter(xrange(2, 9, 3))
-      x.next()
-      callable, args = x.__reduce__()
-      y = callable(*args)
-      assert list(y) == list(x)
+    def test_xrange_iter_reduce(self):
+        x = iter(xrange(2, 9, 3))
+        x.next()
+        callable, args = x.__reduce__()
+        y = callable(*args)
+        assert list(y) == list(x)
 
-   def test_xrange_iter_reduce_one(self):
-      x = iter(xrange(2, 9))
-      x.next()
-      callable, args = x.__reduce__()
-      y = callable(*args)
-      assert list(y) == list(x)
+    def test_xrange_iter_reduce_one(self):
+        x = iter(xrange(2, 9))
+        x.next()
+        callable, args = x.__reduce__()
+        y = callable(*args)
+        assert list(y) == list(x)
 
-   def test_lib_python_xrange_optimization(self):
-      x = xrange(1)
-      assert type(reversed(x)) == type(iter(x))
+    def test_lib_python_xrange_optimization(self):
+        x = xrange(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 AppTestApply:
-   def test_apply(self):
-      def f(*args, **kw):
-         return args, kw
-      args = (1,3)
-      kw = {'a': 1, 'b': 4}
-      assert apply(f) == ((), {})
-      assert apply(f, args) == (args, {})
-      assert apply(f, args, kw) == (args, kw)
+    def test_apply(self):
+        def f(*args, **kw):
+            return args, kw
+        args = (1,3)
+        kw = {'a': 1, 'b': 4}
+        assert apply(f) == ((), {})
+        assert apply(f, args) == (args, {})
+        assert apply(f, args, kw) == (args, kw)
 
 class AppTestAllAny:
     """
         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)

File pypy/module/__builtin__/test/test_minmax.py

View file
  • Ignore whitespace
 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_mixed(self):
-      assert min('1', 2, 3, 'aa') == 2
+    def test_min_mixed(self):
+        assert min('1', 2, 3, 'aa') == 2
 
-   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_mixed(self):
-      assert max('1', 2, 3, 'aa') == 'aa'
+    def test_max_mixed(self):
+        assert max('1', 2, 3, 'aa') == 'aa'
 
-   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'
 
-   def test_max_mixed(self):
-      assert max(('1', 2, 3, 'aa')) == 'aa'
+    def test_max_mixed(self):
+        assert max(('1', 2, 3, 'aa')) == 'aa'
 
 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'
 
-   def test_min_mixed(self):
-      assert min(['1', 2, 3, 'aa']) == 2
+    def test_min_mixed(self):
+        assert min(['1', 2, 3, 'aa']) == 2

File pypy/module/__builtin__/test/test_range.py

View file
  • Ignore whitespace
 class AppTestRange:
 
-   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 range(1) == [0]
+    def test_range_one(self):
+        assert range(1) == [0]
 
-   def test_range_posstartisstop(self):
-      assert range(1, 1) == []
+    def test_range_posstartisstop(self):
+        assert range(1, 1) == []
 
-   def test_range_negstartisstop(self):
-      assert range(-1, -1) == []
+    def test_range_negstartisstop(self):
+        assert range(-1, -1) == []
 
-   def test_range_zero(self):
-      assert range(0) == []
+    def test_range_zero(self):
+        assert range(0) == []
 
-   def test_range_twoargs(self):
-      assert range(1, 2) == [1]
-      
-   def test_range_decreasingtwoargs(self):
-      assert range(3, 1) == []
+    def test_range_twoargs(self):
+        assert range(1, 2) == [1]
 
-   def test_range_negatives(self):
-      assert range(-3) == []
+    def test_range_decreasingtwoargs(self):
+        assert range(3, 1) == []
 
-   def test_range_decreasing_negativestep(self):
-      assert range(5, -2, -1) == [5, 4, 3, 2, 1, 0 , -1]
+    def test_range_negatives(self):
+        assert range(-3) == []
 
-   def test_range_posfencepost1(self):
-       assert range (1, 10, 3) == [1, 4, 7]
+    def test_range_decreasing_negativestep(self):
+        assert range(5, -2, -1) == [5, 4, 3, 2, 1, 0 , -1]
 
-   def test_range_posfencepost2(self):
-       assert range (1, 11, 3) == [1, 4, 7, 10]
+    def test_range_posfencepost1(self):
+        assert range (1, 10, 3) == [1, 4, 7]
 
-   def test_range_posfencepost3(self):
-       assert range (1, 12, 3) == [1, 4, 7, 10]
+    def test_range_posfencepost2(self):
+        assert range (1, 11, 3) == [1, 4, 7, 10]
 
-   def test_range_negfencepost1(self):
-       assert range (-1, -10, -3) == [-1, -4, -7]
+    def test_range_posfencepost3(self):
+        assert range (1, 12, 3) == [1, 4, 7, 10]
 
-   def test_range_negfencepost2(self):
-       assert range (-1, -11, -3) == [-1, -4, -7, -10]
+    def test_range_negfencepost1(self):
+        assert range (-1, -10, -3) == [-1, -4, -7]
 
-   def test_range_negfencepost3(self):
-       assert range (-1, -12, -3) == [-1, -4, -7, -10]
+    def test_range_negfencepost2(self):
+        assert range (-1, -11, -3) == [-1, -4, -7, -10]
 
-   def test_range_decreasing_negativelargestep(self):
-       assert range(5, -2, -3) == [5, 2, -1]
+    def test_range_negfencepost3(self):
+        assert range (-1, -12, -3) == [-1, -4, -7, -10]
 
-   def test_range_increasing_positivelargestep(self):
-       assert range(-5, 2, 3) == [-5, -2, 1]
+    def test_range_decreasing_negativelargestep(self):
+        assert range(5, -2, -3) == [5, 2, -1]
 
-   def test_range_zerostep(self):
-       raises(ValueError, range, 1, 5, 0)
+    def test_range_increasing_positivelargestep(self):
+        assert range(-5, 2, 3) == [-5, -2, 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)
+    def test_range_zerostep(self):
+        raises(ValueError, range, 1, 5, 0)
 
-   def test_range_wrong_type(self):
-       raises(TypeError, range, "42")
+    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)
 
-   def test_range_object_with___int__(self):
-       class A(object):
-           def __int__(self):
-               return 5
+    def test_range_wrong_type(self):
+        raises(TypeError, range, "42")
 
-       assert range(A()) == [0, 1, 2, 3, 4]
-       assert range(0, A()) == [0, 1, 2, 3, 4]
-       assert range(0, 10, A()) == [0, 5]
+    def test_range_object_with___int__(self):
+        class A(object):
+            def __int__(self):
+                return 5
 
-   def test_range_long(self):
-       import sys
-       assert range(-2**100) == []
-       assert range(0, -2**100) == []
-       assert range(0, 2**100, -1) == []
-       assert range(0, 2**100, -1) == []
+        assert range(A()) == [0, 1, 2, 3, 4]
+        assert range(0, A()) == [0, 1, 2, 3, 4]
+        assert range(0, 10, A()) == [0, 5]
 
-       a = long(10 * sys.maxint)
-       assert range(a, a+2) == [a, a+1]
-       assert range(a+2, a, -1L) == [a+2, a+1]
-       assert range(a+4, a, -2) == [a+4, a+2]
-       assert range(a, a*5, a) == [a, 2*a, 3*a, 4*a]
+    def test_range_long(self):
+        import sys
+        assert range(-2**100) == []
+        assert range(0, -2**100) == []
+        assert range(0, 2**100, -1) == []
+        assert range(0, 2**100, -1) == []
 
-   def test_range_cases(self):
-       import sys
-       for start in [10, 10 * sys.maxint]:
-           for stop in [start-4, start-1, start, start+1, start+4]:
-              for step in [1, 2, 3, 4]:
-                  lst = 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 = range(start, stop, step)
-                  expected = []
-                  a = start
-                  while a > stop:
-                      expected.append(a)
-                      a += step
-                  assert lst == expected
+        a = long(10 * sys.maxint)
+        assert range(a, a+2) == [a, a+1]
+        assert range(a+2, a, -1L) == [a+2, a+1]
+        assert range(a+4, a, -2) == [a+4, a+2]
+        assert 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.maxint]:
+            for stop in [start-4, start-1, start, start+1, start+4]:
+                for step in [1, 2, 3, 4]:
+                    lst = 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 = range(start, stop, step)
+                    expected = []
+                    a = start
+                    while a > stop:
+                        expected.append(a)
+                        a += step
+                    assert lst == expected

File pypy/module/__builtin__/test/test_reduce.py

View file
  • Ignore whitespace
 class AppTestReduce:
-   def test_None(self):
-       raises(TypeError, reduce, lambda x, y: x+y, [1,2,3], None)
+    def test_None(self):
+        raises(TypeError, reduce, lambda x, y: x+y, [1,2,3], None)
 
-   def test_sum(self):
-       assert reduce(lambda x, y: x+y, [1,2,3,4], 0) == 10
-       assert reduce(lambda x, y: x+y, [1,2,3,4]) == 10
-   
-   def test_minus(self):
-       assert reduce(lambda x, y: x-y, [10, 2, 8]) == 0
-       assert reduce(lambda x, y: x-y, [2, 8], 10) == 0
+    def test_sum(self):
+        assert reduce(lambda x, y: x+y, [1,2,3,4], 0) == 10
+        assert reduce(lambda x, y: x+y, [1,2,3,4]) == 10
 
-   def test_from_cpython(self):
-      class SequenceClass(object):
-         def __init__(self, n):
-            self.n = n
-         def __getitem__(self, i):
-            if 0 <= i < self.n:
-               return i
-            else:
-               raise IndexError
+    def test_minus(self):
+        assert reduce(lambda x, y: x-y, [10, 2, 8]) == 0
+        assert reduce(lambda x, y: x-y, [2, 8], 10) == 0
 
-      from operator import add
-      assert reduce(add, SequenceClass(5)) == 10
-      assert reduce(add, SequenceClass(5), 42) == 52
-      raises(TypeError, reduce, add, SequenceClass(0))
-      assert reduce(add, SequenceClass(0), 42) == 42
-      assert reduce(add, SequenceClass(1)) == 0
-      assert reduce(add, SequenceClass(1), 42) == 42
-      
-      d = {"one": 1, "two": 2, "three": 3}
-      assert reduce(add, d) == "".join(d.keys())
-      
+    def test_from_cpython(self):
+        class SequenceClass(object):
+            def __init__(self, n):
+                self.n = n
+            def __getitem__(self, i):
+                if 0 <= i < self.n:
+                    return i
+                else:
+                    raise IndexError
+
+        from operator import add
+        assert reduce(add, SequenceClass(5)) == 10
+        assert reduce(add, SequenceClass(5), 42) == 52
+        raises(TypeError, reduce, add, SequenceClass(0))
+        assert reduce(add, SequenceClass(0), 42) == 42
+        assert reduce(add, SequenceClass(1)) == 0
+        assert reduce(add, SequenceClass(1), 42) == 42
+
+        d = {"one": 1, "two": 2, "three": 3}
+        assert reduce(add, d) == "".join(d.keys())

File pypy/module/__builtin__/test/test_zip.py

View file
  • Ignore whitespace
 class AppTestZip:
 
-   def test_zip_no_arguments(self):
-      import sys
-      if sys.version_info < (2,4):
-          # Test 2.3 behaviour
-          raises(TypeError, zip)
-          return
-      # Test 2.4 behaviour
-      assert zip() ==  []
-      assert zip(*[]) == []
-   
-   def test_one_list(self):
-      assert 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)
+            return
+        # Test 2.4 behaviour
+        assert zip() ==  []
+        assert zip(*[]) == []
 
-   def test_three_lists_same_size(self):
-      assert 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 zip([1, 2, 3]) == [(1,), (2,), (3,)]
 
-   def test_three_lists_different_sizes(self):
-      assert zip([1, 2], [3, 4, 5, 6], [6, 7, 8]) == (
-                        [(1, 3, 6), (2, 4, 7)])
+    def test_three_lists_same_size(self):
+        assert zip([1, 2, 3], [3, 4, 5], [6, 7, 8]) == (
+                          [(1, 3, 6), (2, 4, 7), (3, 5, 8)])
 
-   def test_tuples(self):
-      assert zip((1, 2, 3)) == [(1,), (2,), (3,)]
+    def test_three_lists_different_sizes(self):
+        assert zip([1, 2], [3, 4, 5, 6], [6, 7, 8]) == (
+                          [(1, 3, 6), (2, 4, 7)])
 
-   def test_string(self):
-      assert zip('hello') == [('h',), ('e',), ('l',), ('l',), ('o',)]
+    def test_tuples(self):
+        assert zip((1, 2, 3)) == [(1,), (2,), (3,)]
 
-   def test_strings(self):
-      assert zip('hello', 'bye') == (
-                       [('h', 'b'), ('e', 'y'), ('l', 'e')])
+    def test_string(self):
+        assert zip('hello') == [('h',), ('e',), ('l',), ('l',), ('o',)]
 
-   def test_mixed_types(self):
-      assert 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 zip('hello', 'bye') == (
+                         [('h', 'b'), ('e', 'y'), ('l', 'e')])
+
+    def test_mixed_types(self):
+        assert zip('hello', [1,2,3,4], (7,8,9,10)) == (
+                         [('h', 1, 7), ('e', 2, 8), ('l', 3, 9), ('l', 4, 10)])