[pypy-commit] pypy py3.5: Avoid relying on pytest's rarely-used functions (this is unrelated to
arigo
pypy.commits at gmail.com
Fri Nov 18 10:12:04 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88468:b3d7eec2a80e
Date: 2016-11-18 16:11 +0100
http://bitbucket.org/pypy/pypy/changeset/b3d7eec2a80e/
Log: Avoid relying on pytest's rarely-used functions (this is unrelated
to the update to pytest-2.9.2): here, testdir.inline_run(), which
fails in the py3.5 branch for no reason I want to understand.
diff --git a/pypy/tool/pytest/test/test_conftest1.py b/pypy/tool/pytest/test/test_conftest1.py
--- a/pypy/tool/pytest/test/test_conftest1.py
+++ b/pypy/tool/pytest/test/test_conftest1.py
@@ -1,61 +1,78 @@
import py
import sys
+import subprocess
innertest = py.path.local(__file__).dirpath('conftest1_innertest.py')
-pytest_plugins = "pytester"
+#pytest_plugins = "pytester"
+
+
+def subproc_run(*args):
+ # similar to testdir.inline_run(), but running a subprocess to avoid
+ # confusion. Parses the standard output of test_all.py, so somehow
+ # dependent on how it looks like.
+ test_all = py.path.local(__file__).dirpath('..', '..', '..', 'test_all.py')
+ args = [sys.executable, str(test_all), "-v"] + map(str, args)
+ print '=========>', args
+ passed, failed = [], []
+ popen = subprocess.Popen(args, stdout=subprocess.PIPE)
+ output, _ = popen.communicate()
+
+ for line in output.splitlines(False):
+ if line.startswith('conftest1_innertest.py'):
+ line = line[len('conftest1_innertest.py'):]
+ testname, result = line.lstrip(':').strip().split()
+ if result == 'PASSED':
+ passed.append(testname)
+ elif result == 'FAILED':
+ failed.append(testname)
+ else:
+ assert False, "unexpected output line: %r" % (line,)
+ return passed, failed
+
class TestPyPyTests:
- def test_selection_by_keyword_interp(self, testdir):
- sorter = testdir.inline_run("-m", "interplevel", innertest, )
- passed, skipped, failed = sorter.listoutcomes()
+ def test_selection_by_keyword_interp(self):
+ passed, failed = subproc_run("-m", "interplevel", innertest)
assert len(passed) == 2, len(passed)
- assert not skipped and not failed
- assert "test_something" in passed[0].nodeid
- assert "test_method" in passed[1].nodeid
+ assert not failed
+ assert "test_something" in passed[0]
+ assert "test_method" in passed[1]
- def test_selection_by_keyword_app(self, testdir):
- sorter = testdir.inline_run("-m", "applevel -docstring", innertest)
- passed, skipped, failed = sorter.listoutcomes()
+ def test_selection_by_keyword_app(self):
+ passed, failed = subproc_run("-m", "applevel -docstring", innertest)
assert len(passed) == 4
- assert not skipped
assert len(failed) == 2
- assert "app_test_something" in passed[0].nodeid
- assert "test_method_app" in passed[1].nodeid
-
- def test_docstring_in_methods(self, testdir):
- sorter = testdir.inline_run("-k", "AppTestSomething and test_code_in_docstring",
+ assert "app_test_something" in passed[0]
+ assert "test_method_app" in passed[1]
+
+ def test_docstring_in_methods(self):
+ passed, failed = subproc_run("-k", "AppTestSomething and test_code_in_docstring",
innertest)
- passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 1
assert len(failed) == 1
- assert skipped == []
- assert "test_code_in_docstring_ignored" in passed[0].nodeid
- assert "test_code_in_docstring_failing" in failed[0].nodeid
+ assert "test_code_in_docstring_ignored" in passed[0]
+ assert "test_code_in_docstring_failing" in failed[0]
- def test_docstring_in_functions(self, testdir):
- sorter = testdir.inline_run("-k", "app_test_code_in_docstring", innertest)
- passed, skipped, failed = sorter.listoutcomes()
+ def test_docstring_in_functions(self):
+ passed, failed = subproc_run("-k", "app_test_code_in_docstring", innertest)
assert passed == []
assert len(failed) == 1
- assert skipped == []
- assert "app_test_code_in_docstring_failing" in failed[0].nodeid
+ assert "app_test_code_in_docstring_failing" in failed[0]
- def test_docstring_runappdirect(self, testdir):
- sorter = testdir.inline_run(innertest,
+ def test_docstring_runappdirect(self):
+ passed, failed = subproc_run(innertest,
'-k', 'test_code_in_docstring',
'--runappdirect')
- passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 1
assert len(failed) == 2
- assert "test_code_in_docstring_ignored" in passed[0].nodeid
- assert "app_test_code_in_docstring_failing" in failed[0].nodeid
- assert "test_code_in_docstring_failing" in failed[1].nodeid
+ assert "test_code_in_docstring_ignored" in passed[0]
+ assert "app_test_code_in_docstring_failing" in failed[0]
+ assert "test_code_in_docstring_failing" in failed[1]
- def test_raises_inside_closure(self, testdir):
- sorter = testdir.inline_run(innertest, '-k', 'app_test_raise_in_a_closure',
+ def test_raises_inside_closure(self):
+ passed, failed = subproc_run(innertest, '-k', 'app_test_raise_in_a_closure',
'--runappdirect')
- passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 1
print passed
- assert "app_test_raise_in_a_closure" in passed[0].nodeid
+ assert "app_test_raise_in_a_closure" in passed[0]
More information about the pypy-commit
mailing list