summaryrefslogtreecommitdiffstats
path: root/tests/features/steps
diff options
context:
space:
mode:
Diffstat (limited to 'tests/features/steps')
-rw-r--r--tests/features/steps/basic_commands.py13
-rw-r--r--tests/features/steps/crud_database.py8
-rw-r--r--tests/features/steps/expanded.py2
-rw-r--r--tests/features/steps/iocommands.py6
-rw-r--r--tests/features/steps/specials.py7
-rw-r--r--tests/features/steps/wrappers.py10
6 files changed, 29 insertions, 17 deletions
diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py
index 1069662..07e9ec1 100644
--- a/tests/features/steps/basic_commands.py
+++ b/tests/features/steps/basic_commands.py
@@ -65,19 +65,20 @@ def step_ctrl_d(context):
Send Ctrl + D to hopefully exit.
"""
# turn off pager before exiting
- context.cli.sendline("\pset pager off")
+ context.cli.sendcontrol("c")
+ context.cli.sendline(r"\pset pager off")
wrappers.wait_prompt(context)
context.cli.sendcontrol("d")
context.cli.expect(pexpect.EOF, timeout=15)
context.exit_sent = True
-@when('we send "\?" command')
+@when(r'we send "\?" command')
def step_send_help(context):
- """
+ r"""
Send \? to see help.
"""
- context.cli.sendline("\?")
+ context.cli.sendline(r"\?")
@when("we send partial select command")
@@ -96,9 +97,9 @@ def step_see_error_message(context):
@when("we send source command")
def step_send_source_command(context):
context.tmpfile_sql_help = tempfile.NamedTemporaryFile(prefix="pgcli_")
- context.tmpfile_sql_help.write(b"\?")
+ context.tmpfile_sql_help.write(br"\?")
context.tmpfile_sql_help.flush()
- context.cli.sendline("\i {0}".format(context.tmpfile_sql_help.name))
+ context.cli.sendline(fr"\i {context.tmpfile_sql_help.name}")
wrappers.expect_exact(context, context.conf["pager_boundary"] + "\r\n", timeout=5)
diff --git a/tests/features/steps/crud_database.py b/tests/features/steps/crud_database.py
index 3fd8b7a..3f5d0e7 100644
--- a/tests/features/steps/crud_database.py
+++ b/tests/features/steps/crud_database.py
@@ -14,7 +14,7 @@ def step_db_create(context):
"""
Send create database.
"""
- context.cli.sendline("create database {0};".format(context.conf["dbname_tmp"]))
+ context.cli.sendline("create database {};".format(context.conf["dbname_tmp"]))
context.response = {"database_name": context.conf["dbname_tmp"]}
@@ -24,7 +24,7 @@ def step_db_drop(context):
"""
Send drop database.
"""
- context.cli.sendline("drop database {0};".format(context.conf["dbname_tmp"]))
+ context.cli.sendline("drop database {};".format(context.conf["dbname_tmp"]))
@when("we connect to test database")
@@ -33,7 +33,7 @@ def step_db_connect_test(context):
Send connect to database.
"""
db_name = context.conf["dbname"]
- context.cli.sendline("\\connect {0}".format(db_name))
+ context.cli.sendline(f"\\connect {db_name}")
@when("we connect to dbserver")
@@ -59,7 +59,7 @@ def step_see_prompt(context):
Wait to see the prompt.
"""
db_name = getattr(context, "currentdb", context.conf["dbname"])
- wrappers.expect_exact(context, "{0}> ".format(db_name), timeout=5)
+ wrappers.expect_exact(context, f"{db_name}> ", timeout=5)
context.atprompt = True
diff --git a/tests/features/steps/expanded.py b/tests/features/steps/expanded.py
index f34fcf0..265ea39 100644
--- a/tests/features/steps/expanded.py
+++ b/tests/features/steps/expanded.py
@@ -31,7 +31,7 @@ def step_prepare_data(context):
@when("we set expanded {mode}")
def step_set_expanded(context, mode):
"""Set expanded to mode."""
- context.cli.sendline("\\" + "x {}".format(mode))
+ context.cli.sendline("\\" + f"x {mode}")
wrappers.expect_exact(context, "Expanded display is", timeout=2)
wrappers.wait_prompt(context)
diff --git a/tests/features/steps/iocommands.py b/tests/features/steps/iocommands.py
index 613aeb2..a614490 100644
--- a/tests/features/steps/iocommands.py
+++ b/tests/features/steps/iocommands.py
@@ -13,7 +13,7 @@ def step_edit_file(context):
)
if os.path.exists(context.editor_file_name):
os.remove(context.editor_file_name)
- context.cli.sendline("\e {0}".format(os.path.basename(context.editor_file_name)))
+ context.cli.sendline(r"\e {}".format(os.path.basename(context.editor_file_name)))
wrappers.expect_exact(
context, 'Entering Ex mode. Type "visual" to go to Normal mode.', timeout=2
)
@@ -53,7 +53,7 @@ def step_tee_ouptut(context):
)
if os.path.exists(context.tee_file_name):
os.remove(context.tee_file_name)
- context.cli.sendline("\o {0}".format(os.path.basename(context.tee_file_name)))
+ context.cli.sendline(r"\o {}".format(os.path.basename(context.tee_file_name)))
wrappers.expect_exact(context, context.conf["pager_boundary"] + "\r\n", timeout=5)
wrappers.expect_exact(context, "Writing to file", timeout=5)
wrappers.expect_exact(context, context.conf["pager_boundary"] + "\r\n", timeout=5)
@@ -67,7 +67,7 @@ def step_query_select_123456(context):
@when("we stop teeing output")
def step_notee_output(context):
- context.cli.sendline("\o")
+ context.cli.sendline(r"\o")
wrappers.expect_exact(context, "Time", timeout=5)
diff --git a/tests/features/steps/specials.py b/tests/features/steps/specials.py
index 813292c..a85f371 100644
--- a/tests/features/steps/specials.py
+++ b/tests/features/steps/specials.py
@@ -22,5 +22,10 @@ def step_see_refresh_started(context):
Wait to see refresh output.
"""
wrappers.expect_pager(
- context, "Auto-completion refresh started in the background.\r\n", timeout=2
+ context,
+ [
+ "Auto-completion refresh started in the background.\r\n",
+ "Auto-completion refresh restarted.\r\n",
+ ],
+ timeout=2,
)
diff --git a/tests/features/steps/wrappers.py b/tests/features/steps/wrappers.py
index e0f5a20..0ca8366 100644
--- a/tests/features/steps/wrappers.py
+++ b/tests/features/steps/wrappers.py
@@ -39,9 +39,15 @@ def expect_exact(context, expected, timeout):
def expect_pager(context, expected, timeout):
+ formatted = expected if isinstance(expected, list) else [expected]
+ formatted = [
+ f"{context.conf['pager_boundary']}\r\n{t}{context.conf['pager_boundary']}\r\n"
+ for t in formatted
+ ]
+
expect_exact(
context,
- "{0}\r\n{1}{0}\r\n".format(context.conf["pager_boundary"], expected),
+ formatted,
timeout=timeout,
)
@@ -57,7 +63,7 @@ def run_cli(context, run_args=None, prompt_check=True, currentdb=None):
context.cli.logfile = context.logfile
context.exit_sent = False
context.currentdb = currentdb or context.conf["dbname"]
- context.cli.sendline("\pset pager always")
+ context.cli.sendline(r"\pset pager always")
if prompt_check:
wait_prompt(context)