summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2017-03-25 16:28:10 -0700
committerIrina Truong <i.chernyavska@gmail.com>2017-03-31 16:00:54 -0700
commit38558e165e9318db5b9a98fd3e1f10dba51952e2 (patch)
treee16c287011f90482e48f6abe0a2ac12c69900d03 /tests
parent19511b0fe9175be33d32aa7414ad02df4f15855a (diff)
After editor command, expect colored sql.
Diffstat (limited to 'tests')
-rw-r--r--tests/features/iocommands.feature3
-rw-r--r--tests/features/steps/iocommands.py4
-rw-r--r--tests/features/steps/wrappers.py11
3 files changed, 16 insertions, 2 deletions
diff --git a/tests/features/iocommands.feature b/tests/features/iocommands.feature
index 2da76e15..d043dc2e 100644
--- a/tests/features/iocommands.feature
+++ b/tests/features/iocommands.feature
@@ -6,4 +6,5 @@ Feature: I/O commands
and we start external editor providing a file name
and we type sql in the editor
and we exit the editor
- then we see the sql in prompt
+ then we see dbcli prompt
+ and we see the sql in prompt
diff --git a/tests/features/steps/iocommands.py b/tests/features/steps/iocommands.py
index 14d130b5..ed277dae 100644
--- a/tests/features/steps/iocommands.py
+++ b/tests/features/steps/iocommands.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8
from __future__ import unicode_literals
import os
+import re
import wrappers
from behave import when, then
@@ -34,7 +35,8 @@ def step_edit_quit(context):
@then('we see the sql in prompt')
def step_edit_done_sql(context):
- wrappers.expect_exact(context, 'select * from abc', timeout=2)
+ colored_expr = re.compile('select(.+?)\*(.+?)from(.+?)abc')
+ wrappers.expect(context, colored_expr, timeout=2)
# Cleanup the command line.
context.cli.sendcontrol('u')
# Cleanup the edited file.
diff --git a/tests/features/steps/wrappers.py b/tests/features/steps/wrappers.py
index eac7c830..e8dcbb3a 100644
--- a/tests/features/steps/wrappers.py
+++ b/tests/features/steps/wrappers.py
@@ -13,3 +13,14 @@ def expect_exact(context, expected, timeout):
raise Exception('Expected:\n---\n{0!r}\n---\n\nActual:\n---\n{1!r}\n---'.format(
expected,
actual))
+
+
+def expect(context, expected, timeout):
+ try:
+ context.cli.expect(expected, timeout=timeout)
+ except:
+ # Strip color codes out of the output.
+ actual = re.sub(r'\x1b\[([0-9A-Za-z;?])+[m|K]?', '', context.cli.before)
+ raise Exception('Expected:\n---\n{0!r}\n---\n\nActual:\n---\n{1!r}\n---'.format(
+ expected,
+ actual))