Skip to content

Use __file__-relative paths for test fixtures#1445

Merged
hectorcast-db merged 1 commit into
mainfrom
hectorcastejon/fix-relative-paths-in-tests
May 29, 2026
Merged

Use __file__-relative paths for test fixtures#1445
hectorcast-db merged 1 commit into
mainfrom
hectorcastejon/fix-relative-paths-in-tests

Conversation

@hectorcast-db
Copy link
Copy Markdown
Contributor

@hectorcast-db hectorcast-db commented May 26, 2026

Summary

Two tests hardcode relative paths (tests/testdata/... and databricks/__init__.py) that only resolve when pytest's cwd is the SDK root. Switch them to pathlib.Path(__file__)-based paths so they work no matter where pytest is launched.

Why

Today's upstream invocation (make test from 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 with FileNotFoundError.

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 from pathlib.Path(__file__).parent / \"testdata\".
  • tests/test_init_file.py: open(\"databricks/__init__.py\") replaced with open(pathlib.Path(__file__).parent.parent / \"databricks\" / \"__init__.py\").

How is this tested?

  • make test from the SDK root: 2073 passed, 3 skipped, same baseline as main.
  • pytest tests/test_model_serving_auth.py tests/test_init_file.py from outside the SDK root (e.g. /tmp): now passes (previously fails with FileNotFoundError).

NO_CHANGELOG=true

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.
@hectorcast-db hectorcast-db force-pushed the hectorcastejon/fix-relative-paths-in-tests branch from f989668 to d34e47b Compare May 26, 2026 13:35
@github-actions
Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1445
  • Commit SHA: d34e47bfba0c33ffded0cf12bf578eefa07e0d55

Checks will be approved automatically on success.

@hectorcast-db hectorcast-db changed the title Use __file__-relative path for test_model_serving_auth fixtures Use __file__-relative paths for test fixtures May 26, 2026
@hectorcast-db hectorcast-db requested a review from Divyansh-db May 26, 2026 13:36
@hectorcast-db hectorcast-db added this pull request to the merge queue May 29, 2026
Merged via the queue into main with commit 51de41f May 29, 2026
15 of 18 checks passed
@hectorcast-db hectorcast-db deleted the hectorcastejon/fix-relative-paths-in-tests branch May 29, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants