Author: Ronan Lamy <[email protected]>
Branch: 
Changeset: r84977:4c08a181c86a
Date: 2016-06-06 19:05 +0100
http://bitbucket.org/pypy/pypy/changeset/4c08a181c86a/

Log:    Backout 9f49da4855da

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 pytest.config.option.runappdirect:
+        if not option.runappdirect:
             w_call_further = cls.space.appexec([], """():
                 def call_further(f):
                     return f()
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,4 +1,5 @@
 import py
+from pypy import conftest
 from pypy.interpreter import gateway
 from rpython.rlib.jit import non_virtual_ref, vref_None
 
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,7 +89,8 @@
 class AppTestWrapper:
     def setup_class(cls):
         "Run test_various_depths() when we are run with 'pypy py.test -A'."
-        if not py.test.config.option.runappdirect:
+        from pypy.conftest import option
+        if not 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,11 +516,12 @@
             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(py.test.config.option)
+    config = make_config(conftest.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,10 +222,14 @@
         assert not closed[0]  # flush() called before file closed
         os.close(fd)
 
-def test_flush_at_exit(space):
+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)
+    space = make_objspace(config)
     space.appexec([space.wrap(str(tmpfile))], """(tmpfile):
         import io
         f = io.open(tmpfile, 'w', encoding='ascii')
@@ -237,7 +241,12 @@
     assert tmpfile.read() == '42'
 
 
-def test_flush_at_exit_IOError_and_ValueError(space):
+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)
     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 pytest import option
+from pypy.conftest import option
 from pypy.module._rawffi.tracker import Tracker
 
 
@@ -44,3 +44,4 @@
 
     def teardown_class(cls):
         Tracker.DO_TRACING = False
+
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 pytest import option
+from pypy.conftest 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 pytest import config
+from pypy import conftest
 
 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 config.option.runappdirect:
+    if conftest.option.runappdirect:
         import marshal, stat, struct, os, imp
         code = py.code.Source(p.join("x.py").read()).compile()
         s3 = marshal.dumps(code)
@@ -168,7 +168,7 @@
     }
 
     def setup_class(cls):
-        cls.w_runappdirect = cls.space.wrap(config.option.runappdirect)
+        cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect)
         cls.saved_modules = _setup(cls.space)
         #XXX Compile class
 
@@ -1494,6 +1494,8 @@
     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 pytest import config
+from pypy.conftest import option
 from pypy.module.micronumpy import constants as NPY
 
 
@@ -7,7 +7,7 @@
 
     @classmethod
     def setup_class(cls):
-        if config.option.runappdirect:
+        if 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,6 +2,7 @@
 
 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
@@ -22,13 +23,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
@@ -38,7 +39,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
@@ -95,6 +96,7 @@
         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:
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 pytest import config
+from pypy.conftest import option
 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 config.option.runappdirect:
+        if option.runappdirect:
             import platform
             bits, linkage = platform.architecture()
             ptr_size = int(bits[:-3]) // 8
@@ -1088,7 +1088,7 @@
     spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"])
     def setup_class(cls):
         BaseNumpyAppTest.setup_class.im_func(cls)
-        if config.option.runappdirect:
+        if option.runappdirect:
             cls.w_test_for_core_internal = cls.space.wrap(True)
         else:
             cls.w_test_for_core_internal = cls.space.wrap(False)
@@ -1515,7 +1515,7 @@
             else:
                 assert stor2[1] == '\x01'
                 assert stor2[0] == '\x00'
-        if config.option.runappdirect:
+        if 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 pytest import config
+from pypy.conftest import option
 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
@@ -3850,7 +3850,7 @@
 
 class AppTestRepr(BaseNumpyAppTest):
     def setup_class(cls):
-        if config.option.runappdirect:
+        if 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 config.option.runappdirect:
+        if 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 config.option.runappdirect and '__pypy__' not in 
sys.builtin_module_names:
+        if 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,9 +1,14 @@
 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
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,12 +3,11 @@
 import py
 
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
-from pytest import config
+from pypy.conftest import option
 
 class AppTestSupport(BaseNumpyAppTest):
     def setup_class(cls):
-        if (config.option.runappdirect and
-                '__pypy__' not in sys.builtin_module_names):
+        if 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 pytest import config
+from pypy.conftest import option
 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 config.option.runappdirect:
+    if 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 pytest import config
+from pypy import conftest
 
 
 class AppTestBytesArray:
     def setup_class(cls):
-        cls.w_runappdirect = cls.space.wrap(config.option.runappdirect)
+        cls.w_runappdirect = cls.space.wrap(conftest.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,4 +1,5 @@
-from pytest import config
+from __future__ import with_statement
+from pypy.conftest import option
 
 class AppTestObject:
 
@@ -6,13 +7,13 @@
         from pypy.interpreter import gateway
         import sys
 
-        cpython_behavior = (not config.option.runappdirect
+        cpython_behavior = (not 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(config.option.runappdirect)
+        cls.w_appdirect = space.wrap(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 pytest import config
+from pypy.conftest import option
 
 
 class W_Wrapped(W_Root):
@@ -25,7 +25,7 @@
 
 class AppTestProxyNewtype(AppProxy):
     def setup_class(cls):
-        if config.option.runappdirect:
+        if 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 pytest import config
+from pypy.conftest import option
 
 class AppTestBinopCombinations:
 
@@ -83,7 +83,7 @@
     return Base, do_test
 """)
         cls.w_helpers = w_helpers
-        cls.w_appdirect = cls.space.wrap(config.option.runappdirect)
+        cls.w_appdirect = cls.space.wrap(option.runappdirect)
 
     def test_overriding_base_binop_explict(self):
         class MulBase(object):
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,6 +184,7 @@
                 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,13 +3,14 @@
 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(py.test.config.option,**kwds)
+        config = make_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
@@ -18,7 +19,7 @@
     try:
         return _SPACECACHE[key]
     except KeyError:
-        if getattr(py.test.config.option, 'runappdirect', None):
+        if getattr(option, 'runappdirect', None):
             return TinyObjSpace(**kwds)
         space = maketestobjspace(config)
         _SPACECACHE[key] = space
@@ -26,7 +27,7 @@
 
 def maketestobjspace(config=None):
     if config is None:
-        config = make_config(py.test.config.option)
+        config = make_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

Reply via email to