Hardening: Streamlined testing infrastructure, unified toolkit, and established English TDD standards

This commit is contained in:
2026-04-21 10:17:27 +02:00
parent ee3022e95d
commit fff9ec5b0a
9 changed files with 322 additions and 118 deletions

View File

@@ -2,6 +2,12 @@ import pytest
import logging
import os
from unittest.mock import MagicMock
def pytest_addoption(parser):
parser.addoption(
"--live", action="store_true", default=False, help="run tests against a live ADB device (disable DeviceFacade mocks)"
)
MagicMock.app_id = "com.instagram.android"
MagicMock._get_current_app = MagicMock(return_value="com.instagram.android")
@@ -44,7 +50,10 @@ def mock_logger():
return logging.getLogger("test")
@pytest.fixture
def device():
def device(request):
if request.config.getoption("--live"):
from GramAddict.core.device_facade import create_device
return create_device("emulator-5554", "com.instagram.android")
return create_mock_device()
@pytest.fixture(autouse=True)
@@ -68,7 +77,10 @@ def reset_singletons():
yield
@pytest.fixture(autouse=True)
def telepathic_mock(monkeypatch):
def telepathic_mock(monkeypatch, request):
if request.config.getoption("--live"):
# TelepathicEngine is a singleton, allow it to run natively
return None
import GramAddict.core.telepathic_engine
engine = create_mock_telepathic_engine()
monkeypatch.setattr(GramAddict.core.telepathic_engine.TelepathicEngine, "get_instance", lambda: engine)