Generate Test
Create pytest tests following happy-simulator project conventions.
Project Test Patterns
Timing
- Use
ConstantArrivalTimeProviderfor deterministic timing in tests - Use
Instant.from_seconds()for time values - Use
Instant.Epochfor time zero,Instant.Infinityfor auto-termination
File Organization
- Unit tests go in
tests/unit/ - Integration tests go in
tests/integration/ - File naming:
test_<feature>.py - Function naming:
test_<scenario>()
Common Imports
import pytest
from happysimulator import Simulation, Event, Instant
from happysimulator.load import Source, ConstantArrivalTimeProvider
Example Test Structure
def test_example_scenario():
"""Test description explaining what behavior is verified."""
# Arrange
sim = Simulation(end_time=Instant.from_seconds(10))
# Act
sim.run()
# Assert
assert expected_condition
Instructions
- Ask what functionality needs testing if not specified
- Determine if this is a unit test or integration test
- Generate test following the patterns above
- Run the test with
pytest tests/<path> -qto verify it passes
Converted and distributed by TomeVault — claim your Tome and manage your conversions.