databrickslabs / databrickslabs/pytester

The instance of `WorkspaceClient` created by the `ws` fixture is not shared across test functions

Open Beginner friendly
#284 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
139
Forks
16
PR merge metrics
No merged PRs in 30d

Description

The documentation for the ws fixture says:

This fixture initializes a Databricks WorkspaceClient object, which can be used to interact with the Databricks workspace API. The created instance of WorkspaceClient is shared across all test functions within the test session.

This is not true. The fixture uses the default "function" scope, see the pytest documentation:

function: the default scope, the fixture is destroyed at the end of the test.

This can be shown with a simple example:

def test_ws(ws):
    print(id(ws))

def test_ws_2(ws):
    print(id(ws))

When run with pytest --capture=no, we see two different object ids for the two instances created.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ws fixture declaration and the documentation text quoted in the issue. Run the two test functions with pytest --capture=no and compare the observed behavior with the documented scope. Done means the fixture's documented sharing behavior matches its actual scope, with the example serving as a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, testing-qa
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.