def test_psql_style_params_warning(): warned = {} def warn(message, category=None, stacklevel=1): warned[message] = True with hook(warnings, 'warn', warn): assert_eq(encode_sql('SELECT $1'), 'SELECT $1') assert warned.get('PostgreSQL-style bind-parameters deprecated')
def test_unescaped_percentage_warning(): for string in ['%', '%e']: warned = {} def warn(message, category=None, stacklevel=1): warned[message] = True with hook(warnings, 'warn', warn): assert_eq(encode_sql(string), string) assert warned.get('Unescaped % in SQL')