From b420b6bf7d995c39c72505475427590c0e452f69 Mon Sep 17 00:00:00 2001 From: Tejas Kochar Date: Wed, 7 Jan 2026 13:03:33 +0000 Subject: [PATCH 1/3] test to show venv is not being used --- tests/test_venv_usage.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_venv_usage.py diff --git a/tests/test_venv_usage.py b/tests/test_venv_usage.py new file mode 100644 index 000000000..24d81936c --- /dev/null +++ b/tests/test_venv_usage.py @@ -0,0 +1,29 @@ +"""Test to verify that tests are running from within the project's virtual environment. + +This test exists to catch Makefile issues where the venv is created but not actually used. +If this test fails in CI, it means `make test` is using system Python instead of .venv/bin/python. +""" + +import sys + + +def test_running_in_venv(): + """Verify pytest is running from the project's .venv, not system Python.""" + # Log the Python paths being used for visibility in CI output + print(f"\n=== Python Environment Info ===") + print(f"sys.executable: {sys.executable}") + print(f"sys.prefix: {sys.prefix}") + print(f"sys.base_prefix: {sys.base_prefix}") + print(f"================================\n") + + # sys.prefix points to the Python installation being used + # If we're in the venv, it should contain '.venv' + assert '.venv' in sys.prefix, ( + f"Tests are NOT running from the project venv!\n" + f"sys.prefix = {sys.prefix}\n" + f"sys.executable = {sys.executable}\n" + f"This likely means the Makefile is not correctly using the venv it creates." + ) + + assert False, "Test passed, failing to trigger CI failure" + From 244410294e001f6d9c8c2d386163c1afb9929f07 Mon Sep 17 00:00:00 2001 From: Tejas Kochar Date: Wed, 7 Jan 2026 13:04:24 +0000 Subject: [PATCH 2/3] Have Makefile actually use venv --- Makefile | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index c147f4074..8035bb78c 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,41 @@ -dev: - python3 -m venv .venv ifeq ($(OS), Windows_NT) - .venv\Scripts\activate + VENV_BIN = .venv/Scripts else - . .venv/bin/activate + VENV_BIN = .venv/bin endif - pip install '.[dev]' + +dev: + python3 -m venv .venv + $(VENV_BIN)/pip install '.[dev]' install: - pip install . + $(VENV_BIN)/pip install . fmt: - black databricks tests - autoflake -ri databricks tests - isort databricks tests + $(VENV_BIN)/black databricks tests + $(VENV_BIN)/autoflake -ri databricks tests + $(VENV_BIN)/isort databricks tests fmte: - black examples - autoflake -ri examples - isort examples + $(VENV_BIN)/black examples + $(VENV_BIN)/autoflake -ri examples + $(VENV_BIN)/isort examples lint: - pycodestyle databricks - autoflake --check-diff --quiet --recursive databricks + $(VENV_BIN)/pycodestyle databricks + $(VENV_BIN)/autoflake --check-diff --quiet --recursive databricks test: - pytest -m 'not integration and not benchmark' --cov=databricks --cov-report html tests + $(VENV_BIN)/pytest -m 'not integration and not benchmark' --cov=databricks --cov-report html tests integration: - pytest -n auto -m 'integration and not benchmark' --reruns 2 --dist loadgroup --cov=databricks --cov-report html tests + $(VENV_BIN)/pytest -n auto -m 'integration and not benchmark' --reruns 2 --dist loadgroup --cov=databricks --cov-report html tests benchmark: - pytest -m 'benchmark' tests + $(VENV_BIN)/pytest -m 'benchmark' tests coverage: test open htmlcov/index.html clean: - rm -fr dist *.egg-info .pytest_cache build htmlcov + rm -fr dist *.egg-info .pytest_cache build htmlcov .venv From e6a355021d71e69f55ce0b4036c3439938ad92dc Mon Sep 17 00:00:00 2001 From: Tejas Kochar Date: Wed, 7 Jan 2026 13:26:28 +0000 Subject: [PATCH 3/3] fix lint --- tests/test_venv_usage.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_venv_usage.py b/tests/test_venv_usage.py index 24d81936c..6720d0b2f 100644 --- a/tests/test_venv_usage.py +++ b/tests/test_venv_usage.py @@ -18,12 +18,9 @@ def test_running_in_venv(): # sys.prefix points to the Python installation being used # If we're in the venv, it should contain '.venv' - assert '.venv' in sys.prefix, ( + assert ".venv" in sys.prefix, ( f"Tests are NOT running from the project venv!\n" f"sys.prefix = {sys.prefix}\n" f"sys.executable = {sys.executable}\n" f"This likely means the Makefile is not correctly using the venv it creates." ) - - assert False, "Test passed, failing to trigger CI failure" -