mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-06 17:01:07 -04:00
b9e3cacb0e
Added support for Python 3.14+ template strings (t-strings) via the new :func:`_sql.tstring` construct, as defined in :pep:`750`. This feature allows for ergonomic SQL statement construction by automatically interpolating Python values and SQLAlchemy expressions within template strings. Part of the challenge here is the syntax only works on py314, so we have to exclude the test file at many levels when py314 is not used. not sure yet how i want to adjust pep8 tests and rules for this. Fixes: #12548 Change-Id: Ia060d1387ff452fe4f5d924f683529a22a8e1f72
60 lines
1.5 KiB
Python
Executable File
60 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python
|
|
"""
|
|
pytest plugin script.
|
|
|
|
This script is an extension to pytest which
|
|
installs SQLAlchemy's testing plugin into the local environment.
|
|
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
|
|
os.environ["SQLALCHEMY_WARN_20"] = "true"
|
|
|
|
collect_ignore_glob = []
|
|
|
|
# omit py314.py test files on earlier versions of python
|
|
if sys.version_info < (3, 14):
|
|
collect_ignore_glob.append("*_py314.py")
|
|
|
|
# this requires that sqlalchemy.testing was not already
|
|
# imported in order to work
|
|
pytest.register_assert_rewrite("sqlalchemy.testing.assertions")
|
|
|
|
|
|
if not sys.flags.no_user_site:
|
|
# this is needed so that test scenarios like "python setup.py test"
|
|
# work correctly, as well as plain "pytest". These commands assume
|
|
# that the package in question is locally present, but since we have
|
|
# ./lib/, we need to punch that in.
|
|
# We check no_user_site to honor the use of this flag.
|
|
sys.path.insert(
|
|
0,
|
|
os.path.abspath(
|
|
os.path.join(
|
|
os.path.dirname(os.path.abspath(__file__)), "..", "lib"
|
|
)
|
|
),
|
|
)
|
|
|
|
# use bootstrapping so that test plugins are loaded
|
|
# without touching the main library before coverage starts
|
|
bootstrap_file = os.path.join(
|
|
os.path.dirname(__file__),
|
|
"..",
|
|
"lib",
|
|
"sqlalchemy",
|
|
"testing",
|
|
"plugin",
|
|
"bootstrap.py",
|
|
)
|
|
|
|
with open(bootstrap_file) as f:
|
|
code = compile(f.read(), "bootstrap.py", "exec")
|
|
to_bootstrap = "pytest"
|
|
exec(code, globals(), locals())
|
|
from sqla_pytestplugin import * # noqa
|