6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_4451_test.py

52 lines
1.3 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4771
ISSUE: 4771
TITLE: Allow output to trace explain plan form.
DESCRIPTION:
JIRA: CORE-4451
FBTEST: bugs.core_4451
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table test(x int);
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(init=init_script)
2021-11-26 19:20:43 +01:00
2022-01-23 20:41:55 +01:00
act = python_act('db', substitutions=[('[ \t]+', ' '), ('[ \t]+[\\d]+[ \t]+ms', '')])
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Select Expression
-> Aggregate
-> Table "TEST" Full Scan
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
trace = ['time_threshold = 0',
'log_initfini = false',
'print_plan = true',
'explain_plan = true',
'log_statement_prepare = true',
'include_filter=%(from|join)[[:whitespace:]]test%',
]
2021-04-26 20:07:00 +02:00
@pytest.mark.trace
2021-11-26 19:20:43 +01:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action, capsys):
with act.trace(db_events=trace):
act.isql(switches=[], input='select count(*) from test;')
# Process trace
2021-11-26 19:20:43 +01:00
show_line = 0
2022-01-23 20:41:55 +01:00
for line in act.trace_log:
2021-11-26 19:20:43 +01:00
show_line = (show_line + 1 if ('^' * 79) in line or show_line>0 else show_line)
if show_line > 1:
print(line)
# Check
2022-01-23 20:41:55 +01:00
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout