Drop attrs dependency, use dataclasses instead (#10669)
Since pytest now requires Python>=3.7, we can use the stdlib attrs clone, dataclasses, instead of the OG package. attrs is still somewhat nicer than dataclasses and has some extra functionality, but for pytest usage there's not really a justification IMO to impose the extra dependency on users when a standard alternative exists.
This commit is contained in:
+6
-7
@@ -1,3 +1,4 @@
|
||||
import dataclasses
|
||||
import re
|
||||
import sys
|
||||
from typing import List
|
||||
@@ -192,20 +193,18 @@ def mock_timing(monkeypatch: MonkeyPatch):
|
||||
Time is static, and only advances through `sleep` calls, thus tests might sleep over large
|
||||
numbers and obtain accurate time() calls at the end, making tests reliable and instant.
|
||||
"""
|
||||
import attr
|
||||
|
||||
@attr.s
|
||||
@dataclasses.dataclass
|
||||
class MockTiming:
|
||||
_current_time: float = 1590150050.0
|
||||
|
||||
_current_time = attr.ib(default=1590150050.0)
|
||||
|
||||
def sleep(self, seconds):
|
||||
def sleep(self, seconds: float) -> None:
|
||||
self._current_time += seconds
|
||||
|
||||
def time(self):
|
||||
def time(self) -> float:
|
||||
return self._current_time
|
||||
|
||||
def patch(self):
|
||||
def patch(self) -> None:
|
||||
from _pytest import timing
|
||||
|
||||
monkeypatch.setattr(timing, "sleep", self.sleep)
|
||||
|
||||
Reference in New Issue
Block a user