)
def test_nextval_direct(self, connection):
- r = connection.execute(self.tables.seq_pk.c.id.default)
+ r = connection.scalar(self.tables.seq_pk.c.id.default)
eq_(r, testing.db.dialect.default_sequence_base)
@requirements.sequences_optional
schema_translate_map={"alt_schema": config.test_schema}
)
- r = connection.execute(seq)
+ r = connection.scalar(seq)
eq_(r, testing.db.dialect.default_sequence_base)
as we need to delay importing SQLAlchemy until conftest.py has been
processed.
+ NOTE: filters on subclasses of DeprecationWarning or
+ PendingDeprecationWarning have no effect if added here, since pytest
+ will add at each test the following filters
+ ``always::PendingDeprecationWarning`` and ``always::DeprecationWarning``
+ that will take precedence over any added here.
+
"""
- warnings.filterwarnings("ignore", category=exc.SAPendingDeprecationWarning)
- warnings.filterwarnings("error", category=exc.SADeprecationWarning)
warnings.filterwarnings("error", category=exc.SAWarning)
warnings.filterwarnings("always", category=exc.SATestSuiteWarning)
_warnings_warn(msg, exc.SAWarning)
+_not_sa_pattern = re.compile(r"^(?:sqlalchemy\.(?!testing)|alembic\.)")
+
+
def _warnings_warn(
message: Union[str, Warning],
category: Optional[Type[Warning]] = None,
# __globals__ of the decorated string functions we make also.
# we generate this using {"__name__": fn.__module__}
while frame is not None and re.match(
- r"^(?:sqlalchemy\.|alembic\.)", frame.f_globals.get("__name__", "")
+ _not_sa_pattern, frame.f_globals.get("__name__", "")
):
frame = frame.f_back # type: ignore[assignment]
stacklevel += 1