| 69 | |
| 70 | @dataclasses.dataclass |
| 71 | class StepwiseCacheInfo: |
| 72 | # The nodeid of the last failed test. |
| 73 | last_failed: str | None |
| 74 | |
| 75 | # The number of tests in the last time --stepwise was run. |
| 76 | # We use this information as a simple way to invalidate the cache information, avoiding |
| 77 | # confusing behavior in case the cache is stale. |
| 78 | last_test_count: int | None |
| 79 | |
| 80 | # The date when the cache was last updated, for information purposes only. |
| 81 | last_cache_date_str: str |
| 82 | |
| 83 | @property |
| 84 | def last_cache_date(self) -> datetime: |
| 85 | return datetime.fromisoformat(self.last_cache_date_str) |
| 86 | |
| 87 | @classmethod |
| 88 | def empty(cls) -> Self: |
| 89 | return cls( |
| 90 | last_failed=None, |
| 91 | last_test_count=None, |
| 92 | last_cache_date_str=datetime.now().isoformat(), |
| 93 | ) |
| 94 | |
| 95 | def update_date_to_now(self) -> None: |
| 96 | self.last_cache_date_str = datetime.now().isoformat() |
| 97 | |
| 98 | |
| 99 | class StepwisePlugin: |