databrickslabs / databrickslabs/pytester
The instance of `WorkspaceClient` created by the `ws` fixture is not shared across test functions
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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