本文整理汇总了Python中sqlalchemy.testing.is_not_函数的典型用法代码示例。如果您正苦于以下问题:Python is_not_函数的具体用法?Python is_not_怎么用?Python is_not_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_not_函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_info
def test_info(self):
p = self._queuepool_fixture(pool_size=1, max_overflow=0)
c = p.connect()
self.assert_(not c.info)
self.assert_(c.info is c._connection_record.info)
c.info['foo'] = 'bar'
c.close()
del c
c = p.connect()
self.assert_('foo' in c.info)
c.invalidate()
c = p.connect()
self.assert_('foo' not in c.info)
c.info['foo2'] = 'bar2'
c.detach()
self.assert_('foo2' in c.info)
c2 = p.connect()
is_not_(c.connection, c2.connection)
assert not c2.info
assert 'foo2' in c.info
开发者ID:kihon10,项目名称:sqlalchemy,代码行数:26,代码来源:test_pool.py
示例2: test_no_instance_level_collections
def test_no_instance_level_collections(self):
@event.listens_for(self.Target, "event_one")
def listen_one(x, y):
pass
t1 = self.Target()
t2 = self.Target()
t1.dispatch.event_one(5, 6)
t2.dispatch.event_one(5, 6)
is_(
t1.dispatch.__dict__['event_one'],
self.Target.dispatch.event_one.\
_empty_listeners[self.Target]
)
@event.listens_for(t1, "event_one")
def listen_two(x, y):
pass
is_not_(
t1.dispatch.__dict__['event_one'],
self.Target.dispatch.event_one.\
_empty_listeners[self.Target]
)
is_(
t2.dispatch.__dict__['event_one'],
self.Target.dispatch.event_one.\
_empty_listeners[self.Target]
)
开发者ID:Callek,项目名称:sqlalchemy,代码行数:27,代码来源:test_events.py
示例3: test_savepoint_lost_still_runs
def test_savepoint_lost_still_runs(self):
User = self.classes.User
s = self.session(bind=self.bind)
trans = s.begin_nested()
s.connection()
u1 = User(name='ed')
s.add(u1)
# kill off the transaction
nested_trans = trans._connections[self.bind][1]
nested_trans._do_commit()
is_(s.transaction, trans)
assert_raises(
sa_exc.DBAPIError,
s.rollback
)
assert u1 not in s.new
is_(trans._state, _session.CLOSED)
is_not_(s.transaction, trans)
is_(s.transaction._state, _session.ACTIVE)
is_(s.transaction.nested, False)
is_(s.transaction._parent, None)
开发者ID:FluxIX,项目名称:sqlalchemy,代码行数:27,代码来源:test_transaction.py
示例4: test_no_instance_level_collections
def test_no_instance_level_collections(self):
@event.listens_for(self.Target, "event_one")
def listen_one(x, y):
pass
t1 = self.Target()
t2 = self.Target()
t1.dispatch.event_one(5, 6)
t2.dispatch.event_one(5, 6)
is_(
self.Target.dispatch._empty_listener_reg[self.Target]["event_one"],
t1.dispatch.event_one,
)
@event.listens_for(t1, "event_one")
def listen_two(x, y):
pass
is_not_(
self.Target.dispatch._empty_listener_reg[self.Target]["event_one"],
t1.dispatch.event_one,
)
is_(
self.Target.dispatch._empty_listener_reg[self.Target]["event_one"],
t2.dispatch.event_one,
)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:26,代码来源:test_events.py
示例5: test_reconnect
def test_reconnect(self):
"""test that an 'is_disconnect' condition will invalidate the
connection, and additionally dispose the previous connection
pool and recreate."""
db_pool = self.db.pool
# make a connection
conn = self.db.connect()
# connection works
conn.execute(select([1]))
# create a second connection within the pool, which we'll ensure
# also goes away
conn2 = self.db.connect()
conn2.close()
# two connections opened total now
assert len(self.dbapi.connections) == 2
# set it to fail
self.dbapi.shutdown()
assert_raises(
tsa.exc.DBAPIError,
conn.execute, select([1])
)
# assert was invalidated
assert not conn.closed
assert conn.invalidated
# close shouldnt break
conn.close()
is_not_(self.db.pool, db_pool)
# ensure all connections closed (pool was recycled)
eq_(
[c.close.mock_calls for c in self.dbapi.connections],
[[call()], [call()]]
)
conn = self.db.connect()
conn.execute(select([1]))
conn.close()
eq_(
[c.close.mock_calls for c in self.dbapi.connections],
[[call()], [call()], []]
)
开发者ID:aburan28,项目名称:sqlalchemy,代码行数:58,代码来源:test_reconnect.py
示例6: test_chained_add
def test_chained_add(self):
User = self.classes.User
session = Session()
def l1():
return session.query(User)
def l2(q):
return q.filter(User.name == bindparam("name"))
q1 = self.bakery(l1)
q2 = q1.with_criteria(l2)
is_not_(q2, q1)
self._assert_cache_key(q1._cache_key, [l1])
self._assert_cache_key(q2._cache_key, [l1, l2])
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:17,代码来源:test_baked.py
示例7: test_chained_add
def test_chained_add(self):
User = self.classes.User
session = Session()
l1 = lambda: session.query(User)
l2 = lambda q: q.filter(User.name == bindparam('name'))
q1 = self.bakery(l1)
q2 = q1.with_criteria(l2)
is_not_(q2, q1)
self._assert_cache_key(
q1._cache_key,
[l1]
)
self._assert_cache_key(
q2._cache_key,
[l1, l2]
)
开发者ID:CyberCollins,项目名称:sqlalchemy,代码行数:18,代码来源:test_baked.py
示例8: test_chained_add_operator
def test_chained_add_operator(self):
User = self.classes.User
session = Session()
def l1(): return session.query(User)
def l2(q): return q.filter(User.name == bindparam('name'))
q1 = self.bakery(l1)
q2 = q1 + l2
is_not_(q2, q1)
self._assert_cache_key(
q1._cache_key,
[l1]
)
self._assert_cache_key(
q2._cache_key,
[l1, l2]
)
开发者ID:rlugojr,项目名称:sqlalchemy,代码行数:20,代码来源:test_baked.py
示例9: test_autoincrement
def test_autoincrement(self):
Table(
'ai_1', metadata,
Column('int_y', Integer, primary_key=True, autoincrement=True),
Column(
'int_n', Integer, DefaultClause('0'), primary_key=True))
Table(
'ai_2', metadata,
Column('int_y', Integer, primary_key=True, autoincrement=True),
Column('int_n', Integer, DefaultClause('0'), primary_key=True))
Table(
'ai_3', metadata,
Column('int_n', Integer, DefaultClause('0'), primary_key=True),
Column('int_y', Integer, primary_key=True, autoincrement=True))
Table(
'ai_4', metadata,
Column('int_n', Integer, DefaultClause('0'), primary_key=True),
Column('int_n2', Integer, DefaultClause('0'), primary_key=True))
Table(
'ai_5', metadata,
Column('int_y', Integer, primary_key=True, autoincrement=True),
Column('int_n', Integer, DefaultClause('0'), primary_key=True))
Table(
'ai_6', metadata,
Column('o1', String(1), DefaultClause('x'), primary_key=True),
Column('int_y', Integer, primary_key=True, autoincrement=True))
Table(
'ai_7', metadata,
Column('o1', String(1), DefaultClause('x'),
primary_key=True),
Column('o2', String(1), DefaultClause('x'),
primary_key=True),
Column('int_y', Integer, autoincrement=True, primary_key=True))
Table(
'ai_8', metadata,
Column('o1', String(1), DefaultClause('x'),
primary_key=True),
Column('o2', String(1), DefaultClause('x'),
primary_key=True))
metadata.create_all()
table_names = ['ai_1', 'ai_2', 'ai_3', 'ai_4',
'ai_5', 'ai_6', 'ai_7', 'ai_8']
mr = MetaData(testing.db)
for name in table_names:
tbl = Table(name, mr, autoload=True)
tbl = metadata.tables[name]
# test that the flag itself reflects appropriately
for col in tbl.c:
if 'int_y' in col.name:
is_(col.autoincrement, True)
is_(tbl._autoincrement_column, col)
else:
eq_(col.autoincrement, 'auto')
is_not_(tbl._autoincrement_column, col)
# mxodbc can't handle scope_identity() with DEFAULT VALUES
if testing.db.driver == 'mxodbc':
eng = \
[engines.testing_engine(options={
'implicit_returning': True})]
else:
eng = \
[engines.testing_engine(options={
'implicit_returning': False}),
engines.testing_engine(options={
'implicit_returning': True})]
for counter, engine in enumerate(eng):
engine.execute(tbl.insert())
if 'int_y' in tbl.c:
assert engine.scalar(select([tbl.c.int_y])) \
== counter + 1
assert list(
engine.execute(tbl.select()).first()).\
count(counter + 1) == 1
else:
assert 1 \
not in list(engine.execute(tbl.select()).first())
engine.execute(tbl.delete())
开发者ID:FluxIX,项目名称:sqlalchemy,代码行数:84,代码来源:test_types.py
示例10: test_autoincrement
def test_autoincrement(self):
Table(
"ai_1",
metadata,
Column("int_y", Integer, primary_key=True, autoincrement=True),
Column("int_n", Integer, DefaultClause("0"), primary_key=True),
)
Table(
"ai_2",
metadata,
Column("int_y", Integer, primary_key=True, autoincrement=True),
Column("int_n", Integer, DefaultClause("0"), primary_key=True),
)
Table(
"ai_3",
metadata,
Column("int_n", Integer, DefaultClause("0"), primary_key=True),
Column("int_y", Integer, primary_key=True, autoincrement=True),
)
Table(
"ai_4",
metadata,
Column("int_n", Integer, DefaultClause("0"), primary_key=True),
Column("int_n2", Integer, DefaultClause("0"), primary_key=True),
)
Table(
"ai_5",
metadata,
Column("int_y", Integer, primary_key=True, autoincrement=True),
Column("int_n", Integer, DefaultClause("0"), primary_key=True),
)
Table(
"ai_6",
metadata,
Column("o1", String(1), DefaultClause("x"), primary_key=True),
Column("int_y", Integer, primary_key=True, autoincrement=True),
)
Table(
"ai_7",
metadata,
Column("o1", String(1), DefaultClause("x"), primary_key=True),
Column("o2", String(1), DefaultClause("x"), primary_key=True),
Column("int_y", Integer, autoincrement=True, primary_key=True),
)
Table(
"ai_8",
metadata,
Column("o1", String(1), DefaultClause("x"), primary_key=True),
Column("o2", String(1), DefaultClause("x"), primary_key=True),
)
metadata.create_all()
table_names = [
"ai_1",
"ai_2",
"ai_3",
"ai_4",
"ai_5",
"ai_6",
"ai_7",
"ai_8",
]
mr = MetaData(testing.db)
for name in table_names:
tbl = Table(name, mr, autoload=True)
tbl = metadata.tables[name]
# test that the flag itself reflects appropriately
for col in tbl.c:
if "int_y" in col.name:
is_(col.autoincrement, True)
is_(tbl._autoincrement_column, col)
else:
eq_(col.autoincrement, "auto")
is_not_(tbl._autoincrement_column, col)
# mxodbc can't handle scope_identity() with DEFAULT VALUES
if testing.db.driver == "mxodbc":
eng = [
engines.testing_engine(
options={"implicit_returning": True}
)
]
else:
eng = [
engines.testing_engine(
options={"implicit_returning": False}
),
engines.testing_engine(
options={"implicit_returning": True}
),
]
for counter, engine in enumerate(eng):
engine.execute(tbl.insert())
if "int_y" in tbl.c:
assert engine.scalar(select([tbl.c.int_y])) == counter + 1
#.........这里部分代码省略.........
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:101,代码来源:test_types.py
示例11: test_all_import
def test_all_import(self):
for package in self._all_dialect_packages():
for item_name in package.__all__:
is_not_(None, getattr(package, item_name))
开发者ID:cpcloud,项目名称:sqlalchemy,代码行数:4,代码来源:test_all.py
注:本文中的sqlalchemy.testing.is_not_函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论