Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test][fix] capsys fixture recognizes streams #795

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[test][rfct] introduce invoke meth
M3ssman committed Feb 17, 2022
commit 3f7a8a50a5e3cffb4d90015b29c3929e65bc7485
13 changes: 13 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
@@ -98,3 +98,16 @@ def shrink(self):

# use provided logging configuration as default
LOG_CONFIG_PATH = join(Path(dirname(__file__)).parent, 'ocrd_utils', 'ocrd_logging.conf')

def invoke_cli(cli, args, capfd):
"""
capture stdout/sterr on filedescriptor level
"""
code = 0
sys.argv[1:] = args # XXX necessary because sys.argv reflects pytest args not cli args
try:
cli.main(args=args)
except SystemExit as e:
code = e.code
out, err = capfd.readouterr()
return code, out, err