Always print any std streams to console in docs examples tests
parent
64819b2acb
commit
e12def51a8
|
@ -93,14 +93,16 @@ def run_example_in_subproc(loglevel, testdir, arb_addr):
|
||||||
ids=lambda t: t[1],
|
ids=lambda t: t[1],
|
||||||
)
|
)
|
||||||
def test_example(run_example_in_subproc, example_script):
|
def test_example(run_example_in_subproc, example_script):
|
||||||
"""Load and run scripts from this repo's ``examples/`` dir as a user
|
'''
|
||||||
|
Load and run scripts from this repo's ``examples/`` dir as a user
|
||||||
would copy and pasing them into their editor.
|
would copy and pasing them into their editor.
|
||||||
|
|
||||||
On windows a little more "finessing" is done to make
|
On windows a little more "finessing" is done to make
|
||||||
``multiprocessing`` play nice: we copy the ``__main__.py`` into the
|
``multiprocessing`` play nice: we copy the ``__main__.py`` into the
|
||||||
test directory and invoke the script as a module with ``python -m
|
test directory and invoke the script as a module with ``python -m
|
||||||
test_example``.
|
test_example``.
|
||||||
"""
|
|
||||||
|
'''
|
||||||
ex_file = os.path.join(*example_script)
|
ex_file = os.path.join(*example_script)
|
||||||
|
|
||||||
if 'rpc_bidir_streaming' in ex_file and sys.version_info < (3, 9):
|
if 'rpc_bidir_streaming' in ex_file and sys.version_info < (3, 9):
|
||||||
|
@ -110,13 +112,20 @@ def test_example(run_example_in_subproc, example_script):
|
||||||
code = ex.read()
|
code = ex.read()
|
||||||
|
|
||||||
with run_example_in_subproc(code) as proc:
|
with run_example_in_subproc(code) as proc:
|
||||||
proc.wait()
|
try:
|
||||||
err, _ = proc.stderr.read(), proc.stdout.read()
|
proc.wait(timeout=5)
|
||||||
# print(f'STDERR: {err}')
|
finally:
|
||||||
# print(f'STDOUT: {out}')
|
err = proc.stderr.read()
|
||||||
|
errmsg = err.decode()
|
||||||
|
out = proc.stdout.read()
|
||||||
|
outmsg = out.decode()
|
||||||
|
|
||||||
|
if out:
|
||||||
|
print(f'STDOUT: {out.decode()}')
|
||||||
|
|
||||||
# if we get some gnarly output let's aggregate and raise
|
# if we get some gnarly output let's aggregate and raise
|
||||||
if err:
|
if err:
|
||||||
|
print(f'STDERR:\n{errmsg}')
|
||||||
errmsg = err.decode()
|
errmsg = err.decode()
|
||||||
errlines = errmsg.splitlines()
|
errlines = errmsg.splitlines()
|
||||||
last_error = errlines[-1]
|
last_error = errlines[-1]
|
||||||
|
|
Loading…
Reference in New Issue