mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\gh_7548_test.py: refactored, see notes
This commit is contained in:
parent
ba5eecf5e0
commit
70d2e05954
@ -9,20 +9,30 @@ DESCRIPTION:
|
||||
No errors must occur for all of them.
|
||||
NOTES:
|
||||
[19.04.2023] pzotov
|
||||
Confirmed bug on 4.0.3.2930, 5.0.0.1017
|
||||
Confirmed bug on 4.0.3.2929, 5.0.0.1014
|
||||
Checked on 4.0.3.2931, 5.0.0.1021 - all OK.
|
||||
|
||||
[31.08.2023] pzotov
|
||||
Refactored:
|
||||
* output of checked timestamp can be suppressed, see redirection: 'out {os.devnull}';
|
||||
* there is no need to display the same error messages for many charsets; rather, we can use dictionary
|
||||
with key = error message and val = list of character sets which did not pass check (i.e. for which
|
||||
we get "SQLSTATE = 22001 / ... / -string right truncation / -expected length N, actual M";
|
||||
* removed unneeded substitutions, use 'init' arg for db_factory in order to make test run faster;
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from firebird.qa import *
|
||||
from firebird.driver import CHARSET_MAP
|
||||
from collections import defaultdict
|
||||
|
||||
db = db_factory()
|
||||
db = db_factory(init = 'recreate table test(f01 timestamp with time zone);')
|
||||
|
||||
ts = '19-APR-2023 21:15:19.0110'
|
||||
test_sql = f"""
|
||||
set list on;
|
||||
recreate table test(f01 timestamp with time zone);
|
||||
delete from test;
|
||||
insert into test values(timestamp '{ts}');
|
||||
set term ^;
|
||||
execute block as
|
||||
@ -31,17 +41,13 @@ test_sql = f"""
|
||||
end
|
||||
^
|
||||
set term ;^
|
||||
out {os.devnull};
|
||||
select * from test;
|
||||
commit;
|
||||
out;
|
||||
rollback;
|
||||
"""
|
||||
|
||||
substitutions = [ ('[\t ]+', ' '), (f'F01 {ts} .*', f'F01 {ts}') ]
|
||||
|
||||
act = python_act('db', substitutions = substitutions)
|
||||
|
||||
expected_stdout = f"""
|
||||
F01 {ts} Europe/Moscow
|
||||
"""
|
||||
act = python_act('db')
|
||||
|
||||
@pytest.mark.version('>=4.0.3')
|
||||
def test_1(act: Action, capsys):
|
||||
@ -51,26 +57,24 @@ def test_1(act: Action, capsys):
|
||||
cur.execute("select trim(c.rdb$character_set_name) from rdb$character_sets c where coalesce(c.rdb$system_flag,0)<>0 and c.rdb$character_set_name not in ('NONE', 'OCTETS')")
|
||||
cset_list = [x[0] for x in cur.fetchall() if x[0] in CHARSET_MAP]
|
||||
|
||||
#print(cset_list)
|
||||
#assert '' == capsys.readouterr().out
|
||||
# Result: cset_list = ['ASCII', 'UNICODE_FSS', 'UTF8', 'SJIS_0208', ..., 'KOI8U', 'WIN1258', 'GBK', 'GB18030']
|
||||
|
||||
cset_fails = {}
|
||||
for x in cset_list:
|
||||
cset_fails = defaultdict(list)
|
||||
for cset_i in cset_list:
|
||||
act.reset()
|
||||
act.expected_stdout = expected_stdout
|
||||
act.isql(switches=['-q'], charset = x, input = test_sql, combine_output = True)
|
||||
act.expected_stdout = ''
|
||||
act.isql(switches=['-q'], charset = cset_i, input = test_sql, combine_output = True)
|
||||
if act.clean_stdout == act.clean_expected_stdout:
|
||||
pass
|
||||
else:
|
||||
cset_fails[x] = act.clean_stdout
|
||||
cset_fails[act.clean_stdout] += cset_i,
|
||||
|
||||
if cset_fails:
|
||||
print('Detected fail for some charset(s):')
|
||||
print('Detected fails:')
|
||||
for k,v in sorted(cset_fails.items()):
|
||||
print( f'charset: {k}' )
|
||||
print('Character sets:', ','.join(v))
|
||||
print('Result:')
|
||||
for p in v.split('\n'):
|
||||
print(p)
|
||||
print(k)
|
||||
print('')
|
||||
|
||||
|
||||
assert '' == capsys.readouterr().out
|
||||
|
Loading…
Reference in New Issue
Block a user