6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00

Added/Updated tests\bugs\core_4964_test.py: Expected ISQL output must be compared with filtered capsys.readouterr().out rather than with act.stdout. Noted by Dimitry Sibiryakov, https://github.com/FirebirdSQL/firebird-qa/issues/27

This commit is contained in:
pavel-zotov 2024-07-31 23:14:40 +03:00
parent d44c33b9e5
commit b9ac7029fe

View File

@ -31,6 +31,12 @@ NOTES:
Discussed with pcisar, letters since 30-may-2022 13:48, subject: Discussed with pcisar, letters since 30-may-2022 13:48, subject:
"new qa, core_4964_test.py: strange outcome when use... shutil.copy() // comparing to shutil.copy2()" "new qa, core_4964_test.py: strange outcome when use... shutil.copy() // comparing to shutil.copy2()"
[31.07.2024] pzotov
Replaced assert for ISQL output: added diff_patterns that must filter STDERR because we have to suppress message with text
"file ... is not a valid database" as it can be seen only in dev-builds.
Expected ISQL output must be compared with filtered capsys.readouterr().out rather than with act.stdout
Noted by Dimitry Sibiryakov, https://github.com/FirebirdSQL/firebird-qa/issues/27
Checked on 5.0.0.591, 4.0.1.2692, 3.0.8.33535 - both on Windows and Linux. Checked on 5.0.0.591, 4.0.1.2692, 3.0.8.33535 - both on Windows and Linux.
""" """
@ -42,7 +48,10 @@ from difflib import unified_diff
import pytest import pytest
from firebird.qa import * from firebird.qa import *
substitutions = [('[ \t]+', ' '), ('file .* is not a valid database', 'file is not a valid database'), ] substitutions = [
('[ \t]+', ' ')
,('(-)?file .* is not a valid database', 'file is not a valid database')
]
REQUIRED_ALIAS = 'tmp_core_4964_alias' REQUIRED_ALIAS = 'tmp_core_4964_alias'
@ -107,27 +116,63 @@ def test_1(act: Action, tmp_user: User, capsys):
# POINT-1: check that ISQL raises: # POINT-1: check that ISQL raises:
# "SQLSTATE = 08006 / Error occurred during login, please check server firebird.log ..." # "SQLSTATE = 08006 / Error occurred during login, please check server firebird.log ..."
# #
# release build:
# ==================================
# Statement failed, SQLSTATE = 08006
# Error occurred during login, please check server firebird.log for details
# ==================================
# dev-build:
# ==================================
# Statement failed, SQLSTATE = 08006
# Error occurred during login, please check server firebird.log for details
# -file ... is not a valid database
# ==================================
# Last line ("file ... is not a valid database") will be suppressed by substitutions set:
#
isql_err_diff_patterns = [
"Statement failed, SQLSTATE = 08006"
,"Error occurred during login, please check server firebird.log for details"
]
isql_err_diff_patterns = [re.compile(s) for s in isql_err_diff_patterns]
act.expected_stdout = expected_stdout_isql act.expected_stdout = expected_stdout_isql
try: try:
act.isql(switches = ['-q'], input = check_sql, connect_db=False, credentials = False, combine_output = True) act.isql(switches = ['-q'], input = check_sql, connect_db=False, credentials = False, combine_output = True)
finally: finally:
tmp_fdb.unlink() tmp_fdb.unlink()
# ::: NB :::
# Expected ISQL output must be compared with filtered capsys.readouterr().out rather than with act.stdout
for line in act.stdout.splitlines():
if act.match_any(line, isql_err_diff_patterns):
print(line)
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout assert act.clean_stdout == act.clean_expected_stdout
act.reset() act.reset()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time.sleep(1) # Allow content of firebird log be fully flushed on disk. time.sleep(1) # Allow content of firebird log be fully flushed on disk.
fblog_2 = act.get_firebird_log() fblog_2 = act.get_firebird_log()
diff_patterns = [ fb_log_diff_patterns = [
"\\+\\s+Authentication error", "\\+\\s+Authentication error"
"\\+\\s+file .* is not a valid database", ,"\\+\\s+file .* is not a valid database"
] ]
diff_patterns = [re.compile(s) for s in diff_patterns] fb_log_diff_patterns = [re.compile(s) for s in fb_log_diff_patterns]
# BOTH release and dev build will print in firebird.log:
# <hostname> <timestamp>
# Authentication error
# file .* is not a valid database
#
for line in unified_diff(fblog_1, fblog_2): for line in unified_diff(fblog_1, fblog_2):
if line.startswith('+'): if line.startswith('+'):
if act.match_any(line, diff_patterns): if act.match_any(line, fb_log_diff_patterns):
print(line.split('+')[-1]) print(line.split('+')[-1])
############################################################################################################### ###############################################################################################################
@ -138,3 +183,4 @@ def test_1(act: Action, tmp_user: User, capsys):
act.stdout = capsys.readouterr().out act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout assert act.clean_stdout == act.clean_expected_stdout
act.reset() act.reset()