summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/fixtures.py6
-rw-r--r--lib/sqlalchemy/testing/profiling.py25
-rw-r--r--lib/sqlalchemy/testing/suite/test_insert.py8
-rw-r--r--lib/sqlalchemy/testing/warnings.py74
4 files changed, 103 insertions, 10 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index 2d3b27917..54b1cbb46 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -330,6 +330,12 @@ class _ORMTest(object):
sa.orm.clear_mappers()
+def create_session(**kw):
+ kw.setdefault("autoflush", False)
+ kw.setdefault("expire_on_commit", False)
+ return sa.orm.Session(config.db, **kw)
+
+
class ORMTest(_ORMTest, TestBase):
pass
diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py
index f52827ca5..48e44428b 100644
--- a/lib/sqlalchemy/testing/profiling.py
+++ b/lib/sqlalchemy/testing/profiling.py
@@ -241,17 +241,26 @@ def function_call_count(variance=0.05, times=1, warmup=0):
# likely due to the introduction of __signature__.
from sqlalchemy.util import decorator
+ from sqlalchemy.util import deprecations
+ from sqlalchemy.engine import row
+ from sqlalchemy.testing import mock
@decorator
def wrap(fn, *args, **kw):
- for warm in range(warmup):
- fn(*args, **kw)
-
- timerange = range(times)
- with count_functions(variance=variance):
- for time in timerange:
- rv = fn(*args, **kw)
- return rv
+
+ with mock.patch.object(
+ deprecations, "SQLALCHEMY_WARN_20", False
+ ), mock.patch.object(
+ row.LegacyRow, "_default_key_style", row.KEY_OBJECTS_NO_WARN
+ ):
+ for warm in range(warmup):
+ fn(*args, **kw)
+
+ timerange = range(times)
+ with count_functions(variance=variance):
+ for time in timerange:
+ rv = fn(*args, **kw)
+ return rv
return wrap
diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py
index 74347cc77..7a7eac02f 100644
--- a/lib/sqlalchemy/testing/suite/test_insert.py
+++ b/lib/sqlalchemy/testing/suite/test_insert.py
@@ -225,7 +225,9 @@ class InsertBehaviorTest(fixtures.TablesTest):
)
connection.execute(
- table.insert(inline=True).from_select(
+ table.insert()
+ .inline()
+ .from_select(
("id", "data"),
select(table.c.id + 5, table.c.data).where(
table.c.data.in_(["data2", "data3"])
@@ -253,7 +255,9 @@ class InsertBehaviorTest(fixtures.TablesTest):
)
connection.execute(
- table.insert(inline=True).from_select(
+ table.insert()
+ .inline()
+ .from_select(
("id", "data"),
select(table.c.id + 5, table.c.data).where(
table.c.data.in_(["data2", "data3"])
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index 298b20c11..de5db6467 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -43,6 +43,80 @@ def setup_filters():
message=r"^The (Sybase|firebird) dialect is deprecated and will be",
)
+ # 2.0 deprecation warnings, which we will want to have all of these
+ # be "error" however for I98b8defdf7c37b818b3824d02f7668e3f5f31c94
+ # we are moving one at a time
+ for msg in [
+ #
+ # Core execution
+ #
+ r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) function",
+ r"The current statement is being autocommitted using implicit "
+ "autocommit,",
+ r"The connection.execute\(\) method in SQLAlchemy 2.0 will accept "
+ "parameters as a single dictionary or a single sequence of "
+ "dictionaries only.",
+ r"The Connection.connect\(\) function/method is considered legacy",
+ r".*DefaultGenerator.execute\(\)",
+ #
+ # result sets
+ #
+ r"The Row.keys\(\) function/method",
+ r"Using non-integer/slice indices on Row ",
+ #
+ # Core SQL constructs
+ #
+ r"The FromClause\.select\(\).whereclause parameter is deprecated",
+ r"Set functions such as union\(\), union_all\(\), extract\(\),",
+ r"The legacy calling style of select\(\) is deprecated and will be "
+ "removed",
+ r"The FromClause.select\(\) method will no longer accept keyword "
+ "arguments in version 2.0",
+ r"The Join.select\(\) method will no longer accept keyword arguments "
+ "in version 2.0.",
+ r"The \"whens\" argument to case\(\) is now passed",
+ r"The Join.select\(\).whereclause parameter is deprecated",
+ #
+ # DML
+ #
+ r"The (?:update|delete).whereclause parameter will be removed in "
+ "SQLAlchemy 2.0.",
+ r"The (?:insert|update).values parameter will be removed in "
+ "SQLAlchemy 2.0.",
+ r"The update.preserve_parameter_order parameter will be removed in "
+ "SQLAlchemy 2.0.",
+ r"Passing dialect keyword arguments directly to the "
+ "(?:Insert|Update|Delete) constructor",
+ #
+ # ORM configuration
+ #
+ r"Calling the mapper\(\) function directly outside of a "
+ "declarative registry",
+ r"The ``declarative_base\(\)`` function is now available ",
+ r"The ``has_inherited_table\(\)`` function is now available",
+ r"The ``bind`` argument to declarative_base is deprecated and will "
+ "be removed in SQLAlchemy 2.0.",
+ #
+ # ORM Query
+ #
+ r"The Query\.get\(\) function",
+ r"The Query\.from_self\(\) function",
+ #
+ # ORM Session
+ #
+ r"The Session.autocommit parameter is deprecated ",
+ r".*object is being merged into a Session along the backref "
+ "cascade path",
+ r"Passing bind arguments to Session.execute\(\) as keyword arguments",
+ r"The Session.transaction function/method",
+ r"The merge_result\(\) method is superseded by the "
+ r"merge_frozen_result\(\)",
+ r"The Session.begin.subtransactions flag is deprecated",
+ ]:
+ warnings.filterwarnings(
+ "ignore", message=msg, category=sa_exc.RemovedIn20Warning,
+ )
+
try:
import pytest
except ImportError: