Use __file__-relative paths for test fixtures#1445
Merged
Conversation
test_model_serving_auth.py hardcoded "tests/testdata/model-serving- test-token" assuming cwd == SDK root. That works for the upstream `make test` invocation but breaks when pytest is launched from any other directory (e.g. a Bazel test sandbox). Switch to `pathlib.Path(__file__).parent / "testdata" / ...` so the tests resolve their fixtures regardless of cwd.
f989668 to
d34e47b
Compare
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Divyansh-db
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two tests hardcode relative paths (
tests/testdata/...anddatabricks/__init__.py) that only resolve when pytest's cwd is the SDK root. Switch them topathlib.Path(__file__)-based paths so they work no matter where pytest is launched.Why
Today's upstream invocation (
make testfrom the SDK root) is the happy case, so it goes unnoticed. But pytest from any other directory — a different CWD, a CI runner that builds the source tree elsewhere, or a Bazel test sandbox — fails the tests withFileNotFoundError.What changed
Interface changes
None.
Behavioral changes
None (same fixture files, just resolved by absolute path).
Internal changes
tests/test_model_serving_auth.py:\"tests/testdata/model-serving-test-token\"and\"...-v2\"parameters replaced with constants computed frompathlib.Path(__file__).parent / \"testdata\".tests/test_init_file.py:open(\"databricks/__init__.py\")replaced withopen(pathlib.Path(__file__).parent.parent / \"databricks\" / \"__init__.py\").How is this tested?
make testfrom the SDK root: 2073 passed, 3 skipped, same baseline as main.pytest tests/test_model_serving_auth.py tests/test_init_file.pyfrom outside the SDK root (e.g./tmp): now passes (previously fails withFileNotFoundError).NO_CHANGELOG=true