Author: Ronan Lamy <[email protected]>
Branch: py3tests
Changeset: r94028:488e2edbef85
Date: 2018-03-20 13:27 +0100
http://bitbucket.org/pypy/pypy/changeset/488e2edbef85/
Log: Inject a fake pytest module for untranslated new-style applevel
tests
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
@@ -263,21 +263,21 @@
raise
raise oefmt(space.w_AssertionError, "DID NOT RAISE")
-app_raises = gateway.interp2app_temp(pypyraises)
+app_raises = gateway.interp2app(pypyraises)
def pypyskip(space, w_message):
"""skip a test at app-level. """
msg = space.unwrap(w_message)
py.test.skip(msg)
-app_skip = gateway.interp2app_temp(pypyskip)
+app_skip = gateway.interp2app(pypyskip)
-def py3k_pypyskip(space, w_message):
- """skip a test at app-level. """
- msg = space.unwrap(w_message)
+def py3k_pypyskip(space, w_message):
+ """skip a test at app-level. """
+ msg = space.unwrap(w_message)
py.test.skip('[py3k] %s' % msg)
-app_py3k_skip = gateway.interp2app_temp(py3k_pypyskip)
+app_py3k_skip = gateway.interp2app(py3k_pypyskip)
def raises_w(space, w_ExpectedException, *args, **kwds):
try:
diff --git a/pypy/tool/pytest/apptest2.py b/pypy/tool/pytest/apptest2.py
--- a/pypy/tool/pytest/apptest2.py
+++ b/pypy/tool/pytest/apptest2.py
@@ -1,6 +1,8 @@
import sys
+import os
import pytest
+from pypy import pypydir
import pypy.interpreter.function
from pypy.interpreter.error import OperationError
from pypy.tool.pytest import objspace
@@ -19,7 +21,7 @@
stat, co = _pytest.assertion.rewrite._rewrite_test(None,
py.path.local('%s'))
mod = _pytest.assertion.rewrite.create_module(co)
return mod
- """ % (self.config.rootdir, str(self.fspath)))
+ """ % (os.path.dirname(pypydir), str(self.fspath)))
mod_dict = w_mod.getdict(space).unwrap(space)
items = []
for name, w_obj in mod_dict.items():
diff --git a/pypy/tool/pytest/fake_pytest/__init__.py
b/pypy/tool/pytest/fake_pytest/__init__.py
new file mode 100644
--- /dev/null
+++ b/pypy/tool/pytest/fake_pytest/__init__.py
@@ -0,0 +1,9 @@
+from pypy.interpreter.mixedmodule import MixedModule
+
+class Module(MixedModule):
+ applevel_name = 'pytest'
+ interpleveldefs = {
+ 'raises': 'interp_pytest.pypyraises',
+ 'skip': 'interp_pytest.pypyskip'
+ }
+ appleveldefs = {}
diff --git a/pypy/tool/pytest/fake_pytest/interp_pytest.py
b/pypy/tool/pytest/fake_pytest/interp_pytest.py
new file mode 100644
--- /dev/null
+++ b/pypy/tool/pytest/fake_pytest/interp_pytest.py
@@ -0,0 +1,1 @@
+from pypy.tool.pytest.appsupport import pypyraises, pypyskip
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
@@ -30,6 +30,7 @@
config = make_config(option)
if config.objspace.usemodules.thread:
config.translation.thread = True
+ config.objspace.extmodules = 'pypy.tool.pytest.fake_pytest'
space = make_objspace(config)
space.startup() # Initialize all builtin modules
space.setitem(space.builtin.w_dict, space.wrap('AssertionError'),
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit