This repository was archived by the owner on Apr 23, 2025. It is now read-only.
forked from raizamartin/gemini-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
51 lines (39 loc) · 1.65 KB
/
conftest.py
File metadata and controls
51 lines (39 loc) · 1.65 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
42
43
44
45
46
47
48
49
50
51
"""
Pytest configuration and fixtures.
"""
import os
import sys
import pytest
from unittest.mock import MagicMock
# Add src directory to path for imports
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../src')))
def pytest_configure(config):
"""Configure pytest with custom markers."""
config.addinivalue_line("markers", "integration: mark test as requiring API keys")
config.addinivalue_line("markers", "slow: mark test as slow")
def pytest_collection_modifyitems(config, items):
"""Process test items to skip tests with missing dependencies."""
for item in items:
if 'requires_tiktoken' in item.keywords and not _is_module_available('tiktoken'):
item.add_marker(pytest.mark.skip(reason="tiktoken not available"))
if 'requires_yaml' in item.keywords and not _is_module_available('yaml'):
item.add_marker(pytest.mark.skip(reason="yaml not available"))
if 'requires_gemini' in item.keywords and not _is_module_available('google.generativeai'):
item.add_marker(pytest.mark.skip(reason="google.generativeai not available"))
if 'requires_openai' in item.keywords and not _is_module_available('openai'):
item.add_marker(pytest.mark.skip(reason="openai not available"))
def _is_module_available(module_name):
"""Check if a module is available."""
try:
__import__(module_name)
return True
except ImportError:
return False
@pytest.fixture
def mock_module():
"""Create a MagicMock for a module."""
return MagicMock()
@pytest.fixture
def temp_dir(tmpdir):
"""Provide a temporary directory."""
return tmpdir