diff --git a/pybricksdev/compile.py b/pybricksdev/compile.py index c37dfb0..fba33b0 100644 --- a/pybricksdev/compile.py +++ b/pybricksdev/compile.py @@ -74,7 +74,7 @@ async def compile_file( ), ) else: - raise ValueError("mpy_version must be 5") + raise ValueError("mpy_version must be 5 or 6") proc.check_returncode() diff --git a/tests/test_compile.py b/tests/test_compile.py index 7b817f4..545ec17 100644 --- a/tests/test_compile.py +++ b/tests/test_compile.py @@ -31,3 +31,18 @@ async def test_compile_file(abi: int): assert int_bits == 31 finally: os.unlink(f.name) + + +@pytest.mark.asyncio +async def test_compile_file_invalid_abi(): + with NamedTemporaryFile("w", delete=False) as f: + try: + f.write("print('test')") + f.close() + + with pytest.raises(ValueError, match="mpy_version must be 5 or 6"): + await compile_file( + os.path.dirname(f.name), os.path.basename(f.name), abi=4 + ) + finally: + os.unlink(f.name)