Author: Ronny Pfannschmidt <[email protected]>
Branch: split-rpython
Changeset: r60175:ebd8f08afe07
Date: 2013-01-18 15:45 +0100
http://bitbucket.org/pypy/pypy/changeset/ebd8f08afe07/
Log: move expecttest to rpython, where it is used
diff --git a/pypy/tool/pytest/test/test_pytestsupport.py
b/pypy/tool/pytest/test/test_pytestsupport.py
--- a/pypy/tool/pytest/test/test_pytestsupport.py
+++ b/pypy/tool/pytest/test/test_pytestsupport.py
@@ -9,7 +9,6 @@
import os
import sys
import pypy
-conftestpath = py.path.local(pypy.__file__).dirpath("conftest.py")
pytest_plugins = "pytest_pytester"
@@ -101,48 +100,6 @@
def test_equal(self):
assert self.compute(3) == 5
-def test_expectcollect(testdir):
- py.test.importorskip("pexpect")
- conftestpath.copy(testdir.tmpdir)
- sorter = testdir.inline_runsource("""
- class ExpectTestOne:
- def test_one(self):
- pass
- """)
- passed, skipped, failed = sorter.countoutcomes()
- assert passed == 1
-
-def test_safename():
- from pypy.tool.pytest.expecttest import ExpectTestMethod
-
- safe_name = ExpectTestMethod.safe_name
- assert safe_name(['pypy', 'tool', 'test', 'test_pytestsupport.py',
- 'ExpectTest', '()', 'test_one']) == \
- 'pypy_tool_test_test_pytestsupport_ExpectTest_paren_test_one'
-
-def test_safe_filename(testdir):
- py.test.importorskip("pexpect")
- conftestpath.copy(testdir.tmpdir)
- sorter = testdir.inline_runsource("""
- class ExpectTestOne:
- def test_one(self):
- pass
- """)
- evlist = sorter.getcalls("pytest_runtest_makereport")
- ev = [x for x in evlist if x.call.when == "call"][0]
- print ev
- sfn = ev.item.safe_filename()
- print sfn
- assert sfn ==
'test_safe_filename_test_safe_filename_ExpectTestOne_paren_test_one_1.py'
-
-class ExpectTest:
- def test_one(self):
- import os
- import sys
- assert os.ttyname(sys.stdin.fileno())
-
- def test_two(self):
- import pypy
def test_app_test_blow(testdir):
conftestpath.copy(testdir.tmpdir)
diff --git a/rpython/conftest.py b/rpython/conftest.py
--- a/rpython/conftest.py
+++ b/rpython/conftest.py
@@ -2,6 +2,8 @@
import py, pytest
from rpython.tool import leakfinder
+pytest_plugins = 'rpython.tool.pytest.expecttest'
+
cdir = realpath(join(dirname(__file__), 'translator', 'c'))
cache_dir = realpath(join(dirname(__file__), '_cache'))
option = None
diff --git a/rpython/tool/pytest/__init__.py b/rpython/tool/pytest/__init__.py
new file mode 100644
diff --git a/pypy/tool/pytest/expecttest.py b/rpython/tool/pytest/expecttest.py
rename from pypy/tool/pytest/expecttest.py
rename to rpython/tool/pytest/expecttest.py
--- a/pypy/tool/pytest/expecttest.py
+++ b/rpython/tool/pytest/expecttest.py
@@ -7,9 +7,10 @@
import py
-import os, sys
+import os
+import sys
from rpython.tool.udir import udir
-from pypy.conftest import pypydir
+from pypy.conftest import pypydir #XXX
class ExpectTestMethod(py.test.collect.Function):
@@ -71,4 +72,7 @@
except ImportError:
py.test.skip("pexpect not found")
-
[email protected]
+def pytest_pycollect_makeitem(collector, name, obj):
+ if py.std.inspect.isclass(obj) and name.startswith('ExpectTest'):
+ return ExpectClassCollector(name, parent=collector)
diff --git a/rpython/tool/pytest/test/test_expecttest.py
b/rpython/tool/pytest/test/test_expecttest.py
new file mode 100644
--- /dev/null
+++ b/rpython/tool/pytest/test/test_expecttest.py
@@ -0,0 +1,53 @@
+import py
+import rpython
+
+pytest_plugins = "pytest_pytester"
+
+conftestpath = py.path.local(rpython.__file__).dirpath("conftest.py")
+
+
+def test_expectcollect(testdir):
+ py.test.importorskip("pexpect")
+ conftestpath.copy(testdir.tmpdir)
+ sorter = testdir.inline_runsource("""
+ class ExpectTestOne:
+ def test_one(self):
+ pass
+ """)
+ passed, skipped, failed = sorter.countoutcomes()
+ assert passed == 1
+
+
+def test_safename():
+ from rpython.tool.pytest.expecttest import ExpectTestMethod
+
+ safe_name = ExpectTestMethod.safe_name
+ assert safe_name(['pypy', 'tool', 'test', 'test_pytestsupport.py',
+ 'ExpectTest', '()', 'test_one']) == \
+ 'pypy_tool_test_test_pytestsupport_ExpectTest_paren_test_one'
+
+
+def test_safe_filename(testdir):
+ py.test.importorskip("pexpect")
+ conftestpath.copy(testdir.tmpdir)
+ sorter = testdir.inline_runsource("""
+ class ExpectTestOne:
+ def test_one(self):
+ pass
+ """)
+ evlist = sorter.getcalls("pytest_runtest_makereport")
+ ev = [x for x in evlist if x.call.when == "call"][0]
+ print ev
+ sfn = ev.item.safe_filename()
+ print sfn
+ assert sfn ==
'test_safe_filename_test_safe_filename_ExpectTestOne_paren_test_one_1.py'
+
+
+class ExpectTest:
+ def test_one(self):
+ import os
+ import sys
+ assert os.ttyname(sys.stdin.fileno())
+
+ def test_two(self):
+ import pypy
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit