Files
factorio-learning-environment/tests/actions/test_set_research.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

23 lines
541 B
Python

import pytest
from fle.env.game_types import Technology
@pytest.fixture()
def game(configure_game):
return configure_game(all_technologies_researched=False)
def test_set_research(game):
ingredients = game.set_research(Technology.Automation)
assert ingredients[0].count == 10
def test_fail_to_research_locked_technology(game):
try:
game.set_research(Technology.Automation2)
except Exception:
assert True
return
assert False, "Was able to research locked technology. Expected exception."