Skip to content

Commit

Permalink
Fix tests to be explicit about window
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed Dec 27, 2024
1 parent 019cf27 commit 2312e96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from pyboy.api.tile import Tile
from pyboy.utils import WindowEvent, cython_compiled

try:
import sdl2
except ImportError:
sdl2 = None


def test_log_level_none(default_rom, capsys):
pyboy = PyBoy(default_rom, window="null")
Expand Down Expand Up @@ -183,9 +188,11 @@ def test_argv_parser(*args):
assert flags[k] == v


@pytest.mark.skipif(cython_compiled, reason="This test requires access to internal functions not available in Cython")
@pytest.mark.skipif(
cython_compiled or not sdl2, reason="This test requires access to internal functions not available in Cython"
)
def test_no_input_enabled(default_rom):
pyboy = PyBoy(default_rom, no_input=True)
pyboy = PyBoy(default_rom, window="SDL2", no_input=True)
pyboy.set_emulation_speed(0)
with mock.patch("pyboy.plugins.window_sdl2.sdl2_event_pump", return_value=[WindowEvent(WindowEvent.PAUSE)]):
pyboy.tick()
Expand All @@ -200,9 +207,11 @@ def test_no_input_enabled(default_rom):
assert not pyboy.paused


@pytest.mark.skipif(cython_compiled, reason="This test requires access to internal functions not available in Cython")
@pytest.mark.skipif(
cython_compiled or not sdl2, reason="This test requires access to internal functions not available in Cython"
)
def test_no_input_disabled(default_rom):
pyboy = PyBoy(default_rom, no_input=False)
pyboy = PyBoy(default_rom, window="SDL2", no_input=False)
pyboy.set_emulation_speed(0)
with mock.patch("pyboy.plugins.window_sdl2.sdl2_event_pump", return_value=[WindowEvent(WindowEvent.PAUSE)]):
pyboy.tick()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_memoryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def test_memoryview(default_rom, boot_rom):
p = PyBoy(default_rom, bootrom=boot_rom)
p = PyBoy(default_rom, window="null", bootrom=boot_rom)

with open(default_rom, "rb") as f:
rom_bytes = [ord(f.read(1)) for x in range(16)]
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_memoryview(default_rom, boot_rom):


def test_cgb_banks(cgb_acid_file): # Any CGB file
p = PyBoy(cgb_acid_file)
p = PyBoy(cgb_acid_file, window="null")

# Read VRAM banks through both aliases
assert p.memory[0, 0x8000:0x8010] == [0] * 16
Expand Down

0 comments on commit 2312e96

Please sign in to comment.