diff options
author | Dick Marinus <dick@mrns.nl> | 2018-10-14 22:53:19 +0200 |
---|---|---|
committer | Irina Truong <i.chernyavska@gmail.com> | 2018-10-14 13:53:19 -0700 |
commit | 12ad10f6975d9651d0c696a021fc982c2c5de861 (patch) | |
tree | dae143789a82899f08a9b63cd43f6e07f774b643 | |
parent | fcf0eb022ee81cc8e961c08c4a89742a9714cd63 (diff) |
Clean up and add behave logging (#956)
-rw-r--r-- | changelog.rst | 8 | ||||
-rw-r--r-- | tests/features/steps/wrappers.py | 37 |
2 files changed, 40 insertions, 5 deletions
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): |