from .assertions import is_ # noqa
from .assertions import is_false # noqa
from .assertions import is_instance_of # noqa
+from .assertions import is_not # noqa
from .assertions import is_not_ # noqa
from .assertions import is_true # noqa
from .assertions import le_ # noqa
from .assertions import ne_ # noqa
+from .assertions import not_in # noqa
from .assertions import not_in_ # noqa
from .assertions import startswith_ # noqa
from .assertions import uses_deprecated # noqa
assert a is b, msg or "%r is not %r" % (a, b)
-def is_not_(a, b, msg=None):
+def is_not(a, b, msg=None):
"""Assert a is not b, with repr messaging on failure."""
assert a is not b, msg or "%r is %r" % (a, b)
+# deprecated. See #5429
+is_not_ = is_not
+
+
def in_(a, b, msg=None):
"""Assert a in b, with repr messaging on failure."""
assert a in b, msg or "%r not in %r" % (a, b)
-def not_in_(a, b, msg=None):
+def not_in(a, b, msg=None):
"""Assert a in not b, with repr messaging on failure."""
assert a not in b, msg or "%r is in %r" % (a, b)
+# deprecated. See #5429
+not_in_ = not_in
+
+
def startswith_(a, fragment, msg=None):
"""Assert a.startswith(fragment), with repr messaging on failure."""
assert a.startswith(fragment), msg or "%r does not start with %r" % (
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing.mock import call
from sqlalchemy.testing.mock import Mock
from sqlalchemy.testing.util import gc_collect
def listen_two(x, y):
pass
- is_not_(
+ is_not(
self.Target.dispatch._empty_listener_reg[self.Target]["event_one"],
t1.dispatch.event_one,
)
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import pickleable
from sqlalchemy.util import b
is_(tbl._autoincrement_column, col)
else:
eq_(col.autoincrement, "auto")
- is_not_(tbl._autoincrement_column, col)
+ is_not(tbl._autoincrement_column, col)
# mxodbc can't handle scope_identity() with DEFAULT VALUES
from sqlalchemy import dialects
from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
class ImportStarTest(fixtures.TestBase):
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))
+ is_not(None, getattr(package, item_name))
from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import mock
from sqlalchemy.testing.assertsql import CompiledSQL
from sqlalchemy.testing.engines import testing_engine
for crec in crecs:
if crec is target_crec or not set_to_false:
- is_not_(crec.connection, crec.get_connection())
+ is_not(crec.connection, crec.get_connection())
else:
is_(crec.connection, crec.get_connection())
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import is_true
from sqlalchemy.testing.engines import testing_engine
from sqlalchemy.testing.mock import ANY
self.assert_("foo2" in c.info)
c2 = p.connect()
- is_not_(c.connection, c2.connection)
+ is_not(c.connection, c2.connection)
assert not c2.info
assert "foo2" in c.info
c2 = r1.get_connection()
- is_not_(c1, c2)
+ is_not(c1, c2)
is_(c2, r1.connection)
eq_(c2.mock_calls, [])
mock.return_value = 10035
c3 = p.connect()
- is_not_(c3.connection, c_ref())
+ is_not(c3.connection, c_ref())
@testing.requires.timing_intensive
def test_recycle_on_invalidate(self):
time.sleep(0.5)
c3 = p.connect()
- is_not_(c3.connection, c_ref())
+ is_not(c3.connection, c_ref())
@testing.requires.timing_intensive
def test_recycle_on_soft_invalidate(self):
c2.close()
c3 = p.connect()
- is_not_(c3.connection, c_ref())
+ is_not(c3.connection, c_ref())
is_(c3._connection_record, c2_rec)
is_(c2_rec.connection, c3.connection)
from sqlalchemy.testing import in_
from sqlalchemy.testing import is_
from sqlalchemy.testing import is_instance_of
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import is_true
from sqlalchemy.testing import mock
-from sqlalchemy.testing import not_in_
+from sqlalchemy.testing import not_in
from sqlalchemy.testing import skip
from sqlalchemy.testing.schema import Column
from sqlalchemy.testing.schema import Table
meta2 = MetaData()
t1 = Table("t1", meta2, resolve_fks=False, autoload_with=testing.db)
in_("t1", meta2.tables)
- not_in_("t2", meta2.tables)
+ not_in("t2", meta2.tables)
assert_raises(
sa.exc.NoReferencedTableError,
autoload_with=testing.db,
extend_existing=True,
)
- not_in_("t2", meta2.tables)
+ not_in("t2", meta2.tables)
assert_raises(
sa.exc.NoReferencedTableError,
meta2 = MetaData()
meta2.reflect(testing.db, resolve_fks=False, only=["t1"])
in_("t1", meta2.tables)
- not_in_("t2", meta2.tables)
+ not_in("t2", meta2.tables)
t1 = meta2.tables["t1"]
def check_table_column(self, table, name, text, persisted):
is_true(name in table.columns)
col = table.columns[name]
- is_not_(col.computed, None)
+ is_not(col.computed, None)
is_instance_of(col.computed, Computed)
eq_(self.normalize(str(col.computed.sqltext)), text)
from sqlalchemy.testing import assert_raises_message
from sqlalchemy.testing import eq_
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import mock
from sqlalchemy.testing.assertsql import CompiledSQL
from test.orm import _fixtures
q1 = self.bakery(l1)
q2 = q1.with_criteria(l2)
- is_not_(q2, q1)
+ is_not(q2, q1)
self._assert_cache_key(q1._cache_key, [l1])
self._assert_cache_key(q2._cache_key, [l1, l2])
q1 = self.bakery(l1)
q2 = q1 + l2
- is_not_(q2, q1)
+ is_not(q2, q1)
self._assert_cache_key(q1._cache_key, [l1])
self._assert_cache_key(q2._cache_key, [l1, l2])
from sqlalchemy.testing import in_
from sqlalchemy.testing import is_
from sqlalchemy.testing import ne_
-from sqlalchemy.testing import not_in_
+from sqlalchemy.testing import not_in
from sqlalchemy.testing.schema import Column
a.first = 10
is_(i.modified, True)
- not_in_("array", i.unmodified)
+ not_in("array", i.unmodified)
class IndexPropertyJsonTest(fixtures.DeclarativeMappedTest):
j.other = 42
is_(i.modified, True)
- not_in_("json", i.unmodified)
+ not_in("json", i.unmodified)
def test_cast_type(self):
Json = self.classes.Json
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import in_
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing.assertsql import CompiledSQL
from sqlalchemy.testing.schema import Column
from sqlalchemy.testing.schema import Table
def go():
a = q.filter(addresses.c.id == 1).one()
- is_not_(a.user, None)
+ is_not(a.user, None)
u1 = sess.query(User).get(7)
is_(a.user, u1)
from sqlalchemy.testing import eq_
from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing.assertsql import CompiledSQL
from sqlalchemy.testing.mock import ANY
from sqlalchemy.testing.mock import call
listener.flag_checked(instance)
# this is actually u1, because
# we have a strong ref internally
- is_not_(None, instance)
+ is_not(None, instance)
u1 = User(name="u1")
sess.add(u1)
@event.listens_for(sess, "persistent_to_deleted")
def persistent_to_deleted(session, instance):
- is_not_(None, instance)
+ is_not(None, instance)
listener.flag_checked(instance)
sess.delete(u1)
from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import in_
-from sqlalchemy.testing import not_in_
+from sqlalchemy.testing import not_in
from sqlalchemy.testing.schema import Column
from sqlalchemy.testing.schema import Table
from sqlalchemy.util import OrderedSet
# should not emit load for deferred 'excerpt'
eq_(b2.summary, "some summary")
- not_in_("excerpt", b2.__dict__)
+ not_in("excerpt", b2.__dict__)
# now it should emit load for deferred 'excerpt'
eq_(b2.excerpt, "some excerpt")
# should not emit load for deferred 'excerpt'
eq_(b2.summary, "some summary")
- not_in_("excerpt", b2.__dict__)
+ not_in("excerpt", b2.__dict__)
# now it should emit load for deferred 'excerpt'
eq_(b2.excerpt, "some excerpt")
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import is_true
from sqlalchemy.testing import mock
from sqlalchemy.testing.assertsql import AllOf
def go():
a = q.filter(addresses.c.id == 1).one()
- is_not_(a.user, None)
+ is_not(a.user, None)
u1 = sess.query(User).get(7)
is_(a.user, u1)
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import is_true
from sqlalchemy.testing.assertsql import CompiledSQL
from sqlalchemy.testing.entities import ComparableEntity
def go():
a = q.filter(addresses.c.id == 1).one()
- is_not_(a.user, None)
+ is_not(a.user, None)
u1 = sess.query(User).get(7)
is_(a.user, u1)
from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import is_true
from sqlalchemy.testing import mock
from sqlalchemy.testing.util import gc_collect
eq_(trans._state, _session.CLOSED)
# outermost transaction is new
- is_not_(session.transaction, trans)
+ is_not(session.transaction, trans)
# outermost is active
eq_(session.transaction._state, _session.ACTIVE)
session = create_session(autocommit=False)
session.add(User(name="ed"))
session.transaction.commit()
- assert (
- session.transaction is not None
- ), "autocommit=False should start a new transaction"
+
+ is_not(session.transaction, None)
@testing.requires.python2
@testing.requires.savepoints_w_release
assert u1 not in s.new
is_(trans._state, _session.CLOSED)
- is_not_(s.transaction, trans)
+ is_not(s.transaction, trans)
is_(s.transaction._state, _session.ACTIVE)
is_(s.transaction.nested, False)
from sqlalchemy.testing import combinations
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
class DDLComputedTest(fixtures.TestBase, AssertsCompiledSQL):
t2 = t.tometadata(m2)
comp2 = t2.c.y.server_default
- is_not_(comp1, comp2)
+ is_not(comp1, comp2)
is_(comp1.column, t.c.y)
is_(t.c.y.server_onupdate, comp1)
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import in_
from sqlalchemy.testing import mock
-from sqlalchemy.testing import not_in_
+from sqlalchemy.testing import not_in
class DeprecationWarningsTest(fixtures.TestBase):
assert isinstance(func.myfunc().type, DateTime)
in_("myfunc", reg)
- not_in_("MYFUNC", reg)
- not_in_("MyFunc", reg)
+ not_in("MYFUNC", reg)
+ not_in("MyFunc", reg)
in_("myfunc", cs_reg)
eq_(set(cs_reg["myfunc"].keys()), set(["MYFUNC"]))
assert isinstance(func.myfunc().type, Integer)
eq_(reg["myfunc"], functions._CASE_SENSITIVE)
- not_in_("MYFUNC", reg)
- not_in_("MyFunc", reg)
+ not_in("MYFUNC", reg)
+ not_in("MyFunc", reg)
in_("myfunc", cs_reg)
eq_(set(cs_reg["myfunc"].keys()), set(["MYFUNC", "MyFunc"]))
assert isinstance(func.replaceable_func().type, Integer)
in_("replaceable_func", reg)
- not_in_("REPLACEABLE_FUNC", reg)
- not_in_("Replaceable_Func", reg)
+ not_in("REPLACEABLE_FUNC", reg)
+ not_in("Replaceable_Func", reg)
in_("replaceable_func", cs_reg)
eq_(set(cs_reg["replaceable_func"].keys()), set(["REPLACEABLE_FUNC"]))
assert isinstance(func.replaceable_func().type, NullType)
eq_(reg["replaceable_func"], functions._CASE_SENSITIVE)
- not_in_("REPLACEABLE_FUNC", reg)
- not_in_("Replaceable_Func", reg)
+ not_in("REPLACEABLE_FUNC", reg)
+ not_in("Replaceable_Func", reg)
in_("replaceable_func", cs_reg)
eq_(
set(cs_reg["replaceable_func"].keys()),
assert isinstance(func.replaceable_func().type, String)
eq_(reg["replaceable_func"], functions._CASE_SENSITIVE)
- not_in_("REPLACEABLE_FUNC", reg)
- not_in_("Replaceable_Func", reg)
+ not_in("REPLACEABLE_FUNC", reg)
+ not_in("Replaceable_Func", reg)
in_("replaceable_func", cs_reg)
eq_(
set(cs_reg["replaceable_func"].keys()),
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
A = B = t1 = t2 = t3 = table1 = table2 = table3 = table4 = None
adapter = sql_util.ColumnAdapter(t3_alias)
lblx_adapted = adapter.traverse(lbl_x)
- is_not_(lblx_adapted._element, lbl_x._element)
+ is_not(lblx_adapted._element, lbl_x._element)
lblx_adapted = adapter.traverse(lbl_x)
self.assert_compile(
expr = select([t1a.c.col1]).label("x")
expr_adapted = adapter.traverse(expr)
- is_not_(expr, expr_adapted)
+ is_not(expr, expr_adapted)
is_(adapter.columns[expr], expr_adapted)
def test_traverse_memoizes_w_itself(self):
expr = select([t1a.c.col1]).label("x")
expr_adapted = adapter.traverse(expr)
- is_not_(expr, expr_adapted)
+ is_not(expr, expr_adapted)
is_(adapter.traverse(expr), expr_adapted)
def test_columns_memoizes_w_itself(self):
expr = select([t1a.c.col1]).label("x")
expr_adapted = adapter.columns[expr]
- is_not_(expr, expr_adapted)
+ is_not(expr, expr_adapted)
is_(adapter.columns[expr], expr_adapted)
def test_wrapping_fallthrough(self):
select_copy,
"SELECT table1.col1, table1.col2, " "table1.col3, yyy FROM table1",
)
- assert s.columns is not select_copy.columns
- assert s._columns is not select_copy._columns
- assert s._raw_columns is not select_copy._raw_columns
+ is_not(s.columns, select_copy.columns)
+ is_not(s._columns, select_copy._columns)
+ is_not(s._raw_columns, select_copy._raw_columns)
self.assert_compile(
s, "SELECT table1.col1, table1.col2, " "table1.col3 FROM table1"
)
from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.types import ARRAY
from sqlalchemy.types import Boolean
from sqlalchemy.types import Concatenable
)
def test_constant_non_singleton(self):
- is_not_(null(), null())
- is_not_(false(), false())
- is_not_(true(), true())
+ is_not(null(), null())
+ is_not(false(), false())
+ is_not(true(), true())
def test_constant_render_distinct(self):
self.assert_compile(
expr = not_(orig_expr)
isinstance(expr, Label)
eq_(expr.name, "foo")
- is_not_(expr, orig_expr)
+ is_not(expr, orig_expr)
is_(expr._element.operator, operator.inv) # e.g. and not false_
self.assert_compile(
self.table1.c.myid == 1, self.table1.c.myid == 2
).self_group()
expr = not_(orig_expr)
- is_not_(expr, orig_expr)
+ is_not(expr, orig_expr)
self.assert_compile(
expr,
from sqlalchemy.testing import is_
from sqlalchemy.testing import le_
from sqlalchemy.testing import ne_
-from sqlalchemy.testing import not_in_
+from sqlalchemy.testing import not_in
from sqlalchemy.testing.mock import Mock
from sqlalchemy.testing.mock import patch
from sqlalchemy.testing.schema import Column
row = testing.db.execute(content.select(use_labels=True)).first()
in_(content.c.type, row)
- not_in_(bar.c.content_type, row)
+ not_in(bar.c.content_type, row)
in_(sql.column("content_type"), row)
row = testing.db.execute(
).first()
in_(content.c.type, row)
- not_in_(bar.c.content_type, row)
+ not_in(bar.c.content_type, row)
in_(sql.column("content_type"), row)
row = testing.db.execute(
select([func.now().label("content_type")])
).first()
- not_in_(content.c.type, row)
+ not_in(content.c.type, row)
- not_in_(bar.c.content_type, row)
+ not_in(bar.c.content_type, row)
in_(sql.column("content_type"), row)
)
if testing.against("sqlite < 3.10.0"):
- not_in_("user_id", r)
- not_in_("user_name", r)
+ not_in("user_id", r)
+ not_in("user_name", r)
eq_(r["users.user_id"], 1)
eq_(r["users.user_name"], "john")
eq_(list(r.keys()), ["users.user_id", "users.user_name"])
else:
- not_in_("users.user_id", r)
- not_in_("users.user_name", r)
+ not_in("users.user_id", r)
+ not_in("users.user_name", r)
eq_(r["user_id"], 1)
eq_(r["user_name"], "john")
eq_(r["users.user_id"], 1)
eq_(r["users.user_name"], "john")
else:
- not_in_("users.user_id", r)
- not_in_("users.user_name", r)
+ not_in("users.user_id", r)
+ not_in("users.user_name", r)
eq_(list(r.keys()), ["user_id", "user_name"])
)
eq_(r["users.user_id"], 1)
eq_(r["users.user_name"], "john")
- not_in_("user_name", r)
+ not_in("user_name", r)
eq_(list(r.keys()), ["users.user_id", "users.user_name"])
def test_column_accessor_unary(self):
in_("case_insensitive", row._keymap)
in_("CaseSensitive", row._keymap)
- not_in_("casesensitive", row._keymap)
+ not_in("casesensitive", row._keymap)
eq_(row["case_insensitive"], 1)
eq_(row["CaseSensitive"], 2)
in_("case_insensitive", row._keymap)
in_("CaseSensitive", row._keymap)
- not_in_("casesensitive", row._keymap)
+ not_in("casesensitive", row._keymap)
eq_(row["case_insensitive"], 1)
eq_(row["CaseSensitive"], 2)
select([content.c.type.label("content_type")])
).first()
- not_in_(content.c.type, row)
- not_in_(bar.c.content_type, row)
+ not_in(content.c.type, row)
+ not_in(bar.c.content_type, row)
in_(sql.column("content_type"), row)
row = testing.db.execute(
select([func.now().label("content_type")])
).first()
- not_in_(content.c.type, row)
- not_in_(bar.c.content_type, row)
+ not_in(content.c.type, row)
+ not_in(bar.c.content_type, row)
in_(sql.column("content_type"), row)
def test_column_label_overlap_fallback_2(self):
content, bar = self.tables.content, self.tables.bar
row = testing.db.execute(content.select(use_labels=True)).first()
in_(content.c.type, row)
- not_in_(bar.c.content_type, row)
- not_in_(sql.column("content_type"), row)
+ not_in(bar.c.content_type, row)
+ not_in(sql.column("content_type"), row)
def test_columnclause_schema_column_one(self):
keyed2 = self.tables.keyed2
from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
-from sqlalchemy.testing import is_not_
+from sqlalchemy.testing import is_not
from sqlalchemy.testing import mock
from sqlalchemy.testing import pickleable
from sqlalchemy.testing.schema import Column
expr = tab.c.avalue["foo"] == "bar"
is_(expr.right.type._type_affinity, String)
- is_not_(expr.right.type, my_json_normal)
+ is_not(expr.right.type, my_json_normal)
expr = tab.c.bvalue["foo"] == "bar"
is_(expr.right.type._type_affinity, String)
- is_not_(expr.right.type, my_json_variant)
+ is_not(expr.right.type, my_json_variant)
def test_variant_righthand_coercion_returns_self(self):
my_datetime_normal = DateTime()