Skip to content

Commit

Permalink
CI: Fixes for running tests
Browse files Browse the repository at this point in the history
- Fix tests by CDing into the project directory.
- Fix types to be compatible with Python v3.8.
- Fix travelling up to test parent directory
- Fix "path is on mount 'D:', start on mount 'C:'" on Windows by explicitly changing drive
  • Loading branch information
laurence-myers committed Feb 14, 2024
1 parent 54a2b20 commit 7ac38a8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test
name: Build and Test

on: push

Expand Down
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ classifiers = [
Repository = "http://www.github.com/Malvineous/pyopl"

[tool.cibuildwheel]
test-command = "python -m unittest {project}/tests/pyopl_test.py"
test-command = [
"cd {project}",
"python -m unittest {project}/tests/pyopl_test.py"
]

[tool.cibuildwheel.windows]

test-command = [
"D:",
"cd {project}",
"python -m unittest {project}/tests/pyopl_test.py"
]
10 changes: 6 additions & 4 deletions tests/dro_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DROInstructionType(Enum):
class DROData:
def __init__(
self,
codemap: tuple[int, ...],
codemap: typing.Tuple[int, ...],
raw_data: array.array,
short_delay_code: int,
long_delay_code: int
Expand All @@ -50,9 +50,11 @@ def __init__(
self._long_delay_code = long_delay_code

def __iter__(self) -> typing.Iterator[
tuple[DROInstructionType.DELAY_MS, int] |
tuple[DROInstructionType.REGISTER, int, int]
]:
typing.Union[
typing.Tuple["DROInstructionType.DELAY_MS", int],
typing.Tuple["DROInstructionType.REGISTER", int, int]
]
]:
iterator = iter(self._raw_data)
try:
while True:
Expand Down
5 changes: 4 additions & 1 deletion tests/pyopl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

class PyOPLTestCase(unittest.TestCase):
def test_dro_rendering(self) -> None:
test_dir = Path(__file__) / ".."
test_dir = Path(__file__).parent

dro_player = DROPlayer(str(test_dir / "correct_answer.dro"))
rendered_data = dro_player.render_dro()

# This is how I created the `correct_answer.wav`. Doing it this doesn't prove that the output is correct,
# but ensures that it's consistent across all builds.
# with wave.open(str(Path(__file__) / ".." / "out.wav"). "wb") as out_wav_file:
# out_wav_file.setnchannels(2)
# out_wav_file.setsampwidth(2)
Expand Down

0 comments on commit 7ac38a8

Please sign in to comment.