:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(tests): warm the urlconf before the first frozen clock (#97854)
posthog[bot]623311d4c75b
diff --git a/conftest.py b/conftest.pyindex be3d2c8fe76a..43da0f3b3884 100644--- a/conftest.py+++ b/conftest.py@@ -1,5 +1,6 @@import gcimport warnings+import importlibimport pytest@@ -229,6 +230,15 @@ def _cheapen_freezegun_module_hash() -> None:api._get_module_attributes_hash = _fast_module_attributes_hash # ty: ignore[invalid-assignment]+def _warm_urlconf() -> None:+ # The URLconf builds the API router lazily on the first request. Under freeze_time that+ # build fails for any pydantic model whose base was imported before the freeze: the+ # inherited datetime annotation no longer matches the rebound datetime.datetime.+ from django.conf import settings # noqa: PLC0415 — deferred until collection finishes++ importlib.import_module(settings.ROOT_URLCONF)++def pytest_configure(config) -> None:_cache_reverse_rel_identity()_cache_select_masks()@@ -238,7 +248,9 @@ def pytest_configure(config) -> None:_cheapen_freezegun_module_hash()-def pytest_collection_finish() -> None:+def pytest_collection_finish(session) -> None:+ if session.items and not session.config.option.collectonly:+ _warm_urlconf()_end_gc_boot_window()diff --git a/ee/hogai/chat_agent/taxonomy/types.py b/ee/hogai/chat_agent/taxonomy/types.pyindex db767568076f..830ed1e00ff1 100644--- a/ee/hogai/chat_agent/taxonomy/types.py+++ b/ee/hogai/chat_agent/taxonomy/types.py@@ -3,7 +3,7 @@ from typing import Generic, Optional, TypeVarfrom langchain_core.messages import BaseMessage as LangchainBaseMessagefrom langgraph.graph import END, START-from pydantic import BaseModel, ConfigDict, Field+from pydantic import BaseModel, Fieldfrom ee.hogai.utils.types.base import BaseStateWithIntermediateSteps, BaseStateWithMessages@@ -16,9 +16,6 @@ class TaxonomyAgentState(BaseStateWithIntermediateSteps, BaseStateWithMessages,Only includes fields relevant to filter options generation."""- # URL imports can run inside frozen-time tests, where Pydantic sees Freezegun's datetime as arbitrary.- model_config = ConfigDict(arbitrary_types_allowed=True)-output: Optional[OutputType | str] = Field(default=None)"""The output of the taxonomy agent.