1
0
Fork 0

Clean up and add behave logging (#956)

This commit is contained in:
Dick Marinus 2018-10-14 22:53:19 +02:00 committed by Irina Truong
parent fcf0eb022e
commit 12ad10f697
2 changed files with 40 additions and 5 deletions

View File

@ -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:
======

View File

@ -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):