-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconftest.py
50 lines (41 loc) · 1.08 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Pytest configuration file for the tests."""
from __future__ import annotations
import datetime
import random
import time
import uuid
import pytest
from redux_pytest.fixtures import (
event_loop,
needs_finish,
snapshot_prefix,
store,
store_monitor,
store_snapshot,
wait_for,
)
__all__ = [
'event_loop',
'needs_finish',
'snapshot_prefix',
'store',
'store_monitor',
'store_snapshot',
'wait_for',
]
@pytest.fixture(autouse=True)
def _(monkeypatch: pytest.MonkeyPatch) -> None:
"""Mock external resources."""
random.seed(0)
class DateTime(datetime.datetime):
@classmethod
def now(cls: type[DateTime], tz: datetime.tzinfo | None = None) -> DateTime:
_ = tz
return DateTime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.UTC)
monkeypatch.setattr(datetime, 'datetime', DateTime)
monkeypatch.setattr(
time,
'time',
lambda: datetime.datetime.now(tz=datetime.UTC).timestamp(),
)
monkeypatch.setattr(uuid, 'uuid4', lambda: uuid.UUID(int=random.getrandbits(128)))