diff --git a/bin-for-dist/hudson.py b/bin-for-dist/hudson.py index d5f8d6498..24fb92c89 100644 --- a/bin-for-dist/hudson.py +++ b/bin-for-dist/hudson.py @@ -13,9 +13,10 @@ def bincall(*args): args[0] = os.path.join(BIN, args[0]) call(*args) -call("virtualenv", BUILDNAME, '--no-site-packages') +call("virtualenv", os.path.abspath(BUILDNAME), '--no-site-packages') bincall("python", "setup.py", "develop", "-q") bincall("pip", "install", "-r", "testing/pip-reqs1.txt", "-q", "--download-cache=download") -bincall("py.test", "-p", "xmlresult", "--xmlresult=junit.xml", - "--report=skipped", "--runslowtest") +bincall("py.test", "--ignore", BUILDNAME, + "-p", "xmlresult", "--xmlresult=junit.xml", + "--report=skipped", "--runslowtest", *sys.argv[1:]) diff --git a/doc/conftest.py b/doc/conftest.py index 50b4f51c1..9912be1d0 100644 --- a/doc/conftest.py +++ b/doc/conftest.py @@ -2,6 +2,4 @@ import py #py.test.importorskip("pygments") pytest_plugins = ['pytest_restdoc'] -rsyncdirs = ['.'] - collect_ignore = ['test/attic.txt'] diff --git a/py/plugin/pytest_pytester.py b/py/plugin/pytest_pytester.py index b7505b7b2..f91540bd8 100644 --- a/py/plugin/pytest_pytester.py +++ b/py/plugin/pytest_pytester.py @@ -4,6 +4,7 @@ funcargs and support code for testing py.test's own functionality. import py import sys, os +import re import inspect from py.impl.test.config import Config as pytestConfig from py.plugin import hookspec @@ -26,6 +27,7 @@ def pytest_funcarg__reportrecorder(request): request.addfinalizer(lambda: reprec.comregistry.unregister(reprec)) return reprec +rex_outcome = re.compile("(\d+) (\w+)") class RunResult: def __init__(self, ret, outlines, errlines): self.ret = ret @@ -33,6 +35,15 @@ class RunResult: self.errlines = errlines self.stdout = LineMatcher(outlines) self.stderr = LineMatcher(errlines) + def parseoutcomes(self): + for line in reversed(self.outlines): + if 'seconds' in line: + outcomes = rex_outcome.findall(line) + if outcomes: + d = {} + for num, cat in outcomes: + d[cat] = int(num) + return d class TmpTestdir: def __init__(self, request): @@ -245,17 +256,6 @@ class TmpTestdir: return self.config.getfsnode(path) - def prepare(self): - p = self.tmpdir.join("conftest.py") - if not p.check(): - plugins = [x for x in self.plugins if isinstance(x, str)] - if not plugins: - return - p.write("import py ; pytest_plugins = %r" % plugins) - else: - if self.plugins: - print ("warning, ignoring reusing existing %s" % p) - def popen(self, cmdargs, stdout, stderr, **kw): if not hasattr(py.std, 'subprocess'): py.test.skip("no subprocess module") @@ -267,7 +267,6 @@ class TmpTestdir: return py.std.subprocess.Popen(cmdargs, stdout=stdout, stderr=stderr, **kw) def run(self, *cmdargs): - self.prepare() old = self.tmpdir.chdir() #print "chdir", self.tmpdir try: @@ -316,6 +315,9 @@ class TmpTestdir: p = py.path.local.make_numbered_dir(prefix="runpytest-", keep=None, rootdir=self.tmpdir) args = ('--basetemp=%s' % p, ) + args + plugins = [x for x in self.plugins if isinstance(x, str)] + if plugins: + args = ('-p', plugins[0]) + args return self.runpybin("py.test", *args) def spawn_pytest(self, string, expect_timeout=10.0): diff --git a/testing/pip-reqs1.txt b/testing/pip-reqs1.txt index d01b37708..b520ef1d4 100644 --- a/testing/pip-reqs1.txt +++ b/testing/pip-reqs1.txt @@ -1,3 +1,4 @@ docutils pexpect +figleaf hg+http://bitbucket.org/hpk42/execnet#egg=execnet diff --git a/testing/plugin/test_pytest_restdoc.py b/testing/plugin/test_pytest_restdoc.py index 50a40e88a..ce71f0d56 100644 --- a/testing/plugin/test_pytest_restdoc.py +++ b/testing/plugin/test_pytest_restdoc.py @@ -8,53 +8,16 @@ def test_deindent(): assert deindent(' foo\n bar\n') == 'foo\n bar\n' assert deindent(' foo\n bar\n') == ' foo\nbar\n' -class TestApigenLinkRole: - disabled = True - - # these tests are moved here from the former py/doc/conftest.py - def test_resolve_linkrole(self): - from py.impl.doc.conftest import get_apigen_relpath - apigen_relpath = get_apigen_relpath() - - assert resolve_linkrole('api', 'py.foo.bar', False) == ( - 'py.foo.bar', apigen_relpath + 'api/foo.bar.html') - assert resolve_linkrole('api', 'py.foo.bar()', False) == ( - 'py.foo.bar()', apigen_relpath + 'api/foo.bar.html') - assert resolve_linkrole('api', 'py', False) == ( - 'py', apigen_relpath + 'api/index.html') - py.test.raises(AssertionError, 'resolve_linkrole("api", "foo.bar")') - assert resolve_linkrole('source', 'py/foo/bar.py', False) == ( - 'py/foo/bar.py', apigen_relpath + 'source/foo/bar.py.html') - assert resolve_linkrole('source', 'py/foo/', False) == ( - 'py/foo/', apigen_relpath + 'source/foo/index.html') - assert resolve_linkrole('source', 'py/', False) == ( - 'py/', apigen_relpath + 'source/index.html') - py.test.raises(AssertionError, 'resolve_linkrole("source", "/foo/bar/")') - - def test_resolve_linkrole_check_api(self): - assert resolve_linkrole('api', 'py.test.ensuretemp') - py.test.raises(AssertionError, "resolve_linkrole('api', 'py.foo.baz')") - - def test_resolve_linkrole_check_source(self): - assert resolve_linkrole('source', 'py/path/common.py') - py.test.raises(AssertionError, - "resolve_linkrole('source', 'py/foo/bar.py')") - - class TestDoctest: def pytest_funcarg__testdir(self, request): testdir = request.getfuncargvalue("testdir") + testdir.plugins.append("restdoc") assert request.module.__name__ == __name__ testdir.makepyfile(confrest= "from py.plugin.pytest_restdoc import Project") # we scope our confrest file so that it doesn't # conflict with another global confrest.py testdir.makepyfile(__init__="") - for p in testdir.plugins: - if p == globals(): - break - else: - testdir.plugins.append(globals()) return testdir def test_doctest_extra_exec(self, testdir): @@ -63,9 +26,8 @@ class TestDoctest: .. >>> raise ValueError >>> None """) - reprec = testdir.inline_run(xtxt) - passed, skipped, failed = reprec.countoutcomes() - assert failed == 1 + result = testdir.runpytest(xtxt) + result.stdout.fnmatch_lines(['*1 fail*']) def test_doctest_basic(self, testdir): xtxt = testdir.maketxtfile(x=""" @@ -86,25 +48,21 @@ class TestDoctest: end """) - reprec = testdir.inline_run(xtxt) - passed, skipped, failed = reprec.countoutcomes() - assert failed == 0 - assert passed + skipped == 2 + result = testdir.runpytest(xtxt) + result.stdout.fnmatch_lines([ + "*2 passed*" + ]) def test_doctest_eol(self, testdir): ytxt = testdir.maketxtfile(y=".. >>> 1 + 1\r\n 2\r\n\r\n") - reprec = testdir.inline_run(ytxt) - passed, skipped, failed = reprec.countoutcomes() - assert failed == 0 - assert passed + skipped == 2 + result = testdir.runpytest(ytxt) + result.stdout.fnmatch_lines(["*2 passed*"]) def test_doctest_indentation(self, testdir): footxt = testdir.maketxtfile(foo= '..\n >>> print ("foo\\n bar")\n foo\n bar\n') - reprec = testdir.inline_run(footxt) - passed, skipped, failed = reprec.countoutcomes() - assert failed == 0 - assert skipped + passed == 2 + result = testdir.runpytest(footxt) + result.stdout.fnmatch_lines(["*2 passed*"]) def test_js_ignore(self, testdir): xtxt = testdir.maketxtfile(xtxt=""" @@ -112,20 +70,14 @@ class TestDoctest: .. _`blah`: javascript:some_function() """) - reprec = testdir.inline_run(xtxt) - passed, skipped, failed = reprec.countoutcomes() - assert failed == 0 - assert skipped + passed == 3 + result = testdir.runpytest(xtxt) + result.stdout.fnmatch_lines(["*3 passed*"]) def test_pytest_doctest_prepare_content(self, testdir): - l = [] - class MyPlugin: - def pytest_doctest_prepare_content(self, content): - l.append(content) + testdir.makeconftest(""" + def pytest_doctest_prepare_content(content): return content.replace("False", "True") - - testdir.plugins.append(MyPlugin()) - + """) xtxt = testdir.maketxtfile(x=""" hello: @@ -133,9 +85,8 @@ class TestDoctest: False """) - reprec = testdir.inline_run(xtxt) - assert len(l) == 1 - passed, skipped, failed = reprec.countoutcomes() - assert passed >= 1 - assert not failed - assert skipped <= 1 + result = testdir.runpytest(xtxt) + outcomes = result.parseoutcomes() + assert outcomes['passed'] >= 1 + assert 'failed' not in outcomes + assert 'skipped' not in outcomes