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:
Ran Benita
2023-01-20 11:13:36 +02:00
committed by GitHub
parent 4d4ed42c34
commit 310b67b227
25 changed files with 199 additions and 159 deletions
+6 -7
View File
@@ -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)