mirror of
https://github.com/esphome/esphome.git
synced 2026-09-24 05:24:14 +00:00
Fix picotool tests on Windows
Use platform-appropriate binary name (picotool.exe on Windows) when creating mock picotool files in tests.
This commit is contained in:
@@ -8,6 +8,7 @@ import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
@@ -1339,7 +1340,8 @@ def test_upload_using_picotool_success(tmp_path: Path) -> None:
|
||||
toolchain_bin.mkdir(parents=True)
|
||||
picotool_dir = packages_dir / "tool-picotool-rp2040-earlephilhower"
|
||||
picotool_dir.mkdir(parents=True)
|
||||
picotool = picotool_dir / "picotool"
|
||||
binary_name = "picotool.exe" if sys.platform == "win32" else "picotool"
|
||||
picotool = picotool_dir / binary_name
|
||||
picotool.touch()
|
||||
|
||||
mock_idedata = MagicMock()
|
||||
@@ -1412,7 +1414,8 @@ def test_upload_using_picotool_permission_error(tmp_path: Path) -> None:
|
||||
toolchain_bin.mkdir(parents=True)
|
||||
picotool_dir = packages_dir / "tool-picotool-rp2040-earlephilhower"
|
||||
picotool_dir.mkdir(parents=True)
|
||||
picotool = picotool_dir / "picotool"
|
||||
binary_name = "picotool.exe" if sys.platform == "win32" else "picotool"
|
||||
picotool = picotool_dir / binary_name
|
||||
picotool.touch()
|
||||
|
||||
mock_idedata = MagicMock()
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
@@ -415,9 +416,10 @@ def test_get_picotool_path_found(tmp_path: Path) -> None:
|
||||
gcc = toolchain_dir / "arm-none-eabi-gcc"
|
||||
gcc.touch()
|
||||
|
||||
binary_name = "picotool.exe" if sys.platform == "win32" else "picotool"
|
||||
picotool_dir = packages_dir / "tool-picotool-rp2040-earlephilhower"
|
||||
picotool_dir.mkdir(parents=True)
|
||||
picotool = picotool_dir / "picotool"
|
||||
picotool = picotool_dir / binary_name
|
||||
picotool.touch()
|
||||
|
||||
result = util.get_picotool_path(str(gcc))
|
||||
|
||||
Reference in New Issue
Block a user