status#
- class Status(*, state: str = 'PENDING', category: str = 'NONE', status: str = 'NONE', reason: str | None = None, code: int = -1)#
Bases:
objectLightweight status object for test cases.
Examples
status = Status(status=’SUCCESS’) status = Status(status=’SUCCESS’, code=42) # Custom code status = Status(status=’SUCCESS’, reason=”All tests passed”) status = Status.SUCCESS()
# JSON serialization json_str = json.dumps(status.to_dict()) status2 = Status.from_dict(json.loads(json_str))
- STATES: tuple[str, ...] = ('PENDING', 'READY', 'RUNNING', 'NOTRUN', 'COMPLETE')#
- TERMINAL_STATES: tuple[str, str] = ('NOTRUN', 'COMPLETE')#
- CATEGORIES: tuple[str, ...] = ('PASS', 'FAIL', 'CANCEL', 'SKIP', 'NONE')#
- OUTCOMES_BY_CATEGORY: dict[str, tuple[str, ...]] = {'CANCEL': ('CANCELLED', 'INTERRUPTED'), 'FAIL': ('DIFFED', 'FAILED', 'ERROR', 'BROKEN', 'TIMEOUT', 'INVALID'), 'NONE': ('NONE',), 'PASS': ('SUCCESS', 'XDIFF', 'XFAIL'), 'SKIP': ('SKIPPED', 'BLOCKED')}#
- OUTCOME_TO_CATEGORY: dict[str, str] = {'BLOCKED': 'SKIP', 'BROKEN': 'FAIL', 'CANCELLED': 'CANCEL', 'DIFFED': 'FAIL', 'ERROR': 'FAIL', 'FAILED': 'FAIL', 'INTERRUPTED': 'CANCEL', 'INVALID': 'FAIL', 'NONE': 'NONE', 'SKIPPED': 'SKIP', 'SUCCESS': 'PASS', 'TIMEOUT': 'FAIL', 'XDIFF': 'PASS', 'XFAIL': 'PASS'}#
- CATEGORY_FOR_STATE: dict[str, set[str]] = {'COMPLETE': {'CANCEL', 'FAIL', 'PASS'}, 'NOTRUN': {'SKIP'}, 'PENDING': {'NONE'}, 'READY': {'NONE'}, 'RUNNING': {'NONE'}}#
- STATE_FOR_CATEGORY: dict[str, str] = {'CANCEL': 'COMPLETE', 'FAIL': 'COMPLETE', 'NONE': 'PENDING', 'PASS': 'COMPLETE', 'SKIP': 'NOTRUN'}#
- DEFAULT_OUTCOME_FOR_CATEGORY = {'CANCEL': 'CANCELLED', 'FAIL': 'DIFFED', 'NONE': 'NONE', 'PASS': 'SUCCESS', 'SKIP': 'SKIPPED'}#
- COLOR_FOR_CATEGORY: dict[str, str] = {'CANCEL': 'bold magenta', 'FAIL': 'bold red', 'NONE': 'bold', 'PASS': 'bold green', 'SKIP': 'yellow'}#
- HTML_COLOR_FOR_CATEGORY: dict[str, str] = {'CANCEL': '#F202FE', 'FAIL': '#FF3333', 'NONE': '', 'PASS': '#02FE20', 'SKIP': '#FEFD02'}#
- CODE_FOR_OUTCOME: dict[str, int] = {'BLOCKED': 81, 'BROKEN': 67, 'CANCELLED': 70, 'DIFFED': 64, 'ERROR': 66, 'FAILED': 65, 'INTERRUPTED': 71, 'INVALID': 69, 'NONE': -1, 'PENDING': -1, 'READY': -1, 'RUNNING': -1, 'SKIPPED': 80, 'SUCCESS': 0, 'TIMEOUT': 68, 'XDIFF': 10, 'XFAIL': 11}#
- GLYPH_FOR_STATE: dict[str, str] = {'PENDING': '○', 'READY': '○', 'RUNNING': '▶'}#
- GLYPH_FOR_STATUS: dict[str, str] = {'BLOCKED': '⊘', 'BROKEN': '✗', 'CANCELLED': '⊘', 'DIFFED': '✗', 'ERROR': '⚠', 'FAILED': '✗', 'INTERRUPTED': '⊘', 'SKIPPED': '⊘', 'SUCCESS': '✓', 'TIMEOUT': '⏱', 'XDIFF': '✓', 'XFAIL': '✓'}#
- state: str = 'COMPLETE'#
- category: str#
- status: str#
- reason: str | None#
- is_terminal() bool#
- property glyph: str#
- property color: str#
- set(*, state=None, category=None, status=None, reason=None, code=-1) None#
- asdict() dict#
Convert Status to a JSON-serializable dictionary.
- Returns:
Dictionary with category, code, and reason (if present)
- classmethod from_dict(data: dict) Status#
Create a Status from a dictionary (e.g., from JSON).
- Parameters:
data – Dictionary with ‘category’, ‘code’, and optional ‘reason’
- Returns:
Status object
- display_name(**kwargs) str#
- classmethod PENDING()#
- classmethod READY()#
- classmethod RUNNING()#
- classmethod SUCCESS()#
- classmethod XFAIL()#
- classmethod XDIFF()#
- classmethod FAILED(reason: str | None = None, code: int = -1)#
- classmethod DIFFED(reason: str | None = None, code: int = -1)#
- classmethod TIMEOUT(code: int = -1)#
- classmethod ERROR(reason: str | None = None, code: int = -1)#
- classmethod BROKEN(reason: str | None = None, code: int = -1)#
- classmethod SKIPPED(reason: str | None = None)#
- classmethod BLOCKED(reason: str | None = None)#
- classmethod CANCELLED(reason: str | None = None)#
- classmethod INTERRUPTED(reason: str | None = None)#
- cat = 'FAIL'#