Files
factorio-learning-environment/tests/actions/test_render.py
Harshit Sharma 8143457e55
Some checks failed
Lint and Format / lint (push) Has been cancelled
Faster ci cd (#311)
* sessions based

* try out caching + no sleep

* update fixture usage

* better reset usge

* state less on tech, probably breaking change

* better fixtures + decouple resets

* use pytest-xdist w 2 servers

* using diff grouping for dep

* formatting

* formatting

* caching for image

* formatting

* formatting

* use uv

* use uv caching

* remove docker caching (its slower)

* how about 4 workers?

* no redundant resets

* parameterize

* change names

* update all_technologies_researched usage

change log:

- used uv and cache dependencies
- used 2 factorio headless server instances
- added pytest-xdist & used 2 pytest workers
- parametrized the slowest test -- `test_sleep.py` so as to balance it across workers
- clarified resets in `instance.py` so separate instances arent needed for research testing
- better fixture usage, with autouse reset
- added configure_game callback for per test file setup of inventories & research state.
- updated task abc all_technologies_researched usage, its now a param for reset
- using 4 workers instead of 2, can probably double it again lol
- pytest parameterized a slow test
- fixed redundant reset in conftest

final speedup: 9m 4s -> 1m, ≈9.07× faster
2025-08-21 17:31:28 +05:30

36 lines
936 B
Python

import pytest
from fle.env.entities import Position, Layer
from fle.env.game_types import Prototype
@pytest.fixture()
def game(configure_game):
return configure_game(
inventory={
"iron-chest": 1,
"small-electric-pole": 20,
"iron-plate": 10,
"assembling-machine-1": 1,
"pipe-to-ground": 10,
"pipe": 30,
"transport-belt": 50,
"underground-belt": 30,
}
)
def test_basic_render(game):
game.place_entity(Prototype.IronChest, position=Position(x=0, y=0))
game.connect_entities(
Position(x=0, y=-2),
Position(x=15, y=5),
{Prototype.Pipe, Prototype.UndergroundPipe},
)
game.connect_entities(
Position(x=0, y=-10), Position(x=15, y=-10), {Prototype.SmallElectricPole}
)
image = game._render(position=Position(x=0, y=5), layers=Layer.ALL)
image.show()
pass