diff options
author | Federico Caselli <cfederico87@gmail.com> | 2021-11-27 09:53:29 +0100 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-29 16:13:15 -0500 |
commit | e8fb73cfb0c765c71e50e7bb0ec92d419076201d (patch) | |
tree | 56aed678ebb78a071e3eb8ac2a2d366701145c3d /lib/sqlalchemy/testing/plugin/bootstrap.py | |
parent | 29c5fba9ad89e53180f0bd2a026742321093105f (diff) | |
download | sqlalchemy-e8fb73cfb0c765c71e50e7bb0ec92d419076201d.tar.gz |
adapt pytest plugin to support pytest v7
Implemented support for the test suite to run correctly under Pytest 7.
Previously, only Pytest 6.x was supported for Python 3, however the version
was not pinned on the upper bound in tox.ini. Pytest is not pinned in
tox.ini to be lower than version 8 so that SQLAlchemy versions released
with the current codebase will be able to be tested under tox without
changes to the environment. Much thanks to the Pytest developers for
their help with this issue.
Change-Id: I3b12166199be2b913ee16e78b3ebbff415654396
Diffstat (limited to 'lib/sqlalchemy/testing/plugin/bootstrap.py')
-rw-r--r-- | lib/sqlalchemy/testing/plugin/bootstrap.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/sqlalchemy/testing/plugin/bootstrap.py b/lib/sqlalchemy/testing/plugin/bootstrap.py index 1220561e8..e4f6058e1 100644 --- a/lib/sqlalchemy/testing/plugin/bootstrap.py +++ b/lib/sqlalchemy/testing/plugin/bootstrap.py @@ -12,11 +12,10 @@ of the same test environment and standard suites available to SQLAlchemy/Alembic themselves without the need to ship/install a separate package outside of SQLAlchemy. -NOTE: copied/adapted from SQLAlchemy main for backwards compatibility; -this should be removable when Alembic targets SQLAlchemy 1.0.0. """ +import importlib.util import os import sys @@ -27,14 +26,12 @@ to_bootstrap = locals()["to_bootstrap"] def load_file_as_module(name): path = os.path.join(os.path.dirname(bootstrap_file), "%s.py" % name) - if sys.version_info >= (3, 3): - from importlib import machinery - mod = machinery.SourceFileLoader(name, path).load_module() - else: - import imp - - mod = imp.load_source(name, path) + spec = importlib.util.spec_from_file_location(name, path) + assert spec is not None + assert spec.loader is not None + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) return mod |