summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2017-08-18 15:27:43 -0700
committerGitHub <noreply@github.com>2017-08-18 15:27:43 -0700
commitb136196f29599c223db5323a8020ce3aad40d41c (patch)
tree27f851a87ca04a475053a608a48ed2df08e81f29 /tests
parent386838b31fa4928dbbca8df1330f23df977f9b23 (diff)
parentd2ecbde84966f4c3232dfb84b66c716eea307764 (diff)
Merge pull request #780 from dbcli/feature/output_formatter_generator
Preliminary work for a future change in outputting results that uses less memory
Diffstat (limited to 'tests')
-rw-r--r--tests/features/steps/expanded.py1
-rw-r--r--tests/test_main.py58
-rw-r--r--tests/test_pgexecute.py20
3 files changed, 39 insertions, 40 deletions
diff --git a/tests/features/steps/expanded.py b/tests/features/steps/expanded.py
index 31622edf..5360ea22 100644
--- a/tests/features/steps/expanded.py
+++ b/tests/features/steps/expanded.py
@@ -43,7 +43,6 @@ def step_see_data(context, which):
x | 1\r
y | 1.0\r
z | 1.0000\r
- \r
SELECT 1\r
'''),
timeout=1)
diff --git a/tests/test_main.py b/tests/test_main.py
index c35853ee..df99eb45 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -57,14 +57,14 @@ def test_format_output():
'test status', settings)
expected = [
'Title',
- '+---------+---------+\n'
- '| head1 | head2 |\n'
- '|---------+---------|\n'
- '| abc | def |\n'
+ '+---------+---------+',
+ '| head1 | head2 |',
+ '|---------+---------|',
+ '| abc | def |',
'+---------+---------+',
'test status'
]
- assert results == expected
+ assert list(results) == expected
def test_format_array_output(executor):
@@ -78,15 +78,15 @@ def test_format_array_output(executor):
"""
results = run(executor, statement)
expected = [
- '+----------------+------------------------+--------------+\n'
- '| bigint_array | nested_numeric_array | 配列 |\n'
- '|----------------+------------------------+--------------|\n'
- '| {1,2,3} | {{1,2},{3,4}} | {å,魚,текст} |\n'
- '| {} | <null> | {<null>} |\n'
+ '+----------------+------------------------+--------------+',
+ '| bigint_array | nested_numeric_array | 配列 |',
+ '|----------------+------------------------+--------------|',
+ '| {1,2,3} | {{1,2},{3,4}} | {å,魚,текст} |',
+ '| {} | <null> | {<null>} |',
'+----------------+------------------------+--------------+',
'SELECT 2'
]
- assert results == expected
+ assert list(results) == expected
def test_format_array_output_expanded(executor):
@@ -100,17 +100,17 @@ def test_format_array_output_expanded(executor):
"""
results = run(executor, statement, expanded=True)
expected = [
- '-[ RECORD 1 ]-------------------------\n'
- 'bigint_array | {1,2,3}\n'
- 'nested_numeric_array | {{1,2},{3,4}}\n'
- '配列 | {å,魚,текст}\n'
- '-[ RECORD 2 ]-------------------------\n'
- 'bigint_array | {}\n'
- 'nested_numeric_array | <null>\n'
- '配列 | {<null>}\n',
+ '-[ RECORD 1 ]-------------------------',
+ 'bigint_array | {1,2,3}',
+ 'nested_numeric_array | {{1,2},{3,4}}',
+ '配列 | {å,魚,текст}',
+ '-[ RECORD 2 ]-------------------------',
+ 'bigint_array | {}',
+ 'nested_numeric_array | <null>',
+ '配列 | {<null>}',
'SELECT 2'
]
- assert results == expected
+ assert list(results) == expected
def test_format_output_auto_expand():
@@ -120,14 +120,14 @@ def test_format_output_auto_expand():
['head1', 'head2'], 'test status', settings)
table = [
'Title',
- '+---------+---------+\n'
- '| head1 | head2 |\n'
- '|---------+---------|\n'
- '| abc | def |\n'
+ '+---------+---------+',
+ '| head1 | head2 |',
+ '|---------+---------|',
+ '| abc | def |',
'+---------+---------+',
'test status'
]
- assert table_results == table
+ assert list(table_results) == table
expanded_results = format_output(
'Title',
[('abc', 'def')],
@@ -137,12 +137,12 @@ def test_format_output_auto_expand():
)
expanded = [
'Title',
- '-[ RECORD 1 ]-------------------------\n'
- 'head1 | abc\n'
- 'head2 | def\n',
+ '-[ RECORD 1 ]-------------------------',
+ 'head1 | abc',
+ 'head2 | def',
'test status'
]
- assert expanded_results == expanded
+ assert list(expanded_results) == expanded
@dbtest
diff --git a/tests/test_pgexecute.py b/tests/test_pgexecute.py
index 63f65290..3141dc0e 100644
--- a/tests/test_pgexecute.py
+++ b/tests/test_pgexecute.py
@@ -181,25 +181,25 @@ def test_unicode_support_in_output(executor, expanded):
@dbtest
def test_multiple_queries_same_line(executor):
result = run(executor, "select 'foo'; select 'bar'")
- assert len(result) == 4 # 2 * (output+status)
- assert "foo" in result[0]
- assert "bar" in result[2]
+ assert len(result) == 12 # 2 * (output+status) * 3 lines
+ assert "foo" in result[3]
+ assert "bar" in result[9]
@dbtest
def test_multiple_queries_with_special_command_same_line(executor, pgspecial):
result = run(executor, "select 'foo'; \d", pgspecial=pgspecial)
- assert len(result) == 4 # 2 * (output+status)
- assert "foo" in result[0]
+ assert len(result) == 11 # 2 * (output+status) * 3 lines
+ assert "foo" in result[3]
# This is a lame check. :(
- assert "Schema" in result[2]
+ assert "Schema" in result[7]
@dbtest
def test_multiple_queries_same_line_syntaxerror(executor, exception_formatter):
result = run(executor, u"select 'fooé'; invalid syntax é",
exception_formatter=exception_formatter)
- assert u'fooé' in result[0]
+ assert u'fooé' in result[3]
assert 'syntax error at or near "invalid"' in result[-1]
@@ -210,9 +210,9 @@ def pgspecial():
@dbtest
def test_special_command_help(executor, pgspecial):
- result = run(executor, '\\?', pgspecial=pgspecial)[0].split('|')
- assert(result[1].find(u'Command') != -1)
- assert(result[2].find(u'Description') != -1)
+ result = run(executor, '\\?', pgspecial=pgspecial)[1].split('|')
+ assert u'Command' in result[1]
+ assert u'Description' in result[2]
@dbtest