Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mike8699 committed Sep 29, 2024
1 parent d41f077 commit 0376eb3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
44 changes: 30 additions & 14 deletions tests/desmume/emulator_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC
from abc import ABC, abstractmethod
from collections.abc import Callable, Generator
from contextlib import contextmanager
from pathlib import Path
Expand All @@ -11,80 +11,102 @@


class AbstractEmulatorWrapper(ABC):
video = None

@abstractmethod
def open(self, rom_path: str):
raise NotImplementedError

@abstractmethod
def destroy(self):
raise NotImplementedError

@abstractmethod
def wait(self, frames: int):
raise NotImplementedError

@abstractmethod
def button_input(self, buttons: int | list[int], frames: int = 1):
raise NotImplementedError

@abstractmethod
def touch_set(self, x: int, y: int):
raise NotImplementedError

@abstractmethod
def touch_release(self):
raise NotImplementedError

@abstractmethod
def touch_set_and_release(self, position: tuple[int, int], frames: int = 1):
raise NotImplementedError

@abstractmethod
def read_memory(self, start: int, stop: int | None = None):
raise NotImplementedError

@abstractmethod
def write_memory(self, address: int, data: bytes | int):
raise NotImplementedError

@abstractmethod
def set_read_breakpoint(self, address: int, callback: Callable[[int, int], None] | None):
raise NotImplementedError

@abstractmethod
def set_write_breakpoint(self, address: int, callback: Callable[[int, int], None] | None):
raise NotImplementedError

@abstractmethod
def set_exec_breakpoint(self, address: int, callback: Callable[[int, int], None] | None):
raise NotImplementedError

@property
@abstractmethod
def r0(self):
raise NotImplementedError

@r0.setter
@abstractmethod
def r0(self, value: int):
raise NotImplementedError

@property
@abstractmethod
def r1(self):
raise NotImplementedError

@r1.setter
@abstractmethod
def r1(self, value: int):
raise NotImplementedError

@property
@abstractmethod
def r2(self):
raise NotImplementedError

@r2.setter
@abstractmethod
def r2(self, value: int):
raise NotImplementedError

@property
@abstractmethod
def r3(self):
raise NotImplementedError

@r3.setter
@abstractmethod
def r3(self, value: int):
raise NotImplementedError
@property
def video(self):

@abstractmethod
def reset(self):
raise NotImplementedError
@video.setter
def video(self, value):

@abstractmethod
def load_battery_file(self, test_name: str, rom_path: Path):
raise NotImplementedError

@property
Expand All @@ -94,15 +116,9 @@ def event_flag_base_addr(self) -> int:
raise ValueError('Event flag base address not set.')
return addr

def reset(self):
raise NotImplementedError

def load_battery_file(self, test_name: str, rom_path: Path):
raise NotImplementedError

# Optional methods
def stop(self):
pass
return


def start_first_file(desmume_emulator: AbstractEmulatorWrapper):
Expand Down
7 changes: 4 additions & 3 deletions tests/desmume/melonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ def open(self, rom_path: str):
raise TimeoutError('BirdsEye did not connect within 30 seconds')
try:
with socket.create_connection((self._host, self._port), timeout=5):
logger.debug(f"Server {self._host}:{self._port} is available!")
logger.debug(f'Server {self._host}:{self._port} is available!')
break
except (TimeoutError, ConnectionRefusedError):
logger.debug(f"Waiting for server {self._host}:{self._port}...")
logger.debug(f'Waiting for server {self._host}:{self._port}...')
time.sleep(1)

self._client = bird.Client(self._host, self._port)
Expand Down Expand Up @@ -260,7 +260,8 @@ def load_battery_file(self, test_name: str, rom_path: Path):

battery_file_src = Path(__file__).parent / 'test_data' / f'{test_name}.dsv'

# For some reason, MelonDS strips underscores from the rom name when it saves the battery file.
# For some reason, MelonDS strips underscores from
# the rom name when it saves the battery file.
battery_file_dest = (
battery_file_location
/ f'{Path(rom_path.name.replace("_", " ")).with_suffix(".SaveRAM")}'
Expand Down

0 comments on commit 0376eb3

Please sign in to comment.