diff --git a/tests/test_breakpoints.py b/tests/test_breakpoints.py index f320992f6..23f2f562c 100644 --- a/tests/test_breakpoints.py +++ b/tests/test_breakpoints.py @@ -15,7 +15,7 @@ def test_debugprompt(default_rom, monkeypatch): - pyboy = PyBoy(default_rom, window_type="dummy", breakpoints="0:0100,-1:0", debug=False) + pyboy = PyBoy(default_rom, window_type="null", breakpoints="0:0100,-1:0", debug=False) pyboy.set_emulation_speed(0) # Break at 0, step once, continue, break at 100, continue @@ -29,7 +29,7 @@ def test_debugprompt(default_rom, monkeypatch): @pytest.mark.parametrize("commands", ["n\nc\n", "n\nn\nc\n", "c\nc\n", "n\nn\nn\nn\nn\nn\nc\n"]) def test_debugprompt2(default_rom, monkeypatch, commands): - pyboy = PyBoy(default_rom, window_type="dummy", breakpoints="-1:0,-1:3", debug=False) + pyboy = PyBoy(default_rom, window_type="null", breakpoints="-1:0,-1:3", debug=False) pyboy.set_emulation_speed(0) monkeypatch.setattr("sys.stdin", io.StringIO(commands)) @@ -41,7 +41,7 @@ def test_debugprompt2(default_rom, monkeypatch, commands): def test_register_hooks(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) mock = Mock() @@ -55,7 +55,7 @@ def test_register_hooks(default_rom): def test_register_hook_context(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) def _inner_callback(context): @@ -72,8 +72,25 @@ def _inner_callback(context): assert len(_context) == 1 +def test_register_hook_print(default_rom, capfd): + pyboy = PyBoy(default_rom, window_type="null") + pyboy.set_emulation_speed(0) + + def _inner_callback(context): + print(context) + + bank = -1 # "ROM bank number" for bootrom + addr = 0xFC # Address of last instruction. Expected to execute once. + pyboy.hook_register(bank, addr, _inner_callback, "Hello!") + for _ in range(120): + pyboy.tick() + + out, err = capfd.readouterr() + assert out == "Hello!\n" + + def test_symbols_none(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) with pytest.raises(ValueError): @@ -81,7 +98,7 @@ def test_symbols_none(default_rom): def test_symbols_auto_locate(): - pyboy = PyBoy("extras/default_rom/default_rom.gb", window_type="dummy") + pyboy = PyBoy("extras/default_rom/default_rom.gb", window_type="null") pyboy.set_emulation_speed(0) _bank, _addr = pyboy._lookup_symbol("Main.waitVBlank") @@ -90,7 +107,7 @@ def test_symbols_auto_locate(): def test_symbols_path_locate(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy", symbols_file="extras/default_rom/default_rom.sym") + pyboy = PyBoy(default_rom, window_type="null", symbols_file="extras/default_rom/default_rom.sym") pyboy.set_emulation_speed(0) _bank, _addr = pyboy._lookup_symbol("Main.waitVBlank") @@ -99,7 +116,7 @@ def test_symbols_path_locate(default_rom): def test_register_hook_label(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy", symbols_file="extras/default_rom/default_rom.sym") + pyboy = PyBoy(default_rom, window_type="null", symbols_file="extras/default_rom/default_rom.sym") pyboy.set_emulation_speed(0) def _inner_callback(context): @@ -117,7 +134,7 @@ def _inner_callback(context): def test_register_hook_context2(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) def _inner_callback(context): @@ -136,7 +153,7 @@ def _inner_callback(context): def test_register_hooks_double(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) mock = Mock() @@ -146,7 +163,7 @@ def test_register_hooks_double(default_rom): def test_deregister_hooks(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) mock = Mock() @@ -163,7 +180,7 @@ def test_deregister_hooks(default_rom): def test_deregister_hooks2(default_rom): - pyboy = PyBoy(default_rom, window_type="dummy") + pyboy = PyBoy(default_rom, window_type="null") pyboy.set_emulation_speed(0) mock = Mock()