-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
41 lines (33 loc) · 1.01 KB
/
Copy pathconftest.py
File metadata and controls
41 lines (33 loc) · 1.01 KB
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
import sys
from unittest.mock import MagicMock, patch
import pytest
@pytest.fixture(autouse=True)
def mock_heavy_operations():
"""Auto-mock heavy operations for all tests"""
# Mock modules that might not be installed
mock_modules = {
'transformers': MagicMock(),
'sentence_transformers': MagicMock(),
'chromadb': MagicMock(),
'pytesseract': MagicMock()
}
for module_name, mock_module in mock_modules.items():
sys.modules[module_name] = mock_module
yield
# Clean up
for module_name in mock_modules:
if module_name in sys.modules:
del sys.modules[module_name]
@pytest.fixture
def mock_file_operations():
"""Mock file I/O operations"""
with patch('os.path.exists', return_value=True):
with patch('builtins.open'):
yield
@pytest.fixture
def disable_logging():
"""Disable logging during tests"""
import logging
logging.disable(logging.CRITICAL)
yield
logging.disable(logging.NOTSET)