diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-11-02 20:51:28 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-11-02 20:51:28 +0000 |
commit | 72780bae3377c45abb03cb62b638b84ed04375e2 (patch) | |
tree | bf09b8f26fae7e797a2aeb9fc67babd1dd91da7e /test | |
parent | fc5c54fcd4d868c2a4c7ac19668d72f506fe821e (diff) | |
parent | 36e7aebd8d6faac77570403e99f9aa7b2330fa59 (diff) | |
download | sqlalchemy-72780bae3377c45abb03cb62b638b84ed04375e2.tar.gz |
Merge "First round of removal of python 2" into main
Diffstat (limited to 'test')
31 files changed, 39 insertions, 451 deletions
diff --git a/test/aaa_profiling/test_misc.py b/test/aaa_profiling/test_misc.py index ba3283f55..3d6700542 100644 --- a/test/aaa_profiling/test_misc.py +++ b/test/aaa_profiling/test_misc.py @@ -50,8 +50,7 @@ class EnumTest(fixtures.TestBase): class CacheKeyTest(fixtures.TestBase): - # python3 is just to have less variability in test counts - __requires__ = ("cpython", "python_profiling_backend", "python3") + __requires__ = ("cpython", "python_profiling_backend") @testing.fixture(scope="class") def mapping_fixture(self): diff --git a/test/base/test_concurrency_py3k.py b/test/base/test_concurrency_py3k.py index 0b648aa30..3c89108ee 100644 --- a/test/base/test_concurrency_py3k.py +++ b/test/base/test_concurrency_py3k.py @@ -1,7 +1,6 @@ import threading from sqlalchemy import exc -from sqlalchemy import testing from sqlalchemy.testing import async_test from sqlalchemy.testing import eq_ from sqlalchemy.testing import expect_raises @@ -141,7 +140,6 @@ class TestAsyncioCompat(fixtures.TestBase): await to_await @async_test - @testing.requires.python37 async def test_contextvars(self): import asyncio import contextvars @@ -186,9 +184,7 @@ class TestAsyncioCompat(fixtures.TestBase): class TestAsyncAdaptedQueue(fixtures.TestBase): - # uses asyncio.run() in alternate threads which is not available - # in Python 3.6 - __requires__ = ("python37", "greenlet") + __requires__ = ("greenlet",) def test_lazy_init(self): run = [False] diff --git a/test/base/test_events.py b/test/base/test_events.py index 68db5207c..d38f61c1e 100644 --- a/test/base/test_events.py +++ b/test/base/test_events.py @@ -268,7 +268,6 @@ class EventsTest(TearDownLocalEventsFixture, fixtures.TestBase): class SlotsEventsTest(fixtures.TestBase): - @testing.requires.python3 def test_no_slots_dispatch(self): class Target(object): __slots__ = () diff --git a/test/base/test_tutorials.py b/test/base/test_tutorials.py index f2b577216..2393a7f91 100644 --- a/test/base/test_tutorials.py +++ b/test/base/test_tutorials.py @@ -11,8 +11,6 @@ from sqlalchemy.testing import fixtures class DocTest(fixtures.TestBase): - __requires__ = ("python3",) - def _setup_logger(self): rootlogger = logging.getLogger("sqlalchemy.engine.Engine") diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 849c193ea..81e402d93 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -14,7 +14,6 @@ from sqlalchemy.sql.base import DedupeColumnCollection from sqlalchemy.testing import assert_raises from sqlalchemy.testing import assert_raises_message 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 is_ @@ -133,12 +132,8 @@ class OrderedDictTest(fixtures.TestBase): def test_no_sort_legacy_dictionary(self): d1 = {"c": 1, "b": 2, "a": 3} - - if testing.requires.python37.enabled: - util.sort_dictionary(d1) - eq_(list(d1), ["a", "b", "c"]) - else: - assert_raises(AttributeError, util.sort_dictionary, d1) + util.sort_dictionary(d1) + eq_(list(d1), ["a", "b", "c"]) def test_sort_dictionary(self): o = util.OrderedDict() @@ -1882,26 +1877,9 @@ class DictlikeIteritemsTest(fixtures.TestBase): d = subdict(a=1, b=2, c=3) self._ok(d) - if util.py2k: - - def test_UserDict(self): - import UserDict - - d = UserDict.UserDict(a=1, b=2, c=3) - self._ok(d) - def test_object(self): self._notok(object()) - if util.py2k: - - def test_duck_1(self): - class duck1(object): - def iteritems(duck): - return iter(self.baseline) - - self._ok(duck1()) - def test_duck_2(self): class duck2(object): def items(duck): @@ -1909,18 +1887,6 @@ class DictlikeIteritemsTest(fixtures.TestBase): self._ok(duck2()) - if util.py2k: - - def test_duck_3(self): - class duck3(object): - def iterkeys(duck): - return iter(["a", "b", "c"]) - - def __getitem__(duck, key): - return dict(a=1, b=2, c=3).get(key) - - self._ok(duck3()) - def test_duck_4(self): class duck4(object): def iterkeys(duck): @@ -2570,7 +2536,6 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): "apply_kw_proxied": "a, b=b, c=c", }, False, - testing.requires.python3, ), ( py3k_fixtures._kw_plus_posn_fixture, @@ -2583,7 +2548,6 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): "apply_kw_proxied": "a, b=b, c=c, *args", }, False, - testing.requires.python3, ), ( py3k_fixtures._kw_opt_fixture, @@ -2596,7 +2560,6 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): "apply_kw_proxied": "a, b=b, c=c", }, False, - testing.requires.python3, ), argnames="fn,wanted,grouped", ) @@ -2983,25 +2946,8 @@ class TestClassHierarchy(fixtures.TestBase): eq_(set(util.class_hierarchy(A)), set((A, B, C, object))) eq_(set(util.class_hierarchy(B)), set((A, B, C, object))) - if util.py2k: - - def test_oldstyle_mixin(self): - class A(object): - pass - - class Mixin: - pass - - class B(A, Mixin): - pass - - eq_(set(util.class_hierarchy(B)), set((A, B, object))) - eq_(set(util.class_hierarchy(Mixin)), set()) - eq_(set(util.class_hierarchy(A)), set((A, B, object))) - class ReraiseTest(fixtures.TestBase): - @testing.requires.python3 def test_raise_from_cause_same_cause(self): class MyException(Exception): pass @@ -3037,8 +2983,7 @@ class ReraiseTest(fixtures.TestBase): go() assert False except MyOtherException as moe: - if testing.requires.python3.enabled: - is_(moe.__cause__, me) + is_(moe.__cause__, me) def test_raise_from(self): class MyException(Exception): @@ -3059,40 +3004,7 @@ class ReraiseTest(fixtures.TestBase): go() assert False except MyOtherException as moe: - if testing.requires.python3.enabled: - is_(moe.__cause__, me) - - @testing.requires.python2 - def test_safe_reraise_py2k_warning(self): - class MyException(Exception): - pass - - class MyOtherException(Exception): - pass - - m1 = MyException("exc one") - m2 = MyOtherException("exc two") - - def go2(): - raise m2 - - def go(): - try: - raise m1 - except Exception: - with util.safe_reraise(): - go2() - - with expect_warnings( - "An exception has occurred during handling of a previous " - "exception. The previous exception " - "is:.*MyException.*exc one" - ): - try: - go() - assert False - except MyOtherException: - pass + is_(moe.__cause__, me) class TestClassProperty(fixtures.TestBase): @@ -3316,20 +3228,12 @@ class TimezoneTest(fixtures.TestBase): datetime.datetime(2017, 10, 5, 4, 55, 38, tzinfo=timezone(del_)), ) - @testing.requires.python3 - def test_repr_py3k(self): + def test_repr(self): eq_( repr(timezone(datetime.timedelta(hours=5))), "datetime.timezone(%r)" % (datetime.timedelta(hours=5)), ) - @testing.requires.python2 - def test_repr_py2k(self): - eq_( - repr(timezone(datetime.timedelta(hours=5))), - "sqlalchemy.util.timezone(%r)" % (datetime.timedelta(hours=5)), - ) - class TestModuleRegistry(fixtures.TestBase): def test_modules_are_loaded(self): diff --git a/test/dialect/mssql/test_query.py b/test/dialect/mssql/test_query.py index e5e3cd3ad..2498de92a 100644 --- a/test/dialect/mssql/test_query.py +++ b/test/dialect/mssql/test_query.py @@ -15,7 +15,6 @@ from sqlalchemy import select from sqlalchemy import String from sqlalchemy import Table from sqlalchemy import testing -from sqlalchemy import util from sqlalchemy.dialects.mssql import base as mssql from sqlalchemy.testing import AssertsCompiledSQL from sqlalchemy.testing import config @@ -24,7 +23,6 @@ from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures from sqlalchemy.testing.assertsql import CursorSQL from sqlalchemy.testing.assertsql import DialectSQL -from sqlalchemy.util import ue class IdentityInsertTest(fixtures.TablesTest, AssertsCompiledSQL): @@ -140,39 +138,6 @@ class IdentityInsertTest(fixtures.TablesTest, AssertsCompiledSQL): eq_(conn.execute(select(t)).first(), (1, "descrip")) -class QueryUnicodeTest(fixtures.TestBase): - - __only_on__ = "mssql" - __backend__ = True - - @testing.requires.mssql_freetds - @testing.requires.python2 - @testing.provide_metadata - def test_convert_unicode(self, connection): - meta = self.metadata - t1 = Table( - "unitest_table", - meta, - Column("id", Integer, primary_key=True), - Column("descr", mssql.MSText()), - ) - meta.create_all(connection) - connection.execute( - ue("insert into unitest_table values ('abc \xc3\xa9 def')").encode( - "UTF-8" - ) - ) - r = connection.execute(t1.select()).first() - assert isinstance( - r[1], util.text_type - ), "%s is %s instead of unicode, working on %s" % ( - r[1], - type(r[1]), - meta.bind, - ) - eq_(r[1], util.ue("abc \xc3\xa9 def")) - - class QueryTest(testing.AssertsExecutionResults, fixtures.TestBase): __only_on__ = "mssql" __backend__ = True diff --git a/test/dialect/mssql/test_types.py b/test/dialect/mssql/test_types.py index 8e5e3f9c6..a96b74c0a 100644 --- a/test/dialect/mssql/test_types.py +++ b/test/dialect/mssql/test_types.py @@ -909,7 +909,6 @@ class TypeRoundTripTest( ), None, True, - testing.requires.python37, ), ( "dto_param_datetime_naive", diff --git a/test/dialect/oracle/test_dialect.py b/test/dialect/oracle/test_dialect.py index 554e5f18b..f287a9a0b 100644 --- a/test/dialect/oracle/test_dialect.py +++ b/test/dialect/oracle/test_dialect.py @@ -256,7 +256,6 @@ class EncodingErrorsTest(fixtures.TestBase): assert_raises(UnicodeDecodeError, outconverter, utf8_w_errors) @_oracle_char_combinations - @testing.requires.python3 def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type): cx_Oracle.version = "6.3" @@ -277,46 +276,7 @@ class EncodingErrorsTest(fixtures.TestBase): ) @_oracle_char_combinations - @testing.requires.python2 - def test_encoding_errors_sqla_py2k( - self, - cx_Oracle, - cx_oracle_type, - ): - ignore_dialect = cx_oracle.dialect( - dbapi=cx_Oracle, encoding_errors="ignore" - ) - - ignore_outputhandler = ( - ignore_dialect._generate_connection_outputtype_handler() - ) - - cursor = mock.Mock() - ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None) - outconverter = cursor.mock_calls[0][2]["outconverter"] - self._assert_errorhandler(outconverter, True) - - @_oracle_char_combinations - @testing.requires.python2 - def test_no_encoding_errors_sqla_py2k( - self, - cx_Oracle, - cx_oracle_type, - ): - plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle) - - plain_outputhandler = ( - plain_dialect._generate_connection_outputtype_handler() - ) - - cursor = mock.Mock() - plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None) - outconverter = cursor.mock_calls[0][2]["outconverter"] - self._assert_errorhandler(outconverter, False) - - @_oracle_char_combinations - @testing.requires.python3 - def test_encoding_errors_cx_oracle_py3k( + def test_encoding_errors_cx_oracle( self, cx_Oracle, cx_oracle_type, @@ -345,8 +305,7 @@ class EncodingErrorsTest(fixtures.TestBase): ) @_oracle_char_combinations - @testing.requires.python3 - def test_no_encoding_errors_cx_oracle_py3k( + def test_no_encoding_errors_cx_oracle( self, cx_Oracle, cx_oracle_type, diff --git a/test/dialect/oracle/test_types.py b/test/dialect/oracle/test_types.py index 70b00c06f..2b54f2b56 100644 --- a/test/dialect/oracle/test_types.py +++ b/test/dialect/oracle/test_types.py @@ -48,7 +48,6 @@ from sqlalchemy.testing.engines import testing_engine from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table from sqlalchemy.util import b -from sqlalchemy.util import py2k from sqlalchemy.util import u @@ -202,11 +201,7 @@ class TypesTest(fixtures.TestBase): Column("id", Integer, primary_key=True), Column("data", char_type(30), nullable=False), ) - - if py2k and char_type is NCHAR: - v1, v2, v3 = u"value 1", u"value 2", u"value 3" - else: - v1, v2, v3 = "value 1", "value 2", "value 3" + v1, v2, v3 = "value 1", "value 2", "value 3" t.create(connection) connection.execute( @@ -719,17 +714,14 @@ class TypesTest(fixtures.TestBase): eq_(sqla_result, cx_oracle_result) - @testing.only_on("oracle+cx_oracle", "cx_oracle-specific feature") - @testing.fails_if( - testing.requires.python3, "cx_oracle always returns unicode on py3k" - ) def test_coerce_to_unicode(self, connection): engine = testing_engine(options=dict(coerce_to_unicode=False)) with engine.connect() as conn_no_coerce: value = exec_sql( conn_no_coerce, "SELECT 'hello' FROM DUAL" ).scalar() - assert isinstance(value, util.binary_type) + assert not isinstance(value, util.binary_type) + assert isinstance(value, util.text_type) value = exec_sql(connection, "SELECT 'hello' FROM DUAL").scalar() assert isinstance(value, util.text_type) diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py index c0eb4410c..6e665c71b 100644 --- a/test/dialect/postgresql/test_dialect.py +++ b/test/dialect/postgresql/test_dialect.py @@ -35,7 +35,6 @@ from sqlalchemy.dialects.postgresql.psycopg2 import EXECUTEMANY_BATCH from sqlalchemy.dialects.postgresql.psycopg2 import EXECUTEMANY_PLAIN from sqlalchemy.dialects.postgresql.psycopg2 import EXECUTEMANY_VALUES from sqlalchemy.engine import cursor as _cursor -from sqlalchemy.engine import engine_from_config from sqlalchemy.engine import url from sqlalchemy.sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL from sqlalchemy.testing import config @@ -163,44 +162,14 @@ $$ LANGUAGE plpgsql;""" future_connection.dialect.server_version_info, ) - @testing.requires.python3 @testing.requires.psycopg2_compatibility - def test_pg_dialect_no_native_unicode_in_python3(self, testing_engine): + def test_pg_dialect_no_native_unicode_in(self, testing_engine): with testing.expect_raises_message( exc.ArgumentError, "psycopg2 native_unicode mode is required under Python 3", ): testing_engine(options=dict(use_native_unicode=False)) - @testing.requires.python2 - @testing.requires.psycopg2_compatibility - def test_pg_dialect_no_native_unicode_in_python2(self, testing_engine): - e = testing_engine(options=dict(use_native_unicode=False)) - with e.connect() as conn: - eq_( - conn.exec_driver_sql(u"SELECT 'đ voix mâa rĂ©veillĂ©'").scalar(), - u"đ voix mâa rĂ©veillĂ©".encode("utf-8"), - ) - - @testing.requires.python2 - @testing.requires.psycopg2_compatibility - def test_pg_dialect_use_native_unicode_from_config(self): - config = { - "sqlalchemy.url": testing.db.url, - "sqlalchemy.use_native_unicode": "false", - } - - e = engine_from_config(config, _initialize=False) - eq_(e.dialect.use_native_unicode, False) - - config = { - "sqlalchemy.url": testing.db.url, - "sqlalchemy.use_native_unicode": "true", - } - - e = engine_from_config(config, _initialize=False) - eq_(e.dialect.use_native_unicode, True) - def test_psycopg2_empty_connection_string(self): dialect = psycopg2_dialect.dialect() u = url.make_url("postgresql://") diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index e5f027790..ebb4d4b12 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -2403,7 +2403,6 @@ class ArrayEnum(fixtures.TestBase): eq_(connection.execute(sel).fetchall(), [(["foo", "bar"],)]) @_enum_combinations - @testing.requires.python3 def test_array_of_enums_native_roundtrip( self, array_of_enum_fixture, connection, array_cls, enum_cls ): diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index ed0f11907..eb68c0c6f 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -597,7 +597,6 @@ class DialectTest( ) ) - @testing.requires.insert_order_dicts @testing.only_on("sqlite+pysqlite") def test_isolation_level_message(self): # needs to test that all three words are present and we also @@ -714,9 +713,6 @@ class DialectTest( @testing.provide_metadata def test_description_encoding(self, connection): - # amazingly, pysqlite seems to still deliver cursor.description - # as encoded bytes in py2k - t = Table( "x", self.metadata, diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 9296164fb..aeb6b4849 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -391,15 +391,8 @@ class ExecuteTest(fixtures.TablesTest): with testing.db.connect() as conn: assert_raises_message( tsa.exc.StatementError, - util.u( - "A value is required for bind parameter 'uname'\n" - r".*SELECT users.user_name AS .m\xe9il." - ) - if util.py2k - else util.u( - "A value is required for bind parameter 'uname'\n" - ".*SELECT users.user_name AS .mĂ©il." - ), + "A value is required for bind parameter 'uname'\n" + ".*SELECT users.user_name AS .mĂ©il.", conn.execute, select(users.c.user_name.label(name)).where( users.c.user_name == bindparam("uname") @@ -413,14 +406,7 @@ class ExecuteTest(fixtures.TablesTest): message = util.u("some message mĂ©il").encode("utf-8") err = tsa.exc.SQLAlchemyError(message) - if util.py2k: - # string passes it through - eq_(str(err), message) - - # unicode accessor decodes to utf-8 - eq_(unicode(err), util.u("some message mĂ©il")) # noqa F821 - else: - eq_(str(err), util.u("some message mĂ©il")) + eq_(str(err), util.u("some message mĂ©il")) def test_stmt_exception_bytestring_latin1(self): # uncommon case for Py3K, bytestring object passed @@ -428,14 +414,7 @@ class ExecuteTest(fixtures.TablesTest): message = util.u("some message mĂ©il").encode("latin-1") err = tsa.exc.SQLAlchemyError(message) - if util.py2k: - # string passes it through - eq_(str(err), message) - - # unicode accessor decodes to utf-8 - eq_(unicode(err), util.u("some message m\\xe9il")) # noqa F821 - else: - eq_(str(err), util.u("some message m\\xe9il")) + eq_(str(err), util.u("some message m\\xe9il")) def test_stmt_exception_unicode_hook_unicode(self): # uncommon case for Py2K, Unicode object passed @@ -443,18 +422,12 @@ class ExecuteTest(fixtures.TablesTest): message = util.u("some message mĂ©il") err = tsa.exc.SQLAlchemyError(message) - if util.py2k: - eq_(unicode(err), util.u("some message mĂ©il")) # noqa F821 - else: - eq_(str(err), util.u("some message mĂ©il")) + eq_(str(err), util.u("some message mĂ©il")) def test_stmt_exception_object_arg(self): err = tsa.exc.SQLAlchemyError(Foo()) eq_(str(err), "foo") - if util.py2k: - eq_(unicode(err), util.u("fóó")) # noqa F821 - def test_stmt_exception_str_multi_args(self): err = tsa.exc.SQLAlchemyError("some message", 206) eq_(str(err), "('some message', 206)") @@ -731,8 +704,7 @@ class ExecuteTest(fixtures.TablesTest): class UnicodeReturnsTest(fixtures.TestBase): - @testing.requires.python3 - def test_unicode_test_not_in_python3(self): + def test_unicode_test_not_in(self): eng = engines.testing_engine() eng.dialect.returns_unicode_strings = String.RETURNS_UNKNOWN @@ -742,25 +714,6 @@ class UnicodeReturnsTest(fixtures.TestBase): eng.connect, ) - @testing.requires.python2 - def test_unicode_test_fails_warning(self): - class MockCursor(engines.DBAPIProxyCursor): - def execute(self, stmt, params=None, **kw): - if "test unicode returns" in stmt: - raise self.engine.dialect.dbapi.DatabaseError("boom") - else: - return super(MockCursor, self).execute(stmt, params, **kw) - - eng = engines.proxying_engine(cursor_cls=MockCursor) - with testing.expect_warnings( - "Exception attempting to detect unicode returns" - ): - eng.connect() - - # because plain varchar passed, we don't know the correct answer - eq_(eng.dialect.returns_unicode_strings, String.RETURNS_CONDITIONAL) - eng.dispose() - class ConvenienceExecuteTest(fixtures.TablesTest): __backend__ = True diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index d24654f44..0cc7c0508 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -389,7 +389,6 @@ class URLTest(fixtures.TestBase): ), ) - @testing.requires.python3 def test_arg_validation_all_seven_posn(self): """test #7130""" with testing.expect_deprecated( diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 43ec9cc3f..1c730334a 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -744,7 +744,7 @@ class PoolEventsTest(PoolTestBase): assert canary.call_args_list[0][0][0] is dbapi_con assert canary.call_args_list[0][0][2] is exc - @testing.combinations((True, testing.requires.python3), (False,)) + @testing.combinations((True,), (False,)) def test_checkin_event_gc(self, detach_gced): p, canary = self._checkin_event_fixture(_is_asyncio=detach_gced) @@ -1634,7 +1634,7 @@ class QueuePoolTest(PoolTestBase): self._assert_cleanup_on_pooled_reconnect(dbapi, p) - @testing.combinations((True, testing.requires.python3), (False,)) + @testing.combinations((True,), (False,)) def test_userspace_disconnectionerror_weakref_finalizer(self, detach_gced): dbapi, pool = self._queuepool_dbapi_fixture( pool_size=1, max_overflow=2, _is_asyncio=detach_gced diff --git a/test/ext/asyncio/test_engine_py3k.py b/test/ext/asyncio/test_engine_py3k.py index 3c260f9e5..44cf9388c 100644 --- a/test/ext/asyncio/test_engine_py3k.py +++ b/test/ext/asyncio/test_engine_py3k.py @@ -232,7 +232,6 @@ class AsyncEngineTest(EngineFixture): is_false(async_engine == None) @async_test - @testing.requires.python37 async def test_no_attach_to_event_loop(self, testing_engine): """test #6409""" diff --git a/test/ext/asyncio/test_scoping_py3k.py b/test/ext/asyncio/test_scoping_py3k.py index 065dc7442..d722320f3 100644 --- a/test/ext/asyncio/test_scoping_py3k.py +++ b/test/ext/asyncio/test_scoping_py3k.py @@ -1,7 +1,6 @@ import sqlalchemy as sa from sqlalchemy import func from sqlalchemy import select -from sqlalchemy import testing from sqlalchemy.ext.asyncio import async_scoped_session from sqlalchemy.ext.asyncio import AsyncSession as _AsyncSession from sqlalchemy.orm import sessionmaker @@ -12,7 +11,6 @@ from .test_session_py3k import AsyncFixture class AsyncScopedSessionTest(AsyncFixture): - @testing.requires.python37 @async_test async def test_basic(self, async_engine): from asyncio import current_task @@ -46,7 +44,6 @@ class AsyncScopedSessionTest(AsyncFixture): await AsyncSession.flush() eq_(await conn.scalar(stmt), 0) - @testing.requires.python37 def test_attributes(self, async_engine): from asyncio import current_task diff --git a/test/orm/declarative/test_basic.py b/test/orm/declarative/test_basic.py index a405b9f2c..0e3a48458 100644 --- a/test/orm/declarative/test_basic.py +++ b/test/orm/declarative/test_basic.py @@ -469,22 +469,21 @@ class DeclarativeTest(DeclarativeTestBase): ][0] is_(ck.columns.cprop, Bar.__table__.c.cprop) - if testing.requires.python3.enabled: - # test the existing failure case in case something changes - def go(): - class Bat(Base): - __tablename__ = "bat" + # test the existing failure case in case something changes + def go(): + class Bat(Base): + __tablename__ = "bat" - id = Column(Integer, primary_key=True) - cprop = deferred(Column(Integer)) + id = Column(Integer, primary_key=True) + cprop = deferred(Column(Integer)) - # we still can't do an expression like - # "cprop > 5" because the column property isn't - # a full blown column + # we still can't do an expression like + # "cprop > 5" because the column property isn't + # a full blown column - __table_args__ = (CheckConstraint(cprop > 5),) + __table_args__ = (CheckConstraint(cprop > 5),) - assert_raises(TypeError, go) + assert_raises(TypeError, go) def test_relationship_level_msg_for_invalid_callable(self): class A(Base): @@ -2326,7 +2325,6 @@ class DeclarativeTest(DeclarativeTestBase): mt = MyTable(id=5) eq_(mt.id, 5) - @testing.requires.python36 def test_kw_support_in_declarative_meta_init(self): # This will not fail if DeclarativeMeta __init__ supports **kw diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index 3473dcf50..90bb606cb 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -80,12 +80,7 @@ class Canary(object): class OrderedDictFixture(object): @testing.fixture def ordered_dict_mro(self): - if testing.requires.python37.enabled: - return type("ordered", (collections.MappedCollection,), {}) - else: - return type( - "ordered", (util.OrderedDict, collections.MappedCollection), {} - ) + return type("ordered", (collections.MappedCollection,), {}) class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): diff --git a/test/orm/test_dataclasses_py3k.py b/test/orm/test_dataclasses_py3k.py index a9b0ba58d..706024eb5 100644 --- a/test/orm/test_dataclasses_py3k.py +++ b/test/orm/test_dataclasses_py3k.py @@ -26,8 +26,6 @@ except ImportError: class DataclassesTest(fixtures.MappedTest, testing.AssertsCompiledSQL): - __requires__ = ("dataclasses",) - @classmethod def define_tables(cls, metadata): Table( @@ -232,8 +230,6 @@ class DataclassesTest(fixtures.MappedTest, testing.AssertsCompiledSQL): class PlainDeclarativeDataclassesTest(DataclassesTest): - __requires__ = ("dataclasses",) - run_setup_classes = "each" run_setup_mappers = "each" @@ -296,8 +292,6 @@ class PlainDeclarativeDataclassesTest(DataclassesTest): class FieldEmbeddedDeclarativeDataclassesTest( fixtures.DeclarativeMappedTest, DataclassesTest ): - __requires__ = ("dataclasses",) - @classmethod def setup_classes(cls): declarative = cls.DeclarativeBasic.registry.mapped @@ -391,8 +385,6 @@ class FieldEmbeddedDeclarativeDataclassesTest( class FieldEmbeddedWMixinTest(FieldEmbeddedDeclarativeDataclassesTest): - __requires__ = ("dataclasses",) - @classmethod def setup_classes(cls): declarative = cls.DeclarativeBasic.registry.mapped @@ -521,8 +513,6 @@ class FieldEmbeddedWMixinTest(FieldEmbeddedDeclarativeDataclassesTest): class FieldEmbeddedMixinWLambdaTest(fixtures.DeclarativeMappedTest): - __requires__ = ("dataclasses",) - @classmethod def setup_classes(cls): declarative = cls.DeclarativeBasic.registry.mapped @@ -699,8 +689,6 @@ class FieldEmbeddedMixinWLambdaTest(fixtures.DeclarativeMappedTest): class FieldEmbeddedMixinWDeclaredAttrTest(FieldEmbeddedMixinWLambdaTest): - __requires__ = ("dataclasses",) - @classmethod def setup_classes(cls): declarative = cls.DeclarativeBasic.registry.mapped @@ -840,8 +828,6 @@ class FieldEmbeddedMixinWDeclaredAttrTest(FieldEmbeddedMixinWLambdaTest): class PropagationFromMixinTest(fixtures.TestBase): - __requires__ = ("dataclasses",) - def test_propagate_w_plain_mixin_col(self, run_test): @dataclasses.dataclass class CommonMixin: @@ -940,8 +926,6 @@ class PropagationFromMixinTest(fixtures.TestBase): class PropagationFromAbstractTest(fixtures.TestBase): - __requires__ = ("dataclasses",) - def test_propagate_w_plain_mixin_col(self, run_test): @dataclasses.dataclass class BaseType: diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index deb196897..061cad7e3 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -6310,53 +6310,6 @@ class RequirementsTest(fixtures.MappedTest): Column("value", String(10)), ) - if util.py2k: - - def test_baseclass_map_imperatively(self): - ht1 = self.tables.ht1 - - class OldStyle: - pass - - assert_raises( - sa.exc.ArgumentError, - self.mapper_registry.map_imperatively, - OldStyle, - ht1, - ) - - assert_raises( - sa.exc.ArgumentError, - self.mapper_registry.map_imperatively, - 123, - ) - - def test_baseclass_legacy_mapper(self): - ht1 = self.tables.ht1 - - class OldStyle: - pass - - assert_raises( - sa.exc.ArgumentError, - mapper, - OldStyle, - ht1, - ) - - assert_raises( - sa.exc.ArgumentError, - mapper, - 123, - ) - - class NoWeakrefSupport(str): - pass - - # TODO: is weakref support detectable without an instance? - # self.assertRaises( - # sa.exc.ArgumentError, mapper, NoWeakrefSupport, t2) - class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest): __dialect__ = "default" diff --git a/test/orm/test_inspect.py b/test/orm/test_inspect.py index 3cc7640cf..0917544cb 100644 --- a/test/orm/test_inspect.py +++ b/test/orm/test_inspect.py @@ -515,7 +515,6 @@ class %s(SuperCls): exec(code, glbls) return names, glbls[clsname] - @testing.requires.pep520 def test_all_orm_descriptors_pep520_noinh(self): from sqlalchemy.orm import declarative_base @@ -528,7 +527,6 @@ class %s(SuperCls): eq_(MyClass.__mapper__.all_orm_descriptors.keys(), names) - @testing.requires.pep520 def test_all_orm_descriptors_pep520_onelevel_inh(self): from sqlalchemy.orm import declarative_base @@ -549,7 +547,6 @@ class %s(SuperCls): sub_names + base_names, ) - @testing.requires.pep520 def test_all_orm_descriptors_pep520_classical(self): class MyClass(object): pass diff --git a/test/orm/test_instrumentation.py b/test/orm/test_instrumentation.py index a2d4aa9ca..9158b5115 100644 --- a/test/orm/test_instrumentation.py +++ b/test/orm/test_instrumentation.py @@ -613,8 +613,6 @@ class NativeInstrumentationTest(fixtures.MappedTest): class Py3KFunctionInstTest(fixtures.ORMTest): - __requires__ = ("python3",) - def _instrument(self, cls): manager = instrumentation.register_class(cls) canary = [] diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py index 4d620ac48..ec1ef3796 100644 --- a/test/orm/test_mapper.py +++ b/test/orm/test_mapper.py @@ -415,11 +415,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): m = self.mapper(Foo, foo_t) class DontCompareMeToString(int): - if util.py2k: - - def __lt__(self, other): - assert not isinstance(other, basestring) # noqa - return int(self) < other + pass foos = [Foo(id_="f%d" % i) for i in range(5)] states = [attributes.instance_state(f) for f in foos] diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 29ba24b1b..b8269d76d 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -1675,7 +1675,6 @@ class OperatorTest(QueryTest, AssertsCompiledSQL): (operators.mul, "*"), (operators.sub, "-"), (operators.truediv, "/"), - (operators.div, "/"), argnames="py_op, sql_op", id_="ar", ) diff --git a/test/orm/test_scoping.py b/test/orm/test_scoping.py index 87f0a2aae..1558da655 100644 --- a/test/orm/test_scoping.py +++ b/test/orm/test_scoping.py @@ -168,8 +168,8 @@ class ScopedSessionTest(fixtures.MappedTest): eq_(mock_object_session.mock_calls, [mock.call("foo")]) @testing.combinations( - ("style1", testing.requires.python3), - ("style2", testing.requires.python3), + "style1", + "style2", "style3", "style4", ) diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py index b7062cf42..64cac988b 100644 --- a/test/orm/test_transaction.py +++ b/test/orm/test_transaction.py @@ -860,33 +860,6 @@ class SessionTransactionTest(fixtures.RemovesEvents, FixtureTest): # new in 1.4 is_(session._legacy_transaction(), None) - @testing.requires.python2 - @testing.requires.savepoints_w_release - def test_report_primary_error_when_rollback_fails(self): - User, users = self.classes.User, self.tables.users - - self.mapper_registry.map_imperatively(User, users) - - with fixture_session() as session: - - with expect_warnings( - ".*during handling of a previous exception.*" - ): - session.begin_nested() - savepoint = session.connection()._nested_transaction._savepoint - - # force the savepoint to disappear - session.connection().dialect.do_release_savepoint( - session.connection(), savepoint - ) - - # now do a broken flush - session.add_all([User(id=1), User(id=1)]) - - assert_raises_message( - sa_exc.DBAPIError, "ROLLBACK TO SAVEPOINT ", session.flush - ) - class _LocalFixture(FixtureTest): run_setup_mappers = "once" diff --git a/test/sql/test_compare.py b/test/sql/test_compare.py index 2db7a5744..8ec88a760 100644 --- a/test/sql/test_compare.py +++ b/test/sql/test_compare.py @@ -1592,7 +1592,7 @@ class CompareClausesTest(fixtures.TestBase): ) l2 = ClauseList( - table_c.c.x, table_c.c.y, table_d.c.y, operator=operators.div + table_c.c.x, table_c.c.y, table_d.c.y, operator=operators.truediv ) is_false(l1.compare(l2)) diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index c001dc4ef..3bb097714 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -2184,7 +2184,7 @@ class MathOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL): ("add", operator.add, "+"), ("mul", operator.mul, "*"), ("sub", operator.sub, "-"), - ("div", operator.truediv if util.py3k else operator.div, "/"), + ("div", operator.truediv, "/"), ("mod", operator.mod, "%"), id_="iaa", ) @@ -3245,7 +3245,6 @@ class TupleTypingTest(fixtures.TestBase): self._assert_types(expr.right.type.types) # since we want to infer "binary" - @testing.requires.python3 def test_tuple_type_expanding_inference(self): a, b, c = column("a"), column("b"), column("c") @@ -3256,7 +3255,6 @@ class TupleTypingTest(fixtures.TestBase): self._assert_types(expr.right.type.types) - @testing.requires.python3 def test_tuple_type_plain_inference(self): a, b, c = column("a"), column("b"), column("c") diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index e51bdf5a0..67954d9ce 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -13,7 +13,6 @@ from sqlalchemy import select from sqlalchemy import sql from sqlalchemy import Table from sqlalchemy import testing -from sqlalchemy import util from sqlalchemy.engine import default from sqlalchemy.sql import compiler from sqlalchemy.sql import LABEL_STYLE_TABLENAME_PLUS_COL @@ -251,10 +250,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): def test_repr_unicode(self): name = quoted_name(u"ć§ć", None) - if util.py2k: - eq_(repr(name), "'\u59d3\u540d'") - else: - eq_(repr(name), repr(u"ć§ć")) + eq_(repr(name), repr(u"ć§ć")) def test_lower_case_names(self): # Create table with quote defaults diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index 47f26ddab..86aa15f26 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -1139,7 +1139,6 @@ class CursorResultTest(fixtures.TablesTest): eq_(row._mapping[s.c.user_id], 7) eq_(row._mapping[s.c.user_name], "ed") - @testing.requires.python3 def test_ro_mapping_py3k(self, connection): users = self.tables.users @@ -1162,27 +1161,6 @@ class CursorResultTest(fixtures.TablesTest): eq_(odict_row.values(), mapping_row.values()) eq_(odict_row.items(), mapping_row.items()) - @testing.requires.python2 - def test_ro_mapping_py2k(self, connection): - users = self.tables.users - - connection.execute(users.insert(), dict(user_id=1, user_name="foo")) - result = connection.execute(users.select()) - - row = result.first() - dict_row = row._asdict() - - odict_row = collections.OrderedDict( - [("user_id", 1), ("user_name", "foo")] - ) - eq_(dict_row, odict_row) - mapping_row = row._mapping - - eq_(list(mapping_row), list(mapping_row.keys())) - eq_(odict_row.keys(), list(mapping_row.keys())) - eq_(odict_row.values(), list(mapping_row.values())) - eq_(odict_row.items(), list(mapping_row.items())) - @testing.combinations( (lambda result: result), (lambda result: result.first(),), |