Add test suite for memory reader, state builder, and pathfinding#1
Open
ch3ronsa wants to merge 1 commit intoNousResearch:mainfrom
Open
Add test suite for memory reader, state builder, and pathfinding#1ch3ronsa wants to merge 1 commit intoNousResearch:mainfrom
ch3ronsa wants to merge 1 commit intoNousResearch:mainfrom
Conversation
79 tests covering: - RedBlueMemoryReader: player, party, bag, battle, dialog, map, flags, status decoding, Gen-1 encoding table, name tables - State builder: build_game_state sections, error handling, partial failures, build_state_summary output - Pathfinding: A* search, collision maps, wall avoidance, manhattan distance, neighbors, navigate, path_length All tests use mock emulator (no ROM required).
Author
|
On ROM-based integration tests: These tests are intentionally mock-based because Pokemon ROMs are copyrighted and can't be included in the repo or CI. The mock emulator simulates a 64KB RAM buffer with the same That said, integration tests with a real ROM would be valuable for verifying end-to-end behavior. A possible approach: ROM_PATH = Path(os.environ.get("POKEMON_ROM_PATH", ""))
@pytest.mark.skipif(not ROM_PATH.exists(), reason="ROM not available (set POKEMON_ROM_PATH)")
def test_real_emulator_reads_player():
emu = PyBoyEmulator(str(ROM_PATH))
reader = RedBlueMemoryReader(emu)
# advance a few frames, then verify state reads don't crash
...Users with a ROM could run: Happy to add this as a follow-up if the project wants to support it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the first test suite for the project as mentioned in the README's contribution areas ("Tests for memory readers and state builders").
79 tests across 3 test files, all passing. No ROM or emulator required — tests use a mock emulator with a 64KB RAM buffer.
What's covered
test_memory_reader.py(36 tests)read_player: name, rival, money (BCD), badges, position, facingread_party: single Pokemon, empty party, corrupted count (cap at 6)read_bag: items with quantities, empty bag, terminator handlingread_battle: not in battle, wild encounter with enemy dataread_dialog: inactive, active via text_box_id, active via joy_ignore bitread_map_info: known map (Pallet Town), unknown map IDread_flags: has_pokedex, has_oaks_parcel, pokedex counts_decode_status: OK, poison, paralysis, sleep, multiple statustest_state_builder.py(19 tests)test_pathfinding.py(24 tests)Test plan
pytest tests/ -v— 79 passed in 0.52spyproject.tomlpytest config