-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
36 lines (25 loc) · 841 Bytes
/
conftest.py
File metadata and controls
36 lines (25 loc) · 841 Bytes
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
import logging
from collections.abc import Iterator
from unittest.mock import patch
import pytest
from injection import Module, mod
from injection._core.module import Module as CoreModule
from injection.loaders import PythonModuleLoader
from tests.helpers import EventHistory
logging.basicConfig(level=logging.DEBUG)
@pytest.fixture(scope="session", autouse=True)
def __patch_sys_modules() -> Iterator[None]:
with patch.object(PythonModuleLoader, "_sys_modules", {}):
yield
@pytest.fixture(scope="function", autouse=True)
def unlock():
yield
mod().unlock()
@pytest.fixture(scope="function")
def module() -> Module | CoreModule:
return CoreModule()
@pytest.fixture(scope="function")
def event_history(module) -> EventHistory:
history = EventHistory()
module.add_listener(history)
return history