Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak(fetch_objs): Raise ObjectDoesNotExist if object not found #466

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ $ pip install --user --upgrade --pre libtmux

<!-- Maintainers and contributors: Insert change notes for the next release above -->

### Improvement

- `fetch_objs` now raises `ObjectDoesNotExist` with detailed information on
lookup that failed (#466)

## libtmux 0.18.2 (2022-12-30)

### Fixes
Expand Down
7 changes: 7 additions & 0 deletions src/libtmux/neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing as t

from libtmux import exc
from libtmux._internal.query_list import ObjectDoesNotExist
from libtmux.common import tmux_cmd
from libtmux.formats import FORMAT_SEPARATOR

Expand Down Expand Up @@ -239,6 +240,12 @@ def fetch_obj(
if _obj.get(obj_key) == obj_id:
obj = _obj

if obj is None:
raise ObjectDoesNotExist(
f"Could not find {obj_key}={obj_id} for {list_cmd} "
f'{list_extra_args if list_extra_args is not None else ""}'
)

assert obj is not None

return obj
3 changes: 2 additions & 1 deletion tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest

from libtmux import exc
from libtmux._internal.query_list import ObjectDoesNotExist
from libtmux.common import has_gte_version, has_lt_version
from libtmux.pane import Pane
from libtmux.server import Server
Expand Down Expand Up @@ -205,7 +206,7 @@ def test_kill_window(session: Session) -> None:
w.window_id

w.kill_window()
with pytest.raises(AssertionError): # TODO: Replace this will an object not found
with pytest.raises(ObjectDoesNotExist):
w.refresh()


Expand Down