-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Background / Problem
The framework leans on the legacy SessionStore singleton, which silently stuffs attributes into a shared dict via setattr. This hides dependencies, is fragile under parallel execution (xdist workers, threads), and makes state flow opaque. It also forces consumers to rely on environment variables/global state, complicating testing and extension.
What’s Needed
- Introduce a dataclass-based execution context (e.g., SessionContext) that holds state for tests, drivers, reporting, etc.
- Expose that context intentionally - either passed into hooks/services or retrieved via a registry/context manage - rather than via a global singleton.
- Guard attribute writes: retire free-form setattr in SessionStore (or remove the class entirely) in favor of an allowlist or explicit API that maps to the context fields.
- Update hooks (pytest_* modules) and downstream layers (UI clients, reporting, config utils) to depend on the explicit context.
- Ensure compatibility during migration: maintain a compatibility wrapper if needed while consumers are gradually moved.
Acceptance Criteria
- Execution state is represented by a typed context object rather than the current dict-backed singleton.
- Hooks receive or obtain that context explicitly; no new code writes arbitrary attributes on SessionStore.
- Attribute access is validated - attempts to set unknown properties raise errors (guarded allowlist or explicit setter methods).
- All existing functionality (report generation, step decorators, UI driver management, etc.) works without relying on environment variables or SessionStore().storage.
Out of Scope / Follow-ups (optional)
- Migrating to a contextvars/per-worker registry for thread/process isolation (tracked separately if needed).
- Removing the singleton entirely once all consumers depend on the new context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels