[svn r38396] Capturing stdout and stderr when running the update_website tests to not mess
up --rest output. --HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									d3cd1c5bcf
								
							
						
					
					
						commit
						275673ba21
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue