From dbc50c3a9d20e163827ddf480bb3d269035a0565 Mon Sep 17 00:00:00 2001 From: jonathan vanasco Date: Mon, 24 Aug 2020 18:53:31 -0400 Subject: [PATCH] internal test framework files for standardization of is_not/not_in; this is safe for 1.3.x Change-Id: Icba38fdc20f5d8ac407383a4278ccb346e09af38 (cherry picked from commit 672087176eaf3d0e867c6b5c67bfea3c713be42e) --- lib/sqlalchemy/testing/__init__.py | 2 ++ lib/sqlalchemy/testing/assertions.py | 12 +++++++-- test/base/test_events.py | 4 +-- test/dialect/mssql/test_types.py | 4 +-- test/dialect/test_all.py | 4 +-- test/engine/test_execute.py | 4 +-- test/engine/test_pool.py | 12 ++++----- test/engine/test_reflection.py | 12 ++++----- test/ext/test_baked.py | 6 ++--- test/ext/test_indexable.py | 6 ++--- test/orm/test_eager_relations.py | 4 +-- test/orm/test_events.py | 6 ++--- test/orm/test_merge.py | 6 ++--- test/orm/test_selectin_relations.py | 4 +-- test/orm/test_subquery_relations.py | 4 +-- test/orm/test_transaction.py | 11 ++++---- test/sql/test_computed.py | 4 +-- test/sql/test_deprecations.py | 22 +++++++-------- test/sql/test_generative.py | 16 +++++------ test/sql/test_operators.py | 12 ++++----- test/sql/test_resultset.py | 40 ++++++++++++++-------------- test/sql/test_types.py | 6 ++--- 22 files changed, 105 insertions(+), 96 deletions(-) diff --git a/lib/sqlalchemy/testing/__init__.py b/lib/sqlalchemy/testing/__init__.py index 3f21726b21..c85fe5225f 100644 --- a/lib/sqlalchemy/testing/__init__.py +++ b/lib/sqlalchemy/testing/__init__.py @@ -27,10 +27,12 @@ from .assertions import in_ # noqa 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 diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 8aa150b0f4..74d38ad20d 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -264,21 +264,29 @@ def is_(a, b, msg=None): 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" % ( diff --git a/test/base/test_events.py b/test/base/test_events.py index f13137084a..47bea58bf9 100644 --- a/test/base/test_events.py +++ b/test/base/test_events.py @@ -8,7 +8,7 @@ from sqlalchemy.testing import assert_raises_message 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 @@ -162,7 +162,7 @@ class EventsTest(fixtures.TestBase): def listen_two(x, y): pass - is_not_( + is_not( self.Target.dispatch._empty_listener_reg[self.Target]["event_one"], t1.dispatch.event_one, ) diff --git a/test/dialect/mssql/test_types.py b/test/dialect/mssql/test_types.py index 68b024f49d..8c9679a70f 100644 --- a/test/dialect/mssql/test_types.py +++ b/test/dialect/mssql/test_types.py @@ -51,7 +51,7 @@ from sqlalchemy.testing import engines 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 @@ -1051,7 +1051,7 @@ class TypeRoundTripTest( 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 diff --git a/test/dialect/test_all.py b/test/dialect/test_all.py index 1e4366eb72..f03c4745f9 100644 --- a/test/dialect/test_all.py +++ b/test/dialect/test_all.py @@ -1,6 +1,6 @@ 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): @@ -14,4 +14,4 @@ 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)) diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 9885a497ce..304ffe6d41 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -33,7 +33,7 @@ from sqlalchemy.testing import eq_ 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 @@ -2325,7 +2325,7 @@ class HandleErrorTest(fixtures.TestBase): 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()) diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index d6baf19fb5..51d1b3eb48 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -15,7 +15,7 @@ from sqlalchemy.testing import assert_raises_message 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 @@ -151,7 +151,7 @@ class PoolTest(PoolTestBase): 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 @@ -215,7 +215,7 @@ class PoolTest(PoolTestBase): c2 = r1.get_connection() - is_not_(c1, c2) + is_not(c1, c2) is_(c2, r1.connection) eq_(c2.mock_calls, []) @@ -1189,7 +1189,7 @@ class QueuePoolTest(PoolTestBase): 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): @@ -1207,7 +1207,7 @@ class QueuePoolTest(PoolTestBase): 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): @@ -1230,7 +1230,7 @@ class QueuePoolTest(PoolTestBase): 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) diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index 64224d6c27..fef8363cfb 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -27,10 +27,10 @@ from sqlalchemy.testing import fixtures 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 @@ -168,7 +168,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): 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, @@ -208,7 +208,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): autoload_with=testing.db, extend_existing=True, ) - not_in_("t2", meta2.tables) + not_in("t2", meta2.tables) assert_raises( sa.exc.NoReferencedTableError, @@ -240,7 +240,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): 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"] @@ -2272,7 +2272,7 @@ class ComputedColumnTest(fixtures.ComputedReflectionFixtureTest): 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) diff --git a/test/ext/test_baked.py b/test/ext/test_baked.py index 1b008a249a..ec4b9cdeeb 100644 --- a/test/ext/test_baked.py +++ b/test/ext/test_baked.py @@ -22,7 +22,7 @@ from sqlalchemy.orm.query import Query 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 @@ -108,7 +108,7 @@ class StateChangeTest(BakedTest): 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]) @@ -126,7 +126,7 @@ class StateChangeTest(BakedTest): 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]) diff --git a/test/ext/test_indexable.py b/test/ext/test_indexable.py index 2ffd273bc3..295325b7b5 100644 --- a/test/ext/test_indexable.py +++ b/test/ext/test_indexable.py @@ -14,7 +14,7 @@ from sqlalchemy.testing import fixtures 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 @@ -246,7 +246,7 @@ class IndexPropertyArrayTest(fixtures.DeclarativeMappedTest): a.first = 10 is_(i.modified, True) - not_in_("array", i.unmodified) + not_in("array", i.unmodified) class IndexPropertyJsonTest(fixtures.DeclarativeMappedTest): @@ -339,7 +339,7 @@ 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 diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py index cbf2c4bfbf..b7909a8e9c 100644 --- a/test/orm/test_eager_relations.py +++ b/test/orm/test_eager_relations.py @@ -35,7 +35,7 @@ from sqlalchemy.testing import eq_ 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 @@ -1696,7 +1696,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): 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) diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 1774bbc546..54ad88a20e 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -26,7 +26,7 @@ from sqlalchemy.testing import AssertsCompiledSQL 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 @@ -2115,7 +2115,7 @@ class SessionLifecycleEventsTest(_RemoveListeners, _fixtures.FixtureTest): 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) @@ -2148,7 +2148,7 @@ class SessionLifecycleEventsTest(_RemoveListeners, _fixtures.FixtureTest): @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) diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py index b52f4ddb1c..2317ec8cec 100644 --- a/test/orm/test_merge.py +++ b/test/orm/test_merge.py @@ -29,7 +29,7 @@ from sqlalchemy.testing import eq_ 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 @@ -1806,7 +1806,7 @@ class DeferredMergeTest(fixtures.MappedTest): # 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") @@ -1852,7 +1852,7 @@ class DeferredMergeTest(fixtures.MappedTest): # 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") diff --git a/test/orm/test_selectin_relations.py b/test/orm/test_selectin_relations.py index 0d8474abc4..f4c17b482b 100644 --- a/test/orm/test_selectin_relations.py +++ b/test/orm/test_selectin_relations.py @@ -25,7 +25,7 @@ from sqlalchemy.testing import assert_raises_message 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 @@ -1167,7 +1167,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): 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) diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py index 61ff11ec9c..825375d060 100644 --- a/test/orm/test_subquery_relations.py +++ b/test/orm/test_subquery_relations.py @@ -24,7 +24,7 @@ from sqlalchemy.testing import assert_raises_message 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 @@ -1197,7 +1197,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): 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) diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py index 304c9e39a6..b7a05ece00 100644 --- a/test/orm/test_transaction.py +++ b/test/orm/test_transaction.py @@ -27,7 +27,7 @@ from sqlalchemy.testing import eq_ 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 @@ -620,7 +620,7 @@ class SessionTransactionTest(fixtures.RemovesEvents, FixtureTest): 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) @@ -893,9 +893,8 @@ class SessionTransactionTest(fixtures.RemovesEvents, FixtureTest): 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 @@ -1580,7 +1579,7 @@ class SavepointTest(_LocalFixture): 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) diff --git a/test/sql/test_computed.py b/test/sql/test_computed.py index 2999c621cb..b2fc23717d 100644 --- a/test/sql/test_computed.py +++ b/test/sql/test_computed.py @@ -11,7 +11,7 @@ from sqlalchemy.testing import AssertsCompiledSQL 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): @@ -69,7 +69,7 @@ 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) diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index 4559806495..9e3a3182a1 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -35,7 +35,7 @@ from sqlalchemy.testing import eq_ 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): @@ -173,8 +173,8 @@ class CaseSensitiveFunctionDeprecationsTest(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"])) @@ -198,8 +198,8 @@ class CaseSensitiveFunctionDeprecationsTest(fixtures.TestBase): 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"])) @@ -217,8 +217,8 @@ class CaseSensitiveFunctionDeprecationsTest(fixtures.TestBase): 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"])) @@ -241,8 +241,8 @@ class CaseSensitiveFunctionDeprecationsTest(fixtures.TestBase): 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()), @@ -287,8 +287,8 @@ class CaseSensitiveFunctionDeprecationsTest(fixtures.TestBase): 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()), diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py index 469015026e..212206f0a1 100644 --- a/test/sql/test_generative.py +++ b/test/sql/test_generative.py @@ -35,7 +35,7 @@ from sqlalchemy.testing import AssertsExecutionResults 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 @@ -446,7 +446,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): 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( @@ -806,7 +806,7 @@ class ColumnAdapterTest(fixtures.TestBase, AssertsCompiledSQL): 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): @@ -815,7 +815,7 @@ class ColumnAdapterTest(fixtures.TestBase, AssertsCompiledSQL): 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): @@ -824,7 +824,7 @@ class ColumnAdapterTest(fixtures.TestBase, AssertsCompiledSQL): 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): @@ -1799,9 +1799,9 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): 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" ) diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 8b2648ff75..e3224084dc 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -53,7 +53,7 @@ from sqlalchemy.testing import eq_ 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 @@ -1083,9 +1083,9 @@ class ConjunctionTest(fixtures.TestBase, testing.AssertsCompiledSQL): ) 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( @@ -2002,7 +2002,7 @@ class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL): 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( @@ -2016,7 +2016,7 @@ class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL): 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, diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index db7c1f47b2..41dbc4838b 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -34,7 +34,7 @@ from sqlalchemy.testing import in_ 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 @@ -187,7 +187,7 @@ class ResultProxyTest(fixtures.TablesTest): 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( @@ -195,16 +195,16 @@ class ResultProxyTest(fixtures.TablesTest): ).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) @@ -413,15 +413,15 @@ class ResultProxyTest(fixtures.TablesTest): ) 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") @@ -450,8 +450,8 @@ class ResultProxyTest(fixtures.TablesTest): 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"]) @@ -473,7 +473,7 @@ class ResultProxyTest(fixtures.TablesTest): ) 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): @@ -613,7 +613,7 @@ class ResultProxyTest(fixtures.TablesTest): 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) @@ -640,7 +640,7 @@ class ResultProxyTest(fixtures.TablesTest): 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) @@ -1360,24 +1360,24 @@ class KeyTargetingTest(fixtures.TablesTest): 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 diff --git a/test/sql/test_types.py b/test/sql/test_types.py index be8389c9ce..2c028508f1 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -77,7 +77,7 @@ from sqlalchemy.testing import eq_ 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 @@ -2555,12 +2555,12 @@ class ExpressionTest( 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() -- 2.47.2