Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions tests/test_venv_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""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."
)
Loading