summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDick Marinus <dick@mrns.nl>2017-05-01 20:21:32 +0200
committerDick Marinus <dick@mrns.nl>2017-05-13 09:25:24 +0200
commit9ced5a2a3066e44a75000f67035cbeddb09d5df2 (patch)
treefd196e48135a945c6bab1c157c4189940ef34e25
parent588f18caaed83eb5bbc170ec3570b0efe36d4ace (diff)
-rw-r--r--test/features/steps/basic_commands.py2
-rw-r--r--test/features/steps/crud_database.py10
-rw-r--r--test/features/steps/crud_table.py4
-rw-r--r--test/features/steps/iocommands.py10
-rw-r--r--test/features/steps/specials.py2
-rw-r--r--test/features/steps/wrappers.py10
6 files changed, 20 insertions, 18 deletions
diff --git a/test/features/steps/basic_commands.py b/test/features/steps/basic_commands.py
index 299893d..91623da 100644
--- a/test/features/steps/basic_commands.py
+++ b/test/features/steps/basic_commands.py
@@ -38,7 +38,7 @@ def step_send_help(context):
"""
context.cli.sendline('\\?')
wrappers.expect_exact(
- context, context.conf['pager_boundary'] + '\r\n', timeout=5)
+ context, context.conf['pager_boundary'] + '\r\n', timeout=5, ignore_before=True)
@when(u'we send source command')
diff --git a/test/features/steps/crud_database.py b/test/features/steps/crud_database.py
index af8580e..649d249 100644
--- a/test/features/steps/crud_database.py
+++ b/test/features/steps/crud_database.py
@@ -31,7 +31,7 @@ def step_db_drop(context):
context.conf['dbname_tmp']))
wrappers.expect_exact(
- context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
+ context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2, ignore_before=True)
context.cli.sendline('y')
@@ -53,7 +53,7 @@ def step_db_connect_dbserver(context):
@then('dbcli exits')
def step_wait_exit(context):
"""Make sure the cli exits."""
- wrappers.expect_exact(context, pexpect.EOF, timeout=5)
+ wrappers.expect_exact(context, pexpect.EOF, timeout=5, ignore_before=True)
@then('we see dbcli prompt')
@@ -63,7 +63,7 @@ def step_see_prompt(context):
host = context.conf['host']
dbname = context.currentdb
wrappers.expect_exact(context, 'mysql {0}@{1}:{2}> '.format(
- user, host, dbname), timeout=5)
+ user, host, dbname), timeout=5, ignore_before=True)
context.atprompt = True
@@ -89,10 +89,10 @@ def step_see_db_dropped(context):
def step_see_db_connected(context):
"""Wait to see drop database output."""
wrappers.expect_exact(
- context, context.conf['pager_boundary'] + '\r\n', timeout=5)
+ context, context.conf['pager_boundary'] + '\r\n', timeout=5, ignore_before=True)
wrappers.expect_exact(
context, 'You are now connected to database "', timeout=2)
- wrappers.expect_exact(context, '"', timeout=2)
+ wrappers.expect_exact(context, '"', timeout=2, ignore_before=True)
wrappers.expect_exact(context, ' as user "{0}"\r\n'.format(
context.conf['user']), timeout=2)
wrappers.expect_exact(
diff --git a/test/features/steps/crud_table.py b/test/features/steps/crud_table.py
index f6e9f04..26cac72 100644
--- a/test/features/steps/crud_table.py
+++ b/test/features/steps/crud_table.py
@@ -41,7 +41,7 @@ def step_delete_from_table(context):
"""Send deete from table."""
context.cli.sendline('''delete from a where x = 'yyy';''')
wrappers.expect_exact(
- context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
+ context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2, ignore_before=True)
context.cli.sendline('y')
@@ -50,7 +50,7 @@ def step_drop_table(context):
"""Send drop table."""
context.cli.sendline('drop table a;')
wrappers.expect_exact(
- context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
+ context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2, ignore_before=True)
context.cli.sendline('y')
diff --git a/test/features/steps/iocommands.py b/test/features/steps/iocommands.py
index 6fe36f4..40e8b9f 100644
--- a/test/features/steps/iocommands.py
+++ b/test/features/steps/iocommands.py
@@ -17,8 +17,8 @@ def step_edit_file(context):
context.cli.sendline('\e {0}'.format(
os.path.basename(context.editor_file_name)))
wrappers.expect_exact(
- context, 'Entering Ex mode. Type "visual" to go to Normal mode.', timeout=2)
- wrappers.expect_exact(context, '\r\n:', timeout=2)
+ context, 'Entering Ex mode. Type "visual" to go to Normal mode.', timeout=2, ignore_before=True)
+ wrappers.expect_exact(context, '\r\n:', timeout=2, ignore_before=True)
@when('we type sql in the editor')
@@ -26,19 +26,19 @@ def step_edit_type_sql(context):
context.cli.sendline('i')
context.cli.sendline('select * from abc')
context.cli.sendline('.')
- wrappers.expect_exact(context, '\r\n:', timeout=2)
+ wrappers.expect_exact(context, '\r\n:', timeout=2, ignore_before=True)
@when('we exit the editor')
def step_edit_quit(context):
context.cli.sendline('x')
- wrappers.expect_exact(context, "written", timeout=2)
+ wrappers.expect_exact(context, "C written", timeout=2, ignore_before=True)
@then('we see the sql in prompt')
def step_edit_done_sql(context):
for match in 'select * from abc'.split(' '):
- wrappers.expect_exact(context, match, timeout=1)
+ wrappers.expect_exact(context, match, timeout=1, ignore_before=True)
# Cleanup the command line.
context.cli.sendcontrol('c')
# Cleanup the edited file.
diff --git a/test/features/steps/specials.py b/test/features/steps/specials.py
index f7715b9..9c7dc7d 100644
--- a/test/features/steps/specials.py
+++ b/test/features/steps/specials.py
@@ -21,7 +21,7 @@ def step_refresh_completions(context):
def step_see_refresh_started(context):
"""Wait to see refresh output."""
wrappers.expect_exact(
- context, context.conf['pager_boundary'] + '\r\n', timeout=5)
+ context, context.conf['pager_boundary'] + '\r\n', timeout=5, ignore_before=True)
wrappers.expect_exact(
context, 'Auto-completion refresh started in the background.\r\n', timeout=2)
wrappers.expect_exact(
diff --git a/test/features/steps/wrappers.py b/test/features/steps/wrappers.py
index 5070f05..4de8ae7 100644
--- a/test/features/steps/wrappers.py
+++ b/test/features/steps/wrappers.py
@@ -5,9 +5,11 @@ import re
import pexpect
-def expect_exact(context, expected, timeout):
+def expect_exact(context, expected, timeout, ignore_before=False):
try:
context.cli.expect_exact(expected, timeout=timeout)
+ if not ignore_before:
+ assert context.cli.before == ""
except:
# Strip color codes out of the output.
actual = re.sub(r'\x1b\[([0-9A-Za-z;?])+[m|K]?',
@@ -47,7 +49,7 @@ def wait_prompt(context):
"""Make sure prompt is displayed."""
user = context.conf['user']
host = context.conf['host']
- dbname = context.currentdb
- expect_exact(context, 'mysql {0}@{1}:{2}> '.format(
- user, host, dbname), timeout=5)
+ dbname = context.conf['dbname']
+ wrappers.expect_exact(context, 'mysql {0}@{1}:{2}> '.format(
+ user, host, dbname), timeout=5, ignore_before=True)
context.atprompt = True