本文整理汇总了Python中sqlalchemy.testing.exclusions.against函数的典型用法代码示例。如果您正苦于以下问题:Python against函数的具体用法?Python against怎么用?Python against使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了against函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: array_type
def array_type(self):
return only_on(
[
lambda config: against(config, "postgresql")
and not against(config, "+pg8000")
and not against(config, "+zxjdbc")
]
)
示例2: mssql_freetds
def mssql_freetds(self):
return only_on(
LambdaPredicate(
lambda config: (
(against(config, 'mssql+pyodbc') and
config.db.dialect.freetds)
or against(config, 'mssql+pymssql')
)
)
)
示例3: check
def check(config):
if against(config, "mysql+mysqldb"):
# can remove once post 1.3.13 is released
try:
from MySQLdb import converters
from decimal import Decimal
return Decimal not in converters.conversions
except:
return True
return against(
config, "mysql+mysqldb"
) and config.db.dialect._mysql_dbapi_version <= (1, 3, 13)
示例4: json_type
def json_type(self):
return only_on([
lambda config:
against(config, "mysql") and (
(
not config.db.dialect._is_mariadb and
against(config, "mysql >= 5.7")
)
or (
config.db.dialect._mariadb_normalized_version_info >=
(10, 2, 7)
)
),
"postgresql >= 9.3"
])
示例5: reflects_json_type
def reflects_json_type(self):
return only_on([
lambda config: against(config, "mysql >= 5.7") and
not config.db.dialect._is_mariadb,
"postgresql >= 9.3",
"sqlite >= 3.9"
])
示例6: broken_cx_oracle6_numerics
def broken_cx_oracle6_numerics(config):
return exclusions.LambdaPredicate(
lambda config: against(config, 'oracle+cx_oracle') and
config.db.dialect.cx_oracle_ver <= (6, 0, 2) and
config.db.dialect.cx_oracle_ver > (6, ),
"cx_Oracle github issue #77"
)
示例7: check
def check(config):
if not against(config, "postgresql"):
return False
count = config.db.scalar(
"SELECT count(*) FROM pg_extension "
"WHERE extname='%s'" % name)
return bool(count)
示例8: check_hstore
def check_hstore(config):
if not against(config, "postgresql"):
return False
try:
config.db.execute("SELECT 'a=>1,a=>2'::hstore;")
return True
except:
return False
示例9: check_hstore
def check_hstore():
if not against("postgresql"):
return False
try:
self.db.execute("SELECT 'a=>1,a=>2'::hstore;")
return True
except:
return False
示例10: json_type
def json_type(self):
return only_on([
lambda config: against(config, "mysql >= 5.7") and
not config.db.dialect._is_mariadb and
# workaround for:
# https://github.com/PyMySQL/PyMySQL/issues/488
not (config.db.dialect.driver == 'pymysql'),
"postgresql >= 9.3"
])
示例11: check_range_types
def check_range_types(config):
if not against(
config,
["postgresql+psycopg2", "postgresql+psycopg2cffi"]):
return False
try:
config.db.scalar("select '[1,2)'::int4range;")
return True
except:
return False
示例12: check_range_types
def check_range_types():
if not against("postgresql+psycopg2"):
return False
try:
self.db.execute("select '[1,2)'::int4range;")
# only supported in psycopg 2.5+
from psycopg2.extras import NumericRange
return True
except:
return False
示例13: has_fastexecutemany
def has_fastexecutemany(config):
if not against(config, "mssql+pyodbc"):
return False
if config.db.dialect._dbapi_version() < (4, 0, 19):
return False
with config.db.connect() as conn:
drivername = conn.connection.connection.getinfo(
config.db.dialect.dbapi.SQL_DRIVER_NAME)
# on linux this is 'libmsodbcsql-13.1.so.9.2'.
# don't know what it is on windows
return "msodbc" in drivername
示例14: _prep_testing_database
def _prep_testing_database(options, file_config):
from sqlalchemy.testing import config, util
from sqlalchemy.testing.exclusions import against
from sqlalchemy import schema, inspect
if options.dropfirst:
for cfg in config.Config.all_configs():
e = cfg.db
inspector = inspect(e)
try:
view_names = inspector.get_view_names()
except NotImplementedError:
pass
else:
for vname in view_names:
e.execute(
schema._DropView(
schema.Table(vname, schema.MetaData())
)
)
if config.requirements.schemas.enabled_for_config(cfg):
try:
view_names = inspector.get_view_names(schema="test_schema")
except NotImplementedError:
pass
else:
for vname in view_names:
e.execute(
schema._DropView(
schema.Table(
vname,
schema.MetaData(),
schema="test_schema",
)
)
)
util.drop_all_tables(e, inspector)
if config.requirements.schemas.enabled_for_config(cfg):
util.drop_all_tables(e, inspector, schema=cfg.test_schema)
if against(cfg, "postgresql"):
from sqlalchemy.dialects import postgresql
for enum in inspector.get_enums("*"):
e.execute(
postgresql.DropEnumType(
postgresql.ENUM(
name=enum["name"], schema=enum["schema"]
)
)
)
示例15: _prep_testing_database
def _prep_testing_database(options, file_config):
from sqlalchemy.testing import config
from sqlalchemy.testing.exclusions import against
from sqlalchemy import schema, inspect
if options.dropfirst:
for cfg in config.Config.all_configs():
e = cfg.db
inspector = inspect(e)
try:
view_names = inspector.get_view_names()
except NotImplementedError:
pass
else:
for vname in view_names:
e.execute(schema._DropView(
schema.Table(vname, schema.MetaData())
))
if config.requirements.schemas.enabled_for_config(cfg):
try:
view_names = inspector.get_view_names(
schema="test_schema")
except NotImplementedError:
pass
else:
for vname in view_names:
e.execute(schema._DropView(
schema.Table(vname, schema.MetaData(),
schema="test_schema")
))
for tname in reversed(inspector.get_table_names(
order_by="foreign_key")):
e.execute(schema.DropTable(
schema.Table(tname, schema.MetaData())
))
if config.requirements.schemas.enabled_for_config(cfg):
for tname in reversed(inspector.get_table_names(
order_by="foreign_key", schema="test_schema")):
e.execute(schema.DropTable(
schema.Table(tname, schema.MetaData(),
schema="test_schema")
))
if against(cfg, "postgresql"):
from sqlalchemy.dialects import postgresql
for enum in inspector.get_enums("*"):
e.execute(postgresql.DropEnumType(
postgresql.ENUM(
name=enum['name'],
schema=enum['schema'])))