test: add fixed_random_seed fixture with autouse=True (#52)

Ensures all tests have deterministic random behavior by setting
random.seed(42) before each test. This prevents flaky tests caused
by random number generation.

Closes #44
This commit is contained in:
Zihao Xu
2026-01-19 04:46:59 -08:00
committed by GitHub
parent ed2d8720aa
commit daa7a20679

View File

@@ -1,7 +1,18 @@
import pytest
import random
from unittest.mock import MagicMock, AsyncMock, patch
from src.classes.map import Map
@pytest.fixture(autouse=True)
def fixed_random_seed():
"""
Ensure all tests have deterministic random behavior.
This fixture is automatically applied to all tests.
"""
random.seed(42)
yield
from src.classes.tile import TileType, Tile
from src.classes.world import World
from src.classes.calendar import Month, Year, create_month_stamp