Skip to content

Commit b2d8cac

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent abec8b4 commit b2d8cac

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

pytest-embedded-arduino/pytest_embedded_arduino/serial.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ def flash(self) -> None:
103103

104104
if self.fast_flash:
105105
if have_any_ref:
106-
logging.info('fast-flash: reflashing with references for %d/%d binaries',
107-
sum(1 for d in diff_args if d != 'skip'), len(diff_args))
106+
logging.info(
107+
'fast-flash: reflashing with references for %d/%d binaries',
108+
sum(1 for d in diff_args if d != 'skip'),
109+
len(diff_args),
110+
)
108111
else:
109112
diff_args = []
110113
logging.info('fast-flash: no references found, performing full flash')

pytest-embedded-arduino/tests/test_arduino.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
from unittest.mock import MagicMock, patch
66

77
import pytest
8-
9-
from pytest_embedded_arduino.serial import ArduinoSerial, _ALWAYS_FLASH
8+
from pytest_embedded_arduino.serial import _ALWAYS_FLASH, ArduinoSerial
109
from pytest_embedded_serial_esp.serial import EspSerial
1110

1211

@@ -70,6 +69,7 @@ def arduino_serial(mock_app):
7069
# Reference path tests
7170
# ---------------------------------------------------------------------------
7271

72+
7373
def test_ref_path_per_binary(arduino_serial, build_dir):
7474
"""_ref_path must produce a *_flashed.bin companion inside the build dir."""
7575
ref = arduino_serial._ref_path(str(build_dir / 'blink.ino.bin'))
@@ -87,6 +87,7 @@ def test_ref_binaries_lists_all(arduino_serial):
8787
# First flash (no references)
8888
# ---------------------------------------------------------------------------
8989

90+
9091
def test_first_flash_no_diff_with(arduino_serial):
9192
"""First flash (no references) must not pass --diff-with to esptool."""
9293
with patch('pytest_embedded_arduino.serial.esptool.main') as mock_main:
@@ -123,6 +124,7 @@ def test_first_flash_saves_all_refs(arduino_serial):
123124
# Second flash (references exist) — fast reflash
124125
# ---------------------------------------------------------------------------
125126

127+
126128
def _create_all_refs(serial):
127129
"""Write dummy references for all flash_files."""
128130
for _, binary in serial.app.flash_files:
@@ -141,7 +143,7 @@ def test_second_flash_passes_diff_with(arduino_serial):
141143
assert '--diff-with' in args
142144

143145
diff_idx = args.index('--diff-with')
144-
diff_values = args[diff_idx + 1:]
146+
diff_values = args[diff_idx + 1 :]
145147
assert len(diff_values) == len(arduino_serial.app.flash_files)
146148

147149

@@ -154,7 +156,7 @@ def test_second_flash_boot_app0_always_skip(arduino_serial):
154156

155157
args = mock_main.call_args[0][0]
156158
diff_idx = args.index('--diff-with')
157-
diff_values = args[diff_idx + 1:]
159+
diff_values = args[diff_idx + 1 :]
158160

159161
for i, (_, binary) in enumerate(arduino_serial.app.flash_files):
160162
if Path(binary).name in _ALWAYS_FLASH:
@@ -170,7 +172,7 @@ def test_second_flash_non_boot_app0_uses_ref(arduino_serial):
170172

171173
args = mock_main.call_args[0][0]
172174
diff_idx = args.index('--diff-with')
173-
diff_values = args[diff_idx + 1:]
175+
diff_values = args[diff_idx + 1 :]
174176

175177
for i, (_, binary) in enumerate(arduino_serial.app.flash_files):
176178
if Path(binary).name not in _ALWAYS_FLASH:
@@ -194,6 +196,7 @@ def test_diff_with_after_addr_file_pairs(arduino_serial):
194196
# Flash failure / error handling
195197
# ---------------------------------------------------------------------------
196198

199+
197200
def test_flash_failure_does_not_save_refs(arduino_serial):
198201
"""If esptool.main raises, no reference binaries must be created."""
199202
with patch('pytest_embedded_arduino.serial.esptool.main', side_effect=RuntimeError('flash failed')):
@@ -218,6 +221,7 @@ def test_ref_save_failure_logs_warning(arduino_serial, caplog):
218221
# erase_flash
219222
# ---------------------------------------------------------------------------
220223

224+
221225
def test_erase_flash_removes_all_refs(arduino_serial):
222226
"""erase_flash() must delete all reference binaries."""
223227
_create_all_refs(arduino_serial)
@@ -251,6 +255,7 @@ def test_erase_flash_ref_unlink_failure_logs_warning(arduino_serial, caplog):
251255
# fast_flash=False (opt-out) tests
252256
# ---------------------------------------------------------------------------
253257

258+
254259
@pytest.fixture
255260
def arduino_serial_no_fast(mock_app):
256261
return _FakeArduinoSerial(mock_app, fast_flash=False)
@@ -291,6 +296,7 @@ def test_no_fast_flash_erase_does_not_touch_refs(arduino_serial_no_fast):
291296
# Existing hardware-in-the-loop test (requires a real device)
292297
# ---------------------------------------------------------------------------
293298

299+
294300
def test_arduino_serial_flash(testdir):
295301
bin_path = os.path.join(testdir.tmpdir, 'hello_world_arduino', 'build', 'hello_world_arduino.ino.merged.bin')
296302

0 commit comments

Comments
 (0)