Standardize output streams for outputs of commands

This commit is contained in:
Brett Sun 2017-02-24 11:16:17 +01:00 committed by Sylvain Bellemare
parent 0ad0d89fcd
commit fce6b6af52
2 changed files with 9 additions and 1 deletions

View File

@ -36,6 +36,12 @@ logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Note about printing:
# We try to print to stdout for results of a command that may be useful to
# someone (or another program). Strictly informational text, or errors,
# should be printed to stderr.
def run_show_config(args):
"""Show the current configuration"""
# TODO Proposal: remove the "hidden" configuration. Only show config. If
@ -84,7 +90,7 @@ def run_configure(args, skip_if_exists=False):
# select the correct config defaults based on the backend
print('Generating default configuration for backend {}'
.format(args.backend))
.format(args.backend), file=sys.stderr)
conf['database'] = bigchaindb._database_map[args.backend]
if not args.yes:

View File

@ -133,8 +133,10 @@ def test_bigchain_export_my_pubkey_when_pubkey_set(capsys, monkeypatch):
run_export_my_pubkey(args)
out, err = capsys.readouterr()
lines = out.splitlines()
err_lines = err.splitlines()
assert config['keypair']['public'] in lines
assert 'Charlie_Bucket' in lines
assert 'bigchaindb args = {}'.format(args) in err_lines
def test_bigchain_export_my_pubkey_when_pubkey_not_set(monkeypatch):