Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /khulnasoft_DockNet /backend /tests /conftest.py
| import os | |
| from typing import Optional | |
| import pytest | |
| import requests | |
| from pydantic import BaseSettings | |
| from pyinstrument import Profiler | |
| from starlette.datastructures import State | |
| from docknet.clients.shared import BaseUrlSession | |
| from docknet.config import settings | |
| from docknet.utils.state_utils import GlobalState, RequestState | |
| class TestSettings(BaseSettings): | |
| """Test Settings.""" | |
| ACTIVATE_TEST_PROFILING: bool = True | |
| POSTGRES_INTEGRATION_TESTS: bool = False | |
| MINIO_INTEGRATION_TESTS: bool = False | |
| AZURE_BLOB_INTEGRATION_TESTS: bool = False | |
| REMOTE_BACKEND_TESTS: bool = True | |
| REMOTE_BACKEND_ENDPOINT: Optional[str] = None | |
| DOCKER_INTEGRATION_TESTS: bool = True | |
| KUBERNETES_INTEGRATION_TESTS: bool = False | |
| test_settings = TestSettings() | |
| def remote_client() -> requests.Session: | |
| """Initializes a remote client using the configured remote backend endpoint.""" | |
| return BaseUrlSession(base_url=test_settings.REMOTE_BACKEND_ENDPOINT) | |
| def global_state() -> GlobalState: | |
| """Initializes global state.""" | |
| state = GlobalState(State()) | |
| state.settings = settings | |
| return state | |
| def request_state() -> RequestState: | |
| """Initializes request state.""" | |
| request_state = RequestState(State()) | |
| return request_state | |
| def auto_profile_tests(request) -> None: # type: ignore | |
| """Activates automatic profiling.""" | |
| if not test_settings.ACTIVATE_TEST_PROFILING: | |
| # Only execute if debug is activated | |
| yield None | |
| else: | |
| profiler = Profiler() | |
| profiler.start() | |
| yield None | |
| profiler.stop() | |
| try: | |
| output_file = "./prof/" + request.node.nodeid.replace("::", "/") + ".html" | |
| os.makedirs(os.path.dirname(output_file), exist_ok=True) | |
| with open(output_file, "w") as f: | |
| f.write(profiler.output_html()) | |
| except Exception: | |
| # Fail silently | |
| pass | |
Xet Storage Details
- Size:
- 2.02 kB
- Xet hash:
- 1fbd3a5aadd301e790be8e6bd058d69ef7d34084954caa1f4e7c4669ecf9c8d9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.