Skip to content

Commit 92b2c68

Browse files
committed
test: add test for 'open_port_attempts' config option
1 parent 04045d6 commit 92b2c68

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/test_esptool.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,3 +1513,20 @@ def test_custom_reset_sequence(self):
15131513
output = self.run_esptool_error("flash_id")
15141514
assert f"Loaded custom configuration from {config_file_path}" in output
15151515
assert 'Invalid "custom_reset_sequence" option format:' in output
1516+
1517+
def test_open_port_attempts(self):
1518+
# Test that the open_port_attempts option is loaded correctly
1519+
connect_attempts = 5
1520+
config = (
1521+
"[esptool]\n"
1522+
f"open_port_attempts = {connect_attempts}\n"
1523+
"connect_attempts = 1\n"
1524+
"custom_reset_sequence = D0\n" # Invalid reset sequence to make sure connection fails
1525+
)
1526+
config_file_path = os.path.join(os.getcwd(), "esptool.cfg")
1527+
with self.ConfigFile(config_file_path, config):
1528+
output = self.run_esptool_error("flash_id")
1529+
assert f"Loaded custom configuration from {config_file_path}" in output
1530+
assert "Retrying failed connection" in output
1531+
for _ in range(connect_attempts):
1532+
assert "Connecting........" in output

0 commit comments

Comments
 (0)