Skip to content

Commit ec53f57

Browse files
committed
test(balatrobot): add option to specify port
1 parent afd816c commit ec53f57

File tree

2 files changed

+86
-83
lines changed

2 files changed

+86
-83
lines changed

tests/balatrobot/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""BalatroClient-specific test configuration and fixtures."""
2+
3+
import pytest
4+
5+
from balatrobot.client import BalatroClient
6+
from balatrobot.enums import State
7+
from balatrobot.exceptions import BalatroError, ConnectionFailedError
8+
from balatrobot.models import G
9+
10+
11+
@pytest.fixture(scope="function", autouse=True)
12+
def reset_game_to_menu(port):
13+
"""Reset game to menu state before each test."""
14+
try:
15+
with BalatroClient(port=port) as client:
16+
response = client.send_message("go_to_menu", {})
17+
game_state = G.model_validate(response)
18+
assert game_state.state_enum == State.MENU
19+
except (ConnectionFailedError, BalatroError):
20+
# Game not running or other API error, skip setup
21+
pass

0 commit comments

Comments
 (0)