Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
13f0ccd
feat!(Window): Set option flags
tony Feb 5, 2024
fba6d91
refactor!(Window): Deprecate set_window_option -> set_option
tony Feb 5, 2024
5a905eb
tests(Window): Rename test for show_window_options()
tony Feb 6, 2024
3c86458
tests(Window): set_option
tony Feb 6, 2024
d47023b
Window: Add show_option(), deprecate show_window_option()
tony Feb 6, 2024
cfd4763
chore(Window): {set,show}-window-option -> {set,show}-option -w
tony Feb 6, 2024
9b69ac7
libtmux.constants: Add OptionScope and OPTION_SCOPE_FLAG_MAP
tony Feb 6, 2024
ebbacec
feat(Window): scope param for Window.{set,show}_option
tony Feb 6, 2024
3431630
tests(Window): show_options w/ scope
tony Feb 6, 2024
4d2fd59
tests: show_window_option() -> show_option()
tony Feb 6, 2024
c7ddb03
feat(common): Add CmdMixin, CmdProtocol
tony Feb 8, 2024
273c31f
refactor!(options): Move handle_options_error -> options
tony Feb 8, 2024
75de0b6
feat(internal[sparse_array]): Add SparseArray
tony Jun 20, 2024
beac94b
feat(options): Add OptionsMixin
tony Feb 8, 2024
bf19ca6
feat(Window): Use OptionsMixin for Window.set_option, Window.show_opt…
tony Feb 7, 2024
5b3a745
feat(Pane): Use OptionsMixin for Pane.set_option, Pane.show_option(s)
tony Feb 5, 2024
c44709f
feat(Session): Use OptionsMixin for Session.set_option, Session.show_…
tony Feb 7, 2024
bbb5767
feat(Server): Use OptionsMixin for Server.set_option, Server.show_opt…
tony Feb 8, 2024
0f583b2
tests: Handle Window.show_options scope mismatch
tony Feb 7, 2024
d3c4d47
tests(window): Version guard to scope
tony Feb 6, 2024
55563e9
tests(Window): For Window.default_option_scope
tony Feb 8, 2024
e5882ad
docs(options): Add page for option helpers
tony Feb 8, 2024
94b4931
internal(constants[options]): GPT generated dataclasses
tony Feb 9, 2024
8b8d160
tests(test_options): Test OptionsMixin
tony Feb 8, 2024
eb72519
constants: Add HOOK_SCOPE_FLAG_MAP
tony Feb 16, 2024
bb5b398
docs(API): Document internal constants
tony Feb 15, 2024
2245b54
feat(internal[constants]): Add Hooks data structure
tony Feb 15, 2024
b2fb5a7
feat!(hooks): HooksMixin
tony Feb 15, 2024
e6d742c
feat(Pane): Add HooksMixin
tony Feb 15, 2024
4d0a3e0
feat(Window): Add HooksMixin
tony Feb 15, 2024
ef35102
feat(Session): Add HooksMixin
tony Feb 15, 2024
a6a5779
feat(Server): Add HooksMixin
tony Feb 15, 2024
e160705
docs(API): Add Hooks
tony Feb 16, 2024
93d4330
tests(test_hooks): Test HooksMixin
tony Feb 15, 2024
f61c9e3
fix(options): improve type safety for SparseArray handling
tony Feb 23, 2025
4db4672
test(options): update terminal-features test for tmux 3.4
tony Feb 23, 2025
7a31af6
test(options): improve test coverage and type safety
tony Feb 23, 2025
9d60be1
fix(tests): improve type safety in style option tests
tony Feb 23, 2025
7d94e99
fix(tests): handle status-format version compatibility
tony Feb 23, 2025
3fd7458
fix(tests): handle update-environment version compatibility
tony Feb 23, 2025
4dfe898
fix(compat): add tmux version compatibility for 3.2a-3.5
tony Oct 25, 2025
bd68cc8
fix(tests): handle tmux version differences in options tests
tony Oct 25, 2025
917af2a
fix(tests): handle style option format changes in tmux 3.2
tony Oct 25, 2025
dcae8e3
fix(tests): handle bold→bright conversion in complex style test
tony Oct 25, 2025
9c1dc7c
fix(tests): skip format expansion test on tmux <3.2
tony Oct 25, 2025
b6e93f6
feat(constants): add missing tmux 3.5+ options and hooks
tony Nov 26, 2025
a61e279
tests(options): add comprehensive option test grid
tony Nov 26, 2025
9cfafe5
tests(hooks): add comprehensive hook test grid
tony Nov 26, 2025
e8e9190
SparseArray(docs): add comprehensive doctests
tony Nov 26, 2025
4b2feb2
Hooks(docs): add doctests for from_stdout parsing pipeline
tony Nov 26, 2025
423d3b5
options(docs): add force_array=True doctest for hooks parsing
tony Nov 26, 2025
b9cd2f1
hooks(feat): add bulk operations API for managing indexed hooks
tony Nov 26, 2025
69eca19
tests(hooks): add comprehensive bulk operations test grid
tony Nov 26, 2025
62d39a3
fix(tests): set correct min_version for hooks and options
tony Nov 26, 2025
7b136b0
fix(tests): correct min_version for additional hooks and options
tony Nov 26, 2025
210014a
docs(hooks): convert commented examples to runnable doctests
tony Nov 26, 2025
c49c295
refactor(tests): remove dead code and unused xfail
tony Nov 26, 2025
49fea06
docs(internals): add SparseArray doc page
tony Nov 26, 2025
c0b3021
fix(tests): remove undefined TmuxArray reference
tony Nov 27, 2025
f0fac89
hooks(refactor): rename set_hooks_bulk -> set_hooks
tony Nov 28, 2025
34796e1
tests(hooks): update for set_hooks_bulk -> set_hooks rename
tony Nov 28, 2025
6456301
hooks(fix): correct show_hook return type to include SparseArray
tony Nov 28, 2025
d97a3e2
hooks(refactor): remove redundant bulk operations methods
tony Nov 28, 2025
7045630
tests(hooks): update for simplified bulk operations API
tony Nov 28, 2025
afab007
hooks(fix): add doctest cleanup for tmux < 3.0 compatibility
tony Nov 28, 2025
70efe1d
hooks(docs): skip set_hooks doctests for cross-version compat
tony Nov 28, 2025
b0a89a0
hooks(feat): add warning for set_hooks on tmux < 3.0
tony Nov 28, 2025
d9d38b9
tests(hooks): add version compatibility tests
tony Nov 28, 2025
ef284a5
hooks(fix): remove < 3.0 warning and doctest skips
tony Nov 28, 2025
a59b181
tests(hooks): remove < 3.0 module skip
tony Nov 28, 2025
881fa39
tests(hooks): delete version compat test file
tony Nov 28, 2025
0086e86
tests: remove obsolete < 3.2 skipif markers
tony Nov 28, 2025
79bdf0a
hooks(docs): update module docstring for 3.2+ baseline
tony Nov 28, 2025
a9f21f4
SparseArray(fix[append]): Handle empty array case
tony Nov 29, 2025
421e736
hooks(fix[show_hooks]): Store string hook values in returned dict
tony Nov 29, 2025
a2c0b30
options(feat[show_options]): Add public show_options() method
tony Nov 29, 2025
3ba8017
Window(refactor[show_window_options]): Update deprecation to use show…
tony Nov 29, 2025
6b8995c
options(fix[scope_flag]): Skip empty Session scope flag in tmux commands
tony Nov 29, 2025
6681e75
tests(test_options[show_options]): Add parametrized tests for show_op…
tony Nov 29, 2025
1f34b31
tests(test_hooks[run_hook]): Add test for run_hook() method
tony Nov 29, 2025
7d344e7
tests(test_sparse_array): Add tests for SparseArray utility class
tony Nov 29, 2025
6965fa3
tests(test_hooks): Add set_hook flag combination tests
tony Nov 29, 2025
04ecdd6
tests(test_hooks): Add hook scope tests for session/window/pane
tony Nov 29, 2025
f5fe594
tests(test_hooks): Add show_hooks parsing edge case tests
tony Nov 29, 2025
6295916
tests(test_options): Add convert_values SparseArray tests
tony Nov 29, 2025
277bda0
tests(legacy_api/test_window): Remove duplicate test_set_and_show_opt…
tony Nov 29, 2025
0ccd7cd
tests(test_window): Add deprecation warning tests for Window option m…
tony Nov 29, 2025
cd2d14a
tests/legacy_api/test_window.py(refactor): Remove unused has_gte_vers…
tony Nov 29, 2025
f2b0d40
tests/test_window.py(refactor): Simplify version conditionals
tony Nov 29, 2025
74c9681
docs(CHANGES): Add release notes for options and hooks features
tony Nov 29, 2025
327e85e
Window(fix[show_window_option]): Use public show_option() API
tony Nov 30, 2025
f827521
OptionsMixin(fix[show_option]): Forward legacy g parameter
tony Nov 30, 2025
17c4ccd
OptionsMixin(fix[show_option]): Add deprecation warning for g parameter
tony Nov 30, 2025
90757c9
OptionsMixin(fix): Use DeprecationWarning for deprecated g parameter
tony Nov 30, 2025
5afa214
tests(test_options): Add test for g parameter deprecation warning
tony Nov 30, 2025
e5a5b9d
HooksMixin(fix[show_hook]): Forward global_ parameter to _show_hook
tony Nov 30, 2025
3d37594
docs(CHANGES): Remove references to unimplemented hook methods
tony Nov 30, 2025
e4722dc
constants(fix[HOOK_SCOPE_FLAG_MAP]): Map Server scope to -g flag
tony Nov 30, 2025
a93d0fe
HooksMixin(fix[show_hook]): Strip % prefix for control-mode hooks
tony Nov 30, 2025
4c400a2
HooksMixin(fix[set_hook]): Add deprecation warning for g parameter
tony Nov 30, 2025
ebb507f
HooksMixin(feat[run_hook]): Add global_ parameter
tony Nov 30, 2025
3fcc34d
options(refactor[convert_values]): Remove dead SparseArray branch
tony Nov 30, 2025
da38b70
hooks.py(fix[set_hook]): Remove invalid _format parameter
tony Nov 30, 2025
2ca8063
hooks.py(fix[set_hook]): Remove invalid prevent_overwrite parameter
tony Nov 30, 2025
ff368f4
hooks.py(fix[set_hook]): Remove invalid ignore_errors parameter
tony Nov 30, 2025
0c3decc
hooks.py(fix[unset_hook]): Remove invalid ignore_errors parameter
tony Nov 30, 2025
a9a5bb2
hooks.py(fix[show_hooks]): Remove invalid ignore_errors parameter
tony Nov 30, 2025
7c316bf
hooks.py(fix[_show_hook, show_hook]): Remove invalid ignore_errors pa…
tony Nov 30, 2025
ec97859
tests/test_options.py(test): Add test for indexed array option lookup
tony Nov 30, 2025
c2d52ca
options.py(fix[_show_option]): Handle bracketed array indices correctly
tony Nov 30, 2025
f33f5f2
tests/test_window.py(fix): Suppress secondary deprecation warning in …
tony Nov 30, 2025
fa6117e
options.py(fix[explode_complex]): Parse multi-feature terminal-overrides
tony Nov 30, 2025
6b81b0c
hooks.py(fix[show_hook]): Handle indexed hook queries correctly
tony Nov 30, 2025
18d9f80
options.py(fix[_show_option]): Handle inherited option marker in lookups
tony Nov 30, 2025
39d20cc
options.py(fix[explode_arrays]): Preserve inherited marker in array keys
tony Nov 30, 2025
b92cc73
tests/test_options.py(feat): Add inherited array marker preservation …
tony Nov 30, 2025
ded89cd
docs(MIGRATION): Add migration notes for options/hooks API (#516)
tony Nov 30, 2025
9440065
docs(topics): Add options and hooks topic guide (#516)
tony Nov 30, 2025
d24226e
docs(quickstart): Add options section with examples (#516)
tony Nov 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests(test_sparse_array): Add tests for SparseArray utility class
why: Improve code coverage for sparse_array module.
what:
- Add tests for is_sparse_array_list TypeGuard function
- Add tests for SparseArray.append method
- Add tests for SparseArray.iter_values method
- Add tests for SparseArray.as_list method
  • Loading branch information
tony committed Nov 30, 2025
commit 7d344e7dce2167ef23ffbe8dbfe6760cb81d9154
148 changes: 148 additions & 0 deletions tests/test/test_sparse_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
"""Tests for libtmux sparse array utilities."""

from __future__ import annotations

import typing as t

import pytest

from libtmux._internal.sparse_array import SparseArray, is_sparse_array_list


class IsSparseArrayListTestCase(t.NamedTuple):
"""Test case for is_sparse_array_list TypeGuard function."""

test_id: str
input_dict: dict[str, t.Any]
expected: bool


class SparseArrayAppendTestCase(t.NamedTuple):
"""Test case for SparseArray.append method."""

test_id: str
initial_adds: list[tuple[int, str]] # [(index, value), ...] to setup
append_values: list[str] # values to append
expected_keys: list[int] # expected keys in sorted order
expected_mapping: dict[int, str] # specific index -> value checks


class SparseArrayValuesTestCase(t.NamedTuple):
"""Test case for iter_values and as_list methods."""

test_id: str
adds: list[tuple[int, str]] # [(index, value), ...]
expected_values: list[str] # values in sorted index order


IS_SPARSE_ARRAY_LIST_TEST_CASES: list[IsSparseArrayListTestCase] = [
IsSparseArrayListTestCase("empty_dict", {}, True),
IsSparseArrayListTestCase(
"sparse_arrays_only",
{"hook1": SparseArray(), "hook2": SparseArray()},
True,
),
IsSparseArrayListTestCase(
"mixed_values",
{"hook1": SparseArray(), "opt": "string"},
False,
),
IsSparseArrayListTestCase(
"strings_only",
{"key1": "val1", "key2": "val2"},
False,
),
IsSparseArrayListTestCase("none_value", {"key1": None}, False),
]

SPARSE_ARRAY_APPEND_TEST_CASES: list[SparseArrayAppendTestCase] = [
SparseArrayAppendTestCase(
"append_to_empty",
initial_adds=[],
append_values=["first"],
expected_keys=[0],
expected_mapping={0: "first"},
),
SparseArrayAppendTestCase(
"append_after_add",
initial_adds=[(5, "at five")],
append_values=["appended"],
expected_keys=[5, 6],
expected_mapping={5: "at five", 6: "appended"},
),
SparseArrayAppendTestCase(
"multiple_appends",
initial_adds=[],
append_values=["100", "200", "300"],
expected_keys=[0, 1, 2],
expected_mapping={0: "100", 1: "200", 2: "300"},
),
]

SPARSE_ARRAY_VALUES_TEST_CASES: list[SparseArrayValuesTestCase] = [
SparseArrayValuesTestCase(
"sorted_order",
adds=[(10, "ten"), (1, "one"), (5, "five")],
expected_values=["one", "five", "ten"],
),
SparseArrayValuesTestCase(
"empty",
adds=[],
expected_values=[],
),
SparseArrayValuesTestCase(
"consecutive",
adds=[(3, "three"), (1, "one"), (2, "two")],
expected_values=["one", "two", "three"],
),
]


@pytest.mark.parametrize(
"test_case",
[pytest.param(tc, id=tc.test_id) for tc in IS_SPARSE_ARRAY_LIST_TEST_CASES],
)
def test_is_sparse_array_list(test_case: IsSparseArrayListTestCase) -> None:
"""Test is_sparse_array_list TypeGuard function."""
result = is_sparse_array_list(test_case.input_dict)
assert result is test_case.expected


@pytest.mark.parametrize(
"test_case",
[pytest.param(tc, id=tc.test_id) for tc in SPARSE_ARRAY_APPEND_TEST_CASES],
)
def test_sparse_array_append(test_case: SparseArrayAppendTestCase) -> None:
"""Test SparseArray.append method."""
arr: SparseArray[str] = SparseArray()
for index, value in test_case.initial_adds:
arr.add(index, value)
for value in test_case.append_values:
arr.append(value)
assert sorted(arr.keys()) == test_case.expected_keys
for index, expected_value in test_case.expected_mapping.items():
assert arr[index] == expected_value


@pytest.mark.parametrize(
"test_case",
[pytest.param(tc, id=tc.test_id) for tc in SPARSE_ARRAY_VALUES_TEST_CASES],
)
def test_sparse_array_iter_values(test_case: SparseArrayValuesTestCase) -> None:
"""Test SparseArray.iter_values method."""
arr: SparseArray[str] = SparseArray()
for index, value in test_case.adds:
arr.add(index, value)
assert list(arr.iter_values()) == test_case.expected_values


@pytest.mark.parametrize(
"test_case",
[pytest.param(tc, id=tc.test_id) for tc in SPARSE_ARRAY_VALUES_TEST_CASES],
)
def test_sparse_array_as_list(test_case: SparseArrayValuesTestCase) -> None:
"""Test SparseArray.as_list method."""
arr: SparseArray[str] = SparseArray()
for index, value in test_case.adds:
arr.add(index, value)
assert arr.as_list() == test_case.expected_values