diff --git a/changelog.rst b/changelog.rst index 54a4acd6..63c31c23 100644 --- a/changelog.rst +++ b/changelog.rst @@ -1,8 +1,16 @@ Upcoming: ========= +Bug fixes: +---------- * Fix for error listing databases (#951). (Thanks: `Irina Truong`_) +Internal: +--------- + +* Clean up and add behave logging. (Thanks: `Dick Marinus`_) + + 2.0.0: ====== diff --git a/tests/features/steps/wrappers.py b/tests/features/steps/wrappers.py index 9a7f89da..b553a3f1 100644 --- a/tests/features/steps/wrappers.py +++ b/tests/features/steps/wrappers.py @@ -4,17 +4,44 @@ from __future__ import unicode_literals import re import pexpect from pgcli.main import COLOR_CODE_REGEX +import textwrap + +try: + from StringIO import StringIO +except ImportError: + from io import StringIO def expect_exact(context, expected, timeout): + timedout = False try: context.cli.expect_exact(expected, timeout=timeout) - except: + except pexpect.exceptions.TIMEOUT: + timedout = True + if timedout: # Strip color codes out of the output. - actual = COLOR_CODE_REGEX.sub('', context.cli.before) - raise Exception('Expected:\n---\n{0!r}\n---\n\nActual:\n---\n{1!r}\n---'.format( - expected, - actual)) + actual = re.sub(r'\x1b\[([0-9A-Za-z;?])+[m|K]?', + '', context.cli.before) + raise Exception( + textwrap.dedent('''\ + Expected: + --- + {0!r} + --- + Actual: + --- + {1!r} + --- + Full log: + --- + {2!r} + --- + ''').format( + expected, + actual, + context.logfile.getvalue() + ) + ) def expect_pager(context, expected, timeout):