fix lint and formatting violations in tests and source

This commit is contained in:
Username
2026-02-24 16:50:51 +01:00
parent 0f476a25d5
commit 85f373a8b5
5 changed files with 62 additions and 62 deletions

View File

@@ -2,7 +2,7 @@
import struct
from tuimble.audio import FRAME_SIZE, SAMPLE_RATE, AudioPipeline, _apply_gain
from tuimble.audio import FRAME_SIZE, AudioPipeline, _apply_gain
def test_default_construction():
@@ -14,8 +14,9 @@ def test_default_construction():
def test_custom_construction():
ap = AudioPipeline(sample_rate=24000, frame_size=480,
input_device=1, output_device=2)
ap = AudioPipeline(
sample_rate=24000, frame_size=480, input_device=1, output_device=2
)
# Verify via public behavior: get_capture_frame returns None
assert ap.get_capture_frame() is None

View File

@@ -1,8 +1,12 @@
"""Tests for configuration module."""
from tuimble.config import (
AudioConfig, Config, PttConfig, ServerConfig,
_load_section, load_config,
AudioConfig,
Config,
PttConfig,
ServerConfig,
_load_section,
load_config,
)
@@ -55,11 +59,14 @@ def test_server_cert_custom():
def test_load_section_filters_unknown_keys():
"""Unknown keys are silently dropped, valid keys are kept."""
result = _load_section(ServerConfig, {
"host": "example.com",
"typo_field": "oops",
"another_bad": 42,
})
result = _load_section(
ServerConfig,
{
"host": "example.com",
"typo_field": "oops",
"another_bad": 42,
},
)
assert result.host == "example.com"
assert result.port == 64738 # default preserved
@@ -86,8 +93,7 @@ def test_load_config_with_unknown_keys(tmp_path):
"""Config file with unknown keys loads without error."""
toml = tmp_path / "config.toml"
toml.write_text(
'[server]\nhost = "example.com"\nbogus = true\n'
'[ptt]\nfuture_option = "x"\n'
'[server]\nhost = "example.com"\nbogus = true\n[ptt]\nfuture_option = "x"\n'
)
cfg = load_config(toml)
assert cfg.server.host == "example.com"

View File

@@ -2,7 +2,7 @@
import threading
from tuimble.reconnect import INITIAL_DELAY, MAX_RETRIES, ReconnectManager
from tuimble.reconnect import INITIAL_DELAY, ReconnectManager
def _make_manager(connect_fn=None, **overrides):
@@ -22,7 +22,9 @@ def _make_manager(connect_fn=None, **overrides):
log["exhausted"] += 1
if connect_fn is None:
connect_fn = lambda: None
def connect_fn():
return None
mgr = ReconnectManager(
connect_fn=connect_fn,
@@ -67,6 +69,7 @@ def test_success_after_failures():
mgr, log = _make_manager(connect_fn=flaky_connect)
# Patch delay to zero for test speed
import tuimble.reconnect as mod
orig = mod.INITIAL_DELAY
mod.INITIAL_DELAY = 0
try:
@@ -88,7 +91,10 @@ def test_non_retryable_aborts_immediately():
class Rejected(Exception):
retryable = False
mgr, log = _make_manager(connect_fn=lambda: (_ for _ in ()).throw(Rejected("banned")))
def _raise():
raise Rejected("banned")
mgr, log = _make_manager(connect_fn=_raise)
mgr.run()
assert log["exhausted"] == 1
assert log["success"] == 0
@@ -102,6 +108,7 @@ def test_non_retryable_aborts_immediately():
def test_exhaustion_after_max_retries():
"""Loop stops after MAX_RETRIES failed attempts."""
import tuimble.reconnect as mod
orig_delay = mod.INITIAL_DELAY
orig_retries = mod.MAX_RETRIES
mod.INITIAL_DELAY = 0
@@ -155,6 +162,7 @@ def test_backoff_delays():
# We only need the attempt callback to record delays; cancel after
# a few attempts to avoid waiting.
import tuimble.reconnect as mod
orig_delay = mod.INITIAL_DELAY
orig_retries = mod.MAX_RETRIES
mod.INITIAL_DELAY = 0 # zero delay for speed