From 275673ba217acb6aeaabe045f44165f15ab690be Mon Sep 17 00:00:00 2001 From: guido <none@none> Date: Sat, 10 Feb 2007 16:41:31 +0100 Subject: [PATCH] [svn r38396] Capturing stdout and stderr when running the update_website tests to not mess up --rest output. --HG-- branch : trunk --- py/bin/_update_website.py | 9 ++++++--- py/misc/testing/test_update_website.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/py/bin/_update_website.py b/py/bin/_update_website.py index bfbafc651..470b8befa 100755 --- a/py/bin/_update_website.py +++ b/py/bin/_update_website.py @@ -22,7 +22,7 @@ def rsync(pkgpath, apidocspath, gateway, remotepath): rs.add_target(gateway, remotepath, delete=True) rs.send() -def run_tests(pkgpath, args=''): +def run_tests(pkgpath, args='', captureouterr=False): """ run the unit tests and build the docs """ pypath = py.__package__.getpath() pytestpath = pypath.join('bin/py.test') @@ -32,13 +32,16 @@ def run_tests(pkgpath, args=''): apigenpath = pkgpath.join('apigen/apigen.py') # XXX be more general here? if not apigenpath.check(file=True): apigenpath = pypath.join('apigen/apigen.py') - cmd = 'PYTHONPATH="%s:%s" python "%s" --apigen="%s" "%s" %s' % ( + cmd = 'PYTHONPATH="%s:%s" python "%s" %s --apigen="%s" "%s"' % ( pypath.dirpath(), pkgpath.dirpath(), pytestpath, + args, apigenpath, pkgpath, - args) + ) + if captureouterr: + cmd += ' > /dev/null 2>&1' status = py.std.os.system(cmd) return status diff --git a/py/misc/testing/test_update_website.py b/py/misc/testing/test_update_website.py index 5f5974057..976aac1d7 100644 --- a/py/misc/testing/test_update_website.py +++ b/py/misc/testing/test_update_website.py @@ -52,7 +52,7 @@ def test_run_tests(): if py.std.sys.platform == "win32": py.test.skip("update_website is not supposed to be run from win32") pkgpath = setup_pkg('update_website_run_tests') - errors = update_website.run_tests(pkgpath) + errors = update_website.run_tests(pkgpath, captureouterr=True) assert not errors assert pkgpath.join('../apigen').check(dir=True) assert pkgpath.join('../apigen/api/sub.foo.html').check(file=True) @@ -63,6 +63,6 @@ def test_run_tests_failure(): pkgpath = setup_pkg('update_website_run_tests_failure') assert not pkgpath.join('../apigen').check(dir=True) pkgpath.ensure('../apigen', file=True) - errors = update_website.run_tests(pkgpath, '> /dev/null 2>&1') + errors = update_website.run_tests(pkgpath, captureouterr=True) assert errors # some error message