summaryrefslogtreecommitdiff
path: root/test/base/test_utils.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-09-04 21:44:46 +0200
committerFederico Caselli <cfederico87@gmail.com>2022-09-05 22:32:14 +0200
commit741534d840daeeba73aad1703b5bdeb3a0b86db9 (patch)
tree93137388403c76735852bd66a214030a30c75269 /test/base/test_utils.py
parent5caf49ef11aca75541691b7a6fe67b78fa673f93 (diff)
downloadsqlalchemy-741534d840daeeba73aad1703b5bdeb3a0b86db9.tar.gz
Improve compiled extension detection
Ensure that all cython extension are imported by the compied detection logic. This is required since cython extensions moduels are marked as optional in the install, so it's possible that only some of them are compiled. The extensions are enabled only if all of them are correctly compiled Change-Id: I355cbac06f5c7a47d35661f42ebab3b0156c1965
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r--test/base/test_utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py
index 98451cc4f..27945f236 100644
--- a/test/base/test_utils.py
+++ b/test/base/test_utils.py
@@ -2,6 +2,7 @@
import copy
import inspect
+from pathlib import Path
import pickle
import sys
@@ -33,6 +34,8 @@ from sqlalchemy.util import langhelpers
from sqlalchemy.util import preloaded
from sqlalchemy.util import WeakSequence
from sqlalchemy.util._collections import merge_lists_w_ordering
+from sqlalchemy.util._has_cy import _import_cy_extensions
+from sqlalchemy.util._has_cy import HAS_CYEXTENSION
class WeakSequenceTest(fixtures.TestBase):
@@ -3346,3 +3349,18 @@ class MethodOveriddenTest(fixtures.TestBase):
pass
is_true(util.method_is_overridden(HoHo(), Bat.bar))
+
+
+class CyExtensionTest(fixtures.TestBase):
+ @testing.only_if(lambda: HAS_CYEXTENSION, "No Cython")
+ def test_all_cyext_imported(self):
+ ext = _import_cy_extensions()
+ lib_folder = (Path(__file__).parent / ".." / ".." / "lib").resolve()
+ sa_folder = lib_folder / "sqlalchemy"
+ cython_files = [f.resolve() for f in sa_folder.glob("**/*.pyx")]
+ eq_(len(ext), len(cython_files))
+ names = {
+ ".".join(f.relative_to(lib_folder).parts).replace(".pyx", "")
+ for f in cython_files
+ }
+ eq_({m.__name__ for m in ext}, set(names))