MCPcopy
hub / github.com/langroid/langroid / test_settings

Function test_settings

tests/conftest.py:96–127  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

94
95@pytest.fixture(scope="function")
96def test_settings(request):
97 base_settings = dict(
98 debug=request.config.getoption("--show"),
99 cache_type=request.config.getoption("--ct"),
100 stream=not request.config.getoption("--ns"),
101 max_turns=request.config.getoption("--turns"),
102 )
103
104 if request.node.get_closest_marker("fallback"):
105 # we're in a test marked as requiring fallback,
106 # so we re-run with a sequence of settings, mainly
107 # on `chat_model` and `cache`.
108 logger.warning("Running test with fallback settings")
109 models = [request.config.getoption("--m")]
110 if OpenAIChatModel.GPT4o not in models:
111 # we may be using a weaker model, so add GPT4o as first fallback
112 models.append(OpenAIChatModel.GPT4o)
113 models.append(GeminiModel.GEMINI_2_FLASH)
114 caches = [True] + [False] * (len(models) - 1)
115 retry_count = getattr(request.node, "retry_count", 0)
116 model = (
117 models[retry_count]
118 if retry_count < len(models)
119 else request.config.getoption("--m")
120 )
121 cache = caches[retry_count] if retry_count < len(caches) else False
122 logger.warning(f"Retry count: {retry_count}, model: {model}, cache: {cache}")
123 else:
124 model = request.config.getoption("--m")
125 cache = not request.config.getoption("--nc")
126
127 yield Settings(**base_settings, chat_model=model, cache=cache)
128
129
130# Auto-inject this into every test, so we don't need to explicitly

Callers

nothing calls this directly

Calls 1

SettingsClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…