Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r70070:d88001e37970 Date: 2014-03-18 19:45 -0400 http://bitbucket.org/pypy/pypy/changeset/d88001e37970/
Log: cleanups diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py --- a/pypy/interpreter/buffer.py +++ b/pypy/interpreter/buffer.py @@ -71,8 +71,8 @@ assert 0 <= start <= stop return self.value[start:stop] return "".join([self.value[start + i*step] for i in xrange(size)]) +# ____________________________________________________________ -# ____________________________________________________________ class SubBufferMixin(object): _attrs_ = ['buffer', 'offset', 'size'] @@ -98,7 +98,8 @@ if start == stop: return '' # otherwise, adding self.offset might make them # out of bounds - return self.buffer.getslice(self.offset + start, self.offset + stop, step, size) + return self.buffer.getslice(self.offset + start, self.offset + stop, + step, size) class SubBuffer(Buffer): diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py --- a/pypy/module/array/test/test_array.py +++ b/pypy/module/array/test/test_array.py @@ -1,25 +1,8 @@ import sys -import py -import py.test - - -## class AppTestSimpleArray: -## spaceconfig = dict(usemodules=('array',)) -## def setup_class(cls): -## cls.w_simple_array = cls.space.appexec([], """(): -## import array -## return array.simple_array -## """) - -## def test_simple(self): -## a = self.simple_array(10) -## a[5] = 7.42 -## assert a[5] == 7.42 +import pytest class BaseArrayTests: - - def test_ctor(self): assert len(self.array('c')) == 0 assert len(self.array('i')) == 0 @@ -563,7 +546,6 @@ assert not a > 2*a assert not a >= 2*a - def test_reduce(self): import pickle a = self.array('i', [1, 2, 3]) @@ -794,7 +776,6 @@ assert img[3, 25] == 3 * 9 - def test_override_from(self): class mya(self.array): def fromlist(self, lst): @@ -879,41 +860,41 @@ def test_assign_object_with_special_methods(self): from array import array - + class Num(object): def __float__(self): return 5.25 - + def __int__(self): return 7 - + class NotNum(object): pass - + class Silly(object): def __float__(self): return None - + def __int__(self): - return None + return None class OldNum: def __float__(self): return 6.25 - + def __int__(self): return 8 - + class OldNotNum: pass - + class OldSilly: def __float__(self): return None - + def __int__(self): return None - + for tc in 'bBhHiIlL': a = array(tc, [0]) raises(TypeError, a.__setitem__, 0, 1.0) @@ -931,7 +912,7 @@ a = array(tc, [0]) a[0] = 1.0 a[0] = 1 - a[0] = Num() + a[0] = Num() assert a[0] == 5.25 raises(TypeError, a.__setitem__, NotNum()) a[0] = OldNum() @@ -939,24 +920,23 @@ raises(TypeError, a.__setitem__, OldNotNum()) raises(TypeError, a.__setitem__, Silly()) raises(TypeError, a.__setitem__, OldSilly()) - + a = array('c', 'hi') a[0] = 'b' assert a[0] == 'b' - + a = array('u', u'hi') a[0] = u'b' assert a[0] == u'b' - + class TestCPythonsOwnArray(BaseArrayTests): - def setup_class(cls): import array cls.array = array.array import struct cls.struct = struct - cls.tempfile = str(py.test.ensuretemp('array').join('tmpfile')) + cls.tempfile = str(pytest.ensuretemp('array').join('tmpfile')) cls.maxint = sys.maxint @@ -969,7 +949,7 @@ return array.array """) cls.w_tempfile = cls.space.wrap( - str(py.test.ensuretemp('array').join('tmpfile'))) + str(pytest.ensuretemp('array').join('tmpfile'))) cls.w_maxint = cls.space.wrap(sys.maxint) def test_buffer_info(self): @@ -1036,11 +1016,11 @@ def test_getitem_only_ints(self): class MyInt(object): - def __init__(self, x): - self.x = x + def __init__(self, x): + self.x = x - def __int__(self): - return self.x + def __int__(self): + return self.x a = self.array('i', [1, 2, 3, 4, 5, 6]) raises(TypeError, "a[MyInt(0)]") @@ -1050,4 +1030,3 @@ class AppTestArrayBuiltinShortcut(AppTestArray): spaceconfig = AppTestArray.spaceconfig.copy() spaceconfig['objspace.std.builtinshortcut'] = True - diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py --- a/pypy/module/cpyext/test/test_arraymodule.py +++ b/pypy/module/cpyext/test/test_arraymodule.py @@ -1,7 +1,5 @@ from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase -import py -import sys class AppTestArrayModule(AppTestCpythonExtensionBase): enable_leak_checking = False @@ -21,7 +19,7 @@ module = self.import_module(name='array') arr = module.array('i', [1,2,3]) sum = 0 - for i in arr: + for i in arr: sum += i assert sum == 6 @@ -60,4 +58,3 @@ '\x02\0\0\0' '\x03\0\0\0' '\x04\0\0\0') - _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit