From 5285a065867f68a8c35c634327bf8a8840ab2875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iy=C3=A1n=20M=C3=A9ndez=20Veiga?= Date: Sun, 2 Feb 2025 10:16:49 +0100 Subject: [PATCH] Find module path at runtime Currently, this test only passes if you run the test while being in the source repository. Trying to run the test after installing the generated wheel package in a different directory will fail because "./constraint" may not exist, or worse, give a false failure since the shared libraries might exist in the wheel package but not in the source directory. --- tests/test_compilation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_compilation.py b/tests/test_compilation.py index dc67b2b..90fbf40 100644 --- a/tests/test_compilation.py +++ b/tests/test_compilation.py @@ -3,15 +3,15 @@ def test_if_compiled(): """Test whether C-extensions are succesfully ran, if enabled.""" - from constraint import check_if_compiled + import constraint # check if the .so files are commented - dir = Path("./constraint") + dir = Path(constraint.__file__).resolve().parent assert dir.exists() files = list(dir.glob("_*.so")) # check if the code uses C-extensions if len(files) > 0: - assert check_if_compiled() is False + assert constraint.check_if_compiled() is False else: - assert check_if_compiled() + assert constraint.check_if_compiled()