-
Notifications
You must be signed in to change notification settings - Fork 10
Improve make_group/make_acc_group fixture consistency
#50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7b424b9
d93afd3
8ccd960
022d8b0
41e2418
9777e9d
87e48fa
8eb3263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ | |
|
|
||
| import inspect | ||
| from collections.abc import Callable, Generator | ||
| from typing import TypeVar | ||
| from contextlib import contextmanager | ||
| from contextvars import ContextVar | ||
| from typing import Any, TypeVar | ||
| from unittest.mock import MagicMock | ||
|
|
||
| from databricks.labs.lsql.backends import MockBackend | ||
|
|
@@ -21,6 +23,20 @@ def call_fixture(fixture_fn: Callable[..., T], *args, **kwargs) -> T: | |
| return wrapped.obj(*args, **kwargs) | ||
|
|
||
|
|
||
| _FIXTURES: ContextVar[dict[str, Callable[..., T]]] = ContextVar('fixtures') | ||
|
|
||
|
|
||
| @contextmanager | ||
| def fixtures(**kwargs: Callable[..., Any]) -> Generator[None, None, None]: | ||
| prior_fixtures = _FIXTURES.get({}) | ||
| updated_fixtures = {**prior_fixtures, **kwargs} | ||
| token = _FIXTURES.set(updated_fixtures) | ||
| try: | ||
| yield | ||
| finally: | ||
| _FIXTURES.reset(token) | ||
|
||
|
|
||
|
|
||
| class CallContext: | ||
| def __init__(self): | ||
| self._fixtures = { | ||
|
|
@@ -29,6 +45,7 @@ def __init__(self): | |
| 'env_or_skip': self.env_or_skip, | ||
| 'watchdog_remove_after': '2024091313', | ||
| 'watchdog_purge_suffix': 'XXXXX', | ||
| **_FIXTURES.get({}), | ||
| } | ||
|
|
||
| def __getitem__(self, name: str): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.