Author: Matti Picus <[email protected]> Branch: release-5.x Changeset: r84972:e5257f0e43e9 Date: 2016-06-06 19:21 +0300 http://bitbucket.org/pypy/pypy/changeset/e5257f0e43e9/
Log: merge default into release diff --git a/pypy/doc/release-pypy2.7-v5.3.0.rst b/pypy/doc/release-pypy2.7-v5.3.0.rst --- a/pypy/doc/release-pypy2.7-v5.3.0.rst +++ b/pypy/doc/release-pypy2.7-v5.3.0.rst @@ -9,9 +9,11 @@ for lxml, we now pass most (more than 90%) of the upstream numpy test suite, and much of SciPy is supported as well. -We also improved the speed of ... and ... +We updated cffi_ to version 1.7 (small changes, documented here_). -We updated cffi_ to ... +.. _`PyPy3.3 v5.2 alpha 1`: http://morepypy.blogspot.com/2016/05/pypy33-v52-alpha-1-released.html +.. _cffi: https://cffi.readthedocs.org +.. _here: http://cffi.readthedocs.io/en/latest/whatsnew.html You can download the PyPy2.7 v5.3 release here: @@ -30,10 +32,6 @@ .. _`RPython`: https://rpython.readthedocs.org .. _`modules`: http://doc.pypy.org/en/latest/project-ideas.html#make-more-python-modules-pypy-friendly .. _`help`: http://doc.pypy.org/en/latest/project-ideas.html -.. _`numpy`: https://bitbucket.org/pypy/numpy -.. _cffi: https://cffi.readthedocs.org -.. _`fully support for the IBM s390x`: http://morepypy.blogspot.com/2016/04/pypy-enterprise-edition.html -.. _`blog post`: http://morepypy.blogspot.com/2016/04/warmup-improvements-more-efficient.html What is PyPy? ============= @@ -42,8 +40,8 @@ CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison) due to its integrated tracing JIT compiler. -We also welcome developers of other -`dynamic languages`_ to see what RPython can do for them. +We also welcome developers of other `dynamic languages`_ to see what RPython +can do for them. This release supports: @@ -107,12 +105,10 @@ * Revive traceviewer, a tool to use pygame to view traces - * Update to cffi/847bbc0297f8 which improves help() on cffi objects - * Bug Fixes - * Fix issue #2277: only special-case two exact lists in zip(), not list - subclasses, because an overridden __iter__() should be called (probably) + * Fix issue #2277: only special-case two exact lists in zip(), not list + subclasses, because an overridden __iter__() should be called (probably) * Fix issue #2226: Another tweak in the incremental GC- this should ensure that progress in the major GC occurs quickly enough in all cases. @@ -145,7 +141,7 @@ * Implement ufunc.outer on numpypy - * Move PyPy-specific numpy headers to a subdirectory (also changed pypy/numpy + * Move PyPy-specific numpy headers to a subdirectory (also changed `the repo`_ accordingly) * Performance improvements: @@ -185,9 +181,9 @@ * Compile c snippets with -Werror, and fix warnings it exposed -.. _`PyPy3.3 v5.2 alpha 1`: http://morepypy.blogspot.com/2016/05/pypy33-v52-alpha-1-released.html .. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.3.0.html .. _Numpy: https://bitbucket.org/pypy/numpy +.. _`the repo`: https://bitbucket.org/pypy/numpy Please update, and continue to help us make PyPy better. diff --git a/pypy/interpreter/test/test_pyframe.py b/pypy/interpreter/test/test_pyframe.py --- a/pypy/interpreter/test/test_pyframe.py +++ b/pypy/interpreter/test/test_pyframe.py @@ -1,5 +1,5 @@ +import pytest from rpython.tool import udir -from pypy.conftest import option from pypy.interpreter.gateway import interp2app def check_no_w_locals(space, w_frame): @@ -11,7 +11,7 @@ space = cls.space cls.w_udir = cls.space.wrap(str(udir.udir)) cls.w_tempfile1 = cls.space.wrap(str(udir.udir.join('tempfile1'))) - if not option.runappdirect: + if not pytest.config.option.runappdirect: w_call_further = cls.space.appexec([], """(): def call_further(f): return f() @@ -48,10 +48,10 @@ return f.f_code assert g() is g.func_code - def test_f_trace_del(self): + def test_f_trace_del(self): import sys - f = sys._getframe() - del f.f_trace + f = sys._getframe() + del f.f_trace assert f.f_trace is None def test_f_lineno(self): @@ -116,7 +116,7 @@ def f(): assert sys._getframe().f_code.co_name == g() def g(): - return sys._getframe().f_back.f_code.co_name + return sys._getframe().f_back.f_code.co_name f() def test_f_back_virtualref(self): @@ -233,7 +233,7 @@ def test_trace_exc(self): import sys l = [] - def ltrace(a,b,c): + def ltrace(a,b,c): if b == 'exception': l.append(c) return ltrace @@ -298,7 +298,7 @@ def test_trace_return_exc(self): import sys l = [] - def trace(a,b,c): + def trace(a,b,c): if b in ('exception', 'return'): l.append((b, c)) return trace @@ -444,7 +444,7 @@ def test_dont_trace_on_reraise(self): import sys l = [] - def ltrace(a,b,c): + def ltrace(a,b,c): if b == 'exception': l.append(c) return ltrace @@ -466,7 +466,7 @@ def test_dont_trace_on_raise_with_tb(self): import sys l = [] - def ltrace(a,b,c): + def ltrace(a,b,c): if b == 'exception': l.append(c) return ltrace diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py b/pypy/interpreter/test/test_zzpickle_and_slow.py --- a/pypy/interpreter/test/test_zzpickle_and_slow.py +++ b/pypy/interpreter/test/test_zzpickle_and_slow.py @@ -1,9 +1,8 @@ import py -from pypy import conftest from pypy.interpreter import gateway from rpython.rlib.jit import non_virtual_ref, vref_None -class AppTestSlow: +class AppTestSlow: spaceconfig = dict(usemodules=['itertools']) def setup_class(cls): @@ -64,7 +63,7 @@ space.setitem(space.builtin.w_dict, space.wrap('read_exc_type'), space.wrap(read_exc_type_gw)) - + def _detach_helpers(space): space.delitem(space.builtin.w_dict, space.wrap('hide_top_frame')) @@ -92,7 +91,7 @@ pckl = pickle.dumps(code) result = pickle.loads(pckl) assert code == result - + def test_pickle_global_func(self): import new mod = new.module('mod') @@ -109,7 +108,7 @@ assert func is result finally: del sys.modules['mod'] - + def test_pickle_not_imported_module(self): import new mod = new.module('mod') @@ -119,13 +118,13 @@ result = pickle.loads(pckl) assert mod.__name__ == result.__name__ assert mod.__dict__ == result.__dict__ - + def test_pickle_builtin_func(self): import pickle pckl = pickle.dumps(map) result = pickle.loads(pckl) assert map is result - + def test_pickle_non_top_reachable_func(self): def func(): return 42 @@ -142,7 +141,7 @@ assert func.func_dict == result.func_dict assert func.func_doc == result.func_doc assert func.func_globals == result.func_globals - + def test_pickle_cell(self): def g(): x = [42] @@ -171,7 +170,7 @@ f1 = f() saved = hide_top_frame(f1) pckl = pickle.dumps(f1) - restore_top_frame(f1, saved) + restore_top_frame(f1, saved) f2 = pickle.loads(pckl) assert type(f1) is type(f2) @@ -223,7 +222,7 @@ f1 = f() saved = hide_top_frame(f1) pckl = pickle.dumps(f1) - restore_top_frame(f1, saved) + restore_top_frame(f1, saved) f2 = pickle.loads(pckl) def test_frame_setstate_crash(self): @@ -257,21 +256,21 @@ pckl = pickle.dumps(mod) result = pickle.loads(pckl) assert mod is result - + def test_pickle_moduledict(self): import pickle moddict = pickle.__dict__ pckl = pickle.dumps(moddict) result = pickle.loads(pckl) assert moddict is result - + def test_pickle_bltins_module(self): import pickle mod = __builtins__ pckl = pickle.dumps(mod) result = pickle.loads(pckl) assert mod is result - + def test_pickle_buffer(self): skip("Can't pickle buffer objects on top of CPython either. " "Do we really need it?") @@ -280,14 +279,14 @@ pckl = pickle.dumps(a) result = pickle.loads(pckl) assert a == result - + def test_pickle_complex(self): import pickle a = complex(1.23,4.567) pckl = pickle.dumps(a) result = pickle.loads(pckl) assert a == result - + def test_pickle_method(self): class myclass(object): def f(self): @@ -308,7 +307,7 @@ assert method() == result() finally: del sys.modules['mod'] - + def test_pickle_staticmethod(self): class myclass(object): def f(): @@ -319,7 +318,7 @@ pckl = pickle.dumps(method) result = pickle.loads(pckl) assert method() == result() - + def test_pickle_classmethod(self): class myclass(object): def f(cls): @@ -337,7 +336,7 @@ assert method() == result() finally: del sys.modules['mod'] - + def test_pickle_sequenceiter(self): ''' In PyPy there is no distinction here between listiterator and diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py --- a/pypy/module/_cffi_backend/cdataobj.py +++ b/pypy/module/_cffi_backend/cdataobj.py @@ -420,6 +420,14 @@ w_result = ctype.ctitem.unpack_ptr(ctype, ptr, length) return w_result + def dir(self, space): + from pypy.module._cffi_backend.ctypeptr import W_CTypePointer + ct = self.ctype + if isinstance(ct, W_CTypePointer): + ct = ct.ctitem + lst = ct.cdata_dir() + return space.newlist([space.wrap(s) for s in lst]) + class W_CDataMem(W_CData): """This is used only by the results of cffi.cast('int', x) @@ -602,5 +610,6 @@ __call__ = interp2app(W_CData.call), __iter__ = interp2app(W_CData.iter), __weakref__ = make_weakref_descr(W_CData), + __dir__ = interp2app(W_CData.dir), ) W_CData.typedef.acceptable_as_base_class = False diff --git a/pypy/module/_cffi_backend/ctypeobj.py b/pypy/module/_cffi_backend/ctypeobj.py --- a/pypy/module/_cffi_backend/ctypeobj.py +++ b/pypy/module/_cffi_backend/ctypeobj.py @@ -256,6 +256,9 @@ def fget_elements(self, space): return self._fget('e') def fget_relements(self, space):return self._fget('R') + def cdata_dir(self): + return [] + W_CType.typedef = TypeDef( '_cffi_backend.CTypeDescr', diff --git a/pypy/module/_cffi_backend/ctypestruct.py b/pypy/module/_cffi_backend/ctypestruct.py --- a/pypy/module/_cffi_backend/ctypestruct.py +++ b/pypy/module/_cffi_backend/ctypestruct.py @@ -171,6 +171,12 @@ pass return W_CType.getcfield(self, attr) + def cdata_dir(self): + if self.size < 0: + return [] + self.force_lazy_struct() + return self._fields_dict.keys() + class W_CTypeStruct(W_CTypeStructOrUnion): kind = "struct" diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -77,8 +77,8 @@ assert repr(p) == "<ctype 'signed char'>" def check_dir(p, expected): - got = set(name for name in dir(p) if not name.startswith('_')) - assert got == set(expected) + got = [name for name in dir(p) if not name.startswith('_')] + assert got == sorted(expected) def test_inspect_primitive_type(): p = new_primitive_type("signed char") @@ -3608,3 +3608,23 @@ # py.test.raises(ValueError, unpack, p0, -1) py.test.raises(ValueError, unpack, p, -1) + +def test_cdata_dir(): + BInt = new_primitive_type("int") + p = cast(BInt, 42) + check_dir(p, []) + p = newp(new_array_type(new_pointer_type(BInt), None), 5) + check_dir(p, []) + BStruct = new_struct_type("foo") + p = cast(new_pointer_type(BStruct), 0) + check_dir(p, []) # opaque + complete_struct_or_union(BStruct, [('a2', BInt, -1), + ('a1', BInt, -1)]) + check_dir(p, ['a1', 'a2']) # always sorted + p = newp(new_pointer_type(BStruct), None) + check_dir(p, ['a1', 'a2']) + check_dir(p[0], ['a1', 'a2']) + pp = newp(new_pointer_type(new_pointer_type(BStruct)), p) + check_dir(pp, []) + check_dir(pp[0], ['a1', 'a2']) + check_dir(pp[0][0], ['a1', 'a2']) diff --git a/pypy/module/_continuation/test/test_translated.py b/pypy/module/_continuation/test/test_translated.py --- a/pypy/module/_continuation/test/test_translated.py +++ b/pypy/module/_continuation/test/test_translated.py @@ -89,8 +89,7 @@ class AppTestWrapper: def setup_class(cls): "Run test_various_depths() when we are run with 'pypy py.test -A'." - from pypy.conftest import option - if not option.runappdirect: + if not py.test.config.option.runappdirect: py.test.skip("meant only for -A run") def _setup(): diff --git a/pypy/module/_file/test/test_file.py b/pypy/module/_file/test/test_file.py --- a/pypy/module/_file/test/test_file.py +++ b/pypy/module/_file/test/test_file.py @@ -516,12 +516,11 @@ assert s == 'bar\n' def test_flush_at_exit(): - from pypy import conftest from pypy.tool.option import make_config, make_objspace from rpython.tool.udir import udir tmpfile = udir.join('test_flush_at_exit') - config = make_config(conftest.option) + config = make_config(py.test.config.option) space = make_objspace(config) space.appexec([space.wrap(str(tmpfile))], """(tmpfile): f = open(tmpfile, 'w') diff --git a/pypy/module/_io/test/test_fileio.py b/pypy/module/_io/test/test_fileio.py --- a/pypy/module/_io/test/test_fileio.py +++ b/pypy/module/_io/test/test_fileio.py @@ -222,14 +222,10 @@ assert not closed[0] # flush() called before file closed os.close(fd) -def test_flush_at_exit(): - from pypy import conftest - from pypy.tool.option import make_config, make_objspace +def test_flush_at_exit(space): from rpython.tool.udir import udir tmpfile = udir.join('test_flush_at_exit') - config = make_config(conftest.option) - space = make_objspace(config) space.appexec([space.wrap(str(tmpfile))], """(tmpfile): import io f = io.open(tmpfile, 'w', encoding='ascii') @@ -241,12 +237,7 @@ assert tmpfile.read() == '42' -def test_flush_at_exit_IOError_and_ValueError(): - from pypy import conftest - from pypy.tool.option import make_config, make_objspace - - config = make_config(conftest.option) - space = make_objspace(config) +def test_flush_at_exit_IOError_and_ValueError(space): space.appexec([], """(): import io class MyStream(io.IOBase): diff --git a/pypy/module/_rawffi/test/test_tracker.py b/pypy/module/_rawffi/test/test_tracker.py --- a/pypy/module/_rawffi/test/test_tracker.py +++ b/pypy/module/_rawffi/test/test_tracker.py @@ -1,5 +1,5 @@ import py -from pypy.conftest import option +from pytest import option from pypy.module._rawffi.tracker import Tracker @@ -44,4 +44,3 @@ def teardown_class(cls): Tracker.DO_TRACING = False - diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py --- a/pypy/module/cpyext/object.py +++ b/pypy/module/cpyext/object.py @@ -1,7 +1,7 @@ from rpython.rtyper.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP, - PyVarObject, Py_buffer, + PyVarObject, Py_buffer, size_t, Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE, CONST_STRING, FILEP, fwrite) from pypy.module.cpyext.pyobject import ( @@ -14,14 +14,14 @@ import pypy.module.__builtin__.operation as operation -@cpython_api([Py_ssize_t], rffi.VOIDP) +@cpython_api([size_t], rffi.VOIDP) def PyObject_Malloc(space, size): # returns non-zero-initialized memory, like CPython return lltype.malloc(rffi.VOIDP.TO, size, flavor='raw', add_memory_pressure=True) -@cpython_api([rffi.VOIDP, Py_ssize_t], rffi.VOIDP) +@cpython_api([rffi.VOIDP, size_t], rffi.VOIDP) def PyObject_Realloc(space, ptr, size): if not lltype.cast_ptr_to_int(ptr): return lltype.malloc(rffi.VOIDP.TO, size, diff --git a/pypy/module/cpyext/test/conftest.py b/pypy/module/cpyext/test/conftest.py --- a/pypy/module/cpyext/test/conftest.py +++ b/pypy/module/cpyext/test/conftest.py @@ -1,6 +1,7 @@ import py import pytest [email protected] def pytest_configure(config): from pypy.tool.pytest.objspace import gettestobjspace # For some reason (probably a ll2ctypes cache issue on linux64) diff --git a/pypy/module/gc/test/test_referents.py b/pypy/module/gc/test/test_referents.py --- a/pypy/module/gc/test/test_referents.py +++ b/pypy/module/gc/test/test_referents.py @@ -1,4 +1,4 @@ -from pypy.conftest import option +from pytest import option class AppTestReferents(object): diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py --- a/pypy/module/imp/test/test_import.py +++ b/pypy/module/imp/test/test_import.py @@ -13,7 +13,7 @@ from pypy.module.imp import importing -from pypy import conftest +from pytest import config def setuppkg(pkgname, **entries): p = udir.join('impsubdir') @@ -106,7 +106,7 @@ # create compiled/x.py and a corresponding pyc file p = setuppkg("compiled", x = "x = 84") - if conftest.option.runappdirect: + if config.option.runappdirect: import marshal, stat, struct, os, imp code = py.code.Source(p.join("x.py").read()).compile() s3 = marshal.dumps(code) @@ -143,7 +143,7 @@ def _setup(space): dn = setup_directory_structure(space) return space.appexec([space.wrap(dn)], """ - (dn): + (dn): import sys path = list(sys.path) sys.path.insert(0, dn) @@ -168,7 +168,7 @@ } def setup_class(cls): - cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect) + cls.w_runappdirect = cls.space.wrap(config.option.runappdirect) cls.saved_modules = _setup(cls.space) #XXX Compile class @@ -1017,7 +1017,7 @@ cpathname = udir.join('test.pyc') assert not cpathname.check() - + def test_load_source_module_importerror(self): # the .pyc file is created before executing the module space = self.space @@ -1126,11 +1126,11 @@ stream.close() -def test_PYTHONPATH_takes_precedence(space): +def test_PYTHONPATH_takes_precedence(space): if sys.platform == "win32": py.test.skip("unresolved issues with win32 shell quoting rules") - from pypy.interpreter.test.test_zpy import pypypath - extrapath = udir.ensure("pythonpath", dir=1) + from pypy.interpreter.test.test_zpy import pypypath + extrapath = udir.ensure("pythonpath", dir=1) extrapath.join("sched.py").write("print 42\n") old = os.environ.get('PYTHONPATH', None) oldlang = os.environ.pop('LANG', None) @@ -1494,8 +1494,6 @@ spaceconfig = dict(usemodules=['thread', 'time']) def setup_class(cls): - #if not conftest.option.runappdirect: - # py.test.skip("meant as an -A test") tmpfile = udir.join('test_multithreaded_imp.py') tmpfile.write('''if 1: x = 666 diff --git a/pypy/module/micronumpy/test/test_base.py b/pypy/module/micronumpy/test/test_base.py --- a/pypy/module/micronumpy/test/test_base.py +++ b/pypy/module/micronumpy/test/test_base.py @@ -1,4 +1,4 @@ -from pypy.conftest import option +from pytest import config from pypy.module.micronumpy import constants as NPY @@ -7,7 +7,7 @@ @classmethod def setup_class(cls): - if option.runappdirect: + if config.option.runappdirect: import sys if '__pypy__' not in sys.builtin_module_names: import numpy diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py --- a/pypy/module/micronumpy/test/test_complex.py +++ b/pypy/module/micronumpy/test/test_complex.py @@ -2,7 +2,6 @@ import sys -from pypy.conftest import option from pypy.interpreter.error import OperationError from pypy.interpreter.gateway import interp2app from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest @@ -23,13 +22,13 @@ # special values testing if isnan(a): if isnan(b): - return True,'' + return True, '' raise AssertionError(msg + '%r should be nan' % (b,)) if isinf(a): if a == b: - return True,'' - raise AssertionError(msg + 'finite result where infinity expected: '+ \ + return True, '' + raise AssertionError(msg + 'finite result where infinity expected: ' 'expected %r, got %r' % (a, b)) # if both a and b are zero, check whether they have the same sign @@ -39,7 +38,7 @@ if not a and not b: # only check it if we are running on top of CPython >= 2.6 if sys.version_info >= (2, 6) and copysign(1., a) != copysign(1., b): - raise AssertionError( msg + \ + raise AssertionError(msg + 'zero has wrong sign: expected %r, got %r' % (a, b)) # if a-b overflows, or b is infinite, return False. Again, in @@ -96,7 +95,6 @@ cls.w_testcases128 = cls.space.wrap(list(parse_testfile(fname128))) cls.w_testcases64 = cls.space.wrap(list(parse_testfile(fname64))) - cls.w_runAppDirect = cls.space.wrap(option.runappdirect) cls.w_isWindows = cls.space.wrap(os.name == 'nt') if cls.runappdirect: @@ -495,8 +493,8 @@ c = array([1.e+110, 1.e-110], dtype=complex128) d = floor_divide(c**2, c) assert (d == [1.e+110, 0]).all() - - + + def test_basic(self): import sys diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -1,11 +1,11 @@ -from pypy.conftest import option +from pytest import config from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest from pypy.interpreter.gateway import interp2app class BaseAppTestDtypes(BaseNumpyAppTest): def setup_class(cls): BaseNumpyAppTest.setup_class.im_func(cls) - if option.runappdirect: + if config.option.runappdirect: import platform bits, linkage = platform.architecture() ptr_size = int(bits[:-3]) // 8 @@ -372,8 +372,8 @@ a = np.array(data, dtype=b) x = pickle.loads(pickle.dumps(a)) assert (x == a).all() - assert x.dtype == a.dtype - + assert x.dtype == a.dtype + def test_index(self): import numpy as np for dtype in [np.int8, np.int16, np.int32, np.int64]: @@ -1088,7 +1088,7 @@ spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"]) def setup_class(cls): BaseNumpyAppTest.setup_class.im_func(cls) - if option.runappdirect: + if config.option.runappdirect: cls.w_test_for_core_internal = cls.space.wrap(True) else: cls.w_test_for_core_internal = cls.space.wrap(False) @@ -1459,7 +1459,7 @@ "'offsets':[0,76800], " "'itemsize':80000, " "'aligned':True}") - + assert dt == np.dtype(eval(str(dt))) dt = np.dtype({'names': ['r', 'g', 'b'], 'formats': ['u1', 'u1', 'u1'], @@ -1515,7 +1515,7 @@ else: assert stor2[1] == '\x01' assert stor2[0] == '\x00' - if option.runappdirect: + if config.option.runappdirect: cls.w_check_non_native = lambda *args : None else: cls.w_check_non_native = cls.space.wrap(interp2app(check_non_native)) diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py --- a/pypy/module/micronumpy/test/test_ndarray.py +++ b/pypy/module/micronumpy/test/test_ndarray.py @@ -2,7 +2,7 @@ import py import sys -from pypy.conftest import option +from pytest import config from pypy.module.micronumpy.appbridge import get_appbridge_cache from pypy.module.micronumpy.strides import Chunk, new_view, EllipsisChunk from pypy.module.micronumpy.ndarray import W_NDimArray @@ -1878,7 +1878,7 @@ assert map(isnan, e) == [False, False, False, True, False] assert map(isinf, e) == [False, False, True, False, False] assert e.argmax() == 3 - # numpy preserves value for uint16 -> cast_as_float16 -> + # numpy preserves value for uint16 -> cast_as_float16 -> # convert_to_float64 -> convert_to_float16 -> uint16 # even for float16 various float16 nans all_f16 = arange(0xfe00, 0xffff, dtype='uint16') @@ -2608,7 +2608,7 @@ a = np.arange(6).reshape(2,3) i = np.dtype('int32').type(0) assert (a[0] == a[i]).all() - + def test_ellipsis_indexing(self): import numpy as np @@ -3850,7 +3850,7 @@ class AppTestRepr(BaseNumpyAppTest): def setup_class(cls): - if option.runappdirect: + if config.option.runappdirect: py.test.skip("Can't be run directly.") BaseNumpyAppTest.setup_class.im_func(cls) cache = get_appbridge_cache(cls.space) @@ -3867,7 +3867,7 @@ assert repr(array(1.5).real) == "array(1.5)" def teardown_class(cls): - if option.runappdirect: + if config.option.runappdirect: return cache = get_appbridge_cache(cls.space) cache.w_array_repr = cls.old_array_repr @@ -4343,7 +4343,7 @@ class AppTestPyPy(BaseNumpyAppTest): def setup_class(cls): - if option.runappdirect and '__pypy__' not in sys.builtin_module_names: + if config.option.runappdirect and '__pypy__' not in sys.builtin_module_names: py.test.skip("pypy only test") BaseNumpyAppTest.setup_class.im_func(cls) diff --git a/pypy/module/micronumpy/test/test_object_arrays.py b/pypy/module/micronumpy/test/test_object_arrays.py --- a/pypy/module/micronumpy/test/test_object_arrays.py +++ b/pypy/module/micronumpy/test/test_object_arrays.py @@ -1,14 +1,9 @@ from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest -from pypy.conftest import option class AppTestObjectDtypes(BaseNumpyAppTest): spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"]) - def setup_class(cls): - BaseNumpyAppTest.setup_class.im_func(cls) - cls.w_runappdirect = cls.space.wrap(option.runappdirect) - def test_scalar_from_object(self): from numpy import array import sys @@ -200,7 +195,7 @@ from numpy import arange, dtype from cPickle import loads, dumps import sys - + a = arange(15).astype(object) if '__pypy__' in sys.builtin_module_names: raises(NotImplementedError, dumps, a) @@ -211,4 +206,4 @@ a = arange(15).astype(object).reshape((3, 5)) b = loads(dumps(a)) assert (a == b).all() - + diff --git a/pypy/module/micronumpy/test/test_support_app.py b/pypy/module/micronumpy/test/test_support_app.py --- a/pypy/module/micronumpy/test/test_support_app.py +++ b/pypy/module/micronumpy/test/test_support_app.py @@ -3,11 +3,12 @@ import py from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest -from pypy.conftest import option +from pytest import config class AppTestSupport(BaseNumpyAppTest): def setup_class(cls): - if option.runappdirect and '__pypy__' not in sys.builtin_module_names: + if (config.option.runappdirect and + '__pypy__' not in sys.builtin_module_names): py.test.skip("pypy only test") BaseNumpyAppTest.setup_class.im_func(cls) diff --git a/pypy/module/test_lib_pypy/support.py b/pypy/module/test_lib_pypy/support.py --- a/pypy/module/test_lib_pypy/support.py +++ b/pypy/module/test_lib_pypy/support.py @@ -1,6 +1,6 @@ import py -from pypy.conftest import option +from pytest import config from pypy.interpreter.error import OperationError def import_lib_pypy(space, name, skipmsg=None): @@ -9,7 +9,7 @@ Raises a pytest Skip on ImportError if a skip message was specified. """ - if option.runappdirect: + if config.option.runappdirect: try: mod = __import__('lib_pypy.' + name) except ImportError as e: diff --git a/pypy/objspace/std/test/test_bytearrayobject.py b/pypy/objspace/std/test/test_bytearrayobject.py --- a/pypy/objspace/std/test/test_bytearrayobject.py +++ b/pypy/objspace/std/test/test_bytearrayobject.py @@ -1,9 +1,9 @@ -from pypy import conftest +from pytest import config class AppTestBytesArray: def setup_class(cls): - cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect) + cls.w_runappdirect = cls.space.wrap(config.option.runappdirect) def test_basics(self): b = bytearray() diff --git a/pypy/objspace/std/test/test_obj.py b/pypy/objspace/std/test/test_obj.py --- a/pypy/objspace/std/test/test_obj.py +++ b/pypy/objspace/std/test/test_obj.py @@ -1,5 +1,4 @@ -from __future__ import with_statement -from pypy.conftest import option +from pytest import config class AppTestObject: @@ -7,13 +6,13 @@ from pypy.interpreter import gateway import sys - cpython_behavior = (not option.runappdirect + cpython_behavior = (not config.option.runappdirect or not hasattr(sys, 'pypy_translation_info')) space = cls.space cls.w_cpython_behavior = space.wrap(cpython_behavior) cls.w_cpython_version = space.wrap(tuple(sys.version_info)) - cls.w_appdirect = space.wrap(option.runappdirect) + cls.w_appdirect = space.wrap(config.option.runappdirect) cls.w_cpython_apptest = space.wrap(option.runappdirect and not hasattr(sys, 'pypy_translation_info')) def w_unwrap_wrap_unicode(space, w_obj): diff --git a/pypy/objspace/std/test/test_proxy_usercreated.py b/pypy/objspace/std/test/test_proxy_usercreated.py --- a/pypy/objspace/std/test/test_proxy_usercreated.py +++ b/pypy/objspace/std/test/test_proxy_usercreated.py @@ -5,7 +5,7 @@ from pypy.interpreter.typedef import TypeDef from pypy.interpreter.gateway import interp2app from pypy.objspace.std.transparent import register_proxyable -from pypy.conftest import option +from pytest import config class W_Wrapped(W_Root): @@ -25,7 +25,7 @@ class AppTestProxyNewtype(AppProxy): def setup_class(cls): - if option.runappdirect: + if config.option.runappdirect: py.test.skip("Impossible to run on appdirect") AppProxy.setup_class.im_func(cls) cls.w_wrapped = cls.space.wrap(W_Wrapped()) diff --git a/pypy/objspace/test/test_binop_overriding.py b/pypy/objspace/test/test_binop_overriding.py --- a/pypy/objspace/test/test_binop_overriding.py +++ b/pypy/objspace/test/test_binop_overriding.py @@ -1,5 +1,5 @@ # test about the binop operation rule, see issue 412 -from pypy.conftest import option +from pytest import config class AppTestBinopCombinations: @@ -73,7 +73,7 @@ if C is not object: setattr(C, name, f) override_in_hier(n-1) - if C is not object: + if C is not object: delattr(C, name) override_in_hier() @@ -83,7 +83,7 @@ return Base, do_test """) cls.w_helpers = w_helpers - cls.w_appdirect = cls.space.wrap(option.runappdirect) + cls.w_appdirect = cls.space.wrap(config.option.runappdirect) def test_overriding_base_binop_explict(self): class MulBase(object): @@ -105,7 +105,7 @@ if not self.appdirect: skip("slow test, should be run as appdirect test") Base, do_test = self.helpers - + class X(Base): pass class Y(X): @@ -116,7 +116,7 @@ assert not fail def test_binop_combinations_sub(self): - Base, do_test = self.helpers + Base, do_test = self.helpers class X(Base): pass class Y(X): @@ -124,13 +124,13 @@ fail = do_test(X, Y, 'sub', lambda x,y: x-y) #print len(fail) - assert not fail + assert not fail def test_binop_combinations_pow(self): if not self.appdirect: skip("slow test, should be run as appdirect test") Base, do_test = self.helpers - + class X(Base): pass class Y(X): @@ -138,13 +138,13 @@ fail = do_test(X, Y, 'pow', lambda x,y: x**y) #print len(fail) - assert not fail + assert not fail def test_binop_combinations_more_exhaustive(self): if not self.appdirect: skip("very slow test, should be run as appdirect test") Base, do_test = self.helpers - + class X(Base): pass diff --git a/pypy/tool/pytest/appsupport.py b/pypy/tool/pytest/appsupport.py --- a/pypy/tool/pytest/appsupport.py +++ b/pypy/tool/pytest/appsupport.py @@ -184,7 +184,6 @@ source = str(source).strip() except py.error.ENOENT: source = None - from pypy import conftest if source and py.test.config._assertstate.mode != "off": msg = interpret(source, runner, should_fail=True) space.setattr(w_self, space.wrap('args'), diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py --- a/pypy/tool/pytest/objspace.py +++ b/pypy/tool/pytest/objspace.py @@ -3,14 +3,13 @@ from rpython.config.config import ConflictConfigError from pypy.tool.option import make_config, make_objspace from pypy.tool.pytest import appsupport -from pypy.conftest import option _SPACECACHE={} def gettestobjspace(**kwds): """ helper for instantiating and caching space's for testing. """ try: - config = make_config(option,**kwds) + config = make_config(py.test.config.option,**kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped @@ -19,7 +18,7 @@ try: return _SPACECACHE[key] except KeyError: - if getattr(option, 'runappdirect', None): + if getattr(py.test.config.option, 'runappdirect', None): return TinyObjSpace(**kwds) space = maketestobjspace(config) _SPACECACHE[key] = space @@ -27,7 +26,7 @@ def maketestobjspace(config=None): if config is None: - config = make_config(option) + config = make_config(py.test.config.option) if config.objspace.usemodules.thread: config.translation.thread = True space = make_objspace(config) _______________________________________________ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
