1414
1515
1616if TYPE_CHECKING :
17- from typing import ClassVar
18-
1917 from typing_extensions import Self
2018
21- STEPWISE_CACHE_DIR = "cache/stepwise2 "
19+ STEPWISE_CACHE_DIR = "cache/stepwise "
2220
2321
2422def pytest_addoption (parser : Parser ) -> None :
@@ -52,11 +50,8 @@ def pytest_addoption(parser: Parser) -> None:
5250
5351
5452def pytest_configure (config : Config ) -> None :
55- # --stepwise-skip implies stepwise.
56- if config .option .stepwise_skip :
57- config .option .stepwise = True
58- # --stepwise-clear implies stepwise.
59- if config .option .stepwise_reset :
53+ # --stepwise-skip/--stepwise-reset implies stepwise.
54+ if config .option .stepwise_skip or config .option .stepwise_reset :
6055 config .option .stepwise = True
6156 if config .getoption ("stepwise" ):
6257 config .pluginmanager .register (StepwisePlugin (config ), "stepwiseplugin" )
@@ -84,22 +79,20 @@ class StepwiseCacheInfo:
8479 # The date when the cache was last updated, for information purposes only.
8580 last_cache_date_str : str
8681
87- _DATE_FORMAT : ClassVar [str ] = "%Y-%m-%d %H:%M:%S"
88-
8982 @property
9083 def last_cache_date (self ) -> datetime :
91- return datetime .strptime (self .last_cache_date_str , self . _DATE_FORMAT )
84+ return datetime .fromisoformat (self .last_cache_date_str )
9285
9386 @classmethod
9487 def empty (cls ) -> Self :
9588 return cls (
9689 last_failed = None ,
9790 last_test_count = None ,
98- last_cache_date_str = datetime .now ().strftime ( cls . _DATE_FORMAT ),
91+ last_cache_date_str = datetime .now ().isoformat ( ),
9992 )
10093
10194 def update_date_to_now (self ) -> None :
102- self .last_cache_date_str = datetime .now ().strftime ( self . _DATE_FORMAT )
95+ self .last_cache_date_str = datetime .now ().isoformat ( )
10396
10497
10598class StepwisePlugin :
@@ -122,7 +115,7 @@ def _load_cached_info(self) -> StepwiseCacheInfo:
122115 cached_dict ["last_test_count" ],
123116 cached_dict ["last_cache_date_str" ],
124117 )
125- except Exception as e :
118+ except ( KeyError , TypeError ) as e :
126119 error = f"{ type (e ).__name__ } : { e } "
127120 self .report_status .append (f"error reading cache, discarding ({ error } )" )
128121
0 commit comments