style: apply ruff auto-fixes across codebase
- Fix import sorting (isort) across all engine modules - Fix SIM105 try-except-pass patterns (contextlib.suppress) - Fix nested with statements in tests - Fix unused loop variables Run 'uv run pytest' to verify tests still pass.
This commit is contained in:
@@ -14,21 +14,25 @@ class TestTerminalDimensions:
|
||||
|
||||
def test_tw_returns_columns(self):
|
||||
"""tw() returns terminal width."""
|
||||
with patch.object(sys.stdout, "isatty", return_value=True):
|
||||
with patch("os.get_terminal_size") as mock_size:
|
||||
mock_size.return_value = io.StringIO("columns=120")
|
||||
mock_size.columns = 120
|
||||
result = terminal.tw()
|
||||
assert isinstance(result, int)
|
||||
with (
|
||||
patch.object(sys.stdout, "isatty", return_value=True),
|
||||
patch("os.get_terminal_size") as mock_size,
|
||||
):
|
||||
mock_size.return_value = io.StringIO("columns=120")
|
||||
mock_size.columns = 120
|
||||
result = terminal.tw()
|
||||
assert isinstance(result, int)
|
||||
|
||||
def test_th_returns_lines(self):
|
||||
"""th() returns terminal height."""
|
||||
with patch.object(sys.stdout, "isatty", return_value=True):
|
||||
with patch("os.get_terminal_size") as mock_size:
|
||||
mock_size.return_value = io.StringIO("lines=30")
|
||||
mock_size.lines = 30
|
||||
result = terminal.th()
|
||||
assert isinstance(result, int)
|
||||
with (
|
||||
patch.object(sys.stdout, "isatty", return_value=True),
|
||||
patch("os.get_terminal_size") as mock_size,
|
||||
):
|
||||
mock_size.return_value = io.StringIO("lines=30")
|
||||
mock_size.lines = 30
|
||||
result = terminal.th()
|
||||
assert isinstance(result, int)
|
||||
|
||||
def test_tw_fallback_on_error(self):
|
||||
"""tw() falls back to 80 on error."""
|
||||
@@ -84,9 +88,11 @@ class TestTypeOut:
|
||||
@patch("time.sleep")
|
||||
def test_type_out_uses_color(self, mock_sleep):
|
||||
"""type_out applies color codes."""
|
||||
with patch("sys.stdout", new_callable=io.StringIO):
|
||||
with patch("random.random", return_value=0.5):
|
||||
terminal.type_out("Test", color=terminal.G_HI)
|
||||
with (
|
||||
patch("sys.stdout", new_callable=io.StringIO),
|
||||
patch("random.random", return_value=0.5),
|
||||
):
|
||||
terminal.type_out("Test", color=terminal.G_HI)
|
||||
|
||||
|
||||
class TestSlowPrint:
|
||||
|
||||
Reference in New Issue
Block a user