AI-Snake-Game/tests/conftest.py

33 lines
915 B
Python

import pytest
import pygame
import sys
import os
# Add src directory to Python path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
def pytest_configure(config):
"""Initialize pygame once before any tests run"""
# Set SDL to use software rendering and disable audio to reduce resource usage
os.environ['SDL_VIDEODRIVER'] = 'dummy'
os.environ['SDL_AUDIODRIVER'] = 'dummy'
pygame.init()
def pytest_unconfigure(config):
"""Clean up pygame after all tests are done"""
pygame.quit()
@pytest.fixture
def game_config():
"""Basic game configuration"""
return {
'width': 400, # Smaller dimensions for testing
'height': 300,
'block_size': 20,
'fps': 60
}
@pytest.fixture
def mock_screen(game_config):
"""Create a mock pygame screen"""
return pygame.Surface((game_config['width'], game_config['height']))