2025-12-19 08:53:21 +00:00
|
|
|
"""
|
|
|
|
|
Global pytest configuration for all tests.
|
|
|
|
|
|
|
|
|
|
This conftest.py applies to all test directories.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import pytest
|
2026-01-06 22:09:34 +00:00
|
|
|
# import asyncio
|
|
|
|
|
# import tracemalloc
|
|
|
|
|
# import warnings
|
Feat: TrustGraph i18n & Documentation Translation Updates (#781)
Native CLI i18n: The TrustGraph CLI has built-in translation support
that dynamically loads language strings. You can test and use
different languages by simply passing the --lang flag (e.g., --lang
es for Spanish, --lang ru for Russian) or by configuring your
environment's LANG variable.
Automated Docs Translations: This PR introduces autonomously
translated Markdown documentation into several target languages,
including Spanish, Swahili, Portuguese, Turkish, Hindi, Hebrew,
Arabic, Simplified Chinese, and Russian.
2026-04-14 07:07:58 -04:00
|
|
|
import logging
|
2025-12-19 08:53:21 +00:00
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
2026-01-06 22:09:34 +00:00
|
|
|
# Uncomment the lines below to enable asyncio debug mode and tracemalloc
|
|
|
|
|
# for tracing unawaited coroutines and their creation points
|
|
|
|
|
# tracemalloc.start()
|
|
|
|
|
# asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
|
|
|
|
# warnings.simplefilter("always", ResourceWarning)
|
|
|
|
|
# warnings.simplefilter("always", RuntimeWarning)
|
|
|
|
|
|
2025-12-19 08:53:21 +00:00
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
|
|
|
def mock_loki_handler(session_mocker=None):
|
|
|
|
|
"""
|
|
|
|
|
Mock LokiHandler to prevent connection attempts during tests.
|
|
|
|
|
|
|
|
|
|
This fixture runs once per test session and prevents the logging
|
|
|
|
|
module from trying to connect to a Loki server that doesn't exist
|
|
|
|
|
in the test environment.
|
|
|
|
|
"""
|
|
|
|
|
# Try to import logging_loki and mock it if available
|
|
|
|
|
try:
|
|
|
|
|
import logging_loki
|
|
|
|
|
# Create a mock LokiHandler that does nothing
|
|
|
|
|
original_loki_handler = logging_loki.LokiHandler
|
|
|
|
|
|
Feat: TrustGraph i18n & Documentation Translation Updates (#781)
Native CLI i18n: The TrustGraph CLI has built-in translation support
that dynamically loads language strings. You can test and use
different languages by simply passing the --lang flag (e.g., --lang
es for Spanish, --lang ru for Russian) or by configuring your
environment's LANG variable.
Automated Docs Translations: This PR introduces autonomously
translated Markdown documentation into several target languages,
including Spanish, Swahili, Portuguese, Turkish, Hindi, Hebrew,
Arabic, Simplified Chinese, and Russian.
2026-04-14 07:07:58 -04:00
|
|
|
class MockLokiHandler(logging.Handler):
|
2025-12-19 08:53:21 +00:00
|
|
|
"""Mock LokiHandler that doesn't make network calls."""
|
Feat: TrustGraph i18n & Documentation Translation Updates (#781)
Native CLI i18n: The TrustGraph CLI has built-in translation support
that dynamically loads language strings. You can test and use
different languages by simply passing the --lang flag (e.g., --lang
es for Spanish, --lang ru for Russian) or by configuring your
environment's LANG variable.
Automated Docs Translations: This PR introduces autonomously
translated Markdown documentation into several target languages,
including Spanish, Swahili, Portuguese, Turkish, Hindi, Hebrew,
Arabic, Simplified Chinese, and Russian.
2026-04-14 07:07:58 -04:00
|
|
|
|
2025-12-19 08:53:21 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
Feat: TrustGraph i18n & Documentation Translation Updates (#781)
Native CLI i18n: The TrustGraph CLI has built-in translation support
that dynamically loads language strings. You can test and use
different languages by simply passing the --lang flag (e.g., --lang
es for Spanish, --lang ru for Russian) or by configuring your
environment's LANG variable.
Automated Docs Translations: This PR introduces autonomously
translated Markdown documentation into several target languages,
including Spanish, Swahili, Portuguese, Turkish, Hindi, Hebrew,
Arabic, Simplified Chinese, and Russian.
2026-04-14 07:07:58 -04:00
|
|
|
super().__init__()
|
2025-12-19 08:53:21 +00:00
|
|
|
|
|
|
|
|
def emit(self, record):
|
Feat: TrustGraph i18n & Documentation Translation Updates (#781)
Native CLI i18n: The TrustGraph CLI has built-in translation support
that dynamically loads language strings. You can test and use
different languages by simply passing the --lang flag (e.g., --lang
es for Spanish, --lang ru for Russian) or by configuring your
environment's LANG variable.
Automated Docs Translations: This PR introduces autonomously
translated Markdown documentation into several target languages,
including Spanish, Swahili, Portuguese, Turkish, Hindi, Hebrew,
Arabic, Simplified Chinese, and Russian.
2026-04-14 07:07:58 -04:00
|
|
|
return
|
2025-12-19 08:53:21 +00:00
|
|
|
|
|
|
|
|
# Replace the real LokiHandler with our mock
|
|
|
|
|
logging_loki.LokiHandler = MockLokiHandler
|
|
|
|
|
|
|
|
|
|
yield
|
|
|
|
|
|
|
|
|
|
# Restore original after tests
|
|
|
|
|
logging_loki.LokiHandler = original_loki_handler
|
|
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
# If logging_loki isn't installed, no need to mock
|
|
|
|
|
yield
|